1 // File: BOP_ShapeSet.cxx
2 // Created: Thu Jun 17 17:21:05 1993
3 // Author: Jean Yves LEBEY
6 #include <BOP_ShapeSet.ixx>
8 #include <Standard_ProgramError.hxx>
10 #include <TopExp_Explorer.hxx>
15 //=======================================================================
16 //function : BOP_ShapeSet::BOP_ShapeSet
18 //=======================================================================
19 BOP_ShapeSet::BOP_ShapeSet(const TopAbs_ShapeEnum SubShapeType)
21 mySubShapeType(SubShapeType)
23 switch (SubShapeType) {
25 myShapeType = TopAbs_FACE;
28 myShapeType = TopAbs_EDGE;
31 Standard_ProgramError::Raise("ShapeSet : bad ShapeType");
35 //=======================================================================
38 //=======================================================================
39 void BOP_ShapeSet::Delete()
42 //=======================================================================
43 //function : ClearContents
45 //=======================================================================
46 void BOP_ShapeSet::ClearContents()
48 myStartShapes.Clear();
49 mySubShapeMap.Clear();
51 myCurrentShapeNeighbours.Clear();
54 //=======================================================================
57 //=======================================================================
58 void BOP_ShapeSet::AddShape(const TopoDS_Shape& S)
63 //=======================================================================
64 //function : AddStartElement
66 //=======================================================================
67 void BOP_ShapeSet::AddStartElement(const TopoDS_Shape& S)
69 ProcessAddStartElement(S);
72 //=======================================================================
73 //function : AddElement
75 //=======================================================================
76 void BOP_ShapeSet::AddElement(const TopoDS_Shape& S)
81 //=======================================================================
82 //function : ProcessAddShape
84 //=======================================================================
85 void BOP_ShapeSet::ProcessAddShape(const TopoDS_Shape& S)
90 //=======================================================================
91 //function : ProcessAddStartElement
93 //=======================================================================
94 void BOP_ShapeSet::ProcessAddStartElement(const TopoDS_Shape& S)
96 TopTools_ListIteratorOfListOfShape anIt(myStartShapes);
97 for (; anIt.More(); anIt.Next()) {
98 const TopoDS_Shape& aSInner=anIt.Value();
103 myStartShapes.Append(S);
104 ProcessAddElement(S);
107 //=======================================================================
108 //function : ProcessAddElement
110 //=======================================================================
111 void BOP_ShapeSet::ProcessAddElement(const TopoDS_Shape& S)
114 TopTools_ListOfShape Lemp;
116 TopExp_Explorer Ex(S, mySubShapeType);
117 for (; Ex.More(); Ex.Next()) {
118 const TopoDS_Shape& subshape = Ex.Current();
119 b = ( ! mySubShapeMap.Contains(subshape) );
121 mySubShapeMap.Add(subshape, Lemp);
123 mySubShapeMap.ChangeFromKey(subshape).Append(S);
127 //=======================================================================
128 //function : StartElements
130 //=======================================================================
131 const TopTools_ListOfShape& BOP_ShapeSet::StartElements()const
133 return myStartShapes;
136 //=======================================================================
137 //function : InitShapes
139 //=======================================================================
140 void BOP_ShapeSet::InitShapes()
142 myShapesIter.Initialize(myShapes);
145 //=======================================================================
146 //function : MoreShapes
148 //=======================================================================
149 Standard_Boolean BOP_ShapeSet::MoreShapes()const
151 Standard_Boolean b = myShapesIter.More();
155 //=======================================================================
156 //function : NextShape
158 //=======================================================================
159 void BOP_ShapeSet::NextShape()
164 //=======================================================================
167 //=======================================================================
168 const TopoDS_Shape& BOP_ShapeSet::Shape()const
170 const TopoDS_Shape& S = myShapesIter.Value();
174 //=======================================================================
175 //function : InitStartElements
177 //=======================================================================
178 void BOP_ShapeSet::InitStartElements()
180 myStartShapesIter.Initialize(myStartShapes);
183 //=======================================================================
184 //function : MoreStartElements
186 //=======================================================================
187 Standard_Boolean BOP_ShapeSet::MoreStartElements()const
189 Standard_Boolean b = myStartShapesIter.More();
193 //=======================================================================
194 //function : NextStartElement
196 //=======================================================================
197 void BOP_ShapeSet::NextStartElement()
199 myStartShapesIter.Next();
202 //=======================================================================
203 //function : StartElement
205 //=======================================================================
206 const TopoDS_Shape& BOP_ShapeSet::StartElement()const
208 const TopoDS_Shape& S = myStartShapesIter.Value();
212 //=======================================================================
213 //function : InitNeighbours
215 //=======================================================================
216 void BOP_ShapeSet::InitNeighbours(const TopoDS_Shape& S)
218 mySubShapeExplorer.Init(S, mySubShapeType);
223 //=======================================================================
224 //function : MoreNeighbours
226 //=======================================================================
227 Standard_Boolean BOP_ShapeSet::MoreNeighbours()
229 Standard_Boolean b = myIncidentShapesIter.More();
233 //=======================================================================
234 //function : NextNeighbour
236 //=======================================================================
237 void BOP_ShapeSet::NextNeighbour()
239 Standard_Boolean noisimore, ssemore;
241 myIncidentShapesIter.Next();
242 noisimore = ! myIncidentShapesIter.More();
244 ssemore = mySubShapeExplorer.More();
246 mySubShapeExplorer.Next();
252 //=======================================================================
253 //function : Neighbour
255 //=======================================================================
256 const TopoDS_Shape& BOP_ShapeSet::Neighbour()const
258 const TopoDS_Shape& S = myIncidentShapesIter.Value();
262 //=======================================================================
263 //function : ChangeStartShapes
265 //=======================================================================
266 TopTools_ListOfShape& BOP_ShapeSet::ChangeStartShapes()
268 return myStartShapes;
271 //=======================================================================
272 //function : FindNeighbours
274 //=======================================================================
275 void BOP_ShapeSet::FindNeighbours()
277 while (mySubShapeExplorer.More()) {
278 // l = list of edges neighbour of edge myCurrentShape trough
279 // the vertex mySubShapeExplorer.Current(), which is a vertex of the
280 // edge myCurrentShape.
281 const TopoDS_Shape& V = mySubShapeExplorer.Current();
282 const TopTools_ListOfShape & l = MakeNeighboursList(myCurrentShape,V);
283 // myIncidentShapesIter iterates on the neighbour edges of the edge
284 // given as InitNeighbours() argument (this edge has been stored
285 // in the field myCurrentShape).
286 myIncidentShapesIter.Initialize(l);
287 if (myIncidentShapesIter.More()) {
291 mySubShapeExplorer.Next();
296 //=======================================================================
297 //function : MakeNeighboursList
299 //=======================================================================
300 const TopTools_ListOfShape & BOP_ShapeSet::MakeNeighboursList(const TopoDS_Shape& ,//Earg,
301 const TopoDS_Shape& Varg)
303 const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(Varg);
307 //=======================================================================
308 //function : MaxNumberSubShape
310 //=======================================================================
311 Standard_Integer BOP_ShapeSet::MaxNumberSubShape(const TopoDS_Shape& Shape)
313 Standard_Integer i, m = 0;
315 TopExp_Explorer SE(Shape, mySubShapeType);
318 const TopoDS_Shape& SubShape = SE.Current();
319 if(!mySubShapeMap.Contains(SubShape)) {
324 const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(SubShape);