0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_SolidBuilder.cxx
CommitLineData
b311480e 1// Created on: 1996-01-05
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <TopoDS_Shape.hxx>
7fd59977 19#include <TopOpeBRepBuild_BlockBuilder.hxx>
42cf5bc1 20#include <TopOpeBRepBuild_Loop.hxx>
7fd59977 21#include <TopOpeBRepBuild_LoopSet.hxx>
42cf5bc1 22#include <TopOpeBRepBuild_ShapeSet.hxx>
23#include <TopOpeBRepBuild_ShellFaceClassifier.hxx>
24#include <TopOpeBRepBuild_ShellFaceSet.hxx>
25#include <TopOpeBRepBuild_SolidBuilder.hxx>
7fd59977 26
27//=======================================================================
28//function : TopOpeBRepBuild_SolidBuilder
29//purpose :
30//=======================================================================
7fd59977 31TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder()
32{
33}
34
35//=======================================================================
36//function : TopOpeBRepBuild_SolidBuilder
37//purpose :
38//=======================================================================
39
40TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder
41(TopOpeBRepBuild_ShellFaceSet& SFS, const Standard_Boolean ForceClass)
42{
43 InitSolidBuilder(SFS,ForceClass);
44}
45
46//=======================================================================
47//function : InitSolidBuilder
48//purpose :
49//=======================================================================
50
51void TopOpeBRepBuild_SolidBuilder::InitSolidBuilder
52(TopOpeBRepBuild_ShellFaceSet& SFS, const Standard_Boolean ForceClass)
53{
54 MakeLoops(SFS);
55 TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
56 TopOpeBRepBuild_LoopSet& LS = myLoopSet;
57 TopOpeBRepBuild_ShellFaceClassifier SFC(BB);
58 mySolidAreaBuilder.InitSolidAreaBuilder(LS,SFC,ForceClass);
59}
60
61//=======================================================================
62//function : InitSolid
63//purpose :
64//=======================================================================
65
66Standard_Integer TopOpeBRepBuild_SolidBuilder::InitSolid()
67{
68 Standard_Integer n = mySolidAreaBuilder.InitArea();
69 return n;
70}
71
72//=======================================================================
73//function : MoreSolid
74//purpose :
75//=======================================================================
76
77Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreSolid() const
78{
79 Standard_Boolean b = mySolidAreaBuilder.MoreArea();
80 return b;
81}
82
83//=======================================================================
84//function : NextSolid
85//purpose :
86//=======================================================================
87
88void TopOpeBRepBuild_SolidBuilder::NextSolid()
89{
90 mySolidAreaBuilder.NextArea();
91}
92
93//=======================================================================
94//function : InitShell
95//purpose :
96//=======================================================================
97
98Standard_Integer TopOpeBRepBuild_SolidBuilder::InitShell()
99{
100 Standard_Integer n = mySolidAreaBuilder.InitLoop();
101 return n;
102}
103
104//=======================================================================
105//function : MoreShell
106//purpose :
107//=======================================================================
108
109Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreShell() const
110{
111 Standard_Boolean b = mySolidAreaBuilder.MoreLoop();
112 return b;
113}
114
115//=======================================================================
116//function : NextShell
117//purpose :
118//=======================================================================
119
120void TopOpeBRepBuild_SolidBuilder::NextShell()
121{
122 mySolidAreaBuilder.NextLoop();
123}
124
125//=======================================================================
126//function : IsOldShell
127//purpose :
128//=======================================================================
129
130Standard_Boolean TopOpeBRepBuild_SolidBuilder::IsOldShell() const
131{
132 const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
133 Standard_Boolean b = L->IsShape();
134 return b;
135}
136
137//=======================================================================
138//function : OldShell
139//purpose :
140//=======================================================================
141
142const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::OldShell() const
143{
144 const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
145 const TopoDS_Shape& B = L->Shape();
146 return B;
147}
148
149//=======================================================================
150//function : InitFace
151//purpose :
152//=======================================================================
153
154Standard_Integer TopOpeBRepBuild_SolidBuilder::InitFace()
155{
156 const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
157 if ( L->IsShape() )
9775fa61 158 throw Standard_DomainError("TopOpeBRepBuild_SolidBuilder:InitFace");
7fd59977 159 else {
160 myBlockIterator = L->BlockIterator();
161 myBlockIterator.Initialize();
162 }
163 Standard_Integer n = myBlockIterator.Extent();
164 return n;
165}
166
167//=======================================================================
168//function : MoreFace
169//purpose :
170//=======================================================================
171
172Standard_Boolean TopOpeBRepBuild_SolidBuilder::MoreFace() const
173{
174 Standard_Boolean b = myBlockIterator.More();
175 return b;
176}
177
178//=======================================================================
179//function : NextFace
180//purpose :
181//=======================================================================
182
183void TopOpeBRepBuild_SolidBuilder::NextFace()
184{
185 myBlockIterator.Next();
186}
187
188//=======================================================================
189//function : Face
190//purpose :
191//=======================================================================
192
193const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::Face() const
194{
0797d9d3 195#ifdef OCCT_DEBUG
7fd59977 196// const Standard_Integer i = myBlockIterator.Value(); // DEB
197#endif
198 const TopoDS_Shape& F = myBlockBuilder.Element(myBlockIterator);
199 return F;
200}
201
202//=======================================================================
203//function : MakeLoops
204//purpose :
205//=======================================================================
206
207void TopOpeBRepBuild_SolidBuilder::MakeLoops(TopOpeBRepBuild_ShapeSet& SS)
208{
209 TopOpeBRepBuild_BlockBuilder& BB = myBlockBuilder;
210 TopOpeBRepBuild_ListOfLoop& LL = myLoopSet.ChangeListOfLoop();
211
212 // Build blocks on elements of SS
213 BB.MakeBlock(SS);
214
215 // make list of loop (LL) of the LoopSet
216 // - on shapes of the ShapeSet (SS)
217 // - on blocks of the BlockBuilder (BB)
218
219 LL.Clear();
220
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);
226 }
227
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);
233 }
234
235}