File indexing completed on 2026-10-27 09:39:08
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 <NCollection_Vec3.hxx>
0021 #include <Standard_TypeDef.hxx>
0022 #include <Precision.hxx>
0023 #include <Select3D_SensitiveEntity.hxx>
0024
0025
0026
0027 class SelectMgr_SortCriterion
0028 {
0029 public:
0030 occ::handle<Select3D_SensitiveEntity> Entity;
0031 gp_Pnt Point;
0032 NCollection_Vec3<float> Normal;
0033 double Depth;
0034
0035 double MinDist;
0036 double Tolerance;
0037 int SelectionPriority;
0038 int DisplayPriority;
0039 int ZLayerPosition;
0040 int NbOwnerMatches;
0041
0042 bool IsPreferPriority;
0043
0044 public:
0045 DEFINE_STANDARD_ALLOC
0046
0047
0048 SelectMgr_SortCriterion()
0049 : Depth(0.0),
0050 MinDist(0.0),
0051 Tolerance(0.0),
0052 SelectionPriority(0),
0053 DisplayPriority(0),
0054 ZLayerPosition(0),
0055 NbOwnerMatches(0),
0056 IsPreferPriority(false)
0057 {
0058 }
0059
0060
0061 bool IsCloserDepth(const SelectMgr_SortCriterion& theOther) const
0062 {
0063
0064 if (ZLayerPosition != theOther.ZLayerPosition)
0065 {
0066 return ZLayerPosition > theOther.ZLayerPosition;
0067 }
0068
0069
0070 if (std::abs(Depth - theOther.Depth) > Tolerance + theOther.Tolerance)
0071 {
0072 return Depth < theOther.Depth;
0073 }
0074
0075 double aCos = 1.0;
0076 if (Normal.Modulus() > 0 && theOther.Normal.Modulus() > 0)
0077 {
0078 gp_Dir aNormal(Normal.x(), Normal.y(), Normal.z());
0079 gp_Dir anOtherNormal(theOther.Normal.x(), theOther.Normal.y(), theOther.Normal.z());
0080 aCos = std::abs(std::cos(aNormal.Angle(anOtherNormal)));
0081 }
0082
0083 double aDepth = Depth - Tolerance;
0084 double anOtherDepth = theOther.Depth - theOther.Tolerance;
0085
0086
0087 if (std::abs(aDepth - anOtherDepth) > Precision::Confusion())
0088 {
0089 if ((aCos > 0.5 && std::abs(Tolerance - theOther.Tolerance) < Precision::Confusion())
0090 || std::abs(aCos - 1.0) < Precision::Confusion())
0091 {
0092 return aDepth < anOtherDepth;
0093 }
0094 }
0095
0096
0097 if (SelectionPriority > theOther.SelectionPriority)
0098 {
0099 return true;
0100 }
0101
0102 if (DisplayPriority > theOther.DisplayPriority)
0103 {
0104 return true;
0105 }
0106
0107
0108 return SelectionPriority == theOther.SelectionPriority && MinDist < theOther.MinDist;
0109 }
0110
0111
0112
0113 bool IsHigherPriority(const SelectMgr_SortCriterion& theOther) const
0114 {
0115
0116 if (ZLayerPosition != theOther.ZLayerPosition)
0117 {
0118 return ZLayerPosition > theOther.ZLayerPosition;
0119 }
0120
0121 if (SelectionPriority != theOther.SelectionPriority)
0122 {
0123 return SelectionPriority > theOther.SelectionPriority;
0124 }
0125
0126 if (DisplayPriority != theOther.DisplayPriority)
0127 {
0128 return DisplayPriority > theOther.DisplayPriority;
0129 }
0130
0131
0132 if (std::abs(Depth - theOther.Depth) <= Precision::Confusion())
0133 {
0134 return MinDist < theOther.MinDist;
0135 }
0136
0137 return Depth < theOther.Depth;
0138 }
0139 };
0140
0141 #endif