File indexing completed on 2026-07-29 09:16:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _SelectMgr_SortCriterion_HeaderFile
0018 #define _SelectMgr_SortCriterion_HeaderFile
0019
0020 #include <Graphic3d_Vec3.hxx>
0021 #include <Precision.hxx>
0022 #include <Select3D_SensitiveEntity.hxx>
0023
0024
0025
0026 class SelectMgr_SortCriterion
0027 {
0028 public:
0029 Handle(Select3D_SensitiveEntity) Entity;
0030 gp_Pnt Point;
0031 Graphic3d_Vec3 Normal;
0032 Standard_Real Depth;
0033
0034 Standard_Real MinDist;
0035 Standard_Real Tolerance;
0036 Standard_Integer SelectionPriority;
0037 Standard_Integer DisplayPriority;
0038 Standard_Integer ZLayerPosition;
0039 Standard_Integer NbOwnerMatches;
0040
0041 Standard_Boolean IsPreferPriority;
0042
0043 public:
0044 DEFINE_STANDARD_ALLOC
0045
0046
0047 SelectMgr_SortCriterion()
0048 : Depth(0.0),
0049 MinDist(0.0),
0050 Tolerance(0.0),
0051 SelectionPriority(0),
0052 DisplayPriority(0),
0053 ZLayerPosition(0),
0054 NbOwnerMatches(0),
0055 IsPreferPriority(Standard_False)
0056 {
0057 }
0058
0059
0060 bool IsCloserDepth(const SelectMgr_SortCriterion& theOther) const
0061 {
0062
0063 if (ZLayerPosition != theOther.ZLayerPosition)
0064 {
0065 return ZLayerPosition > theOther.ZLayerPosition;
0066 }
0067
0068
0069 if (Abs(Depth - theOther.Depth) > Tolerance + theOther.Tolerance)
0070 {
0071 return Depth < theOther.Depth;
0072 }
0073
0074 Standard_Real aCos = 1.0;
0075 if (Normal.Modulus() > 0 && theOther.Normal.Modulus() > 0)
0076 {
0077 gp_Dir aNormal(Normal.x(), Normal.y(), Normal.z());
0078 gp_Dir anOtherNormal(theOther.Normal.x(), theOther.Normal.y(), theOther.Normal.z());
0079 aCos = Abs(Cos(aNormal.Angle(anOtherNormal)));
0080 }
0081
0082 Standard_Real aDepth = Depth - Tolerance;
0083 Standard_Real anOtherDepth = theOther.Depth - theOther.Tolerance;
0084
0085
0086 if (Abs(aDepth - anOtherDepth) > Precision::Confusion())
0087 {
0088 if ((aCos > 0.5 && Abs(Tolerance - theOther.Tolerance) < Precision::Confusion())
0089 || Abs(aCos - 1.0) < Precision::Confusion())
0090 {
0091 return aDepth < anOtherDepth;
0092 }
0093 }
0094
0095
0096 if (SelectionPriority > theOther.SelectionPriority)
0097 {
0098 return true;
0099 }
0100
0101 if (DisplayPriority > theOther.DisplayPriority)
0102 {
0103 return true;
0104 }
0105
0106
0107 return SelectionPriority == theOther.SelectionPriority && MinDist < theOther.MinDist;
0108 }
0109
0110
0111
0112 bool IsHigherPriority(const SelectMgr_SortCriterion& theOther) const
0113 {
0114
0115 if (ZLayerPosition != theOther.ZLayerPosition)
0116 {
0117 return ZLayerPosition > theOther.ZLayerPosition;
0118 }
0119
0120 if (SelectionPriority != theOther.SelectionPriority)
0121 {
0122 return SelectionPriority > theOther.SelectionPriority;
0123 }
0124
0125 if (DisplayPriority != theOther.DisplayPriority)
0126 {
0127 return DisplayPriority > theOther.DisplayPriority;
0128 }
0129
0130
0131 if (Abs(Depth - theOther.Depth) <= Precision::Confusion())
0132 {
0133 return MinDist < theOther.MinDist;
0134 }
0135
0136 return Depth < theOther.Depth;
0137 }
0138 };
0139
0140 #endif