Integration of OCCT 6.5.0 from SVN
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_VertexInfo.cxx
1 #include <TopOpeBRepBuild_VertexInfo.ixx>
2 #include <TopoDS.hxx>
3 #include <TopTools_ListIteratorOfListOfShape.hxx>
4 #include <stdio.h>
5
6 //=======================================================================
7 // function :TopOpeBRepBuild_VertexInfo
8 // purpose: 
9 //=======================================================================
10   TopOpeBRepBuild_VertexInfo::TopOpeBRepBuild_VertexInfo()
11 {
12   mySmart=Standard_False;
13   myFoundOut=0;
14   myEdgesPassed.Clear();
15 }
16 //=======================================================================
17 // function :TopOpeBRepBuild_VertexInfo::SetVertex
18 // purpose: 
19 //=======================================================================
20   void TopOpeBRepBuild_VertexInfo::SetVertex(const TopoDS_Vertex& aV) 
21 {
22   myVertex=aV;
23 }
24 //=======================================================================
25 // function :TopOpeBRepBuild_VertexInfo::Vertex
26 // purpose: 
27 //=======================================================================
28   const TopoDS_Vertex& TopOpeBRepBuild_VertexInfo::Vertex() const
29 {
30   return myVertex;
31 }
32 //=======================================================================
33 // function :TopOpeBRepBuild_VertexInfo::SetSmart
34 // purpose: 
35 //=======================================================================
36   void TopOpeBRepBuild_VertexInfo::SetSmart(const Standard_Boolean aFlag) 
37 {
38   mySmart=aFlag;
39 }
40 //=======================================================================
41 // function :TopOpeBRepBuild_VertexInfo:Smart
42 // purpose: 
43 //=======================================================================
44    Standard_Boolean TopOpeBRepBuild_VertexInfo::Smart() const
45 {
46   return mySmart;
47 }
48 //=======================================================================
49 // function :TopOpeBRepBuild_VertexInfo:NbCases
50 // purpose: 
51 //=======================================================================
52    Standard_Integer TopOpeBRepBuild_VertexInfo::NbCases() const
53 {//myCurrentIn
54   return myLocalEdgesOut.Extent();
55 }
56
57 //=======================================================================
58 // function :TopOpeBRepBuild_VertexInfo:FoundOut
59 // purpose: 
60 //=======================================================================
61    Standard_Integer TopOpeBRepBuild_VertexInfo::FoundOut () const
62 {
63   return myFoundOut;
64 }
65
66 //=======================================================================
67 // function :TopOpeBRepBuild_VertexInfo::AddIn
68 // purpose: 
69 //=======================================================================
70   void TopOpeBRepBuild_VertexInfo::AddIn(const TopoDS_Edge& anE) 
71 {
72   myEdgesIn.Add(anE);
73 }
74
75 //=======================================================================
76 // function :TopOpeBRepBuild_VertexInfo::AddOut
77 // purpose: 
78 //=======================================================================
79   void TopOpeBRepBuild_VertexInfo::AddOut(const TopoDS_Edge& anE) 
80 {
81   myEdgesOut.Add(anE);
82 }
83
84 //=======================================================================
85 // function :TopOpeBRepBuild_VertexInfo::SetCurrentIn
86 // purpose: 
87 //=======================================================================
88   void TopOpeBRepBuild_VertexInfo::SetCurrentIn(const TopoDS_Edge& anE) 
89 {
90   myCurrentIn=anE;
91 }
92
93 //=======================================================================
94 // function :TopOpeBRepBuild_VertexInfo::EdgesIn
95 // purpose: 
96 //=======================================================================
97   const TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::EdgesIn() const  
98 {
99   return myEdgesIn;
100 }
101
102 //=======================================================================
103 // function :TopOpeBRepBuild_VertexInfo::EdgesOut
104 // purpose: 
105 //=======================================================================
106   const TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::EdgesOut() const  
107 {
108   return myEdgesOut;
109 }
110
111 //=======================================================================
112 // function :TopOpeBRepBuild_VertexInfo::ChangeEdgesOut
113 // purpose: 
114 //=======================================================================
115   TopTools_IndexedMapOfOrientedShape& TopOpeBRepBuild_VertexInfo::ChangeEdgesOut()
116 {
117   return myEdgesOut;
118 }
119
120 //=======================================================================
121 // function :TopOpeBRepBuild_VertexInfo::Dump
122 // purpose: 
123 //=======================================================================
124   void TopOpeBRepBuild_VertexInfo::Dump() const
125 {
126   printf(" *** Dump the Vertex Info ***\n");
127   printf(" mySmart  : %d\n", mySmart);
128   printf(" Edges    : %d In, %d Out\n", myEdgesIn.Extent(), myEdgesOut.Extent());
129   
130   
131   printf("\n");
132 }
133
134 //=======================================================================
135 // function :TopOpeBRepBuild_VertexInfo::AppendPassed
136 // purpose: 
137 //=======================================================================
138   void TopOpeBRepBuild_VertexInfo::AppendPassed(const TopoDS_Edge& anE) 
139 {
140   myEdgesPassed.Prepend(anE);
141 }
142
143
144 //=======================================================================
145 // function :TopOpeBRepBuild_VertexInfo::RemovePassed
146 // purpose: 
147 //=======================================================================
148   void TopOpeBRepBuild_VertexInfo::RemovePassed() 
149 {
150   myEdgesPassed.RemoveFirst();
151 }
152 //=======================================================================
153 // function :TopOpeBRepBuild_VertexInfo::ListPassed
154 // purpose: 
155 //=======================================================================
156   const TopTools_ListOfShape&  TopOpeBRepBuild_VertexInfo::ListPassed() const 
157 {
158   return myEdgesPassed;
159 }
160 //=======================================================================
161 // function :TopOpeBRepBuild_VertexInfo::Prepare
162 // purpose: 
163 //=======================================================================
164   void TopOpeBRepBuild_VertexInfo::Prepare(const TopTools_ListOfShape& aL)  
165 {
166   myLocalEdgesOut.Clear();
167
168   TopTools_IndexedMapOfOrientedShape tmpMap;
169   
170   TopTools_ListIteratorOfListOfShape anIt(aL);
171   for (; anIt.More(); anIt.Next()) {
172     tmpMap.Add(anIt.Value());
173   }
174
175   Standard_Integer i = 1, nb = myEdgesOut.Extent();
176   for(; i <= nb; i++) {
177     const TopoDS_Shape& aE = myEdgesOut(i);
178     if(!tmpMap.Contains(aE))
179       myLocalEdgesOut.Add(aE);
180   }
181
182   tmpMap.Clear();
183 }
184
185 //=======================================================================
186 // function :TopOpeBRepBuild_VertexInfo:CurrentOut
187 // purpose: 
188 //=======================================================================
189   const TopoDS_Edge& TopOpeBRepBuild_VertexInfo::CurrentOut () 
190 {
191
192   Standard_Integer i, aNbOut, aNbPassed ;
193   aNbOut =myLocalEdgesOut.Extent();
194   aNbPassed=myEdgesPassed.Extent();
195   
196   TopTools_IndexedMapOfOrientedShape aMapPassed;
197   TopTools_ListIteratorOfListOfShape anIt(myEdgesPassed);
198   for (; anIt.More(); anIt.Next()) {
199     aMapPassed.Add (anIt.Value());
200   }
201
202   for (i=1; i<=aNbOut; i++) {
203     if (!aMapPassed.Contains(myLocalEdgesOut(i))) {
204       myCurrent=TopoDS::Edge(myLocalEdgesOut(i));
205       myFoundOut=1;
206       return myCurrent;
207     }
208   }
209   myFoundOut=0;
210   TopoDS_Edge aS;
211   myCurrent=aS;
212   return myCurrent;
213 }
214
215
216
217
218