0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_VertexInfo.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
42cf5bc1 14
7fd59977 15#include <TopoDS.hxx>
42cf5bc1 16#include <TopoDS_Edge.hxx>
17#include <TopoDS_Vertex.hxx>
18#include <TopOpeBRepBuild_VertexInfo.hxx>
7fd59977 19#include <TopTools_ListIteratorOfListOfShape.hxx>
7fd59977 20
42cf5bc1 21#include <stdio.h>
7fd59977 22//=======================================================================
23// function :TopOpeBRepBuild_VertexInfo
24// purpose:
25//=======================================================================
b311480e 26TopOpeBRepBuild_VertexInfo::TopOpeBRepBuild_VertexInfo()
7fd59977 27{
28 mySmart=Standard_False;
29 myFoundOut=0;
30 myEdgesPassed.Clear();
31}
32//=======================================================================
33// function :TopOpeBRepBuild_VertexInfo::SetVertex
34// purpose:
35//=======================================================================
36 void TopOpeBRepBuild_VertexInfo::SetVertex(const TopoDS_Vertex& aV)
37{
38 myVertex=aV;
39}
40//=======================================================================
41// function :TopOpeBRepBuild_VertexInfo::Vertex
42// purpose:
43//=======================================================================
44 const TopoDS_Vertex& TopOpeBRepBuild_VertexInfo::Vertex() const
45{
46 return myVertex;
47}
48//=======================================================================
49// function :TopOpeBRepBuild_VertexInfo::SetSmart
50// purpose:
51//=======================================================================
52 void TopOpeBRepBuild_VertexInfo::SetSmart(const Standard_Boolean aFlag)
53{
54 mySmart=aFlag;
55}
56//=======================================================================
57// function :TopOpeBRepBuild_VertexInfo:Smart
58// purpose:
59//=======================================================================
60 Standard_Boolean TopOpeBRepBuild_VertexInfo::Smart() const
61{
62 return mySmart;
63}
64//=======================================================================
65// function :TopOpeBRepBuild_VertexInfo:NbCases
66// purpose:
67//=======================================================================
68 Standard_Integer TopOpeBRepBuild_VertexInfo::NbCases() const
69{//myCurrentIn
70 return myLocalEdgesOut.Extent();
71}
72
73//=======================================================================
74// function :TopOpeBRepBuild_VertexInfo:FoundOut
75// purpose:
76//=======================================================================
77 Standard_Integer TopOpeBRepBuild_VertexInfo::FoundOut () const
78{
79 return myFoundOut;
80}
81
82//=======================================================================
83// function :TopOpeBRepBuild_VertexInfo::AddIn
84// purpose:
85//=======================================================================
86 void TopOpeBRepBuild_VertexInfo::AddIn(const TopoDS_Edge& anE)
87{
88 myEdgesIn.Add(anE);
89}
90
91//=======================================================================
92// function :TopOpeBRepBuild_VertexInfo::AddOut
93// purpose:
94//=======================================================================
95 void TopOpeBRepBuild_VertexInfo::AddOut(const TopoDS_Edge& anE)
96{
97 myEdgesOut.Add(anE);
98}
99
100//=======================================================================
101// function :TopOpeBRepBuild_VertexInfo::SetCurrentIn
102// purpose:
103//=======================================================================
104 void TopOpeBRepBuild_VertexInfo::SetCurrentIn(const TopoDS_Edge& anE)
105{
106 myCurrentIn=anE;
107}
108
109//=======================================================================
110// function :TopOpeBRepBuild_VertexInfo::EdgesIn
111// purpose:
112//=======================================================================
113 const TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::EdgesIn() const
114{
115 return myEdgesIn;
116}
117
118//=======================================================================
119// function :TopOpeBRepBuild_VertexInfo::EdgesOut
120// purpose:
121//=======================================================================
122 const TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::EdgesOut() const
123{
124 return myEdgesOut;
125}
126
127//=======================================================================
128// function :TopOpeBRepBuild_VertexInfo::ChangeEdgesOut
129// purpose:
130//=======================================================================
131 TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::ChangeEdgesOut()
132{
133 return myEdgesOut;
134}
135
136//=======================================================================
137// function :TopOpeBRepBuild_VertexInfo::Dump
138// purpose:
139//=======================================================================
140 void TopOpeBRepBuild_VertexInfo::Dump() const
141{
142 printf(" *** Dump the Vertex Info ***\n");
cf0786da 143 printf(" mySmart : %d\n", (mySmart ? 0 : 1));
7fd59977 144 printf(" Edges : %d In, %d Out\n", myEdgesIn.Extent(), myEdgesOut.Extent());
145
146
147 printf("\n");
148}
149
150//=======================================================================
151// function :TopOpeBRepBuild_VertexInfo::AppendPassed
152// purpose:
153//=======================================================================
154 void TopOpeBRepBuild_VertexInfo::AppendPassed(const TopoDS_Edge& anE)
155{
156 myEdgesPassed.Prepend(anE);
157}
158
159
160//=======================================================================
161// function :TopOpeBRepBuild_VertexInfo::RemovePassed
162// purpose:
163//=======================================================================
164 void TopOpeBRepBuild_VertexInfo::RemovePassed()
165{
166 myEdgesPassed.RemoveFirst();
167}
168//=======================================================================
169// function :TopOpeBRepBuild_VertexInfo::ListPassed
170// purpose:
171//=======================================================================
172 const TopTools_ListOfShape& TopOpeBRepBuild_VertexInfo::ListPassed() const
173{
174 return myEdgesPassed;
175}
176//=======================================================================
177// function :TopOpeBRepBuild_VertexInfo::Prepare
178// purpose:
179//=======================================================================
180 void TopOpeBRepBuild_VertexInfo::Prepare(const TopTools_ListOfShape& aL)
181{
182 myLocalEdgesOut.Clear();
183
184 TopTools_IndexedMapOfOrientedShape tmpMap;
185
186 TopTools_ListIteratorOfListOfShape anIt(aL);
187 for (; anIt.More(); anIt.Next()) {
188 tmpMap.Add(anIt.Value());
189 }
190
191 Standard_Integer i = 1, nb = myEdgesOut.Extent();
192 for(; i <= nb; i++) {
193 const TopoDS_Shape& aE = myEdgesOut(i);
194 if(!tmpMap.Contains(aE))
195 myLocalEdgesOut.Add(aE);
196 }
197
198 tmpMap.Clear();
199}
200
201//=======================================================================
202// function :TopOpeBRepBuild_VertexInfo:CurrentOut
203// purpose:
204//=======================================================================
205 const TopoDS_Edge& TopOpeBRepBuild_VertexInfo::CurrentOut ()
206{
207
96a95605 208 Standard_Integer i, aNbOut;
7fd59977 209 aNbOut =myLocalEdgesOut.Extent();
7fd59977 210
211 TopTools_IndexedMapOfOrientedShape aMapPassed;
212 TopTools_ListIteratorOfListOfShape anIt(myEdgesPassed);
213 for (; anIt.More(); anIt.Next()) {
214 aMapPassed.Add (anIt.Value());
215 }
216
217 for (i=1; i<=aNbOut; i++) {
218 if (!aMapPassed.Contains(myLocalEdgesOut(i))) {
219 myCurrent=TopoDS::Edge(myLocalEdgesOut(i));
220 myFoundOut=1;
221 return myCurrent;
222 }
223 }
224 myFoundOut=0;
225 TopoDS_Edge aS;
226 myCurrent=aS;
227 return myCurrent;
228}
229
230
231
232
233