File indexing completed on 2026-06-14 08:28:38
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 : public NCollection_CellFilter_InspectorXY
0027 {
0028 public:
0029 typedef Standard_Integer Target;
0030
0031
0032
0033 BRepMesh_VertexInspector(const Handle(NCollection_IncAllocator)& theAllocator)
0034 : myIndex(0),
0035 myMinSqDist(RealLast()),
0036 myVertices(new IMeshData::VectorOfVertex),
0037 myDelNodes(theAllocator)
0038 {
0039 SetTolerance(Precision::Confusion());
0040 }
0041
0042
0043
0044 Standard_Integer Add(const BRepMesh_Vertex& theVertex)
0045 {
0046 if (myDelNodes.IsEmpty())
0047 {
0048 myVertices->Append(theVertex);
0049 return myVertices->Length();
0050 }
0051
0052 Standard_Integer aNodeIndex = myDelNodes.First();
0053 myVertices->ChangeValue(aNodeIndex - 1) = theVertex;
0054 myDelNodes.RemoveFirst();
0055 return aNodeIndex;
0056 }
0057
0058
0059
0060 void SetTolerance(const Standard_Real theTolerance)
0061 {
0062 myTolerance[0] = theTolerance * theTolerance;
0063 myTolerance[1] = 0.;
0064 }
0065
0066
0067
0068
0069
0070 void SetTolerance(const Standard_Real theToleranceX, const Standard_Real theToleranceY)
0071 {
0072 myTolerance[0] = theToleranceX * theToleranceX;
0073 myTolerance[1] = theToleranceY * theToleranceY;
0074 }
0075
0076
0077 void Clear()
0078 {
0079 myVertices->Clear();
0080 myDelNodes.Clear();
0081 }
0082
0083
0084
0085 void Delete(const Standard_Integer theIndex)
0086 {
0087 myVertices->ChangeValue(theIndex - 1).SetMovability(BRepMesh_Deleted);
0088 myDelNodes.Append(theIndex);
0089 }
0090
0091
0092 Standard_Integer NbVertices() const { return myVertices->Length(); }
0093
0094
0095 BRepMesh_Vertex& GetVertex(Standard_Integer theIndex)
0096 {
0097 return myVertices->ChangeValue(theIndex - 1);
0098 }
0099
0100
0101 void SetPoint(const gp_XY& thePoint)
0102 {
0103 myIndex = 0;
0104 myMinSqDist = RealLast();
0105 myPoint = thePoint;
0106 }
0107
0108
0109 Standard_Integer GetCoincidentPoint() const { return myIndex; }
0110
0111
0112
0113 const IMeshData::ListOfInteger& GetListOfDelPoints() const { return myDelNodes; }
0114
0115
0116 const Handle(IMeshData::VectorOfVertex)& Vertices() const { return myVertices; }
0117
0118
0119 Handle(IMeshData::VectorOfVertex)& ChangeVertices() { return myVertices; }
0120
0121
0122
0123
0124 Standard_EXPORT NCollection_CellFilter_Action Inspect(const Standard_Integer theTargetIndex);
0125
0126
0127 static Standard_Boolean IsEqual(const Standard_Integer theIndex,
0128 const Standard_Integer theTargetIndex)
0129 {
0130 return (theIndex == theTargetIndex);
0131 }
0132
0133 private:
0134 Standard_Integer myIndex;
0135 Standard_Real myMinSqDist;
0136 Standard_Real myTolerance[2];
0137 Handle(IMeshData::VectorOfVertex) myVertices;
0138 IMeshData::ListOfInteger myDelNodes;
0139 gp_XY myPoint;
0140 };
0141
0142 #endif