0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_FREGU.cxx
CommitLineData
b311480e 1// Created on: 1996-03-07
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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TopOpeBRepBuild_Builder.ixx>
18
19#include <TopOpeBRepBuild_WireToFace.hxx>
20#include <TopOpeBRepTool.hxx>
21#include <TopExp_Explorer.hxx>
22#include <TopExp.hxx>
23#include <TopoDS.hxx>
24#include <TopoDS_Wire.hxx>
25#include <TopoDS_Face.hxx>
26#include <BRep_Builder.hxx>
27#include <BRep_Tool.hxx>
28#include <Standard_ProgramError.hxx>
29#include <TopOpeBRepDS_define.hxx>
30
31#ifdef DEB
1d0a9d4d 32extern Standard_Boolean TopOpeBRepBuild_GetcontextNOREGUFA();
33extern Standard_Boolean TopOpeBRepBuild_GetcontextREGUXPU();
34extern Standard_Boolean TopOpeBRepBuild_GettraceSAVFREGU();
7fd59977 35void debregufa(const Standard_Integer /*iF*/) {}
36#endif
37
38#ifdef DRAW
39#include <DBRep.hxx>
40#endif
41
42#define M_FORWARD(O) (O == TopAbs_FORWARD)
43#define M_REVERSED(O) (O == TopAbs_REVERSED)
44
45//=======================================================================
46//function : RegularizeFaces
47//purpose :
48//=======================================================================
49void TopOpeBRepBuild_Builder::RegularizeFaces
50(const TopoDS_Shape& FF,const TopTools_ListOfShape& lnewFace,TopTools_ListOfShape& LOF)
51{
52 LOF.Clear();
53 myMemoSplit.Clear();
54
55 TopTools_ListIteratorOfListOfShape itl(lnewFace);
56 for (;itl.More();itl.Next()) {
57 const TopoDS_Shape& newFace = itl.Value();
58 TopTools_ListOfShape newFaceLOF;
59 RegularizeFace(FF,newFace,newFaceLOF);
60#ifdef DEB
61// Standard_Integer nnewFaceLOF = newFaceLOF.Extent(); // DEB
62#endif
63 LOF.Append(newFaceLOF);
64 }
65#ifdef DEB
66// Standard_Integer nLOF = LOF.Extent(); // DEB
67#endif
68
69 Standard_Integer nr = myMemoSplit.Extent();
70 if (nr == 0 ) return;
71
72 // lfsdFF = faces SameDomain de FF
73 TopTools_ListOfShape lfsdFF,lfsdFF1,lfsdFF2;
74 GFindSamDom(FF,lfsdFF1,lfsdFF2);
75 lfsdFF.Append(lfsdFF1);
76 lfsdFF.Append(lfsdFF2);
77
78 TopTools_ListIteratorOfListOfShape itlfsdFF(lfsdFF);
79 for (; itlfsdFF.More(); itlfsdFF.Next()) {
80 const TopoDS_Shape& fsdFF = itlfsdFF.Value();
81 // au moins une arete de FF dont le Split() est lui meme Split()
82 TopExp_Explorer x;
83 for (x.Init(fsdFF,TopAbs_EDGE);x.More();x.Next()) {
84// for (TopExp_Explorer x(fsdFF,TopAbs_EDGE);x.More();x.Next()) {
85 const TopoDS_Shape& e = x.Current();
86#ifdef DEB
87// Standard_Integer ie = myDataStructure->Shape(e); //DEB
88// Standard_Boolean issect = myDataStructure->DS().IsSectionEdge(TopoDS::Edge(e));
89#endif
90
91 Standard_Integer ranke = GShapeRank(e);
92 TopAbs_State staeope = (ranke==1) ? myState1 : myState2;
93
94 for (Standard_Integer iiista = 1; iiista <= 2; iiista++ ) {
95
96 TopAbs_State stae = staeope;
97 if (iiista == 2) stae = TopAbs_ON;
98
99 Standard_Boolean issplite = IsSplit(e,stae);
100 if (!issplite) continue;
101
102 TopTools_ListOfShape& lspe = ChangeSplit(e,stae);
103#ifdef DEB
104// Standard_Integer nlspe = lspe.Extent(); // DEB
105#endif
106 TopTools_ListOfShape newlspe;
107 for (TopTools_ListIteratorOfListOfShape itl1(lspe);itl1.More();itl1.Next()) {
108 const TopoDS_Shape& esp = itl1.Value();
109 Standard_Boolean espmemo = myMemoSplit.Contains(esp);
110 if (!espmemo) newlspe.Append(esp);
111 else {
112 const TopTools_ListOfShape& lspesp = Splits(esp,stae);
113 GCopyList(lspesp,newlspe);
114 }
115 }
116 lspe.Clear();
117 GCopyList(newlspe,lspe);
118
119 } // iiista
120 } // explorer (fsdFF,TopAbs_EDGE)
121 } // itlfsdFF.More()
122} // RegularizeFaces
123
124/*static void FUN_setInternal(TopoDS_Face& F)
125{
126 TopExp_Explorer ex(F,TopAbs_EDGE);
127 TopTools_MapOfShape meF,meR,meI;
128 for (; ex.More(); ex.Next()){
129 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
130 TopAbs_Orientation oE = E.Orientation();
131 Standard_Boolean isclo = BRep_Tool::IsClosed(E,F); // E has 2d rep on F
132 if (isclo) continue;
133 Standard_Boolean isb = Standard_False; // the edge is FOR + REV in F
134 if (M_FORWARD(oE)) {meF.Add(E); isb = meR.Contains(E);}
135 else if (M_REVERSED(oE)) {meR.Add(E); isb = meF.Contains(E);}
136 if (isb) meI.Add(E.Oriented(TopAbs_INTERNAL));
137 }
138
139 BRep_Builder BB;
140 TopTools_MapIteratorOfMapOfShape it(meI);
141 for (; it.More(); it.Next()){
142 const TopoDS_Edge& E = TopoDS::Edge(it.Key());
143 BB.Remove(F,E.Oriented(TopAbs_FORWARD));
144 BB.Remove(F,E.Oriented(TopAbs_REVERSED));
145 BB.Add(F,E);
146 }
147}*/
148
149//=======================================================================
150//function : RegularizeFace
151//purpose :
152//=======================================================================
153void TopOpeBRepBuild_Builder::RegularizeFace
154(const TopoDS_Shape& FF,const TopoDS_Shape& anewFace,TopTools_ListOfShape& LOF)
155{
156 LOF.Clear();
157 const TopoDS_Face& newFace = TopoDS::Face(anewFace);
158 Standard_Boolean toregu = Standard_True;
159 Standard_Boolean usewtof = Standard_True;
160
161#ifdef DEB
162 Standard_Integer iF;Standard_Boolean tSPSFF=GtraceSPS(FF,iF);
163// Standard_Boolean savfregu = TopOpeBRepBuild_GettraceSAVFREGU();
164 if (TopOpeBRepBuild_GetcontextNOREGUFA()) toregu = Standard_False;
165 if (TopOpeBRepBuild_GetcontextREGUXPU()) usewtof = Standard_False;
166 if (tSPSFF) debregufa(iF);
167#endif
168
169 // If the same edge appears FOR+REV in the resulting face and
170 // whereas it's not a closing edge, set it as INTERNAL instead.
171 // FRA60275(iF=4) + PRO16297
172// FUN_setInternal(newFace);
173
174 if (!toregu) {
175 LOF.Append(newFace);
176 return;
177 }
178
179 TopTools_DataMapOfShapeListOfShape ownw; // OldWires --> NewWires;
180 Standard_Boolean rw = Standard_False;
181 Standard_Boolean rf = Standard_False;
182 myESplits.Clear();
183
184 rw = TopOpeBRepTool::RegularizeWires(newFace,ownw,myESplits);
185
186 if ( !rw ) {
187 LOF.Append(newFace);
188 return;
189 }
190
191 TopTools_ListOfShape newfaces;
192 if (usewtof) {
193 TopOpeBRepBuild_WireToFace wtof;
194 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itownw(ownw);
195 for (; itownw.More(); itownw.Next()) {
196 const TopTools_ListOfShape& lw = itownw.Value();
197
198 // xpu200798 : cto902D4 f14ou
199 // recall ownw = {(ow = old wire, lnw = {list of new wires descendant of old wire}}
200 // if lnw is empty, then ow is kept unchanged.
201 Standard_Boolean kept = lw.IsEmpty();
202 if (kept) {
203 const TopoDS_Wire& ow = TopoDS::Wire(itownw.Key());
204 wtof.AddWire(ow);
205 }
206 for(TopTools_ListIteratorOfListOfShape iw(lw);iw.More();iw.Next()) {
207 const TopoDS_Wire& w = TopoDS::Wire(iw.Value());
208 wtof.AddWire(w);
209 }
210 }
211 wtof.MakeFaces(newFace,newfaces);
212#ifdef DEB
213// Standard_Integer nnewfaces = newfaces.Extent(); // DEB
214#endif
215 rf = (newfaces.Extent() != 0);
216 }
217 else {
218 rf = TopOpeBRepTool::RegularizeFace(newFace,ownw,newfaces);
219 }
220
221 if (!rf) {
222 LOF.Append(newFace);
223 return;
224 }
225
226#ifdef DEB
227 if (tSPSFF) { cout<<"RegularizeFace "<<iF<<endl; debregufa(iF); }
228#endif
229
230 // LOF = nouvelles faces regularisees de newFace
231 TopTools_ListIteratorOfListOfShape itlnf(newfaces);
232 for (; itlnf.More(); itlnf.Next())
233 LOF.Append(TopoDS::Face(itlnf.Value()));
234
235 // mise a jour des aretes decoupees
236 // Edge(FF) = {E}, E-->Split(E) = {E'}, E'-->myESplits(E') = {E''}
237
238 TopTools_MapOfShape menf; // menf = aretes de newFace
239 TopExp_Explorer x;
240 for (x.Init(newFace,TopAbs_EDGE);x.More();x.Next()) {
241 const TopoDS_Shape& E = x.Current();
242 menf.Add(E);
243 }
244
245 // lfsdFF = faces SameDomain de FF
246 TopTools_ListOfShape lfsdFF,lfsdFF1,lfsdFF2;
247 GFindSamDom(FF,lfsdFF1,lfsdFF2);
248 lfsdFF.Append(lfsdFF1);
249 lfsdFF.Append(lfsdFF2);
250
251 TopTools_ListIteratorOfListOfShape itlfsdFF(lfsdFF);
252 for (; itlfsdFF.More(); itlfsdFF.Next()) {
253 const TopoDS_Shape& fsdFF = itlfsdFF.Value();
254
255#ifdef DEB
256 Standard_Integer ifsdFF=0;Standard_Boolean tSPSfsdFF=GtraceSPS(fsdFF,ifsdFF);
257 if (tSPSfsdFF) debregufa(ifsdFF);
258#endif
259
260 Standard_Integer rankfsdFF = GShapeRank(fsdFF);
261 TopAbs_State stafsdFF = (rankfsdFF == 1) ? myState1 : myState2;
262#ifdef DEB
263// Standard_Boolean issplitfsdFF = IsSplit(fsdFF,stafsdFF);
264#endif
265
266/*#ifdef DEB
267 const TopTools_ListOfShape& lspfsdFF = Splits(fsdFF,stafsdFF);
268 Standard_Integer nlspfsdFF = lspfsdFF.Extent();
269#endif*/
270
271 // iteration sur les aretes de fsdFF
272 for (x.Init(fsdFF,TopAbs_EDGE);x.More();x.Next()) {
273
274 //fsdFFe : 1 edge de fsdFF = 1 face SameDomain de FF
275 const TopoDS_Shape& fsdFFe = x.Current();
276
277#ifdef DEB
278 Standard_Integer ifsdFFe = 0;Standard_Boolean tSPSfsdFFe=GtraceSPS(fsdFFe,ifsdFFe);
279 if (tSPSfsdFFe) debregufa(ifsdFFe);
280#endif
281
282 // a priori, on ne peut avoir plus de deux etats splites
283 // sur l'arete , soit (IN + ON) , soit (OUT + ON)
284 for (Standard_Integer iiista = 1; iiista <= 2; iiista++ ) {
285 TopAbs_State stafsdFFe = stafsdFF;
286 if (iiista == 2) stafsdFFe = TopAbs_ON;
287
288 TopTools_ListOfShape& lspfsdFFe = ChangeSplit(fsdFFe,stafsdFFe);
289#ifdef DEB
290// Standard_Boolean issplitfsdFFe = IsSplit(fsdFFe,stafsdFFe);
291// Standard_Integer nlspfsdFFe = lspfsdFFe.Extent();
292#endif
293
7fd59977 294 for (TopTools_ListIteratorOfListOfShape it(lspfsdFFe);it.More();it.Next()) {
295
296 // fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe
297
298 const TopoDS_Shape& espfsdFFe = it.Value();
299 Standard_Boolean inmenf = menf.Contains(espfsdFFe);
300 if (!inmenf) continue;
301
302 // fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe
303 // espfsdFFe est une arete de Split(fsdFFe) ET figure dans newFace (Cf supra E')
304
305 Standard_Boolean resplitloc = myESplits.IsBound(espfsdFFe);
306 if (resplitloc) {
307
308 // fsdFFe (Cf supra E) a ete splittee, espfdsFFe = arete splittee de fsdFFe
309 // espfsdFFe est une arete de Split(fsdFFe) ET figure dans newFace (Cf supra E')
310 // espfsdFFe de newFace a ete redecoupee par RegularizeWires
311
312 // son decoupage lresplit est stocke dans la DS du Builder
313 const TopTools_ListOfShape& lresplit = myESplits.Find(espfsdFFe); //Cf supra E''
7fd59977 314
315 // on memorise que espfsdFFe est redecoupee ...
316 myMemoSplit.Add(espfsdFFe);
317
318 // on stocke le nouveau decoupage de espfsdFFe dans la DS du builder ...
319 TopTools_ListOfShape& lsp = ChangeSplit(espfsdFFe,stafsdFFe);
320 GCopyList(lresplit,lsp);
7fd59977 321 }
322 } // it.More
323 } // iiista
324 } // explore(fsdFF,TopAbs_EDGE)
325 } // itlfsdFF.More()
326
327#ifdef DRAW
328 if (tSPSFF) debregufa(iF);
329 if (tSPSFF && savfregu) {
330 TCollection_AsciiString str("fregu"); str = str + iF;
331 DBRep::Set(str.ToCString(),newFace);
332 cout<<"newFace "<<str<<" built on face "<<iF<<" saved"<<endl;
333 }
334#endif
335
336} // RegularizeFace