File indexing completed on 2025-01-18 10:04:54
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
0030 Handle(Select3D_SensitiveEntity) Entity;
0031 gp_Pnt Point;
0032 Graphic3d_Vec3 Normal;
0033 Standard_Real Depth;
0034 Standard_Real MinDist;
0035 Standard_Real Tolerance;
0036 Standard_Integer Priority;
0037 Standard_Integer ZLayerPosition;
0038 Standard_Integer NbOwnerMatches;
0039
0040 public:
0041 DEFINE_STANDARD_ALLOC
0042
0043
0044 SelectMgr_SortCriterion()
0045 : Depth (0.0),
0046 MinDist (0.0),
0047 Tolerance(0.0),
0048 Priority (0),
0049 ZLayerPosition (0),
0050 NbOwnerMatches (0) {}
0051
0052
0053 bool IsCloserDepth (const SelectMgr_SortCriterion& theOther) const
0054 {
0055
0056 if (ZLayerPosition != theOther.ZLayerPosition)
0057 {
0058 return ZLayerPosition > theOther.ZLayerPosition;
0059 }
0060
0061
0062 if (Abs (Depth - theOther.Depth) > Tolerance + theOther.Tolerance)
0063 {
0064 return Depth < theOther.Depth;
0065 }
0066
0067 Standard_Real aCos = 1.0;
0068 if (Normal.Modulus() > 0 && theOther.Normal.Modulus() > 0)
0069 {
0070 gp_Dir aNormal (Normal.x(), Normal.y(), Normal.z());
0071 gp_Dir anOtherNormal (theOther.Normal.x(), theOther.Normal.y(), theOther.Normal.z());
0072 aCos = Abs (Cos (aNormal.Angle (anOtherNormal)));
0073 }
0074
0075 Standard_Real aDepth = Depth - Tolerance;
0076 Standard_Real anOtherDepth = theOther.Depth - theOther.Tolerance;
0077
0078
0079 if (Abs (aDepth - anOtherDepth) > Precision::Confusion())
0080 {
0081 if ((aCos > 0.5 && Abs (Tolerance - theOther.Tolerance) < Precision::Confusion())
0082 || Abs (aCos - 1.0) < Precision::Confusion())
0083 {
0084 return aDepth < anOtherDepth;
0085 }
0086 }
0087
0088
0089 if (Priority > theOther.Priority)
0090 {
0091 return true;
0092 }
0093
0094
0095 return Priority == theOther.Priority
0096 && MinDist < theOther.MinDist;
0097 }
0098
0099
0100 bool IsHigherPriority (const SelectMgr_SortCriterion& theOther) const
0101 {
0102
0103 if (ZLayerPosition != theOther.ZLayerPosition)
0104 {
0105 return ZLayerPosition > theOther.ZLayerPosition;
0106 }
0107
0108 if (Priority > theOther.Priority)
0109 {
0110 return true;
0111 }
0112 else if (Priority != theOther.Priority)
0113 {
0114 return false;
0115 }
0116
0117
0118 if (Abs (Depth - theOther.Depth) <= Precision::Confusion())
0119 {
0120 return MinDist < theOther.MinDist;
0121 }
0122
0123 return Depth < theOther.Depth;
0124 }
0125
0126 };
0127
0128 #endif