1 // Created on: 1993-06-17
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <BOP_ShapeSet.ixx>
24 #include <Standard_ProgramError.hxx>
26 #include <TopExp_Explorer.hxx>
31 //=======================================================================
32 //function : BOP_ShapeSet::BOP_ShapeSet
34 //=======================================================================
35 BOP_ShapeSet::BOP_ShapeSet(const TopAbs_ShapeEnum SubShapeType)
37 mySubShapeType(SubShapeType)
39 switch (SubShapeType) {
41 myShapeType = TopAbs_FACE;
44 myShapeType = TopAbs_EDGE;
47 Standard_ProgramError::Raise("ShapeSet : bad ShapeType");
51 //=======================================================================
54 //=======================================================================
55 void BOP_ShapeSet::Delete()
58 //=======================================================================
59 //function : ClearContents
61 //=======================================================================
62 void BOP_ShapeSet::ClearContents()
64 myStartShapes.Clear();
65 mySubShapeMap.Clear();
67 myCurrentShapeNeighbours.Clear();
70 //=======================================================================
73 //=======================================================================
74 void BOP_ShapeSet::AddShape(const TopoDS_Shape& S)
79 //=======================================================================
80 //function : AddStartElement
82 //=======================================================================
83 void BOP_ShapeSet::AddStartElement(const TopoDS_Shape& S)
85 ProcessAddStartElement(S);
88 //=======================================================================
89 //function : AddElement
91 //=======================================================================
92 void BOP_ShapeSet::AddElement(const TopoDS_Shape& S)
97 //=======================================================================
98 //function : ProcessAddShape
100 //=======================================================================
101 void BOP_ShapeSet::ProcessAddShape(const TopoDS_Shape& S)
106 //=======================================================================
107 //function : ProcessAddStartElement
109 //=======================================================================
110 void BOP_ShapeSet::ProcessAddStartElement(const TopoDS_Shape& S)
112 TopTools_ListIteratorOfListOfShape anIt(myStartShapes);
113 for (; anIt.More(); anIt.Next()) {
114 const TopoDS_Shape& aSInner=anIt.Value();
119 myStartShapes.Append(S);
120 ProcessAddElement(S);
123 //=======================================================================
124 //function : ProcessAddElement
126 //=======================================================================
127 void BOP_ShapeSet::ProcessAddElement(const TopoDS_Shape& S)
130 TopTools_ListOfShape Lemp;
132 TopExp_Explorer Ex(S, mySubShapeType);
133 for (; Ex.More(); Ex.Next()) {
134 const TopoDS_Shape& subshape = Ex.Current();
135 b = ( ! mySubShapeMap.Contains(subshape) );
137 mySubShapeMap.Add(subshape, Lemp);
139 mySubShapeMap.ChangeFromKey(subshape).Append(S);
143 //=======================================================================
144 //function : StartElements
146 //=======================================================================
147 const TopTools_ListOfShape& BOP_ShapeSet::StartElements()const
149 return myStartShapes;
152 //=======================================================================
153 //function : InitShapes
155 //=======================================================================
156 void BOP_ShapeSet::InitShapes()
158 myShapesIter.Initialize(myShapes);
161 //=======================================================================
162 //function : MoreShapes
164 //=======================================================================
165 Standard_Boolean BOP_ShapeSet::MoreShapes()const
167 Standard_Boolean b = myShapesIter.More();
171 //=======================================================================
172 //function : NextShape
174 //=======================================================================
175 void BOP_ShapeSet::NextShape()
180 //=======================================================================
183 //=======================================================================
184 const TopoDS_Shape& BOP_ShapeSet::Shape()const
186 const TopoDS_Shape& S = myShapesIter.Value();
190 //=======================================================================
191 //function : InitStartElements
193 //=======================================================================
194 void BOP_ShapeSet::InitStartElements()
196 myStartShapesIter.Initialize(myStartShapes);
199 //=======================================================================
200 //function : MoreStartElements
202 //=======================================================================
203 Standard_Boolean BOP_ShapeSet::MoreStartElements()const
205 Standard_Boolean b = myStartShapesIter.More();
209 //=======================================================================
210 //function : NextStartElement
212 //=======================================================================
213 void BOP_ShapeSet::NextStartElement()
215 myStartShapesIter.Next();
218 //=======================================================================
219 //function : StartElement
221 //=======================================================================
222 const TopoDS_Shape& BOP_ShapeSet::StartElement()const
224 const TopoDS_Shape& S = myStartShapesIter.Value();
228 //=======================================================================
229 //function : InitNeighbours
231 //=======================================================================
232 void BOP_ShapeSet::InitNeighbours(const TopoDS_Shape& S)
234 mySubShapeExplorer.Init(S, mySubShapeType);
239 //=======================================================================
240 //function : MoreNeighbours
242 //=======================================================================
243 Standard_Boolean BOP_ShapeSet::MoreNeighbours()
245 Standard_Boolean b = myIncidentShapesIter.More();
249 //=======================================================================
250 //function : NextNeighbour
252 //=======================================================================
253 void BOP_ShapeSet::NextNeighbour()
255 Standard_Boolean noisimore, ssemore;
257 myIncidentShapesIter.Next();
258 noisimore = ! myIncidentShapesIter.More();
260 ssemore = mySubShapeExplorer.More();
262 mySubShapeExplorer.Next();
268 //=======================================================================
269 //function : Neighbour
271 //=======================================================================
272 const TopoDS_Shape& BOP_ShapeSet::Neighbour()const
274 const TopoDS_Shape& S = myIncidentShapesIter.Value();
278 //=======================================================================
279 //function : ChangeStartShapes
281 //=======================================================================
282 TopTools_ListOfShape& BOP_ShapeSet::ChangeStartShapes()
284 return myStartShapes;
287 //=======================================================================
288 //function : FindNeighbours
290 //=======================================================================
291 void BOP_ShapeSet::FindNeighbours()
293 while (mySubShapeExplorer.More()) {
294 // l = list of edges neighbour of edge myCurrentShape trough
295 // the vertex mySubShapeExplorer.Current(), which is a vertex of the
296 // edge myCurrentShape.
297 const TopoDS_Shape& V = mySubShapeExplorer.Current();
298 const TopTools_ListOfShape & l = MakeNeighboursList(myCurrentShape,V);
299 // myIncidentShapesIter iterates on the neighbour edges of the edge
300 // given as InitNeighbours() argument (this edge has been stored
301 // in the field myCurrentShape).
302 myIncidentShapesIter.Initialize(l);
303 if (myIncidentShapesIter.More()) {
307 mySubShapeExplorer.Next();
312 //=======================================================================
313 //function : MakeNeighboursList
315 //=======================================================================
316 const TopTools_ListOfShape & BOP_ShapeSet::MakeNeighboursList(const TopoDS_Shape& ,//Earg,
317 const TopoDS_Shape& Varg)
319 const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(Varg);
323 //=======================================================================
324 //function : MaxNumberSubShape
326 //=======================================================================
327 Standard_Integer BOP_ShapeSet::MaxNumberSubShape(const TopoDS_Shape& Shape)
329 Standard_Integer i, m = 0;
331 TopExp_Explorer SE(Shape, mySubShapeType);
334 const TopoDS_Shape& SubShape = SE.Current();
335 if(!mySubShapeMap.Contains(SubShape)) {
340 const TopTools_ListOfShape& l = mySubShapeMap.FindFromKey(SubShape);