Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-06-01 |
2 | // Created by: Oleg AGASHIN | |
3 | // Copyright (c) 2011-2012 OPEN CASCADE SAS | |
4 | // | |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
51c3cc5f O |
20 | |
21 | #include <gp_XY.hxx> | |
22 | #include <Precision.hxx> | |
23 | #include <BRepMesh_VertexInspector.hxx> | |
24 | #include <BRepMesh_Vertex.hxx> | |
25 | ||
26 | ||
27 | //======================================================================= | |
28 | //function : BRepMesh_VertexInspector | |
29 | //purpose : Constructor | |
51c3cc5f O |
30 | //======================================================================= |
31 | ||
32 | BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp, | |
33 | const BRepMesh_BaseAllocator& theAlloc) | |
34 | : myTol(0,1), | |
35 | myResInd(theAlloc), | |
36 | myVertices(nbComp), | |
37 | myDelNodes(theAlloc) | |
38 | { | |
39 | SetTolerance( Precision::Confusion() ); | |
40 | } | |
41 | ||
42 | BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp, | |
43 | const Standard_Real aTol, | |
44 | const BRepMesh_BaseAllocator& theAlloc) | |
45 | : myTol(0,1), | |
46 | myResInd(theAlloc), | |
47 | myVertices(nbComp), | |
48 | myDelNodes(theAlloc) | |
49 | { | |
50 | SetTolerance( aTol ); | |
51 | } | |
52 | ||
53 | BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp, | |
54 | const Standard_Real aTolX, | |
55 | const Standard_Real aTolY, | |
56 | const BRepMesh_BaseAllocator& theAlloc) | |
57 | : myTol(0,1), | |
58 | myResInd(theAlloc), | |
59 | myVertices(nbComp), | |
60 | myDelNodes(theAlloc) | |
61 | { | |
62 | SetTolerance( aTolX, aTolY ); | |
63 | } | |
64 | ||
65 | //======================================================================= | |
66 | //function : Inspect | |
67 | //purpose : | |
68 | // | |
69 | //======================================================================= | |
70 | NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect (const Standard_Integer theTarget) | |
71 | { | |
72 | const BRepMesh_Vertex& aVertex = myVertices(theTarget-1); | |
73 | if( aVertex.Movability() == BRepMesh_Deleted ) | |
74 | { | |
75 | myDelNodes.Append(theTarget); | |
76 | return CellFilter_Purge; | |
77 | } | |
78 | ||
79 | const gp_XY& aPos = aVertex.Coord(); | |
80 | Standard_Real dx,dy; | |
81 | dx = myCurrent.X() - aPos.X(); | |
82 | dy = myCurrent.Y() - aPos.Y(); | |
83 | ||
84 | Standard_Boolean inTol; | |
85 | if ( myTol(1) == 0. ) | |
86 | { | |
87 | inTol = (dx*dx + dy*dy) <= myTol(0); | |
88 | } | |
89 | else | |
90 | { | |
91 | inTol = ( (dx*dx) <= myTol(0) ) && | |
92 | ( (dy*dy) <= myTol(1) ); | |
93 | } | |
94 | if ( inTol ) | |
95 | myResInd.Append(theTarget); | |
96 | return CellFilter_Keep; | |
97 | } | |
98 | ||
99 | //======================================================================= | |
100 | //function : Add | |
101 | //purpose : | |
102 | // | |
103 | //======================================================================= | |
104 | Standard_Integer BRepMesh_VertexInspector::Add(const BRepMesh_Vertex& theVertex) | |
105 | { | |
106 | if( myDelNodes.IsEmpty() ) | |
107 | { | |
108 | myVertices.Append(theVertex); | |
109 | return myVertices.Length(); | |
110 | } | |
111 | ||
112 | Standard_Integer aNodeIndex = myDelNodes.First(); | |
113 | myVertices(aNodeIndex-1) = theVertex; | |
114 | myDelNodes.RemoveFirst(); | |
115 | return aNodeIndex; | |
116 | } |