File indexing completed on 2026-09-24 09:15:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BRepExtrema_ProximityValueTool_HeaderFile
0017 #define _BRepExtrema_ProximityValueTool_HeaderFile
0018
0019 #include <BRepExtrema_ProximityDistTool.hxx>
0020 #include <BRepExtrema_TriangleSet.hxx>
0021 #include <NCollection_CellFilter.hxx>
0022 #include <Precision.hxx>
0023
0024 typedef NCollection_DynamicArray<gp_XYZ> VectorOfPoint;
0025
0026
0027
0028 class BRepExtrema_VertexInspector
0029 {
0030 public:
0031 static constexpr int Dimension = 3;
0032
0033 typedef gp_XYZ Point;
0034 typedef int Target;
0035
0036 static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
0037
0038 static Point Shift(const Point& thePnt, double theTol)
0039 {
0040 return Point(thePnt.X() + theTol, thePnt.Y() + theTol, thePnt.Z() + theTol);
0041 }
0042
0043
0044 BRepExtrema_VertexInspector()
0045 : myTol(Precision::SquareConfusion()),
0046 myIsNeedAdd(true)
0047 {
0048 }
0049
0050
0051 void Add(const gp_XYZ& thePnt) { myPoints.Append(thePnt); }
0052
0053
0054 void SetTol(const double theTol) { myTol = theTol; }
0055
0056
0057 void SetCurrent(const gp_XYZ& theCurPnt)
0058 {
0059 myCurrent = theCurPnt;
0060 myIsNeedAdd = true;
0061 }
0062
0063 bool IsNeedAdd() const { return myIsNeedAdd; }
0064
0065
0066 Standard_EXPORT NCollection_CellFilter_Action Inspect(const int theTarget);
0067
0068 private:
0069 double myTol;
0070 bool myIsNeedAdd;
0071 VectorOfPoint myPoints;
0072 gp_XYZ myCurrent;
0073 };
0074
0075 typedef typename BRepExtrema_ProximityDistTool::ProxPnt_Status ProxPnt_Status;
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 class BRepExtrema_ProximityValueTool
0087 {
0088
0089 public:
0090
0091 Standard_EXPORT BRepExtrema_ProximityValueTool();
0092
0093
0094 Standard_EXPORT BRepExtrema_ProximityValueTool(
0095 const occ::handle<BRepExtrema_TriangleSet>& theSet1,
0096 const occ::handle<BRepExtrema_TriangleSet>& theSet2,
0097 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList1,
0098 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList2);
0099
0100 public:
0101
0102 Standard_EXPORT void LoadTriangleSets(const occ::handle<BRepExtrema_TriangleSet>& theSet1,
0103 const occ::handle<BRepExtrema_TriangleSet>& theSet2);
0104
0105
0106 Standard_EXPORT void LoadShapeLists(const NCollection_DynamicArray<TopoDS_Shape>& theShapeList1,
0107 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList2);
0108
0109
0110
0111 Standard_EXPORT void SetNbSamplePoints(const int theSamples1 = 0, const int theSamples2 = 0);
0112
0113
0114 Standard_EXPORT void Perform(double& theTolerance);
0115
0116
0117 bool IsDone() const { return myIsDone; }
0118
0119
0120 void MarkDirty() { myIsDone = false; }
0121
0122
0123 double Distance() const { return myDistance; }
0124
0125
0126 void ProximityPoints(gp_Pnt& thePoint1, gp_Pnt& thePoint2) const
0127 {
0128 thePoint1 = myPnt1;
0129 thePoint2 = myPnt2;
0130 }
0131
0132
0133 void ProximityPointsStatus(ProxPnt_Status& thePointStatus1, ProxPnt_Status& thePointStatus2) const
0134 {
0135 thePointStatus1 = myPntStatus1;
0136 thePointStatus2 = myPntStatus2;
0137 }
0138
0139 private:
0140
0141 bool getInfoForRefinement(const TopoDS_Shape& theShapes,
0142 TopAbs_ShapeEnum& theShapeType,
0143 int& theNbNodes,
0144 double& theStep);
0145
0146
0147 double computeProximityDist(const occ::handle<BRepExtrema_TriangleSet>& theSet1,
0148 const int theNbSamples1,
0149 const BVH_Array3d& theAddVertices1,
0150 const NCollection_DynamicArray<ProxPnt_Status>& theAddStatus1,
0151 const occ::handle<BRepExtrema_TriangleSet>& theSet2,
0152 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList1,
0153 const NCollection_DynamicArray<TopoDS_Shape>& theShapeList2,
0154 BVH_Vec3d& thePoint1,
0155 BVH_Vec3d& thePoint2,
0156 ProxPnt_Status& thePointStatus1,
0157 ProxPnt_Status& thePointStatus2) const;
0158
0159
0160 bool getShapesAdditionalVertices();
0161
0162
0163 bool getEdgeAdditionalVertices(const TopoDS_Edge& theEdge,
0164 const double theStep,
0165 BVH_Array3d& theAddVertices,
0166 NCollection_DynamicArray<ProxPnt_Status>& theAddStatuses);
0167
0168
0169 bool getFaceAdditionalVertices(const TopoDS_Face& theFace,
0170 const double theStep,
0171 BVH_Array3d& theAddVertices,
0172 NCollection_DynamicArray<ProxPnt_Status>& theAddStatuses);
0173
0174
0175
0176 void doRecurTrgSplit(const gp_Pnt (&theTrg)[3],
0177 const ProxPnt_Status (&theEdgesStatus)[3],
0178 const double theTol,
0179 const double theStep,
0180 BVH_Array3d& theAddVertices,
0181 NCollection_DynamicArray<ProxPnt_Status>& theAddStatuses);
0182
0183 private:
0184
0185 occ::handle<BRepExtrema_TriangleSet> mySet1;
0186
0187 occ::handle<BRepExtrema_TriangleSet> mySet2;
0188
0189
0190 NCollection_DynamicArray<TopoDS_Shape> myShapeList1;
0191
0192 NCollection_DynamicArray<TopoDS_Shape> myShapeList2;
0193
0194
0195 TopoDS_Shape myShape1;
0196
0197 TopoDS_Shape myShape2;
0198
0199 BVH_Array3d myAddVertices1;
0200 BVH_Array3d myAddVertices2;
0201
0202
0203 NCollection_DynamicArray<ProxPnt_Status> myAddStatus1;
0204 NCollection_DynamicArray<ProxPnt_Status> myAddStatus2;
0205
0206
0207 bool myIsInitS1;
0208 bool myIsInitS2;
0209
0210 bool myIsRefinementRequired1;
0211 bool myIsRefinementRequired2;
0212
0213 int myNbNodes1;
0214 int myNbNodes2;
0215
0216 double myStep1;
0217 double myStep2;
0218
0219 NCollection_CellFilter<BRepExtrema_VertexInspector> myCells;
0220 BRepExtrema_VertexInspector myInspector;
0221
0222 TopAbs_ShapeEnum myShapeType1;
0223 TopAbs_ShapeEnum myShapeType2;
0224
0225 double myDistance;
0226 bool myIsDone;
0227
0228 int myNbSamples1;
0229 int myNbSamples2;
0230
0231
0232 gp_Pnt myPnt1, myPnt2;
0233
0234
0235 ProxPnt_Status myPntStatus1, myPntStatus2;
0236 };
0237
0238 #endif