1 // Created on: 1996-01-05
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <TopoDS_Shape.hxx>
19 #include <TopOpeBRepBuild_BlockBuilder.hxx>
20 #include <TopOpeBRepBuild_Loop.hxx>
21 #include <TopOpeBRepBuild_LoopSet.hxx>
22 #include <TopOpeBRepBuild_ShapeSet.hxx>
23 #include <TopOpeBRepBuild_ShellFaceClassifier.hxx>
24 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
25 #include <TopOpeBRepBuild_SolidBuilder.hxx>
27 //=======================================================================
28 //function : TopOpeBRepBuild_SolidBuilder
30 //=======================================================================
31 TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder()
35 //=======================================================================
36 //function : TopOpeBRepBuild_SolidBuilder
38 //=======================================================================
40 TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder
41 (TopOpeBRepBuild_ShellFaceSet& SFS, const Standard_Boolean ForceClass)
43 InitSolidBuilder(SFS,ForceClass);
46 //=======================================================================
47 //function : InitSolidBuilder
49 //=======================================================================
51 void TopOpeBRepBuild_SolidBuilder::InitSolidBuilder
52 (TopOpeBRepBuild_ShellFaceSet& SFS, const Standard_Boolean ForceClass)
55 TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
56 TopOpeBRepBuild_LoopSet& LS = myLoopSet;
57 TopOpeBRepBuild_ShellFaceClassifier SFC(BB);
58 mySolidAreaBuilder.InitSolidAreaBuilder(LS,SFC,ForceClass);
61 //=======================================================================
62 //function : InitSolid
64 //=======================================================================
66 Standard_Integer TopOpeBRepBuild_SolidBuilder::InitSolid()
68 Standard_Integer n = mySolidAreaBuilder.InitArea();
72 //=======================================================================
73 //function : MoreSolid
75 //=======================================================================
77 Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreSolid() const
79 Standard_Boolean b = mySolidAreaBuilder.MoreArea();
83 //=======================================================================
84 //function : NextSolid
86 //=======================================================================
88 void TopOpeBRepBuild_SolidBuilder::NextSolid()
90 mySolidAreaBuilder.NextArea();
93 //=======================================================================
94 //function : InitShell
96 //=======================================================================
98 Standard_Integer TopOpeBRepBuild_SolidBuilder::InitShell()
100 Standard_Integer n = mySolidAreaBuilder.InitLoop();
104 //=======================================================================
105 //function : MoreShell
107 //=======================================================================
109 Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreShell() const
111 Standard_Boolean b = mySolidAreaBuilder.MoreLoop();
115 //=======================================================================
116 //function : NextShell
118 //=======================================================================
120 void TopOpeBRepBuild_SolidBuilder::NextShell()
122 mySolidAreaBuilder.NextLoop();
125 //=======================================================================
126 //function : IsOldShell
128 //=======================================================================
130 Standard_Boolean TopOpeBRepBuild_SolidBuilder::IsOldShell() const
132 const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
133 Standard_Boolean b = L->IsShape();
137 //=======================================================================
138 //function : OldShell
140 //=======================================================================
142 const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::OldShell() const
144 const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
145 const TopoDS_Shape& B = L->Shape();
149 //=======================================================================
150 //function : InitFace
152 //=======================================================================
154 Standard_Integer TopOpeBRepBuild_SolidBuilder::InitFace()
156 const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
158 throw Standard_DomainError("TopOpeBRepBuild_SolidBuilder:InitFace");
160 myBlockIterator = L->BlockIterator();
161 myBlockIterator.Initialize();
163 Standard_Integer n = myBlockIterator.Extent();
167 //=======================================================================
168 //function : MoreFace
170 //=======================================================================
172 Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreFace() const
174 Standard_Boolean b = myBlockIterator.More();
178 //=======================================================================
179 //function : NextFace
181 //=======================================================================
183 void TopOpeBRepBuild_SolidBuilder::NextFace()
185 myBlockIterator.Next();
188 //=======================================================================
191 //=======================================================================
193 const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::Face() const
196 // const Standard_Integer i = myBlockIterator.Value(); // DEB
198 const TopoDS_Shape& F = myBlockBuilder.Element(myBlockIterator);
202 //=======================================================================
203 //function : MakeLoops
205 //=======================================================================
207 void TopOpeBRepBuild_SolidBuilder::MakeLoops(TopOpeBRepBuild_ShapeSet& SS)
209 TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
210 TopOpeBRepBuild_ListOfLoop& LL = myLoopSet.ChangeListOfLoop();
212 // Build blocks on elements of SS
215 // make list of loop (LL) of the LoopSet
216 // - on shapes of the ShapeSet (SS)
217 // - on blocks of the BlockBuilder (BB)
221 // Add shapes of SS as shape loops
222 for(SS.InitShapes(); SS.MoreShapes(); SS.NextShape()) {
223 const TopoDS_Shape& S = SS.Shape();
224 Handle(TopOpeBRepBuild_Loop) ShapeLoop = new TopOpeBRepBuild_Loop(S);
225 LL.Append(ShapeLoop);
228 // Add blocks of BB as block loops
229 for (BB.InitBlock(); BB.MoreBlock(); BB.NextBlock()) {
230 TopOpeBRepBuild_BlockIterator BI = BB.BlockIterator();
231 Handle(TopOpeBRepBuild_Loop) BlockLoop = new TopOpeBRepBuild_Loop(BI);
232 LL.Append(BlockLoop);