0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_SolidBuilder.cxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
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>
26
27 //=======================================================================
28 //function : TopOpeBRepBuild_SolidBuilder
29 //purpose  : 
30 //=======================================================================
31 TopOpeBRepBuild_SolidBuilder::TopOpeBRepBuild_SolidBuilder()
32 {
33 }
34
35 //=======================================================================
36 //function : TopOpeBRepBuild_SolidBuilder
37 //purpose  : 
38 //=======================================================================
39
40 TopOpeBRepBuild_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
51 void 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
66 Standard_Integer TopOpeBRepBuild_SolidBuilder::InitSolid()
67 {
68   Standard_Integer n = mySolidAreaBuilder.InitArea();
69   return n;
70 }
71
72 //=======================================================================
73 //function : MoreSolid
74 //purpose  : 
75 //=======================================================================
76
77 Standard_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
88 void TopOpeBRepBuild_SolidBuilder::NextSolid()
89 {
90   mySolidAreaBuilder.NextArea();
91 }
92
93 //=======================================================================
94 //function : InitShell
95 //purpose  : 
96 //=======================================================================
97
98 Standard_Integer TopOpeBRepBuild_SolidBuilder::InitShell()
99 {
100   Standard_Integer n = mySolidAreaBuilder.InitLoop();
101   return n;
102 }
103
104 //=======================================================================
105 //function : MoreShell
106 //purpose  : 
107 //=======================================================================
108
109 Standard_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
120 void TopOpeBRepBuild_SolidBuilder::NextShell()
121 {
122   mySolidAreaBuilder.NextLoop();
123 }
124
125 //=======================================================================
126 //function : IsOldShell
127 //purpose  : 
128 //=======================================================================
129
130 Standard_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
142 const 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
154 Standard_Integer TopOpeBRepBuild_SolidBuilder::InitFace()
155 {
156   const Handle(TopOpeBRepBuild_Loop)& L = mySolidAreaBuilder.Loop();
157   if ( L->IsShape() )
158     throw Standard_DomainError("TopOpeBRepBuild_SolidBuilder:InitFace");
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
172 Standard_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
183 void TopOpeBRepBuild_SolidBuilder::NextFace()
184 {
185   myBlockIterator.Next();
186 }
187
188 //=======================================================================
189 //function : Face
190 //purpose  : 
191 //=======================================================================
192
193 const TopoDS_Shape& TopOpeBRepBuild_SolidBuilder::Face() const
194 {
195 #ifdef OCCT_DEBUG
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
207 void 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 }