1 // Created on: 2011-06-02
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 #include <BRepMesh_VertexTool.hxx>
19 #include <Precision.hxx>
20 #include <BRepMesh_Vertex.hxx>
21 #include <BRepMesh_VertexInspector.hxx>
23 //=======================================================================
26 //=======================================================================
27 NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect(
28 const Standard_Integer theTarget)
30 const BRepMesh_Vertex& aVertex = myVertices->Value(theTarget - 1);
31 if(aVertex.Movability() == BRepMesh_Deleted)
33 myDelNodes.Append(theTarget);
34 return CellFilter_Purge;
37 gp_XY aVec = (myPoint - aVertex.Coord());
38 Standard_Boolean inTol;
39 if (Abs(myTolerance[1]) < Precision::Confusion())
41 inTol = aVec.SquareModulus() < myTolerance[0];
45 inTol = ((aVec.X() * aVec.X()) < myTolerance[0]) &&
46 ((aVec.Y() * aVec.Y()) < myTolerance[1]);
49 myResIndices.Append(theTarget);
51 return CellFilter_Keep;
54 //=======================================================================
55 //function : BRepMesh_VertexTool
57 //=======================================================================
58 BRepMesh_VertexTool::BRepMesh_VertexTool(
59 const Standard_Integer theReservedSize,
60 const Handle(NCollection_IncAllocator)& theAllocator)
61 : myAllocator (theAllocator),
62 myCellFilter(0., myAllocator),
63 mySelector (Max(theReservedSize, 64),myAllocator)
65 const Standard_Real aTol = Precision::Confusion();
66 SetCellSize ( aTol + 0.05 * aTol );
67 SetTolerance( aTol, aTol );
70 //=======================================================================
73 //=======================================================================
74 Standard_Integer BRepMesh_VertexTool::Add(
75 const BRepMesh_Vertex& theVertex,
76 const Standard_Boolean isForceAdd)
78 Standard_Integer aIndex = isForceAdd ? 0 : FindIndex(theVertex);
81 aIndex = mySelector.Add(theVertex);
83 gp_XY aMinPnt, aMaxPnt;
84 expandPoint(theVertex.Coord(), aMinPnt, aMaxPnt);
85 myCellFilter.Add(aIndex, aMinPnt, aMaxPnt);
90 //=======================================================================
93 //=======================================================================
94 void BRepMesh_VertexTool::Delete(const Standard_Integer theIndex)
96 BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
98 gp_XY aMinPnt, aMaxPnt;
99 expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
101 myCellFilter.Remove(theIndex, aMinPnt, aMaxPnt);
102 mySelector.Delete(theIndex);
105 //=======================================================================
106 //function : Substitute
108 //=======================================================================
109 void BRepMesh_VertexTool::Substitute(
110 const Standard_Integer theIndex,
111 const BRepMesh_Vertex& theVertex)
113 BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
115 gp_XY aMinPnt, aMaxPnt;
116 expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
118 myCellFilter.Remove(theIndex, aMinPnt, aMaxPnt);
121 expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
122 myCellFilter.Add(theIndex, aMinPnt, aMaxPnt);
125 //=======================================================================
126 //function : Statistics
128 //=======================================================================
129 void BRepMesh_VertexTool::Statistics(Standard_OStream& theStream) const
131 theStream << "\nStructure Statistics\n---------------\n\n";
132 theStream << "This structure has " << mySelector.NbVertices() << " Nodes\n\n";