1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <BOP_SolidBuilder.ixx>
22 #include <BOP_ShellFaceClassifier.hxx>
23 #include <BOP_Loop.hxx>
24 #include <BOP_SFSCorrector.hxx>
28 // ==============================================================
29 // function: BOP_SolidBuilder
31 // ==============================================================
32 BOP_SolidBuilder::BOP_SolidBuilder()
36 // ==============================================================
37 // function: BOP_SolidBuilder
39 // ==============================================================
40 BOP_SolidBuilder::BOP_SolidBuilder(BOP_ShellFaceSet& theSFS,
41 const Standard_Boolean theForceClassFlag)
43 InitSolidBuilder(theSFS, theForceClassFlag);
46 // ==============================================================
47 // function: InitSolidBuilder
49 // ==============================================================
50 void BOP_SolidBuilder::InitSolidBuilder(BOP_ShellFaceSet& theSFS,
51 const Standard_Boolean theForceClassFlag)
54 BOP_SFSCorrector aSFSCor;
55 aSFSCor.SetSFS(theSFS);
57 BOP_ShellFaceSet& aNewSFS=aSFSCor.NewSFS();
62 BOP_ShellFaceClassifier SFC(myBlockBuilder);
64 mySolidAreaBuilder.InitSolidAreaBuilder(myLoopSet, SFC, theForceClassFlag);
67 // ==============================================================
68 // function: InitSolid
70 // ==============================================================
71 Standard_Integer BOP_SolidBuilder::InitSolid()
73 return mySolidAreaBuilder.InitArea();
76 // ==============================================================
77 // function: MoreSolid
79 // ==============================================================
80 Standard_Boolean BOP_SolidBuilder::MoreSolid() const
82 return mySolidAreaBuilder.MoreArea();
85 // ==============================================================
86 // function: NextSolid
88 // ==============================================================
89 void BOP_SolidBuilder::NextSolid()
91 mySolidAreaBuilder.NextArea();
94 // ==============================================================
95 // function: InitShell
97 // ==============================================================
98 Standard_Integer BOP_SolidBuilder::InitShell()
100 return mySolidAreaBuilder.InitLoop();
103 // ==============================================================
104 // function: MoreShell
106 // ==============================================================
107 Standard_Boolean BOP_SolidBuilder::MoreShell() const
109 return mySolidAreaBuilder.MoreLoop();
112 // ==============================================================
113 // function: NextShell
115 // ==============================================================
116 void BOP_SolidBuilder::NextShell()
118 mySolidAreaBuilder.NextLoop();
121 // ==============================================================
122 // function: IsOldShell
124 // ==============================================================
125 Standard_Boolean BOP_SolidBuilder::IsOldShell() const
127 return mySolidAreaBuilder.Loop()->IsShape();
130 // ==============================================================
131 // function: OldShell
133 // ==============================================================
134 TopoDS_Shell BOP_SolidBuilder::OldShell() const
137 Standard_DomainError::Raise("BOP_SolidBuilder::OldShell");
140 return TopoDS::Shell(mySolidAreaBuilder.Loop()->Shape());
143 // ==============================================================
144 // function: InitFace
146 // ==============================================================
147 Standard_Integer BOP_SolidBuilder::InitFace()
149 const Handle(BOP_Loop)& aLoop = mySolidAreaBuilder.Loop();
152 Standard_DomainError::Raise("BOP_SolidBuilder::InitFace");
154 myBlockIterator = aLoop->BlockIterator();
155 myBlockIterator.Initialize();
157 return myBlockIterator.Extent();
160 // ==============================================================
161 // function: MoreFace
163 // ==============================================================
164 Standard_Boolean BOP_SolidBuilder::MoreFace() const
166 return myBlockIterator.More();
169 // ==============================================================
170 // function: NextFace
172 // ==============================================================
173 void BOP_SolidBuilder::NextFace()
175 myBlockIterator.Next();
178 // ==============================================================
181 // ==============================================================
182 const TopoDS_Face& BOP_SolidBuilder::Face() const
184 const TopoDS_Shape& aShape = myBlockBuilder.Element(myBlockIterator);
185 return TopoDS::Face(aShape);
188 // ==============================================================
189 // function: MakeLoops
191 // ==============================================================
192 void BOP_SolidBuilder::MakeLoops(BOP_ShapeSet& theSFS)
194 myBlockBuilder.MakeBlock(theSFS);
196 BOP_ListOfLoop& aList = myLoopSet.ChangeListOfLoop();
199 // Add shapes of theSFS as shape loops
200 for(theSFS.InitShapes(); theSFS.MoreShapes(); theSFS.NextShape()) {
201 Handle(BOP_Loop) aShapeLoop = new BOP_Loop(theSFS.Shape());
202 aList.Append(aShapeLoop);
205 // Add blocks of myBlockBuilder as block loops
206 for(myBlockBuilder.InitBlock(); myBlockBuilder.MoreBlock(); myBlockBuilder.NextBlock()) {
207 BOP_BlockIterator aBlockIterator = myBlockBuilder.BlockIterator();
208 Handle(BOP_Loop) aShapeLoop = new BOP_Loop(aBlockIterator);
209 aList.Append(aShapeLoop);