1 // Created on: 2011-06-01
2 // Created by: Oleg AGASHIN
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BRepMesh_VertexInspector_HeaderFile
17 #define _BRepMesh_VertexInspector_HeaderFile
19 #include <Precision.hxx>
22 #include <BRepMesh.hxx>
23 #include <NCollection_CellFilter.hxx>
24 #include <BRepMesh_Vertex.hxx>
26 //! Class intended for fast searching of the coincidence points.
27 class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
30 typedef Standard_Integer Target;
33 //! @param theReservedSize size to be reserved for vector of vertices.
34 //! @param theAllocator memory allocator to be used by internal collections.
35 Standard_EXPORT BRepMesh_VertexInspector (
36 const Standard_Integer theReservedSize,
37 const Handle(NCollection_IncAllocator)& theAllocator)
38 : myResIndices(theAllocator),
39 myVertices (new BRepMesh::VectorOfVertex(theReservedSize)),
40 myDelNodes (theAllocator)
42 SetTolerance( Precision::Confusion() );
45 //! Registers the given vertex.
46 //! @param theVertex vertex to be registered.
47 Standard_EXPORT Standard_Integer Add(const BRepMesh_Vertex& theVertex)
49 if( myDelNodes.IsEmpty() )
51 myVertices->Append(theVertex);
52 return myVertices->Length();
55 Standard_Integer aNodeIndex = myDelNodes.First();
56 myVertices->ChangeValue(aNodeIndex - 1) = theVertex;
57 myDelNodes.RemoveFirst();
62 //! Sets the tolerance to be used for identification of
63 //! coincident vertices equal for both dimensions.
64 inline void SetTolerance(const Standard_Real theTolerance)
66 myTolerance[0] = theTolerance * theTolerance;
70 //! Sets the tolerance to be used for identification of
71 //! coincident vertices.
72 //! @param theToleranceX tolerance for X dimension.
73 //! @param theToleranceY tolerance for Y dimension.
74 inline void SetTolerance(const Standard_Real theToleranceX,
75 const Standard_Real theToleranceY)
77 myTolerance[0] = theToleranceX * theToleranceX;
78 myTolerance[1] = theToleranceY * theToleranceY;
81 //! Clear inspector's internal data structures.
88 //! Deletes vertex with the given index.
89 //! @param theIndex index of vertex to be removed.
90 inline void Delete(const Standard_Integer theIndex)
92 myVertices->ChangeValue(theIndex - 1).SetMovability(BRepMesh_Deleted);
93 myDelNodes.Append(theIndex);
96 //! Returns number of registered vertices.
97 inline Standard_Integer NbVertices() const
99 return myVertices->Length();
102 //! Returns vertex with the given index.
103 inline BRepMesh_Vertex& GetVertex(Standard_Integer theIndex)
105 return myVertices->ChangeValue(theIndex - 1);
108 //! Set reference point to be checked.
109 inline void SetPoint(const gp_XY& thePoint)
111 myResIndices.Clear();
115 //! Returns index of point coinciding with regerence one.
116 inline const Standard_Integer GetCoincidentPoint() const
118 if ( myResIndices.Size() > 0 )
120 return myResIndices.First();
125 //! Returns list with indexes of vertices that have movability attribute
126 //! equal to BRepMesh_Deleted and can be replaced with another node.
127 inline const BRepMesh::ListOfInteger& GetListOfDelPoints() const
132 //! Returns set of mesh vertices.
133 inline const BRepMesh::HVectorOfVertex& Vertices() const
138 //! Returns set of mesh vertices for modification.
139 inline BRepMesh::HVectorOfVertex& ChangeVertices()
144 //! Performs inspection of a point with the given index.
145 //! @param theTargetIndex index of a circle to be checked.
146 //! @return status of the check.
147 Standard_EXPORT NCollection_CellFilter_Action Inspect(const Standard_Integer theTargetIndex);
149 //! Checks indices for equlity.
150 Standard_EXPORT static Standard_Boolean IsEqual(const Standard_Integer theIndex,
151 const Standard_Integer theTargetIndex)
153 return (theIndex == theTargetIndex);
158 Standard_Real myTolerance[2];
159 BRepMesh::ListOfInteger myResIndices;
160 BRepMesh::HVectorOfVertex myVertices;
161 BRepMesh::ListOfInteger myDelNodes;