0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_Section.cxx
CommitLineData
b311480e 1// Created on: 1997-01-14
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1997-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 <BRep_Builder.hxx>
7fd59977 19#include <BRep_Tool.hxx>
42cf5bc1 20#include <Geom2d_Curve.hxx>
7fd59977 21#include <Geom2d_TrimmedCurve.hxx>
42cf5bc1 22#include <Geom_Curve.hxx>
23#include <GeomAPI_ProjectPointOnCurve.hxx>
24#include <gp_Pnt.hxx>
25#include <Standard_NoSuchObject.hxx>
7fd59977 26#include <Standard_ProgramError.hxx>
42cf5bc1 27#include <TCollection_AsciiString.hxx>
28#include <TopExp.hxx>
29#include <TopoDS.hxx>
30#include <TopoDS_Edge.hxx>
31#include <TopoDS_Face.hxx>
32#include <TopoDS_Shape.hxx>
33#include <TopoDS_Vertex.hxx>
34#include <TopOpeBRepBuild_Builder.hxx>
35#include <TopOpeBRepBuild_define.hxx>
36#include <TopOpeBRepBuild_EdgeBuilder.hxx>
37#include <TopOpeBRepBuild_FaceBuilder.hxx>
38#include <TopOpeBRepBuild_GTool.hxx>
39#include <TopOpeBRepBuild_GTopo.hxx>
40#include <TopOpeBRepBuild_HBuilder.hxx>
41#include <TopOpeBRepBuild_PaveSet.hxx>
42#include <TopOpeBRepBuild_ShapeSet.hxx>
43#include <TopOpeBRepBuild_ShellFaceSet.hxx>
44#include <TopOpeBRepBuild_SolidBuilder.hxx>
45#include <TopOpeBRepBuild_WireEdgeSet.hxx>
46#include <TopOpeBRepDS_BuildTool.hxx>
7fd59977 47#include <TopOpeBRepDS_connex.hxx>
42cf5bc1 48#include <TopOpeBRepDS_CurveExplorer.hxx>
49#include <TopOpeBRepDS_CurveIterator.hxx>
50#include <TopOpeBRepDS_EXPORT.hxx>
51#include <TopOpeBRepDS_HDataStructure.hxx>
52#include <TopOpeBRepDS_PointIterator.hxx>
53#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
54#include <TopOpeBRepDS_SurfaceIterator.hxx>
7fd59977 55#include <TopOpeBRepDS_TKI.hxx>
7fd59977 56#include <TopOpeBRepTool_2d.hxx>
42cf5bc1 57#include <TopOpeBRepTool_CurveTool.hxx>
7fd59977 58#include <TopOpeBRepTool_EXPORT.hxx>
42cf5bc1 59#include <TopOpeBRepTool_ShapeExplorer.hxx>
60#include <TopOpeBRepTool_TOOL.hxx>
7fd59977 61
62#define MGhc3 Handle(Geom_Curve)
63#define MGhc2 Handle(Geom2d_Curve)
64
0797d9d3 65#ifdef OCCT_DEBUG
1d0a9d4d 66extern Standard_Boolean TopOpeBRepBuild_GettraceSPS();
7fd59977 67Standard_EXPORT void debsplitse(const Standard_Integer) {}
68Standard_EXPORT void debsplitsemess(const Standard_Integer i,const TCollection_AsciiString& s = "");
69Standard_EXPORT void debsplitsemess(const Standard_Integer i,const TCollection_AsciiString& s){cout<<"+++ debsplitse "<<s<<" E"<<i<<endl;debsplitse(i);}
70Standard_EXPORT void debspseou(const Standard_Integer i) {debsplitsemess(i,"OUT");}
71Standard_EXPORT void debspsein(const Standard_Integer i) {debsplitsemess(i,"IN ");}
72Standard_EXPORT void debspseon(const Standard_Integer i) {debsplitsemess(i,"ON ");}
1d0a9d4d 73extern Standard_Boolean TopOpeBRepTool_GettraceC2D();
7fd59977 74#endif
75
76#ifdef DRAW
77#include <TopOpeBRepTool_DRAW.hxx>
78#endif
79
80//Standard_IMPORT void FUN_tool_ttranslate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE);
81
82#include <TopOpeBRepTool_ShapeTool.hxx>
83#include <GeomAdaptor_Surface.hxx>
84#include <GeomAbs_SurfaceType.hxx>
85//---------------------------------------------
86static Standard_Boolean FUN_periodicS(const TopoDS_Shape& F)
87//---------------------------------------------
88{
89 if (F.IsNull()) return Standard_False;
90 if (F.ShapeType() != TopAbs_FACE) return Standard_False;
91 Handle(Geom_Surface) SSS = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F));
92 GeomAdaptor_Surface GAS(SSS);
93 GeomAbs_SurfaceType styp = GAS.GetType();
94 Standard_Boolean periodic = Standard_False;
95 if (styp == GeomAbs_Cylinder) periodic = Standard_True;
96 if (styp == GeomAbs_Cone) periodic = Standard_True;
97 if (styp == GeomAbs_Sphere) periodic = Standard_True;
98 // NYI : for Torus,SurfaceOfRevolution..
99 return periodic;
100}
101
102static Standard_Boolean FUN_periodic(const TopoDS_Face& F,Standard_Boolean& uper,Standard_Boolean& vper)
103{
104 const Handle(Geom_Surface)& su = BRep_Tool::Surface(F);
105 uper = su->IsUPeriodic();
106 vper = su->IsVPeriodic();
107 Standard_Boolean per = (uper || vper);
108 return per;
109}
110
111static Standard_Boolean FUN_onboundsper(const gp_Pnt2d& uv,const TopoDS_Face& F)
112{
113 // 2d :
114 const Handle(Geom_Surface)& su = BRep_Tool::Surface(F);
115 Standard_Boolean uclo = su->IsUPeriodic();
116 Standard_Boolean vclo = su->IsVPeriodic();
117 if (!uclo && !vclo) return Standard_False;
118
119 Standard_Real u1,u2,v1,v2; su->Bounds(u1,u2,v1,v2);
120 Standard_Real toluv = 1.e-8*1.e-2; // nyinyitol
121 if (uclo) {
122 Standard_Real d1 = Abs(u1-uv.X()); Standard_Boolean on1 = (d1 < toluv);
123 Standard_Real d2 = Abs(u2-uv.X()); Standard_Boolean on2 = (d2 < toluv);
124 return (on1 || on2);
125 }
126 if (vclo) {
127 Standard_Real d1 = Abs(v1-uv.Y()); Standard_Boolean on1 = (d1 < toluv);
128 Standard_Real d2 = Abs(v2-uv.Y()); Standard_Boolean on2 = (d2 < toluv);
129 return (on1 || on2);
130 }
131 return Standard_False;
132}
133
134static Standard_Boolean FUN_onboundsper(const TopoDS_Edge& E,const TopoDS_Face& F, gp_Pnt2d& uv)
135// uv is found by projection pnt(E,par)
136{
137 // 3d :
138 Standard_Real f,l; FUN_tool_bounds(E,f,l); Standard_Real x=0.45678; Standard_Real par=f*x+(1-x)*l;
139 Standard_Real tolF = BRep_Tool::Tolerance(F)*1.e2; // nyitol
140 Standard_Boolean ok = FUN_tool_parF(E,par,F,uv,tolF);
141 if (!ok) return Standard_False;
142
143 Standard_Boolean onbp = ::FUN_onboundsper(uv,F);
144 return onbp;
145}
146
147
148
149//-----------------------------------------------------------------------
150static Standard_Boolean FUN_PinC(const gp_Pnt& P,const Handle(Geom_Curve)& C,const Standard_Real pmin,const Standard_Real pmax,const Standard_Real tol)
151//-----------------------------------------------------------------------
152{
153 Standard_Boolean PinC = Standard_False;
154 GeomAPI_ProjectPointOnCurve mydm(P,C,pmin,pmax);
155 Standard_Boolean dmdone = ( mydm.Extrema().IsDone() );
156 if ( dmdone ) {
157 if ( mydm.NbPoints() ) {
158 Standard_Real d = mydm.LowerDistance();
159 PinC = (d <= tol);
160 }
161 }
162 return PinC;
163}
164
165//-----------------------------------------------------------------------
166static Standard_Boolean FUN_PinE(const gp_Pnt& P, const TopoDS_Edge& E)
167//-----------------------------------------------------------------------
168{
169 Standard_Boolean PinE = Standard_False;
170 Standard_Real f,l; Handle(Geom_Curve) CE = BRep_Tool::Curve(E,f,l);
171 Standard_Real tolE = BRep_Tool::Tolerance(E);
172 PinE = FUN_PinC(P,CE,f,l,tolE);
173 return PinE;
174}
175
176#include <BRep_Tool.hxx>
ec357c5c 177#include <TopOpeBRepDS_ShapeShapeInterference.hxx>
7fd59977 178//-----------------------------------------------------------------------
179static Standard_Boolean FUN_EstaEE(const TopoDS_Edge& E, const TopAbs_State sta, const TopoDS_Edge& EE)
180//-----------------------------------------------------------------------
181{
182 Standard_Boolean EinEE = Standard_False;
183 Standard_Real f,l;
184 //modified by NIZNHY-PKV Wed Nov 3 11:40:14 1999 from
185
186 if (BRep_Tool::Degenerated(E)) {
187 if (sta == TopAbs_IN) return Standard_False;
188 else return Standard_True;
189 }
190 //modified by NIZNHY-PKV Wed Nov 3 11:40:19 1999 to
191
192 Handle(Geom_Curve) CE = BRep_Tool::Curve(E,f,l);
193 Standard_Real t = 0.417789; // Oi blya... ???
194 Standard_Real p = (1-t)*f + t*l;
195 gp_Pnt P = CE->Value(p);
196 EinEE = FUN_PinE(P,EE);
197 if (sta == TopAbs_IN) return EinEE;
198 else if (sta == TopAbs_OUT) return !EinEE;
9775fa61 199 else throw Standard_ProgramError("TopOpeBRepBuild FUN_EstaEE on invalid state");
7fd59977 200}
201
202//=======================================================================
203//function : TopOpeBRepBuild_Builder::InitSection
204//purpose :
205//=======================================================================
206void TopOpeBRepBuild_Builder::InitSection()
207{
208 mySectionDone = Standard_False;
209 mySection.Clear();
210 mySplitSectionEdgesDone = Standard_False;
211 mySplitON.Clear();
212}
213
214//-----------------------------------------------------------------------
215// LE : list of edges from where is extracted LEsta = edges located <sta> / edge E
216// N.B. : LEsta is expanded and NOT reinitialized
217static void FUN_selLEE(TopTools_ListOfShape& LE,const TopoDS_Edge& E,const TopAbs_State sta,TopTools_ListOfShape& LEsta)
218{
219 TopTools_ListIteratorOfListOfShape it(LE);
220 while (it.More()) {
221 const TopoDS_Edge& Ecur = TopoDS::Edge(it.Value());
222 Standard_Boolean ok = FUN_EstaEE(Ecur,sta,E);
223 if (ok) {
224 LEsta.Append(Ecur);
225 LE.Remove(it);
226 }
227 else it.Next();
228 }
229}
230
231//-----------------------------------------------------------------------
232// search the existence of shape E in time as shape of a mesh cell
233// (shape,listofshape) of the list loslos.
234Standard_Boolean FUN_FindEinSLOS(const TopoDS_Shape& E,const TopOpeBRepBuild_ListOfShapeListOfShape& loslos)
235{
236 Standard_Boolean f = Standard_False;
237 for (TopOpeBRepBuild_ListIteratorOfListOfShapeListOfShape it(loslos); it.More(); it.Next()) {
238 const TopoDS_Shape& S = it.Value().Shape();
239 Standard_Boolean issame = (S.IsSame(E));
240 if (issame) {
241 f = Standard_True;
242 break;
243 }
244 }
245 return f;
246}
247
248//=======================================================================
249//function : SplitSectionEdges
250//purpose :
251//=======================================================================
252void TopOpeBRepBuild_Builder::SplitSectionEdges()
253{
254 if (mySplitSectionEdgesDone) return;
255
256 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
257 Standard_Integer i,n = BDS.NbSectionEdges();
536a3cb8 258
7fd59977 259 for (i = 1; i <= n; i++) { // 1
260 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i));
261 if(E.IsNull()) continue;
262 SplitSectionEdge(E);
263 } // 1
264
265 TopOpeBRepBuild_DataMapOfShapeListOfShapeListOfShape MEIN;
266 TopTools_DataMapOfShapeListOfShape MEOUT;
267
268 for (i = 1; i <= n; i++) { // 2
269 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i));
270 if(E.IsNull()) continue;
271 Standard_Integer iE = myDataStructure->Shape(E);
272 Standard_Integer rE = BDS.AncestorRank(E);
273
0797d9d3 274#ifdef OCCT_DEBUG
7fd59977 275 Standard_Boolean tSPS = GtraceSPS(E,iE); if (tSPS) debsplitsemess(iE); Standard_Integer DEBiESD = 1;
276#endif
277
278 Standard_Boolean isspliton = IsSplit(E,TopAbs_ON);
279 if (!isspliton) continue;
280
281 const TopTools_ListOfShape& LESD = BDS.ShapeSameDomain(E);
282 if ( LESD.IsEmpty() ) continue;
283
284 const TopTools_ListOfShape& LEspon = Splits(E,TopAbs_ON);
285 TopTools_ListOfShape LEoutLESD; GCopyList(LEspon,LEoutLESD);
286 Standard_Integer iRef = BDS.SameDomainRef(E);
287
288 // LEoutLESD = list of edges Split(E,ON) OUT of all
289 // edges of the list of edges same domain of E in 3d only
290 // edges LEoutLESD are attached in Split(ON) to E only.
291
292 for (TopTools_ListIteratorOfListOfShape itLESD(LESD); itLESD.More(); itLESD.Next()) { // 2.1
293 const TopoDS_Edge& ESD = TopoDS::Edge(itLESD.Value());
294 Standard_Integer iESD = myDataStructure->Shape(ESD);
295 const TopTools_ListOfShape& LESDspon = Splits(ESD,TopAbs_ON);
296
0797d9d3 297#ifdef OCCT_DEBUG
7fd59977 298 if (tSPS) {
299 TCollection_AsciiString str("# edge ");str=str+iE+" sd3d edge "+iESD;
300 TCollection_AsciiString stru(str.Length(),'-');
301 cout<<endl;if(DEBiESD==1)cout<<stru<<endl;
302 DEBiESD++;cout<<str<<endl;debsplitsemess(iE);
303 }
304#endif
305
306 // reduction of LEoutLESD = edges OUT all ESD
307 TopTools_ListOfShape dummylos;
308 FUN_selLEE(LEoutLESD,ESD,TopAbs_IN,dummylos);
309
310 const TopoDS_Edge *pE1 = NULL, *pE2 = NULL;
311 const TopTools_ListOfShape *plos1 = NULL, *plos2 = NULL;
312 Standard_Integer nLEspon = LEspon.Extent();
313 Standard_Integer nLESDspon = LESDspon.Extent();
314
315 if ( nLEspon != 0 && nLESDspon != 0 ) {
0ebaa4db 316 Standard_Boolean takeE = ((rE == 1 && iESD != iRef) || iE == iRef);
317 pE1 = takeE ? &E : &ESD;
318 pE2 = !takeE ? &E : &ESD;
319 plos1 = takeE ? &LEspon : &LESDspon;
320 plos2 = !takeE ? &LEspon : &LESDspon;
7fd59977 321 }
322 else if ( nLEspon != 0 ) {
0ebaa4db 323 pE1 = &E;
324 pE2 = &ESD;
325 plos1 = &LEspon;
326 plos2 = &LESDspon;
7fd59977 327 }
328 else if ( nLESDspon != 0 ) {
0ebaa4db 329 pE1 = &ESD;
330 pE2 = &E;
331 plos1 = &LESDspon;
332 plos2 = &LEspon;
7fd59977 333 }
334
335 if (pE1 == NULL || pE2 == NULL) continue;
336 if (plos1 == NULL || plos2 == NULL) continue;
337
338 const TopoDS_Edge& E1 = *pE1;
339 const TopoDS_Edge& E2 = *pE2;
340 const TopTools_ListOfShape& LE1 = *plos1;
341
342 // selection of edges IN E2 = LEinE2
343 TopTools_ListOfShape LE1loc;
344 GCopyList(LE1,LE1loc);
345 TopTools_ListOfShape LE1inE2;
346 FUN_selLEE(LE1loc,E2,TopAbs_IN,LE1inE2);
347 Standard_Integer nLE1inE2 = LE1inE2.Extent();
348
349#ifdef DRAW
350 if (tSPS) {
351 cout<<"# edges ON "<<iE<<" ";
352 TopAbs::Print(TopAbs_IN,cout); cout<<" / esd";
353 cout<<" "<<iESD;
354 cout<<" : ("<<nLE1inE2<<")"<<endl;
355 TCollection_AsciiString str("ON");str=str+iE+"IN"+iESD;
356 FDRAW_DINLOE(" ",LE1inE2,str,"");
357 }
358#endif
359
360 // edges E1 and E2 share LE1inE2
361 if (nLE1inE2 != 0) { // 2.2
362
363 Standard_Boolean E1b = MEIN.IsBound(E1);
364 TopOpeBRepBuild_ListOfShapeListOfShape thelist;
365 if (!E1b) MEIN.Bind(E1, thelist);
366 TopOpeBRepBuild_ListOfShapeListOfShape& LE1loslos = MEIN.ChangeFind(E1);
0797d9d3 367#ifdef OCCT_DEBUG
7fd59977 368// Standard_Integer nLE1 = LE1loslos.Extent();
369#endif
370
371 Standard_Boolean E2b = MEIN.IsBound(E2);
372 TopOpeBRepBuild_ListOfShapeListOfShape thelist2;
373 if (!E2b) MEIN.Bind(E2,thelist2);
374 TopOpeBRepBuild_ListOfShapeListOfShape& LE2loslos = MEIN.ChangeFind(E2);
0797d9d3 375#ifdef OCCT_DEBUG
7fd59977 376// Standard_Integer nLE2 = LE2loslos.Extent();
377#endif
378
379 Standard_Boolean E2elemofE1 = FUN_FindEinSLOS(E2,LE1loslos);
380 Standard_Boolean E1elemofE2 = FUN_FindEinSLOS(E1,LE2loslos);
381
382 Standard_Boolean condadd = (!E2elemofE1 && !E1elemofE2);
383 if (condadd) {
384 // regularization of edges of LE1inE2 -> LR
385 TopTools_ListOfShape LR;
386 for (TopTools_ListIteratorOfListOfShape ite(LE1inE2);ite.More();ite.Next()){
387 const TopoDS_Edge& e = TopoDS::Edge(ite.Value());
388 TopTools_ListOfShape newle; Standard_Boolean ok = TopOpeBRepTool_TOOL::SplitE(e,newle);
389 if (ok) LR.Append(newle);
390 else LR.Append(e);
391 }
392 {
393 TopOpeBRepBuild_ShapeListOfShape thelist3;
394 LE1loslos.Append(thelist3);
395 TopOpeBRepBuild_ShapeListOfShape& E1slos = LE1loslos.Last();
396 E1slos.ChangeShape() = E2;
397 GCopyList(LR,E1slos.ChangeList());
398 }
399 {
400 TopOpeBRepBuild_ShapeListOfShape thelist4;
401 LE2loslos.Append(thelist4);
402 TopOpeBRepBuild_ShapeListOfShape& E2slos = LE2loslos.Last();
403 E2slos.ChangeShape() = E1;
404 GCopyList(LR,E2slos.ChangeList());
405 }
406 }
407 } // 2.2
408 }
409
410#ifdef DRAW
411 if (tSPS) {
412 cout<<endl<<"# edges ON "<<iE<<" ";
413 TopAbs::Print(TopAbs_OUT,cout);cout<<" / lesd";
414 for(TopTools_ListIteratorOfListOfShape it(LESD);it.More();it.Next())
415 cout<<" "<<myDataStructure->Shape(it.Value());
416 Standard_Integer n=LEoutLESD.Extent();cout<<" : ("<<n<<")"<<endl;
417 TCollection_AsciiString str("ON");str=str+iE+"OUT";
418 FDRAW_DINLOE(" ",LEoutLESD,str,"");
419 }
420#endif
421
422 if (!MEOUT.IsBound(E)) {
423 TopTools_ListOfShape thelist5;
424 MEOUT.Bind(E, thelist5);
425 }
426 GCopyList(LEoutLESD,MEOUT.ChangeFind(E));
427
428 } // 2
429
430 for (i = 1; i <= n; i++) { // 3
431 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i));
432 if(E.IsNull()) continue;
0797d9d3 433#ifdef OCCT_DEBUG
7fd59977 434 Standard_Integer iE = myDataStructure->Shape(E);
435// Standard_Integer rE = GShapeRank(E);
436 Standard_Boolean tSPS = GtraceSPS(E,iE);
437 if (tSPS) debsplitsemess(iE);
438#endif
439
440 Standard_Boolean isspliton = IsSplit(E,TopAbs_ON);;
441 if (!isspliton) continue;
442
443 const TopTools_ListOfShape& LESD = BDS.ShapeSameDomain(E);
444 if ( LESD.IsEmpty() ) continue;
445
446 Standard_Boolean isbMEOUT = MEOUT.IsBound(E);
447 Standard_Boolean isbMEIN = MEIN.IsBound(E);
448 if (!isbMEOUT && !isbMEIN) continue;
449
450 TopTools_ListOfShape& LEspon = ChangeSplit(E,TopAbs_ON);
451 LEspon.Clear();
452
453 if (isbMEOUT) {
454 const TopTools_ListOfShape& LEOUT = MEOUT.Find(E);
0797d9d3 455#ifdef OCCT_DEBUG
7fd59977 456// Standard_Integer nOUT = LEOUT.Extent();
457#endif
458 GCopyList(LEOUT,LEspon);
459 }
460
461 if (isbMEIN) {
462 const TopOpeBRepBuild_ListOfShapeListOfShape& loslos = MEIN.Find(E);
0797d9d3 463#ifdef OCCT_DEBUG
7fd59977 464// Standard_Integer nloslos = loslos.Extent();
465#endif
466 for (TopOpeBRepBuild_ListIteratorOfListOfShapeListOfShape it(loslos); it.More(); it.Next()) {
467 const TopTools_ListOfShape& los = it.Value().List();
0797d9d3 468#ifdef OCCT_DEBUG
7fd59977 469// Standard_Integer nlos = los.Extent();
470#endif
471 GCopyList(los,LEspon);
472 }
473 }
474 } // 3
475
476 BRep_Builder BB;
477 for (i = 1; i <= n; i++) { // 4
478 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if(E.IsNull()) continue;
0797d9d3 479#ifdef OCCT_DEBUG
7fd59977 480 Standard_Integer idebE; Standard_Boolean tSPS = GtraceSPS(E,idebE); if (tSPS) debsplitsemess(idebE);
481#endif
482 const TopTools_ListOfShape& lesd = BDS.ShapeSameDomain(E);
483 if (lesd.IsEmpty()) continue;
484
485 Standard_Integer iE = BDS.Shape(E);
0797d9d3 486#ifdef OCCT_DEBUG
7fd59977 487// Standard_Integer rE = BDS.AncestorRank(E);
488#endif
489 Standard_Integer RE = BDS.SameDomainRef(E);
490 if (iE != RE) continue;
491
492 TopTools_ListOfShape lF; TopTools_ListIteratorOfListOfShape itlesd;
493 for(itlesd.Initialize(lesd);itlesd.More();itlesd.Next()) {
494 const TopoDS_Edge& esd = TopoDS::Edge(itlesd.Value());
0797d9d3 495#ifdef OCCT_DEBUG
7fd59977 496// Standard_Integer iesd = BDS.Shape(esd);
497#endif
498 const TopTools_ListOfShape& lf = FDSCNX_EdgeConnexitySameShape(esd,myDataStructure);
499 GCopyList(lf,lF);
500 }
0797d9d3 501#ifdef OCCT_DEBUG
7fd59977 502// Standard_Integer nlF = lF.Extent();
503#endif
504
505 TopTools_ListOfShape& lon = ChangeSplit(E,TopAbs_ON);
506 Standard_Real tolE = BRep_Tool::Tolerance(E);
507 TopTools_ListIteratorOfListOfShape it(lF); for(;it.More();it.Next()) {
508 const TopoDS_Face& F = TopoDS::Face(it.Value());
509 Standard_Integer iF = BDS.Shape(F); Standard_Integer rF = BDS.AncestorRank(iF);
510
511 TopoDS_Edge esdF; Standard_Boolean besdF = Standard_False; // NYI pointer on esdF
512 for(itlesd.Initialize(lesd);itlesd.More();itlesd.Next()) {
513 const TopoDS_Edge& esd = TopoDS::Edge(itlesd.Value());
514 Standard_Integer iesd = BDS.Shape(esd); Standard_Integer resd = BDS.AncestorRank(iesd);
515 if (resd == rF) {
516 TopExp_Explorer ex;
517 for (ex.Init(F,TopAbs_EDGE);ex.More();ex.Next()) {
518// for (TopExp_Explorer ex(F,TopAbs_EDGE);ex.More();ex.Next()) {
519 const TopoDS_Shape& ee = ex.Current();
520 Standard_Boolean eq = (ee.IsEqual(esd));
521 if (eq) { esdF = esd; besdF = Standard_True; break; }
522 }
523 }
524 if (besdF) break;
525 }
526
527 TopTools_ListIteratorOfListOfShape itlon(lon); for(;itlon.More();itlon.Next()) {
528 TopoDS_Edge& eon = TopoDS::Edge(itlon.Value());
529 Standard_Real f,l; Standard_Boolean hasPC = FC2D_HasCurveOnSurface(eon,F);
530 if (hasPC) continue;
0797d9d3 531#ifdef OCCT_DEBUG
7fd59977 532 if (TopOpeBRepTool_GettraceC2D()) {
533 cout<<"\n#TopOpeBRepBuild_Builder::SSE : hasPC = 0 ES"<<i<<" E"<<idebE<<" sur F"<<iF<<endl;
534 cout<<"tsee s "<<iF<<" "<<idebE<<";"<<endl;
535 }
536#endif
537// Standard_Real tolpc; MGhc2 PC = FC2D_CurveOnSurface(eon,F,esdF,f,l,tolpc);
538 Standard_Real tolpc; MGhc2 PC = FC2D_CurveOnSurface(eon,F,esdF,f,l,tolpc,Standard_True);//xpu051198 :PRO15049
539 hasPC = (!PC.IsNull());
9775fa61 540 if (!hasPC) throw Standard_ProgramError("TopOpeBRepBuild_Builder::SSE null PC on F");
7fd59977 541 Standard_Real tol = Max(tolE,tolpc);
542 BB.UpdateEdge(eon,PC,F,tol);
543 }
544 }
545 } // 4
546
547 Standard_Integer nsha = BDS.NbShapes();
548 for (i = 1; i <= nsha; i++) { // 5
549 const TopoDS_Shape& FOR = myDataStructure->Shape(i);
550 Standard_Boolean isface = (FOR.ShapeType() == TopAbs_FACE);
551 if (!isface) continue;
552 const TopoDS_Face& FF = TopoDS::Face(FOR);
0797d9d3 553#ifdef OCCT_DEBUG
7fd59977 554// Standard_Integer iFF = BDS.Shape(FF);
555#endif
556 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(FF); Standard_Integer nLI = LI.Extent();
557 if (nLI == 0) continue;
558 for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI); ILI.More(); ILI.Next() ) {
c5f3a425 559 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI (Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(ILI.Value()));
7fd59977 560 if (SSI.IsNull()) continue;
561 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
562 if (ST != TopOpeBRepDS_FACE) continue;
563 const TopOpeBRepDS_Transition& TFE = SSI->Transition();
564 TopAbs_ShapeEnum shab = TFE.ShapeBefore(),shaa = TFE.ShapeAfter();
565 if (shaa != TopAbs_FACE || shab != TopAbs_FACE) continue;
566 const TopoDS_Face& FS = TopoDS::Face( myDataStructure->Shape(SI));
0797d9d3 567#ifdef OCCT_DEBUG
7fd59977 568// Standard_Integer iFS = myDataStructure->Shape(FS);
569#endif
570 Standard_Boolean FSisper = FUN_periodicS(FS);
571 if (!FSisper) continue;
572
573 const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->Shape(GI));
0797d9d3 574#ifdef OCCT_DEBUG
7fd59977 575// Standard_Integer iEG = myDataStructure->Shape(EG);
576#endif
577 Standard_Boolean isrest = myDataStructure->DS().IsSectionEdge(EG); if (!isrest) continue;
0797d9d3 578#ifdef OCCT_DEBUG
7fd59977 579// Standard_Real tolE = BRep_Tool::Tolerance(EG);
580#endif
581 Standard_Boolean haspc = FC2D_HasCurveOnSurface(EG,FS); if (haspc) continue;
582 Standard_Boolean hasc3d = FC2D_HasC3D(EG);
9775fa61 583 if (!hasc3d) throw Standard_ProgramError("TopOpeBRepBuild_Builder::SSE EG without C3D");
7fd59977 584 Standard_Real pf,pl,tolpc; Handle(Geom2d_Curve) PC;
585 Standard_Boolean trim3d = Standard_True; PC = FC2D_CurveOnSurface(EG,FS,pf,pl,tolpc,trim3d);
9775fa61 586 if (PC.IsNull()) throw Standard_ProgramError("TopOpeBRepBuild_Builder::SSE EG without PC on FS");
7fd59977 587 }
588 } //5
589
590 for (i = 1; i <= nsha; i++) { // 6
591 // xpu201198, for all periodic surfaces
592 const TopoDS_Shape& FOR = myDataStructure->Shape(i);
593 Standard_Boolean isface = (FOR.ShapeType() == TopAbs_FACE);
594 if (!isface) continue;
595 const TopoDS_Face& FF = TopoDS::Face(FOR);
0797d9d3 596#ifdef OCCT_DEBUG
7fd59977 597// Standard_Integer iFF = BDS.Shape(FF);
598#endif
599 Standard_Boolean FFuper,FFvper; Standard_Boolean FFisper = FUN_periodic(FF,FFuper,FFvper);
600 if (!FFisper) continue;
601
602 const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(FF); Standard_Integer nLI = LI.Extent();
603 if (nLI == 0) continue;
604 for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI); ILI.More(); ILI.Next() ) {
c5f3a425 605 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI (Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(ILI.Value()));
7fd59977 606 if (SSI.IsNull()) continue;
607 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
608 if (ST != TopOpeBRepDS_FACE) continue;
609 Standard_Boolean GB = SSI->GBound();
610 if (GB == 1) continue;
611
612 const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->Shape(GI));
0797d9d3 613#ifdef OCCT_DEBUG
7fd59977 614// Standard_Integer iEG = myDataStructure->Shape(EG);
615#endif
616 Standard_Boolean isrest = myDataStructure->DS().IsSectionEdge(EG); if (!isrest) continue;
617
618 // xpu191198 : cto016*
619 Standard_Real pf,pl,tolpc; Handle(Geom2d_Curve) PC;
620 Standard_Boolean trim3d = Standard_True; PC = FC2D_CurveOnSurface(EG,FF,pf,pl,tolpc,trim3d);
621 Standard_Boolean isoU,isoV; gp_Pnt2d o2d; gp_Dir2d d2d;
622 Standard_Boolean ISO = TopOpeBRepTool_TOOL::UVISO(PC,isoU,isoV,d2d,o2d);
623 if (ISO) {
624 TopTools_ListIteratorOfListOfShape itON(Splits(EG,TopAbs_ON));
625 TopTools_ListOfShape newlON;
626 for (; itON.More(); itON.Next()){
627 TopoDS_Edge eon = TopoDS::Edge(itON.Value());
628
629 Standard_Real pfon,plon,tolpcon; Handle(Geom2d_Curve) PCon;
630 PCon = FC2D_CurveOnSurface(eon,FF,pfon,plon,tolpcon,trim3d);
631
632 Standard_Boolean isouon,isovon; gp_Pnt2d o2don; gp_Dir2d d2don;
633 Standard_Boolean ISOon = TopOpeBRepTool_TOOL::UVISO(PCon,isouon,isovon,d2don,o2don);
634 Standard_Boolean PCko = !ISOon || ((isoU && !isouon) || (isoV && !isovon));
9775fa61 635 if (PCko) throw Standard_ProgramError("TopOpeBRepBuild_Builder::splitON");
7fd59977 636
637 Standard_Boolean test = (FFuper && isoU) || (FFvper && isoV);
638 if (!test) { newlON.Append(eon); continue;}
639
640 gp_Pnt2d uvok; Standard_Boolean isonclo = FUN_onboundsper(eon,FF,uvok); //3d
641 if (isonclo) { newlON.Append(eon); continue;}
642
643 Standard_Boolean isonclo2 = FUN_onboundsper(o2don,FF); //2d
644 if (isonclo2) {
645 gp_Vec2d tr;
646 if (isoU) {Standard_Real dtr = uvok.X() - o2don.X();tr = gp_Vec2d(dtr,0.);}
647 else {Standard_Real dtr = uvok.Y() - o2don.Y();tr = gp_Vec2d(0.,dtr);}
648 Standard_Real mag = tr.Magnitude();
649 Standard_Real toluv = 1.e-8*1.e2; // NYINYI
650 if (mag > toluv) TopOpeBRepTool_TOOL::TrslUVModifE(tr,FF,eon);
651 }
652 newlON.Append(eon);
653 } // itON
654 TopTools_ListOfShape& nlON = ChangeSplit(EG,TopAbs_ON);
655 nlON.Clear(); nlON.Append(newlON);
656 } // ISO
657 } //ILI(LI)
658 } //6
659 mySplitSectionEdgesDone = Standard_True;
660} // SplitSectionEdges
661
7fd59977 662#define TheIN (1)
663#define TheON (2)
664#define TheOUT (3)
1d0a9d4d 665Standard_Integer GLOBAL_issp = 0; //++
7fd59977 666
667#define HASSD2d (2)
668#define HASSD3d (3)
669Standard_EXPORT Standard_Integer GLOBAL_hassd = 0; //++
670
671//=======================================================================
672//function : SplitSectionEdge
673//purpose :
674//=======================================================================
675void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA)
676{
0797d9d3 677#ifdef OCCT_DEBUG
7fd59977 678 Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EA,iE);
679 if (tSPS) debsplitsemess(iE);
680#endif
681
682 TopOpeBRepDS_DataStructure& BDS = myDataStructure->ChangeDS();
683 const TopoDS_Edge& EOR = TopoDS::Edge(EA);
684 TopoDS_Edge EF = EOR; EF.Orientation(TopAbs_FORWARD);
685 Standard_Integer rankEF = myDataStructure->DS().AncestorRank(EF); // GShapeRank <- GMapShapes, appele par Merge
686
687// FUN_removeonGB(myDataStructure,EOR); //xpu041198
688
689 Standard_Boolean hg = myDataStructure->HasGeometry(EOR);
690 Standard_Boolean hsd3d = FDS_HasSameDomain3d(BDS,EOR);
691 Standard_Boolean hsd2d = FDS_HasSameDomain2d(BDS,EOR);
0797d9d3 692#ifdef OCCT_DEBUG
7fd59977 693 Standard_Boolean issplit = IsSplit(EOR,TopAbs_ON);
694#endif
695
696 Standard_Boolean cond = (hg || hsd3d); //REST2 //( hg && (!hsd) );
697
698 GLOBAL_hassd = 0; // initializing
699 if(hsd3d) GLOBAL_hassd=3; //++
700 if(hsd2d) GLOBAL_hassd=2; //++
701
702 if (mySplitSectionEdgesDone) {
0797d9d3 703#ifdef OCCT_DEBUG
7fd59977 704 if(tSPS) {
705 GdumpSHA(EF, (char *) "SplitSectionEdges done : ");
706 if (issplit) cout<<" "<<Splits(EOR,TopAbs_ON).Extent()<<" edges splitON"<<endl;
707 else cout<<" !IsSplit"<<endl;
708 }
709#endif
710 return;
711 }
712
0797d9d3 713#ifdef OCCT_DEBUG
7fd59977 714 if(tSPS)GdumpSHASTA(EF,TopAbs_ON,"--- SplitSectionEdges ");
715 if(tSPS)cout<<" (hg="<<hg<<"||hsd3d="<<hsd3d<<")="<<cond<<endl;
716#endif
717
718 // xpu161198 BUC60382(e3on) SE EOR has all its interferences "on bounds"
719 Standard_Boolean allGb1=Standard_False;
720 TopoDS_Vertex vf,vl; TopExp::Vertices(TopoDS::Edge(EOR),vf,vl);
721 const TopOpeBRepDS_ListOfInterference& loi = BDS.ShapeInterferences(EOR);
722 TopOpeBRepDS_ListIteratorOfListOfInterference it(loi);
723 for (; it.More(); it.Next()){
724 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
725 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
726 if (GT == TopOpeBRepDS_POINT) {allGb1=Standard_False; break;}
727 Standard_Integer rkG = BDS.AncestorRank(G);
728 const TopoDS_Vertex& v = TopoDS::Vertex(BDS.Shape(G));
729 if (rkG==rankEF) {
730 allGb1 = (v.IsSame(vf) || v.IsSame(vl));
731 }
732 else {
733 TopoDS_Shape oov; Standard_Boolean hsdmv = FUN_ds_getoov(v,myDataStructure,oov);
734 if (!hsdmv) allGb1=Standard_False;
735 allGb1 = (oov.IsSame(vf) || oov.IsSame(vl));
736 }
737 if (!allGb1) break;
738 } // tki
739
740
741 Standard_Boolean mke = !cond;
742 mke = mke || !hg; //xpu271098 cto002J2(e9on)
743 mke = mke || allGb1; //xpu161198 BUC60382(e3on)
744 if (mke) {
745 MarkSplit(EOR,TopAbs_ON);
746 TopTools_ListOfShape& LON = ChangeSplit(EOR,TopAbs_ON);
0797d9d3 747#ifdef OCCT_DEBUG
7fd59977 748// Standard_Integer non = LON.Extent(); // DEB
749#endif
750
751 TopoDS_Edge newEOR;
752 FUN_ds_CopyEdge(EOR,newEOR);
753 Standard_Boolean hasnewEOR=Standard_False;
754 BRep_Builder BB;
755 TopExp_Explorer exv(EOR, TopAbs_VERTEX);
756 for (; exv.More(); exv.Next()){
757 const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
758 Standard_Real parv = BRep_Tool::Parameter(v,EOR);
759 Standard_Integer iv = BDS.Shape(v);
760 Standard_Integer ivref = 0;
761 Standard_Boolean hsd = Standard_False;
762 if (iv != 0)
763 hsd = myDataStructure->HasSameDomain(v);
764 if (hsd)
765 ivref = myDataStructure->SameDomainReference(v);
766 Standard_Boolean setref = hsd && (iv != ivref);
767 TopoDS_Vertex vref = TopoDS::Vertex(BDS.Shape(ivref));
768 if (!setref)
769 {BB.Add(newEOR,v); FUN_ds_Parameter(newEOR,v,parv); continue;}
770 hasnewEOR = Standard_True;
771 vref.Orientation(v.Orientation());
772 BB.Add(newEOR,vref);
773 FUN_ds_Parameter(newEOR,vref,parv);
774 }
775 if (hasnewEOR)
776 LON.Append(newEOR);
777 else
778 LON.Append(EOR);
779 return;
780 } // mke
781
782 TopTools_ListOfShape LESD1,LESD2; GFindSamDom(EOR,LESD1,LESD2);
783
0797d9d3 784#ifdef OCCT_DEBUG
7fd59977 785 if(tSPS)GdumpSHASTA(EF,TopAbs_ON,"--- SplitSectionEdges ");
786 if(tSPS){
787 cout<<" (hg="<<hg<<"||hsd3d="<<hsd3d<<")="<<cond<<endl;
788 GdumpSHA(EOR, (char *) "SplitSectionEdge");
789 cout<<endl;
790 GdumpSAMDOM(LESD1, (char *) "LESD1 : ");
791 GdumpSAMDOM(LESD2, (char *) "LESD2 : ");
792 }
793#endif
794
795 {
0797d9d3 796#ifdef OCCT_DEBUG
7fd59977 797 if (tSPS) debspseon(iE);
798#endif
799 TopOpeBRepBuild_GTopo G = TopOpeBRepBuild_GTool::GComUnsh(TopAbs_FACE,TopAbs_FACE);
800 myEdgeReference = EF;
801 TopOpeBRepBuild_PaveSet PVS(EF);
802
803 GLOBAL_issp = TheON; //++
804 GFillEdgePVS(EF,myEmptyShapeList,G,PVS);
805 GLOBAL_issp = 0; //++
806
807 // Create an edge builder EDBU
808 TopOpeBRepBuild_PaveClassifier VCL(EF);
809 Standard_Boolean equalpar = PVS.HasEqualParameters();
810 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
811 TopOpeBRepBuild_EdgeBuilder EDBU;
812 EDBU.InitEdgeBuilder(PVS,VCL);
813
814 // Build the new edges LEM
815 TopTools_ListOfShape LEM;
816 GEDBUMakeEdges(EF,EDBU,LEM);
817
818 // xpu : 18-03-98 (cto 016 B2)
819 // splits edges of LEM with internal vertices
820 TopTools_ListOfShape newLEM; TopTools_ListIteratorOfListOfShape ite(LEM);
821 for (; ite.More(); ite.Next()){
822 const TopoDS_Edge& esp = TopoDS::Edge(ite.Value());
823 TopTools_ListOfShape lspe; Standard_Boolean ok = TopOpeBRepTool_TOOL::SplitE(esp,lspe);
824 Standard_Boolean nonwesp = (!ok) || (lspe.Extent() < 2);
825 if (nonwesp) newLEM.Append(esp);
826 else newLEM.Append(lspe);
827 }
828 LEM.Clear(); LEM.Append(newLEM);
829
830 // connect new edges LEM as split parts (ON,SOLID)
831 MarkSplit(EOR,TopAbs_ON);
832 TopTools_ListOfShape& LON = ChangeSplit(EOR,TopAbs_ON);
833 GCopyList(LEM,LON);
834 }
835
836//modified by NIZHNY-MZV Mon Apr 17 16:25:51 2000 TopTools_ListOfShape losOO;
837//modified by NIZHNY-MZV Mon Apr 17 16:25:52 2000 if (rankEF == 1) losOO.Append(GLOBALDS_shape2);
838//modified by NIZHNY-MZV Mon Apr 17 16:25:53 2000 else if (rankEF == 2) losOO.Append(GLOBALDS_shape1);
839
840 {
0797d9d3 841#ifdef OCCT_DEBUG
7fd59977 842 if (tSPS) debspsein(iE);
843#endif
844 TopOpeBRepBuild_GTopo G = TopOpeBRepBuild_GTool::GCutUnsh(TopAbs_FACE,TopAbs_FACE);
845 G = G.CopyPermuted(); // parts (IN,OUT) 3d are constructed
846 myEdgeReference = EF;
847 TopOpeBRepBuild_PaveSet PVS(EF);
848
849 GLOBAL_issp = TheIN; //++
850 GFillEdgePVS(EF,myEmptyShapeList,G,PVS);
851 GLOBAL_issp = 0; //++
852
853 // Create an edge builder EDBU
854 TopOpeBRepBuild_PaveClassifier VCL(EF);
855 Standard_Boolean equalpar = PVS.HasEqualParameters();
856 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
857 TopOpeBRepBuild_EdgeBuilder EDBU;
858 EDBU.InitEdgeBuilder(PVS,VCL);
859
860 // Build the new edges LEM
861 TopTools_ListOfShape LEMNC;
862 GEDBUMakeEdges(EF,EDBU,LEMNC);
863
864//modified by NIZHNY-MZV Mon Apr 17 15:23:28 2000 TopTools_ListOfShape LEM;
865//modified by NIZHNY-MZV Mon Apr 17 15:23:16 2000 GKeepShapes(EF,losOO,TopAbs_IN,LEMNC,LEM);
866
867 // connect new edges LEM as split parts (IN,SOLID)
868 MarkSplit(EOR,TopAbs_IN);
869 TopTools_ListOfShape& LINN = ChangeSplit(EOR,TopAbs_IN);
870 GCopyList(LEMNC,LINN);
871 }
872
873 {
0797d9d3 874#ifdef OCCT_DEBUG
7fd59977 875 if (tSPS) debspseou(iE);
876#endif
877 TopOpeBRepBuild_GTopo G = TopOpeBRepBuild_GTool::GCutUnsh(TopAbs_FACE,TopAbs_FACE);
878 // parts (OUT,IN) 3d are constructed
879 myEdgeReference = EF;
880 TopOpeBRepBuild_PaveSet PVS(EF);
881
882 GLOBAL_issp = TheOUT; //++
883 GFillEdgePVS(EF,myEmptyShapeList,G,PVS);
884 GLOBAL_issp = 0; //++
885
886 // Create an edge builder EDBU
887 TopOpeBRepBuild_PaveClassifier VCL(EF);
888 Standard_Boolean equalpar = PVS.HasEqualParameters();
889 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
890 TopOpeBRepBuild_EdgeBuilder EDBU;
891 EDBU.InitEdgeBuilder(PVS,VCL);
892
893 // Build the new edges LEM
894 TopTools_ListOfShape LEM;
895 GEDBUMakeEdges(EF,EDBU,LEM);
896
897 // connect new edges LEM as split parts (OUT,SOLID)
898 MarkSplit(EOR,TopAbs_OUT);
899 TopTools_ListOfShape& LINN = ChangeSplit(EOR,TopAbs_OUT);
900 GCopyList(LEM,LINN);
901 }
902
903 GLOBAL_hassd=0; //++
904}
905
906//=======================================================================
907//function : Section
908//purpose :
909//=======================================================================
910const TopTools_ListOfShape& TopOpeBRepBuild_Builder::Section()
911{
912 if (mySectionDone) return mySection;
913 mySectionDone = Standard_True;
914 SectionCurves(mySection);
915 SectionEdges(mySection);
916 return mySection;
917}
918
919//=======================================================================
920//function : Section
921//purpose :
922//=======================================================================
923void TopOpeBRepBuild_Builder::Section(TopTools_ListOfShape& L)
924{
925 L = Section();
926}
927
928//=======================================================================
929//function : SectionCurves
930//purpose :
931//=======================================================================
932void TopOpeBRepBuild_Builder::SectionCurves(TopTools_ListOfShape& LSE)
933{
934 TopOpeBRepDS_CurveExplorer cex(myDataStructure->DS());
935 for (; cex.More(); cex.Next()) {
936 Standard_Integer ic = cex.Index();
937 TopTools_ListIteratorOfListOfShape itloe(NewEdges(ic));
938 for(;itloe.More();itloe.Next()) {
939 LSE.Append(itloe.Value());
940 }
941 }
942}
943
944//=======================================================================
945//function : SectionEdges
946//purpose :
947//=======================================================================
948void TopOpeBRepBuild_Builder::SectionEdges(TopTools_ListOfShape& LSE)
949{
950 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
951 Standard_Integer i,nes = BDS.NbSectionEdges();
952
953 Standard_Integer iskpart = IsKPart();
954 if ( iskpart == 1 ) { // iskole
955 for (i=1;i<=nes;i++ ) {
956 const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i));
957 // modif fbi 16-09-97: case possible if RemoveSectionEdge was called
958 if(E.IsNull())
959 continue;
960 // end modif fbi
961 LSE.Append(E);
962 }
963 return;
964 }
965
966 SplitSectionEdges();
967
968 // common of edges of section
969
970 TopTools_MapOfShape MOS;
971
972 for (i=1;i<=nes;i++) {
973
974 const TopoDS_Shape& es = BDS.SectionEdge(i);
975 // modif fbi 16-09-97: case possible if RemoveSectionEdge was called
976 if(es.IsNull())
977 continue;
978 // end modif fbi
979 Standard_Boolean issplitIN = IsSplit(es,TopAbs_IN);
980 Standard_Boolean issplitON = IsSplit(es,TopAbs_ON);
981 TopAbs_State staspl=(issplitON)?TopAbs_ON:(issplitIN)?TopAbs_IN:TopAbs_UNKNOWN;
982
0797d9d3 983#ifdef OCCT_DEBUG
7fd59977 984 Standard_Integer iii; Standard_Boolean tSPS = GtraceSPS(es,iii);
985 if (tSPS) {
986 GdumpSHA(es, (char *) "--- Section ");
987 cout<<" splitIN "<<issplitIN<<" "<<Splits(es,TopAbs_IN).Extent()<<endl;
988 cout<<" splitON "<<issplitON<<" "<<Splits(es,TopAbs_ON).Extent()<<endl;
989 }
990#endif
991
992 if (staspl != TopAbs_UNKNOWN) {
993 for(TopTools_ListIteratorOfListOfShape it(Splits(es,staspl));it.More();it.Next()) {
994 const TopoDS_Shape& S = it.Value();
995 if ( !MOS.Contains(S) ) {
996 MOS.Add(S);
997 LSE.Append(S);
998 }
999 }
1000 }
1001 else {
1002 Standard_Boolean hasgeom = myDataStructure->HasGeometry(es);
1003 Standard_Boolean hassame = myDataStructure->HasSameDomain(es);
1004 Standard_Boolean take = !(hasgeom || hassame);
1005 if (take) {
1006 if ( !MOS.Contains(es) ) {
1007 MOS.Add(es);
1008 LSE.Append(es);
1009 }
1010 }
1011 }
1012 } // for i [1..nes]
1013} // SectionEdges
1014
1015//=======================================================================
1016//function : FillSecEdgeAncestorMap
1017//purpose :
1018//=======================================================================
1019
1020void TopOpeBRepBuild_Builder::FillSecEdgeAncestorMap(const Standard_Integer aShapeRank,
1021 const TopTools_MapOfShape& aMapON,
1022 TopTools_DataMapOfShapeShape& anAncMap)
1023 const
1024{
1025 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
1026
1027 Standard_Integer i,nse = BDS.NbSectionEdges();
1028 for (i=1; i<=nse; i++) {
1029 const TopoDS_Shape& es = BDS.SectionEdge(i);
1030 if(es.IsNull() || ShapeRank(es) != aShapeRank)
1031 continue;
1032 if (aMapON.Contains(es)) {
1033 anAncMap.Bind(es,es);
1034 continue;
1035 }
1036 TopAbs_State states[3] = {TopAbs_IN, TopAbs_ON, TopAbs_OUT};
1037 for (Standard_Integer j=0; j < 3; j++) {
1038// Standard_Boolean isSplit = IsSplit(es,states[j]);
1039 if (IsSplit(es,states[j])) {
1040 TopTools_ListIteratorOfListOfShape it(Splits(es,states[j]));
1041 for(;it.More();it.Next()) {
1042 const TopoDS_Shape& aS = it.Value();
1043 if (aMapON.Contains(aS))
1044 anAncMap.Bind(aS,es);
1045 }
1046 }
1047 }
1048 }
1049}