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