File indexing completed on 2026-09-18 09:19:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _BRepMesh_VertexTool_HeaderFile
0015 #define _BRepMesh_VertexTool_HeaderFile
0016
0017 #include <Standard_Transient.hxx>
0018 #include <BRepMesh_VertexInspector.hxx>
0019 #include <Standard_OStream.hxx>
0020 #include <gp_XY.hxx>
0021 #include <IMeshData_Types.hxx>
0022
0023
0024
0025
0026 class BRepMesh_VertexTool : public Standard_Transient
0027 {
0028 public:
0029
0030
0031 Standard_EXPORT BRepMesh_VertexTool(const occ::handle<NCollection_IncAllocator>& theAllocator);
0032
0033
0034 void SetCellSize(const double theSize)
0035 {
0036 myCellFilter.Reset(theSize, myAllocator);
0037 mySelector.Clear();
0038 }
0039
0040
0041
0042
0043 void SetCellSize(const double theSizeX, const double theSizeY)
0044 {
0045 double aCellSizeC[2] = {theSizeX, theSizeY};
0046 NCollection_Array1<double> aCellSize(aCellSizeC[0], 1, 2);
0047 myCellFilter.Reset(aCellSize, myAllocator);
0048 mySelector.Clear();
0049 }
0050
0051
0052
0053 void SetTolerance(const double theTolerance)
0054 {
0055 mySelector.SetTolerance(theTolerance);
0056 myTolerance[0] = theTolerance;
0057 myTolerance[1] = theTolerance;
0058 }
0059
0060
0061
0062
0063
0064 void SetTolerance(const double theToleranceX, const double theToleranceY)
0065 {
0066 mySelector.SetTolerance(theToleranceX, theToleranceY);
0067 myTolerance[0] = theToleranceX;
0068 myTolerance[1] = theToleranceY;
0069 }
0070
0071
0072
0073
0074
0075 void GetTolerance(double& theToleranceX, double& theToleranceY)
0076 {
0077 theToleranceX = myTolerance[0];
0078 theToleranceY = myTolerance[1];
0079 }
0080
0081
0082
0083
0084
0085
0086 Standard_EXPORT int Add(const BRepMesh_Vertex& theVertex, const bool isForceAdd);
0087
0088
0089 Standard_EXPORT void DeleteVertex(const int theIndex);
0090
0091
0092 const Handle(IMeshData::VectorOfVertex)& Vertices() const { return mySelector.Vertices(); }
0093
0094
0095 Handle(IMeshData::VectorOfVertex)& ChangeVertices() { return mySelector.ChangeVertices(); }
0096
0097
0098 const BRepMesh_Vertex& FindKey(const int theIndex) { return mySelector.GetVertex(theIndex); }
0099
0100
0101 int FindIndex(const BRepMesh_Vertex& theVertex)
0102 {
0103 mySelector.SetPoint(theVertex.Coord());
0104 myCellFilter.Inspect(theVertex.Coord(), mySelector);
0105 return mySelector.GetCoincidentPoint();
0106 }
0107
0108
0109 int Extent() const { return mySelector.NbVertices(); }
0110
0111
0112 bool IsEmpty() const { return (Extent() == 0); }
0113
0114
0115
0116
0117 Standard_EXPORT void Substitute(const int theIndex, const BRepMesh_Vertex& theVertex);
0118
0119
0120 void RemoveLast() { DeleteVertex(Extent()); }
0121
0122
0123
0124 const IMeshData::ListOfInteger& GetListOfDelNodes() const
0125 {
0126 return mySelector.GetListOfDelPoints();
0127 }
0128
0129 DEFINE_STANDARD_RTTIEXT(BRepMesh_VertexTool, Standard_Transient)
0130
0131 private:
0132
0133
0134
0135
0136 void expandPoint(const gp_XY& thePoint, gp_XY& theMinPoint, gp_XY& theMaxPoint)
0137 {
0138 theMinPoint.SetX(thePoint.X() - myTolerance[0]);
0139 theMinPoint.SetY(thePoint.Y() - myTolerance[1]);
0140 theMaxPoint.SetX(thePoint.X() + myTolerance[0]);
0141 theMaxPoint.SetY(thePoint.Y() + myTolerance[1]);
0142 }
0143
0144 private:
0145 occ::handle<NCollection_IncAllocator> myAllocator;
0146 IMeshData::VertexCellFilter myCellFilter;
0147 BRepMesh_VertexInspector mySelector;
0148 double myTolerance[2];
0149 };
0150
0151 #endif