File indexing completed on 2026-09-22 08:57:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BRepExtrema_ProximityDistTool_HeaderFile
0017 #define _BRepExtrema_ProximityDistTool_HeaderFile
0018
0019 #include <BRepExtrema_ElementFilter.hxx>
0020 #include <NCollection_DataMap.hxx>
0021 #include <TColStd_PackedMapOfInteger.hxx>
0022 #include <BRepExtrema_TriangleSet.hxx>
0023 #include <BVH_Distance.hxx>
0024 #include <BVH_Tools.hxx>
0025 #include <Poly_Triangulation.hxx>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class BRepExtrema_ProximityDistTool
0038 : public BVH_Distance<double, 3, BVH_Vec3d, BRepExtrema_TriangleSet>
0039 {
0040 public:
0041 typedef typename BVH_Tools<double, 3>::BVH_PrjStateInTriangle BVH_PrjState;
0042
0043 enum ProxPnt_Status
0044 {
0045 ProxPnt_Status_BORDER,
0046 ProxPnt_Status_MIDDLE,
0047 ProxPnt_Status_UNKNOWN
0048 };
0049
0050 public:
0051
0052
0053 struct PrjState
0054 {
0055 PrjState()
0056 : myTrgIdx(0),
0057 myPrjState(BVH_PrjState::BVH_PrjStateInTriangle_INNER),
0058 myNumberOfFirstNode(0),
0059 myNumberOfLastNode(0)
0060 {
0061 }
0062
0063 PrjState(const int theTrgIdx,
0064 const BVH_PrjState thePrjState,
0065 const int theNumberOfFirstNode,
0066 const int theNumberOfLastNode)
0067 : myTrgIdx(theTrgIdx),
0068 myPrjState(thePrjState),
0069 myNumberOfFirstNode(theNumberOfFirstNode),
0070 myNumberOfLastNode(theNumberOfLastNode)
0071 {
0072 }
0073
0074 int GetTrgIdx() const { return myTrgIdx; }
0075
0076 BVH_PrjState GetPrjState() const { return myPrjState; }
0077
0078 int GetNumberOfFirstNode() const { return myNumberOfFirstNode; }
0079
0080 int GetNumberOfLastNode() const { return myNumberOfLastNode; }
0081
0082 private:
0083 int myTrgIdx;
0084 BVH_PrjState myPrjState;
0085
0086 int myNumberOfFirstNode;
0087 int myNumberOfLastNode;
0088
0089 };
0090
0091 public:
0092
0093 Standard_EXPORT BRepExtrema_ProximityDistTool();
0094
0095
0096 Standard_EXPORT BRepExtrema_ProximityDistTool(
0097 const occ::handle<BRepExtrema_TriangleSet>& theSet1,
0098 const int theNbSamples1,
0099 const BVH_Array3d& theAddVertices1,
0100 const NCollection_DynamicArray<ProxPnt_Status>& theAddStatus1,
0101 const occ::handle<BRepExtrema_TriangleSet>& theSet2,
0102 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList1,
0103 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList2);
0104
0105 public:
0106
0107 Standard_EXPORT void LoadTriangleSets(const occ::handle<BRepExtrema_TriangleSet>& theSet1,
0108 const occ::handle<BRepExtrema_TriangleSet>& theSet2);
0109
0110
0111 Standard_EXPORT void LoadShapeLists(const NCollection_DynamicArray<TopoDS_Shape>& theShapeList1,
0112 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList2);
0113
0114
0115 void LoadAdditionalPointsFirstSet(const BVH_Array3d& theAddVertices1,
0116 const NCollection_DynamicArray<ProxPnt_Status>& theAddStatus1);
0117
0118
0119 Standard_EXPORT void Perform();
0120
0121 public:
0122
0123 Standard_EXPORT bool RejectNode(const BVH_Vec3d& theCornerMin,
0124 const BVH_Vec3d& theCornerMax,
0125 double& theMetric) const override;
0126
0127
0128 Standard_EXPORT bool Accept(const int theSgmIdx, const double&) override;
0129
0130 public:
0131
0132 Standard_EXPORT static bool IsNodeOnBorder(const int theNodeIdx,
0133 const occ::handle<Poly_Triangulation>& theTr);
0134
0135
0136 Standard_EXPORT static bool IsEdgeOnBorder(const int theTrgIdx,
0137 const int theFirstEdgeNodeIdx,
0138 const int theSecondEdgeNodeIdx,
0139 const occ::handle<Poly_Triangulation>& theTr);
0140
0141 public:
0142
0143 void ProximityPoints(BVH_Vec3d& thePoint1, BVH_Vec3d& thePoint2) const
0144 {
0145 thePoint1 = myPnt1;
0146 thePoint2 = myPnt2;
0147 }
0148
0149
0150 void ProximityPointsStatus(ProxPnt_Status& thePointStatus1, ProxPnt_Status& thePointStatus2) const
0151 {
0152 thePointStatus1 = myPntStatus1;
0153 thePointStatus2 = myPntStatus2;
0154 }
0155
0156
0157 double ProximityDistance() const { return myProxDist; }
0158
0159 protected:
0160
0161 Standard_EXPORT double ComputeDistance();
0162
0163
0164 Standard_EXPORT void DefineStatusProxPnt();
0165
0166 private:
0167
0168 void goThroughtSet1(const BVH_Array3d& aVertices1, const bool theIsAdditionalSet);
0169
0170
0171 void defineStatusProxPnt1();
0172
0173
0174 void defineStatusProxPnt2();
0175
0176 protected:
0177
0178 double myMinDistance;
0179
0180 BVH_Vec3d myMinDistPoint;
0181
0182 BVH_Vec3d myExtremaPoint;
0183
0184 double myProxDist;
0185
0186
0187 BVH_Vec3d myPnt1, myPnt2;
0188
0189
0190 ProxPnt_Status myPntStatus1, myPntStatus2;
0191
0192 private:
0193
0194 occ::handle<BRepExtrema_TriangleSet> mySet1;
0195
0196 occ::handle<BRepExtrema_TriangleSet> mySet2;
0197
0198
0199 NCollection_DynamicArray<TopoDS_Shape> myShapeList1;
0200
0201 NCollection_DynamicArray<TopoDS_Shape> myShapeList2;
0202
0203 int myNbSamples1;
0204
0205
0206 int myIsProxVtx1FromAddSet;
0207 BVH_Array3d myAddVertices1;
0208
0209 NCollection_DynamicArray<ProxPnt_Status> myAddStatus1;
0210
0211
0212
0213 int myProxVtxIdx1;
0214
0215
0216 PrjState myProxPrjState;
0217
0218
0219 PrjState myExtPrjState;
0220
0221
0222 PrjState myMinPrjState;
0223 };
0224
0225 #endif