File indexing completed on 2026-09-12 09:16:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BRepMesh_VertexInspector_HeaderFile
0017 #define _BRepMesh_VertexInspector_HeaderFile
0018
0019 #include <Precision.hxx>
0020 #include <gp_XY.hxx>
0021 #include <IMeshData_Types.hxx>
0022 #include <NCollection_CellFilter.hxx>
0023 #include <BRepMesh_Vertex.hxx>
0024
0025
0026 class BRepMesh_VertexInspector
0027 {
0028 public:
0029 static constexpr int Dimension = 2;
0030
0031 typedef gp_XY Point;
0032 typedef int Target;
0033
0034 static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
0035
0036 static Point Shift(const Point& thePnt, double theTol)
0037 {
0038 return Point(thePnt.X() + theTol, thePnt.Y() + theTol);
0039 }
0040
0041
0042
0043 BRepMesh_VertexInspector(const occ::handle<NCollection_IncAllocator>& theAllocator)
0044 : myIndex(0),
0045 myMinSqDist(RealLast()),
0046 myVertices(new IMeshData::VectorOfVertex),
0047 myDelNodes(theAllocator)
0048 {
0049 SetTolerance(Precision::Confusion());
0050 }
0051
0052
0053
0054 int Add(const BRepMesh_Vertex& theVertex)
0055 {
0056 if (myDelNodes.IsEmpty())
0057 {
0058 myVertices->Append(theVertex);
0059 return myVertices->Length();
0060 }
0061
0062 int aNodeIndex = myDelNodes.First();
0063 myVertices->ChangeValue(aNodeIndex - 1) = theVertex;
0064 myDelNodes.RemoveFirst();
0065 return aNodeIndex;
0066 }
0067
0068
0069
0070 void SetTolerance(const double theTolerance)
0071 {
0072 myTolerance[0] = theTolerance * theTolerance;
0073 myTolerance[1] = 0.;
0074 }
0075
0076
0077
0078
0079
0080 void SetTolerance(const double theToleranceX, const double theToleranceY)
0081 {
0082 myTolerance[0] = theToleranceX * theToleranceX;
0083 myTolerance[1] = theToleranceY * theToleranceY;
0084 }
0085
0086
0087 void Clear()
0088 {
0089 myVertices->Clear();
0090 myDelNodes.Clear();
0091 }
0092
0093
0094
0095 void Delete(const int theIndex)
0096 {
0097 myVertices->ChangeValue(theIndex - 1).SetMovability(BRepMesh_Deleted);
0098 myDelNodes.Append(theIndex);
0099 }
0100
0101
0102 int NbVertices() const { return myVertices->Length(); }
0103
0104
0105 BRepMesh_Vertex& GetVertex(int theIndex) { return myVertices->ChangeValue(theIndex - 1); }
0106
0107
0108 void SetPoint(const gp_XY& thePoint)
0109 {
0110 myIndex = 0;
0111 myMinSqDist = RealLast();
0112 myPoint = thePoint;
0113 }
0114
0115
0116 int GetCoincidentPoint() const { return myIndex; }
0117
0118
0119
0120 const IMeshData::ListOfInteger& GetListOfDelPoints() const { return myDelNodes; }
0121
0122
0123 const Handle(IMeshData::VectorOfVertex)& Vertices() const { return myVertices; }
0124
0125
0126 Handle(IMeshData::VectorOfVertex)& ChangeVertices() { return myVertices; }
0127
0128
0129
0130
0131 Standard_EXPORT NCollection_CellFilter_Action Inspect(const int theTargetIndex);
0132
0133
0134 static bool IsEqual(const int theIndex, const int theTargetIndex)
0135 {
0136 return (theIndex == theTargetIndex);
0137 }
0138
0139 private:
0140 int myIndex;
0141 double myMinSqDist;
0142 double myTolerance[2];
0143 Handle(IMeshData::VectorOfVertex) myVertices;
0144 IMeshData::ListOfInteger myDelNodes;
0145 gp_XY myPoint;
0146 };
0147
0148 #endif