0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_BuilderON.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_BuilderON.ixx>
18
19#include <TopOpeBRepTool_EXPORT.hxx>
20#include <TopOpeBRepTool_TOOL.hxx>
21#include <TopOpeBRepDS_EXPORT.hxx>
22#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
23#include <TopOpeBRepBuild_define.hxx>
24#include <TopOpeBRepDS_connex.hxx>
25#include <BRep_Tool.hxx>
26#include <TopoDS.hxx>
27#include <Precision.hxx>
28#include <BRepAdaptor_Surface.hxx>
29#include <GeomAbs_SurfaceType.hxx>
30#include <TopOpeBRepTool_SC.hxx>
31#include <BRepLProp_SurfaceTool.hxx>
32#include <BRepLProp_SLProps.hxx>
33
34#ifdef DEB
35Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEINTERNAL();
36Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEEXTERNAL();
37Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOSG();
38Standard_EXPORT void debON(const Standard_Integer iF)
39{cout<<"++ debON "<<iF<<" "<<endl;}
40Standard_EXPORT void debON(const Standard_Integer iF, const TopAbs_State TB1,const TopAbs_State TB2)
41{cout<<"++ debON "<<iF<<" :TB1=";TopAbs::Print(TB1,cout);cout<<",TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
42Standard_EXPORT void debfillonf(const Standard_Integer iF)
43{cout<<"++ debfillonf "<<iF<<" "<<endl;}
44Standard_EXPORT void debfillone(const Standard_Integer iE)
45{cout<<"++ debfillone "<<iE<<" "<<endl;}
46Standard_EXPORT void debfillonfe(){}
47Standard_EXPORT void debfillonfemess(const Standard_Integer f,const Standard_Integer e)
48{cout<<"++ debfillonfe f"<<f<<" e"<<e<<endl;debfillonfe();}
49Standard_EXPORT void debfillonfe3d(){}
50Standard_EXPORT void debfillonfemess3d(const Standard_Integer f,const Standard_Integer e)
51{cout<<"++ debfillonfe3d f"<<f<<" e"<<e<<endl;debfillonfe3d();}
52Standard_EXPORT void debfillonfemess(const Standard_Integer iFOR,const Standard_Integer iEG,const TopOpeBRepBuild_PBuilder& PB,const TopOpeBRepBuild_PWireEdgeSet& PWES,const TCollection_AsciiString& str)
53{PB->GdumpSHASTA(iEG,TopAbs_ON,*PWES,str); debfillonfemess(iFOR,iEG); }
54Standard_EXPORT void debaddpwes(const Standard_Integer iFOR,const TopAbs_State TB1,const Standard_Integer iEG,const TopAbs_Orientation neworiE,const TopOpeBRepBuild_PBuilder& PB,const TopOpeBRepBuild_PWireEdgeSet& PWES,const TCollection_AsciiString& str1,const TCollection_AsciiString& str2)
55{PB->GdumpSHASTA(iFOR,TB1,*PWES,str1,str2);cout<<iEG<<" : 1 edge ";TopAbs::Print(neworiE,cout);cout<<endl; }
56Standard_EXPORT Standard_Boolean DEBTEFOR(const TopOpeBRepBuild_Builder& B,const Standard_Integer iFOR,const Standard_Integer GI)
57{return B.GtraceSPS(iFOR,GI); }
58#endif
59
60#ifdef DEB
61Standard_EXPORT void FUN_RaiseON()
62{Standard_Failure::Raise("BuilderON");}
63static void FUN_cout(const TopoDS_Shape& eON)
64{
65 TopAbs_Orientation oE = eON.Orientation();
66 if (oE == TopAbs_FORWARD) cout<<"-> + eONF"<<endl;
67 if (oE == TopAbs_REVERSED) cout<<"-> + eONR"<<endl;
68 if (oE == TopAbs_INTERNAL) cout<<"-> + eONI"<<endl;
69 if (oE == TopAbs_EXTERNAL) cout<<"-> + eONE"<<endl;
70}
71#endif
72
73#define M_FORWARD(st) (st == TopAbs_FORWARD)
74#define M_REVERSED(st) (st == TopAbs_REVERSED)
75#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
76#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
77
78// NYI : TopOpeBRepTool_ShapeTool::ShapesSameOriented -> CurvesSameOriented NYI for E !line
79//Standard_IMPORT Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
80
81//=======================================================================
82//function : TopOpeBRepBuild_BuilderON
83//purpose :
84//=======================================================================
85TopOpeBRepBuild_BuilderON::TopOpeBRepBuild_BuilderON()
86{
87}
88
89//=======================================================================
90//function : TopOpeBRepBuild_BuilderON
91//purpose :
92//=======================================================================
93TopOpeBRepBuild_BuilderON::TopOpeBRepBuild_BuilderON(const TopOpeBRepBuild_PBuilder& PB, const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG,
94 const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES)
95{
96 Perform(PB,FOR,PG,PLSclass,PWES);
97}
98
99//=======================================================================
100//function : Perform
101//purpose :
102//=======================================================================
103void TopOpeBRepBuild_BuilderON::Perform(const TopOpeBRepBuild_PBuilder& PB,const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG,
104 const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES)
105{
106 myPB = PB;
107 myFace = FOR;
108 myPG = PG;
109 myPLSclass = PLSclass;
110 myPWES = PWES;
111
112#ifdef DEB
113 Standard_Integer iFOR;Standard_Boolean tFOR=myPB->GtraceSPS(FOR,iFOR);
114 if (tFOR) debfillonf(iFOR);
115#endif
116
117 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
118 const TopOpeBRepDS_ListOfInterference& LI=BDS.ShapeInterferences(myFace);
119 for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI);ILI.More();ILI.Next() ) {
120 const Handle(TopOpeBRepDS_Interference)& I=ILI.Value();
121 GFillONPartsWES1(I);
122 }
123}
124
125//=======================================================================
126//function : GFillONCheckI
127//purpose :
128//=======================================================================
129Standard_Boolean TopOpeBRepBuild_BuilderON::GFillONCheckI(const Handle(TopOpeBRepDS_Interference)& I) const
130{
131 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
132
133 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI=Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
134 if (SSI.IsNull()) return Standard_False;
135
136 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
137 if (GT != TopOpeBRepDS_EDGE || ST != TopOpeBRepDS_FACE) return Standard_False;
138#ifdef DEB
139// Standard_Integer iFOR=BDS.Shape(myFace);
140#endif
141 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI, Standard_False));
142#ifdef DEB
143// Standard_Integer iEG=BDS.Shape(EG, Standard_False);
144#endif
145 const TopoDS_Shape& FS=BDS.Shape(SI, Standard_False);
146#ifdef DEB
147// Standard_Integer iFS=BDS.Shape(FS, Standard_False);
148#endif
149 TopAbs_ShapeEnum ShapeInterf=TopAbs_FACE;
150 const TopOpeBRepDS_Transition& TFE=SSI->Transition();
151 TopAbs_ShapeEnum shab=TFE.ShapeBefore(),shaa=TFE.ShapeAfter();
152 if (shaa != ShapeInterf || shab != ShapeInterf) return Standard_False;
153
154 Standard_Boolean isrest=BDS.IsSectionEdge(EG);
155 Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON);
156 Standard_Boolean keep=(isrest && issplit);
157 if ( !keep ) return Standard_False;
158
159 const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON);
160 if (lEspON.Extent() == 0) return Standard_False;
161
162#ifdef DEB
163// const TopoDS_Shape& EspON=lEspON.First();
164#endif
165 Standard_Integer rankFS=myPB->GShapeRank(FS);
166 Standard_Integer rankFOR=myPB->GShapeRank(myFace);
167 if (rankFS == 0 || rankFOR == 0) return Standard_False;
168
169 return Standard_True;
170} // GFillONCheckI
171
172//=======================================================================
173//function : GFillONPartsWES1
174//purpose :
175//=======================================================================
176void TopOpeBRepBuild_BuilderON::GFillONPartsWES1(const Handle(TopOpeBRepDS_Interference)& I)
177{
178 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
179#ifdef DEB
180 Standard_Integer iFOR=
181#endif
182 BDS.Shape(myFace);
183 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(I,GT,GI,ST,SI);
184
185 Standard_Boolean Iok=GFillONCheckI(I);
186 if (!Iok) return;
187
188 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
189// const TopoDS_Shape& FS=BDS.Shape(SI);
190#ifdef DEB
191// Standard_Integer iEG=BDS.Shape(EG);
192// Standard_Integer iFS=BDS.Shape(FS);
193#endif
194
195#ifdef DEB
196 Standard_Boolean tEFOR=DEBTEFOR(*myPB,iFOR,GI);
197 if (tEFOR) debfillonfemess(iFOR,GI,myPB,myPWES,"--- GFillONPartsWES1");
198#endif
199
200 const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON);
201#ifdef DEB
202// Standard_Integer nEspON=lEspON.Extent();
203#endif
204 for(TopTools_ListIteratorOfListOfShape it(lEspON);it.More();it.Next()) {
205 const TopoDS_Shape& EspON=it.Value();
206 GFillONPartsWES2(I,EspON);
207 }
208} // GFillONPartsWES1
209
210#ifdef DEB
211Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString& m)
212{
213 cout<<m;
214}
215#else
216Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString&)
217{
218}
219#endif
220
221//------------------------------------------------------
222#ifdef DEB
223Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder& B,
224#else
225Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder&,
226#endif
227 const TopoDS_Shape& sEG,
228 const TopoDS_Shape& sFOR,
229 const TopoDS_Shape& sFS,
230#ifdef DEB
231 const Standard_Boolean EGBoundFOR,
232#else
233 const Standard_Boolean,
234#endif
235 const TopOpeBRepDS_Transition& TFE,
236 const TopAbs_State TB1,
237 const TopAbs_State )
238//------------------------------------------------------
239{
240 // on construit l'etat TB1 de FOR par rapport a FS.
241 // sur face FOR,on transitionne (TFE) en l'arete EG par rapport a la face FS.
242 // TFE est defini sur la geometrie naturelle de la face orientee FOR,
243 // c'est a dire sur FF=FOR orientee FORWARD,par rapport a la matiere
244 // definie par la face orientee FS.
245 // on cherche oEGFF=orientation de EG dans FF
246 TopoDS_Edge EG=TopoDS::Edge(sEG);
247 TopoDS_Face FF=TopoDS::Face(sFOR);FF.Orientation(TopAbs_FORWARD);
248 TopoDS_Face FS=TopoDS::Face(sFS);
249
250#ifdef DEB
251 Standard_Integer iEG;/*Standard_Boolean tEG=*/B.GtraceSPS(EG,iEG);
252 Standard_Integer iFF;/*Standard_Boolean tFF=*/B.GtraceSPS(FF,iFF);
253 Standard_Integer iFS;/*Standard_Boolean tFS=*/B.GtraceSPS(FS,iFS);
254 Standard_Boolean tFFEG=DEBTEFOR(B,iFF,iEG);if (tFFEG) debfillonfemess(iFF,iEG);
255 Standard_Boolean tFSEG=DEBTEFOR(B,iFS,iEG);if (tFSEG) debfillonfemess(iFS,iEG);
256#endif
257
96a95605 258#ifdef DEB
7fd59977 259 Standard_Boolean keep1=Standard_True;
260 Standard_Boolean keep2=Standard_True;
96a95605 261#endif
7fd59977 262 Standard_Boolean keep3=Standard_True;
263 Standard_Boolean isclosedFF=BRep_Tool::IsClosed(EG,FF);
264 if (isclosedFF) {
96a95605 265#ifdef DEB
7fd59977 266 keep1=Standard_True;
267 keep2=Standard_True;
96a95605 268#endif
7fd59977 269 keep3=Standard_True;
270 }
271 else {
272 TopAbs_Orientation oEGFF=TopAbs_FORWARD;
273 FUN_tool_orientEinF(EG,FF,oEGFF);
274
96a95605 275#ifdef DEB
7fd59977 276 TopAbs_Orientation omatFS1=TFE.Orientation(TB1);
277 if (oEGFF == TopAbs_REVERSED) omatFS1=TopAbs::Complement(omatFS1);
278 keep1=(omatFS1 == TopAbs_FORWARD);
279
280 TopAbs_Orientation omatFS2=TFE.Orientation(TB1);
281 keep2=(omatFS2 == oEGFF);
96a95605 282#endif
7fd59977 283
284 TopAbs_State tfeb=TFE.Before();
285 TopAbs_State tfea=TFE.After();
286 if (oEGFF == TopAbs_FORWARD ) keep3=(tfea == TB1);
287 else if (oEGFF == TopAbs_REVERSED) keep3=(tfeb == TB1);
288 else if (oEGFF == TopAbs_EXTERNAL) keep3=(tfea == TB1 || tfeb == TB1);
289 else if (oEGFF == TopAbs_INTERNAL) keep3=(tfea == TB1 || tfeb == TB1);
290 }
291
292#ifdef DEB
293 if (tFFEG || tFSEG) {
294 if ( keep1 != keep2 || keep1 != keep3 || keep2 != keep3 ) {
295 cout<<"\nkeepEON : EGB "<<EGBoundFOR<<" EG "<<iEG<<" FOR "<<iFF<<" FS "<<iFS;
296 cout<<" keep1 "<<keep1<<" keep2 "<<keep2<<" keep3 "<<keep3;
297 cout<<" !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=";
298 cout<<endl;
299 }
300 }
301#endif
302
303 return keep3;
304}
305
306Standard_EXPORT TopAbs_State FUN_build_TB(const TopOpeBRepBuild_PBuilder& PB,const Standard_Integer rank)
307{
308 Standard_Boolean opeFus = PB->Opefus();
309 Standard_Boolean opec12 = PB->Opec12();
310 Standard_Boolean opec21 = PB->Opec21();
311 Standard_Boolean opeCom = PB->Opecom();
312 TopAbs_State sta = TopAbs_UNKNOWN;
313 if (opeFus) sta = TopAbs_OUT;
314 if (opeCom) sta = TopAbs_IN;
315 if (opec12) sta = (rank == 1) ? TopAbs_OUT : TopAbs_IN;
316 if (opec21) sta = (rank == 2) ? TopAbs_OUT : TopAbs_IN;
317 return sta;
318}
319
320static Standard_Boolean FUN_Kpart0(const GeomAbs_SurfaceType& ST1, const GeomAbs_SurfaceType& ST2)
321{
322 Standard_Boolean plane1 = (ST1 == GeomAbs_Plane);
323 Standard_Boolean cyli1 = (ST1 == GeomAbs_Cylinder);
324 Standard_Boolean cone1 = (ST1 == GeomAbs_Cone);
325
326 Standard_Boolean cyli2 = (ST2 == GeomAbs_Cylinder);
327 Standard_Boolean cone2 = (ST2 == GeomAbs_Cone);
328 Standard_Boolean sphe2 = (ST2 == GeomAbs_Sphere);
329 Standard_Boolean quad2 = cyli2 || cone2 || sphe2 || (ST2 == GeomAbs_Torus);
330
331 if (plane1 && quad2) return Standard_True;
332 if (cyli1 && sphe2) return Standard_True;
333 if (cone1 && sphe2) return Standard_True;
334 return Standard_False;
335}
336static Standard_Integer FUN_Kpart(const GeomAbs_SurfaceType& ST1, const GeomAbs_SurfaceType& ST2)
337{
338 Standard_Boolean kpart0 = FUN_Kpart0(ST1,ST2);
339 if (kpart0) return 1;
340 kpart0 = FUN_Kpart0(ST2,ST1);
341 if (kpart0) return 2;
342 return 0;
343}
344
345static Standard_Integer FUN_findeSD
346(const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& EspON, const TopoDS_Edge& EG, const TopoDS_Face& FOR,
347 TopAbs_Orientation& oeSD, const Standard_Integer D)
348{
349 // chercher eSD = SameDomain3d/2d de EG, arete de FOR, qui contient EspON
350 gp_Pnt ptON; Standard_Real parON;
351 FUN_tool_findPinE(EspON,ptON,parON);
352 TopTools_ListOfShape lesdSD;
353 if (D == 3) FDS_HasSameDomain3d(BDS,EG,&lesdSD);
354 if (D == 2) FDS_HasSameDomain2d(BDS,EG,&lesdSD);
355 for(TopTools_ListIteratorOfListOfShape it(lesdSD);it.More();it.Next()) {
356 TopoDS_Edge eSD = TopoDS::Edge(it.Value());
357 TopAbs_Orientation oesd; Standard_Boolean eSDofFOR = FUN_tool_orientEinFFORWARD(eSD,FOR,oesd);
358 if (!eSDofFOR) continue;
359 TopAbs_State staeSD = FUN_tool_staPinE(ptON,eSD);
360 if (staeSD == TopAbs_IN) {
361 Standard_Integer i = BDS.Shape(eSD); oeSD = oesd;
362 return i;
363 }
364 }
365 return 0;
366}
367
368static Standard_Boolean ComputeFaceCrvtInSec(const TopoDS_Face& aFace,
369 const gp_Pnt2d& aP2d,
370 const gp_Dir& aSecDir,
371 Standard_Real& aCrvt)
372{
373 BRepAdaptor_Surface aSurf(aFace);
374 Standard_Integer cn = BRepLProp_SurfaceTool::Continuity(aSurf);
375 if (cn < 2) return Standard_False;
376 BRepLProp_SLProps aProp(aSurf, aP2d.X(), aP2d.Y(), 2, Precision::Confusion());
377 if (!aProp.IsCurvatureDefined()) return Standard_False;
378
379 if (aProp.IsUmbilic()) {
380 aCrvt = aProp.MaxCurvature();
381 return Standard_True;
382 }
383
384 Standard_Real maxCrv = aProp.MaxCurvature();
385 Standard_Real minCrv = aProp.MinCurvature();
386 gp_Dir maxDir, minDir;
387 aProp.CurvatureDirections(maxDir, minDir);
388 Standard_Real cosMax = aSecDir * maxDir;
389 Standard_Real cosMin = aSecDir * minDir;
390 aCrvt = maxCrv * cosMax + minCrv * cosMin;
391 return Standard_True;
392}
393
394//=======================================================================
395//function : GFillONPartsWES2
396//purpose :
397//=======================================================================
398void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& EspON)
399{
400 const Handle(TopOpeBRepDS_HDataStructure)& HDS=myPB->DataStructure();
401 const TopOpeBRepDS_DataStructure& BDS= HDS->DS();
402 const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI=Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
403 TopAbs_State TB1,TB2;myPG->StatesON(TB1,TB2); TopAbs_State TB=TB1;
404 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
405 const TopOpeBRepDS_Transition& TFE=SSI->Transition(); Standard_Boolean EGBoundFOR=SSI->GBound();
406 const TopoDS_Face& FOR=TopoDS::Face(myFace); Standard_Integer iFOR=BDS.Shape(FOR);
407 const TopoDS_Edge& eON=TopoDS::Edge(EspON);
408 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
409#ifdef DEB
410 Standard_Integer iEG=
411#endif
412 BDS.Shape(EG);
413 const TopoDS_Face& FS=TopoDS::Face(BDS.Shape(SI)); Standard_Integer iFS=BDS.Shape(FS);
414
415 Standard_Real tola = Precision::Angular()*1.e3;//nyitol
416
417 TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation();
418 TopAbs_Orientation oFS = BDS.Shape(iFS).Orientation();
419
420 Standard_Boolean isclosedFF=FUN_tool_IsClosingE(EG,FOR,FOR); //xpu240898 : cto900J5 faulty yapc2(FOR17,FS18,EG15)
421 Standard_Boolean isclosedFS=FUN_tool_IsClosingE(EG,FS,FS); //xpu240898
422 Standard_Boolean isclosed=(isclosedFF || isclosedFS);
423 Standard_Boolean isrest=BDS.IsSectionEdge(EG);
424#ifdef DEB
425// Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON);
426#endif
427 Standard_Integer rankFS=myPB->GShapeRank(FS);
428 Standard_Integer rankEG=myPB->GShapeRank(EG);
429 Standard_Integer rankFOR=myPB->GShapeRank(FOR);
430 TopAbs_Orientation OTFE = TFE.Orientation(TopAbs_IN);
431 TopAbs_State TFEbef = TFE.Before();
432 TopAbs_State TFEaft = TFE.After();
433#ifdef DEB
434// Standard_Boolean EGboundFOR =
435// Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I)->GBound();
436#endif
437 Standard_Boolean eghassd = HDS->HasSameDomain(EG);
438 TopTools_ListOfShape le3;Standard_Boolean eghassd3d = FDS_HasSameDomain3d(BDS,EG,&le3);
439 Standard_Integer ie3d = 0; TopAbs_Orientation oe3d = TopAbs_EXTERNAL;
440 Standard_Integer ie2d = 0; TopAbs_Orientation oe2d = TopAbs_EXTERNAL;
441 TopTools_ListOfShape lfcx; FDSCNX_FaceEdgeConnexFaces(FS,EG,HDS,lfcx);
442 Standard_Integer nlfcx=lfcx.Extent();
443
444 Standard_Boolean hsdFOR = HDS->HasSameDomain(FOR);
445 TopOpeBRepDS_Config cFOR = TopOpeBRepDS_UNSHGEOMETRY;
446 Standard_Integer irefFOR = 0;
447 TopAbs_Orientation orefFOR = TopAbs_EXTERNAL;
448 Standard_Boolean FORisref = Standard_False;
449 if (hsdFOR) {
450 cFOR = BDS.SameDomainOri(iFOR);
451 if (hsdFOR) irefFOR = BDS.SameDomainRef(FOR);
452 if (irefFOR != 0) orefFOR = BDS.Shape(irefFOR).Orientation();
453 FORisref = (irefFOR == iFOR);
454 }
455
456 Standard_Boolean opeFus = myPB->Opefus();
457 Standard_Boolean opec12 = myPB->Opec12();
458#ifdef DEB
459// Standard_Boolean opec21 = myPB->Opec21();
460#endif
461 Standard_Boolean opeCut = myPB->Opec12() || myPB->Opec21();
462 Standard_Boolean opeCom = myPB->Opecom();
463 Standard_Boolean ComOfCut = opeCut && (TB1 == TB2) && (TB1 == TopAbs_IN); //xpu200598 only if FFSDSO
464
465 TopAbs_State TBFOR = FUN_build_TB(myPB,rankFOR);
466
467#ifdef DEB
468 Standard_Boolean tFOR=myPB->GtraceSPS(iFOR);Standard_Boolean tE=myPB->GtraceSPS(GI);
469 Standard_Boolean tEFOR=DEBTEFOR(*myPB,iFOR,GI);
470 if (tFOR) debON(iFOR);
471#endif
472
473 Standard_Real factor = 1.e2;
474 Standard_Real tolEG = BRep_Tool::Tolerance(EG)*factor; //NYITOLXPU
475 Standard_Real tolFOR = BRep_Tool::Tolerance(FOR)*factor; //NYITOLXPU
476 Standard_Real tolFS = BRep_Tool::Tolerance(FS)*factor; //NYITOLXPU
477
478 Standard_Real f,l; FUN_tool_bounds(eON,f,l); Standard_Real x=0.456189; Standard_Real parON = (1-x)*f + x*l;
479
480
481 // xpu150698 : spON(EG)=spON1+spON2+.., spON1 ON EsdEG, spON2 shares no
482 // geometry with any other edge.
483 // FRA11018 (FOR=f5,EG=e18,EsdEG=e7)
484 Standard_Boolean espONesd = Standard_False; Standard_Integer Iesd=0;// xpu150698
485 if (eghassd) espONesd = FUN_ds_ONesd(BDS,GI,EspON,Iesd);// xpu150698
1d47d8d0 486 Standard_Boolean eONsoEsd = Standard_False;
7fd59977 487 if (eghassd && (Iesd != 0)) {
488 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
489 Standard_Boolean ok = FUN_tool_curvesSO(eON,Esd,eONsoEsd);
490 if (!ok) return;
491 }
492
493 Standard_Boolean eONFS = Standard_True; // xpu240898
494 if (eghassd && (!espONesd)) {
495 gp_Pnt pON; Standard_Boolean ok = FUN_tool_value(parON,eON,pON);
496 if (!ok) return;
497 gp_Pnt2d uvFS; Standard_Real d=1.; ok = FUN_tool_projPonboundedF(pON,FS,uvFS,d);
498 if (!ok) return;
499 Standard_Real tolF = FUN_tool_maxtol(FS); eONFS = (d < tolF);
500 }
501 // ------------------------------------
502 Standard_Boolean eghassdON = eghassd && espONesd;
503 Standard_Boolean eghassd3dON = eghassd3d && espONesd;
504 // ------------------------------------
505
506 Standard_Boolean yap00 = Standard_True; //xpu180998 : cto900Q2
507 yap00 = yap00 && (!isclosed);
508 yap00 = yap00 && (EGBoundFOR);
509 yap00 = yap00 && (espONesd);
510 yap00 = yap00 && (!hsdFOR); //xpu280998 : PRO14892 (FOR16,FS30,GI20)
511 if (yap00) {
512 const TopOpeBRepDS_ListOfInterference& lI = BDS.ShapeInterferences(FOR);
513 TopOpeBRepDS_ListOfInterference lIcopy; FDS_assign(lI,lIcopy);
514 TopOpeBRepDS_ListOfInterference lIGesd; Standard_Integer nGesd = FUN_selectGIinterference(lIcopy,Iesd,lIGesd);
515 if (nGesd != 0) yap00=Standard_False; // ES has interference on G=edge(Iesd)
516 }
517
518 Standard_Boolean yap0 = Standard_True;
519 yap0 = yap0 && (!isclosed);
520 yap0 = yap0 && (EGBoundFOR);
521 yap0 = yap0 && (!eghassd);
522
523 Standard_Boolean yap0bis = Standard_True; // xpu160698
524 yap0bis = yap0bis && (!isclosed);
525 yap0bis = yap0bis && (EGBoundFOR);
526 yap0bis = yap0bis && (eghassd); // xpu300798 : cto 902 B7
527 yap0bis = yap0bis && (!eghassdON);
528 yap0bis = yap0bis && eONFS; //xpu240898 : cto900J3 (e7on_2 NOT ON FS, FOR18,FS17,EG7)
529 yap0bis = yap0bis && !ComOfCut; // xpu270798 : boxes240798, f14in,GI=34
530 if ( yap0bis ) {
531 yap0 = Standard_True;
532 }
533
534 Standard_Boolean hassd3dON = Standard_False;
535// if (isclosed && !EGBoundFOR && eghassd3d) { -xpu110898 -> yapc3
536 if (!EGBoundFOR && eghassd3d) {
537 ie3d = ::FUN_findeSD(BDS,eON,EG,FOR,oe3d,3);
538 hassd3dON = (ie3d != 0);
539 }
540
541 Standard_Boolean yapc1 = Standard_True;
542 yapc1 = yapc1 && (isclosed);
543 yapc1 = yapc1 && (!EGBoundFOR);
544 yapc1 = yapc1 && (eghassd3d);
545 yapc1 = yapc1 && hassd3dON; //xpu230798
546
547 Standard_Boolean yapc2a = Standard_True;
548 yapc2a = yapc2a && (isclosed);
549 yapc2a = yapc2a && (!eghassd3d);
550
551 //xpu240798 cto902A3 (iFOR=5,GI=3,iFCX=6) : complement yapc1
552 Standard_Boolean yapc2b = Standard_True;
553 yapc2b = yapc2b && (isclosed);
554 yapc2b = yapc2b && (!EGBoundFOR);
555 yapc2b = yapc2b && (eghassd3d);
556 yapc2b = yapc2b && (!hassd3dON);
557
558 Standard_Boolean yapc2c = Standard_True;
559 yapc2c = yapc2c && (isclosed);
560 yapc2c = yapc2c && (EGBoundFOR);
561 yapc2c = yapc2c && (eghassd3d);
562
563 Standard_Boolean yapc2 = yapc2a;
564 yapc2 = yapc2 || yapc2b || yapc2c; //xpu240798
565
566 Standard_Boolean yapc3 = Standard_True;
567 yapc3 = yapc3 && (!isclosed);
568 yapc3 = yapc3 && (eghassd3d);
569 yapc3 = yapc3 && (hassd3dON);
570 Standard_Boolean e3closedFOR = Standard_False;
571 if (hassd3dON) {
572 const TopoDS_Edge& e3d = TopoDS::Edge(BDS.Shape(ie3d));
573 e3closedFOR = BRep_Tool::IsClosed(e3d,FOR);
574 }
575 yapc3 = yapc3 && e3closedFOR; // => !EGBoundFOR
576
577 //=========================================
578 if ( yap00 ) {
579#ifdef DEB
580 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap0 GFillON");
581 if (tE) {cout<<"yap00(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
582 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
583#endif
584
585 TopAbs_Orientation oeff;
586 FUN_tool_orientEinFFORWARD(EG,FOR,oeff);
587 Standard_Boolean add = Standard_False;
588 if (oeff == TopAbs_FORWARD) add = (TFEaft == TB);
589 else if (oeff == TopAbs_REVERSED) add = (TFEbef == TB);
590 else if (oeff == TopAbs_INTERNAL) add = Standard_True;
591 else if (oeff == TopAbs_EXTERNAL) add = Standard_True;
592 if (!add) return;
593
594 const TopoDS_Shape& Esd = BDS.Shape(Iesd);
595 Standard_Boolean isONFS=Standard_False; TopExp_Explorer ex(FS, TopAbs_EDGE);
596 for (; ex.More(); ex.Next())
597 if (ex.Current().IsSame(Esd)) {isONFS=Standard_True;break;}
598 if (!isONFS) return;
599
600 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
601 if (!ok) return;
602 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,eON,samegeom);
603 if (!ok) return;
604 TopAbs_Orientation neworiE = oeff;
605 if (!samegeom && (M_FORWARD(neworiE) || M_REVERSED(neworiE))) neworiE = TopAbs::Complement(neworiE);
606
607 TopoDS_Shape newE = EspON;
608 newE.Orientation(neworiE);
609#ifdef DEB
610 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap00 GFillON","WES+ EspON ");
611 if (tE) FUN_cout(newE);
612#endif
613 myPWES->AddStartElement(newE);
614 return;
615 }
616
617 //=========================================
618 if ( yap0 ) {
619#ifdef DEB
620 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap0 GFillON");
621 if (tE) {cout<<"yap0(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
622 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
623#endif
624
625 TopAbs_Orientation oeff;
626 FUN_tool_orientEinFFORWARD(EG,FOR,oeff);
627 Standard_Boolean add = Standard_False;
628 if (oeff == TopAbs_FORWARD) add = (TFEaft == TB);
629 else if (oeff == TopAbs_REVERSED) add = (TFEbef == TB);
630 else if (oeff == TopAbs_INTERNAL) add = Standard_True;
631 else if (oeff == TopAbs_EXTERNAL) add = Standard_True;
632 if (!add) return; //xpu100698
633
634 // parEG :
635 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
636 if (!ok) return;
637 // ngFS, ngFOR, xxFOR :
638 Standard_Real tolON = Max(tolFS,tolEG);
639 tolON *= 1.e2;//*****CAREFULL***** : xpu040998, cto 904 A3
640 gp_Vec ngFS; ok = FUN_tool_nggeomF(parEG,EG,FS,ngFS,tolON);
641 if (!ok) return;
642 tolON = Max(tolFOR,tolEG);
643 tolON *= 1.e2;//*****CAREFULL***** : xpu040998, cto 904 A3
644 gp_Vec ngFOR; ok = FUN_tool_nggeomF(parEG,EG,FOR,ngFOR,tolON);
645 if (!ok) return;
646 gp_Dir xxFOR; ok = FUN_tool_getxx(FOR,EG,parEG,ngFOR,xxFOR);
647 if (!ok) return;
648 // ntFS, ntFOR, ntdot :
649 gp_Dir ntFS(ngFS); if (M_REVERSED(oFS)) ntFS.Reverse();
650 gp_Dir ntFOR(ngFOR); if (M_REVERSED(oFOR)) ntFOR.Reverse();
651 Standard_Real ntdot = ntFOR.Dot(ntFS);
652
653 // xpu180698 : Kpart=FOR tangent to FS at EG
654 Standard_Boolean Kpart = (OTFE == TopAbs_EXTERNAL) || (OTFE == TopAbs_INTERNAL);
655 if (Kpart) {
656 Standard_Boolean Ktg = (Abs(1-Abs(ntdot)) < tola*1.e2);
657 Kpart = Ktg;
658 }
659 if (Kpart) {
660 gp_Pnt2d UVfor,UVfs; ok = FUN_tool_paronEF(EG,parEG,FOR,UVfor,tolFOR);
661 if (!ok) return;
662 gp_Pnt Pfor,Pfs; FUN_tool_value(UVfor,FOR,Pfor);
663 tolON = Max(Max(tolFOR,tolFS),tolEG) * 10.;
664 Standard_Real d;
665
666 BRepAdaptor_Surface BSfor(FOR); GeomAbs_SurfaceType STfor = BSfor.GetType();
667 BRepAdaptor_Surface BSfs(FS); GeomAbs_SurfaceType STfs = BSfs.GetType();
668 Standard_Integer kpart = FUN_Kpart(STfor,STfs);
669 if (kpart == 0) {
670 // MSV: general case, such as BSpline or Bezier surface or two cylinders.
671 // We should detect if FOR and FS have different curvature in section
672 // by plane perpendicular to EG at point parEG.
673 Standard_Real crvFOR,crvFS;
674 if (!ComputeFaceCrvtInSec(FOR,UVfor,xxFOR,crvFOR)) return;
675 if (!FUN_tool_projPonF(Pfor,FS,UVfs,d)) return;
676 if (!ComputeFaceCrvtInSec(FS,UVfs,xxFOR,crvFS)) return;
677 if (M_REVERSED(oFOR)) crvFOR = -crvFOR;
678 if (M_REVERSED(oFS)) crvFS = -crvFS;
679 if (ntdot < 0.) crvFS = -crvFS;
680 Standard_Real eps = Precision::Confusion();
681 Standard_Real absCrvFOR = Abs(crvFOR), absCrvFS = Abs(crvFS);
682 if (absCrvFOR <= eps && absCrvFS <= eps) return;
683 if (absCrvFOR > eps && absCrvFS > eps) {
684 Standard_Real tolR = tolON;
685 Standard_Real rcrvFOR = 1./crvFOR, rcrvFS = 1./crvFS;
686 if (Abs(rcrvFOR - rcrvFS) <= tolR) return;
687 }
688 // if we are here the curvatures are different
689 }
690 // SO :
691 Standard_Boolean SO = (ntdot > 0.);
692 // Pfor :
693 Pfor.Translate(xxFOR.XYZ()*tolON*10.);
694 ok = FUN_tool_projPonF(Pfor,FOR,UVfor,d);
695 if (!ok) return;
696 FUN_tool_value(UVfor,FOR,Pfor);
697 // Pfs :
698 ok = FUN_tool_projPonF(Pfor,FS,UVfs,d);
699 if (!ok) return;
700 FUN_tool_value(UVfs,FS,Pfs);
701 // Dforfs :
702 gp_Dir Dforfs(gp_Vec(Pfor,Pfs));
703
704 Standard_Boolean keep = Standard_True;
705 Standard_Real dot = Dforfs.Dot(ntFOR); // xpu250698
706 if (SO) {
707 Standard_Boolean so2and3 = (dot > 0); // xpu250698
708 Standard_Boolean so2 = so2and3; // xpu250698
709
710 if (opeFus) keep = !so2;
711 if (opeCom) keep = so2;
712 if (opeCut) {
713 if (TBFOR == TopAbs_OUT) keep = !so2;
714 else keep = so2;
715 }
716 } // SO
717 else {
718 Standard_Boolean do1and2 = (dot > 0); // xpu250698
719 Standard_Boolean do1 = do1and2; // xpu250698
720
721 if (opeFus) keep = do1;
722 if (opeCom) keep = !do1;
723 if (opeCut) {
724 if (TBFOR == TopAbs_OUT) keep = do1;
725 else keep = !do1;
726 }
727 } // !SO
728 if (!keep) return;
729 } //Kpart
730 else {
731 // dot :
732 Standard_Real dot = ntFS.Dot(xxFOR);
733 Standard_Boolean positive = (dot > 0);
734
735 Standard_Boolean keep = Standard_True;
736 if (opeFus) {
737 keep = positive;
738 }
739 if (opeCom) {
740 keep = !positive;
741 }
742 if (opeCut) {
743 if (positive) keep = (TBFOR == TopAbs_OUT);
744 else keep = (TBFOR != TopAbs_OUT);
745 }
746 if (!keep) return;
747 }
748
749 TopoDS_Face newF = FOR;
750 TopoDS_Shape newE = EspON;
751 TopAbs_Orientation neworiE; FUN_tool_orientEinFFORWARD(EG,newF,neworiE);
752
753 if (hsdFOR) {
754 //xpu260698 : cto902A5 : fonds de poche (FOR=f14,GI=e24,refFOR=f13)
755 Standard_Boolean reverse = Standard_False;
756 if (!FORisref) {
757 // xpu170698 : PRO13555 (FOR=f19,GI=e10,FS=f15)
758 Standard_Boolean FORDO = (cFOR == TopOpeBRepDS_DIFFORIENTED);
759 if (FORDO) reverse = !reverse;
760 if (oFOR != orefFOR) reverse = !reverse;
761 }
762
763 if (opeFus) {//nyixpu260698
764 }
765 if (opeCom) {//nyixpu260698
766 }
767 if (opeCut) {
768 if (TBFOR == TopAbs_IN) {
769 // xpu290798 : cto902C1 (FOR19,FS16,GI22) f9ou is DO f19in
770 // sp(f9)+sp(f19) are in same WES, e22on is OUT f9 =>
771 // do NOT reverse neworiE
772// reverse = Standard_True;
773 }
774 else {}
775 }
776 if (reverse) neworiE = TopAbs::Complement(neworiE);
777 } // hsdFOR
778
779 newE.Orientation(neworiE);
780#ifdef DEB
781 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap0 GFillON","WES+ EspON ");
782 if (tE) FUN_cout(newE);
783#endif
784 myPWES->AddStartElement(newE);
785 return;
786 } //yap0
787
788 //=========================================
789 if ( yapc1 ) {
790#ifdef DEB
791 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yapc1 GFillON");
792 if (tE) {cout<<"yapc1(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
793 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
794#endif
795 const TopoDS_Edge& e3d = TopoDS::Edge(BDS.Shape(ie3d));
796
797 // e3d = SameDomain3d de EG, arete de FOR, qui contient EspON
798 TopOpeBRepDS_Config cf; Standard_Boolean cfok = FDS_Config3d(EspON,e3d,cf);
799 if (!cfok) return;
800
801 TopAbs_Orientation oe3dk = oe3d;
802// Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(EG,e3d);
803 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
804 if (!ok) return; //nyiRAISE
805 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,e3d,samegeom);
806 if (!ok) return; //nyiRAISE
807#ifdef DEB
808 if (!TopOpeBRepBuild_GetcontextNOSG()) {
809#endif
810 if (!samegeom) oe3dk = TopAbs::Complement(oe3dk);
811#ifdef DEB
812 }
813#endif
814
815 Standard_Boolean keep3d = Standard_False;
816 if (oe3dk == TopAbs_FORWARD) keep3d = (TFEaft == TB1);
817 else if (oe3dk == TopAbs_REVERSED) keep3d = (TFEbef == TB1);
818 else if (oe3dk == TopAbs_INTERNAL) keep3d = Standard_True;
819 else if (oe3dk == TopAbs_EXTERNAL) keep3d = Standard_False;
820
821#ifdef DEB
822// if(tEFOR) {cout<<endl<<"yapc1 keep3d : "<<keep3d<<endl;debfillonfemess3d(iFOR,iEG);}
823#endif
824
825 if (keep3d) {
826 TopAbs_Orientation neworiE = oe3d;
827 if (cf == TopOpeBRepDS_DIFFORIENTED) neworiE = TopAbs::Complement(neworiE);
828 TopoDS_Shape newE = EspON;
829 newE.Orientation(neworiE);
830
831#ifdef DEB
832 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yapc1 GFillON","WES+ EspON ");
833 if (tE) FUN_cout(newE);
834#endif
835 myPWES->AddStartElement(newE);
836 }
837
838 return;
839 } // yapc1
840
841 //=========================================
842 if ( yapc2 ) {
843#ifdef DEB
844 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yapc2 GFillON");
845 if (tE) {cout<<"yapc2(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
846 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
847#endif
848
849 Standard_Boolean keep = Standard_False;
850 if (EGBoundFOR) keep=FUN_keepEON(*myPB,EG,FOR,FS,EGBoundFOR,TFE,TB1,TB2);
851 else keep=Standard_True;
852 if ( !keep ) return;
853
854 TopAbs_Orientation neworiE = TFE.Orientation(TB1);
855 Standard_Boolean giveoEinFOR = EGBoundFOR && (!isclosedFF) && (M_EXTERNAL(neworiE) || M_INTERNAL(neworiE));
856 if (giveoEinFOR) FUN_tool_orientEinFFORWARD(EG,FOR,neworiE);
857
858 // xpu230798 : cto902A3 (iFOR=5,GI=3,iFCX=6)
859 // (iFOR=20,GI=3,iFCX=6)
860 if (yapc2b && (!M_EXTERNAL(neworiE))){
861 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(FOR);
862 TopAbs_State state2d = FSC_StateEonFace(EspON,0.345,FOR,PSC);
863 if (state2d != TopAbs_IN) return;
864 }
865
866 TopoDS_Shape newE=EspON;
867 Standard_Boolean addFORREV = Standard_False;
868 TopAbs_Orientation neworiEk = TopAbs_EXTERNAL;
869 if (!isclosedFF) neworiEk = neworiE;
870 else if (M_FORWARD(neworiE) || M_REVERSED(neworiE)) neworiEk = neworiE;
871 else if (M_INTERNAL(neworiE)) addFORREV = Standard_True;
872 newE.Orientation(neworiEk);
873
874#ifdef DEB
875 if (tEFOR) {
876 if (!isclosedFF)
877 debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yapc2 GFillON","WES+ EspON not closed");
878 else if (M_FORWARD(neworiE) || M_REVERSED(neworiE))
879 debaddpwes(iFOR,TB1,iEG,neworiEk,myPB,myPWES,"yapc2 GFillON closed","WES+ EspON F|R");
880 else if (M_INTERNAL(neworiE)) {
881 debaddpwes(iFOR,TB1,iEG,TopAbs_FORWARD, myPB,myPWES,"yapc2 GFillON closed","WES+ EspON INTERNAL");
882 debaddpwes(iFOR,TB1,iEG,TopAbs_REVERSED,myPB,myPWES,"yapc2 GFillON closed","WES+ EspON INTERNAL");
883 }
884 }
885 if (tE) {
886 if (addFORREV) {
887 newE.Orientation(TopAbs_FORWARD); FUN_cout(newE);
888 newE.Orientation(TopAbs_REVERSED); FUN_cout(newE);
889 }
890 else FUN_cout(newE);
891 }
892#endif
893
894 if (addFORREV) {
895 newE.Orientation(TopAbs_FORWARD);
896// Standard_Boolean ok = FUN_tool_correctCLO(TopoDS::Edge(newE),FOR); // xpu201198 cto016*
897 myPWES->AddStartElement(newE);
898
899 newE.Orientation(TopAbs_REVERSED);
900// ok = FUN_tool_correctCLO(TopoDS::Edge(newE),FOR); // xpu201198 cto016*
901 myPWES->AddStartElement(newE);
902 }
903 else {
904// Standard_Boolean ok = FUN_tool_correctCLO(TopoDS::Edge(newE),FOR); // xpu201198 cto016*
905 myPWES->AddStartElement(newE);
906 }
907 return;
908 } // yapc2
909
910 //=========================================
911 if ( yapc3 ) {
912#ifdef DEB
913 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yapc3 GFillON");
914 if (tE) {cout<<"yapc3(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
915 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
916#endif
917
918 Standard_Boolean keep = Standard_False;
919 if (EGBoundFOR) keep=FUN_keepEON(*myPB,EG,FOR,FS,EGBoundFOR,TFE,TB1,TB2);
920 else keep=Standard_True;
921 if ( !keep ) return;
922
923 TopAbs_Orientation neworiE = TFE.Orientation(TB1);
924 Standard_Boolean giveoEinFOR = EGBoundFOR && !isclosedFF && (M_EXTERNAL(neworiE) || M_INTERNAL(neworiE));
925 if (giveoEinFOR) FUN_tool_orientEinFFORWARD(EG,FOR,neworiE);
926
927 TopoDS_Shape newE=EspON;
928 Standard_Boolean addFORREV = Standard_False;
929 TopAbs_Orientation neworiEk = TopAbs_EXTERNAL;
930
931 // xpu110798 : cto902B4 (FOR6,EG15,FS17)
932 if (M_INTERNAL(OTFE) || M_EXTERNAL(OTFE)) {
933 Standard_Boolean SO = Standard_False; // "approximate same oriented (FOR,FS)"
934 // parEG :
935 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
936 if (!ok) return;// nyiRAISE
937 // ntFS :
938 gp_Pnt2d uvFS; ok = FUN_tool_paronEF(EG,parEG,FS,uvFS,tolFS); // !EGBoundFOR
939 if (!ok) return;// nyiRAISE
940 gp_Vec ngFS = FUN_tool_nggeomF(uvFS,FS);
941 gp_Dir ntFS(ngFS); if (M_REVERSED(oFS)) ntFS.Reverse();
942 // ntFOR :
943 gp_Pnt2d uvFOR; ok = FUN_tool_parF(EG,parEG,FOR,uvFOR,tolFOR);
944 if (!ok) return;// nyiRAISE
945 gp_Vec ngFOR = FUN_tool_nggeomF(uvFOR,FOR);
946 gp_Dir ntFOR(ngFOR); if (M_REVERSED(oFOR)) ntFOR.Reverse();
947
948 Standard_Real dot = ntFOR.Dot(ntFS);
949 Standard_Boolean nulldot = (Abs(dot) < tola);
950 if (nulldot) {
951 // xxFS :
952 gp_Dir xxFS; ok = FUN_tool_getxx(FS,EG,parEG,ngFS,xxFS);
953 if (!ok) return;// nyiRAISE
954 Standard_Real dot2 = ntFOR.Dot(xxFS);
955 SO = (dot2 < 0.);
956 }
957 else {
958 SO = (dot > 0.);
959 }
960
961 Standard_Boolean unkeepclo = Standard_False;
962 if (SO && M_EXTERNAL(OTFE) && opeCom) unkeepclo = Standard_True;
963 if (SO && M_INTERNAL(OTFE) && opeFus) unkeepclo = Standard_True;
964 addFORREV = !unkeepclo;
965 }
966
967 if (!addFORREV) {
968 neworiEk = neworiE;
969 Standard_Boolean samegeom; Standard_Boolean ok = FUN_tool_curvesSO(eON,EG,samegeom);
970 if (!ok) return; // nyiRAISE
971 Standard_Boolean reverse = (!samegeom);
972#ifdef DEB
973 if (TopOpeBRepBuild_GetcontextNOSG())
974 // MSV 21.03.2002: restore the genaral behaviour, since the function
975 // FUN_UNKFstasta was corrected.
976 reverse = Standard_False; //we exclude this line from #ifdef DEB because
977 //in optimised mode this line will never be included , and that follows to regressions
978 //MZV-12-05-2000
979#endif
980
981 if (reverse) neworiEk = TopAbs::Complement(neworiEk);
982 newE.Orientation(neworiEk);
983 }
984
985#ifdef DEB
986 if (tEFOR) {
987 if (!addFORREV)
988 debaddpwes(iFOR,TB1,iEG,neworiEk,myPB,myPWES,"yapc3 GFillON","WES+ EspON ");
989 else {
990 debaddpwes(iFOR,TB1,iEG,TopAbs_FORWARD, myPB,myPWES,"yapc3 GFillON closed","WES+ EspON ");
991 debaddpwes(iFOR,TB1,iEG,TopAbs_REVERSED,myPB,myPWES,"yapc3 GFillON closed","WES+ EspON ");
992 }
993 }
994#endif
995
996 if (addFORREV) {
997 newE.Orientation(TopAbs_FORWARD); myPWES->AddStartElement(newE);
998 newE.Orientation(TopAbs_REVERSED); myPWES->AddStartElement(newE);
999 }
1000 else {
1001 myPWES->AddStartElement(newE);
1002 }
1003 return;
1004 } // yapc3
1005
1006 if (nlfcx == 0) return;
1007 const TopoDS_Face& FCX=TopoDS::Face(lfcx.First()); Standard_Integer iFCX=BDS.Shape(FCX);
1008
1009 // faces samedomain de FCX
1010 TopTools_ListOfShape LFSO,LFDO,LFSO1,LFDO1,LFSO2,LFDO2;
1011 myPB->GFindSamDomSODO(FCX,LFSO,LFDO);
1012 Standard_Integer rankFCX=myPB->GShapeRank(FCX),rankX=(rankFCX)?((rankFCX==1)?2:1):0;
1013 // DEB : rankFCX doit etre=rankFS
1014
1015 // LFSO2,LFDO2=faces samedomain de FCX dans le shape oppose (rankX)
1016 // rankX=shape oppose=shape de FOR.
1017 myPB->GFindSameRank(LFSO,rankFCX,LFSO1); myPB->GFindSameRank(LFDO,rankFCX,LFDO1);
1018 myPB->GFindSameRank(LFSO,rankX,LFSO2); myPB->GFindSameRank(LFDO,rankX,LFDO2);
1019
1020 // FFinSO=appartenance de FOR a l'ensemble des faces sameoriented de FCX=LFSO2
1021 Standard_Boolean FFinSDSO=Standard_False;
1022 {
1023 for(TopTools_ListIteratorOfListOfShape i(LFSO2);i.More();i.Next()) {
1024 const TopoDS_Shape& F=i.Value();
1025 if (F.IsSame(FOR)) {FFinSDSO=Standard_True;break;}
1026 }
1027 }
1028 // FFinDO=appartenance de FOR a l'ensemble des faces difforiented de FCX=LFDO2
1029 Standard_Boolean FFinSDDO=Standard_False;
1030 {
1031 for(TopTools_ListIteratorOfListOfShape i(LFDO2);i.More();i.Next()) {
1032 const TopoDS_Shape& F=i.Value();
1033 if (F.IsSame(FOR)) {FFinSDDO=Standard_True;break;}
1034 }
1035 }
1036 // FFinSD=appartenance de FOR a l'ensemble des faces samedomain de FCX
1037 Standard_Boolean FFinSD=(FFinSDSO || FFinSDDO);
1038
1039 TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation();
1040 TopOpeBRepDS_Config cFCX = BDS.SameDomainOri(iFCX);
1041 Standard_Integer irefFCX = BDS.SameDomainRef(FCX);
1042 TopAbs_Orientation orefFCX = BDS.Shape(irefFCX).Orientation();
1043 Standard_Boolean FCXisref = (irefFCX == iFCX);
1044
1045#ifdef DEB
1046// Standard_Real tolFCX = factor*BRep_Tool::Tolerance(FCX); //NYITOLXPU
1047#endif
1048
1049 TopAbs_Orientation oegFCXF;Standard_Boolean EGBoundFCX = FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF);
1050 TopAbs_Orientation oegFCX ;
1051 FUN_tool_orientEinF(EG,FCX,oegFCX);
1052
1053 if (!EGBoundFOR && !espONesd) { //xpu220998 : ctocylcongA1 (FOR10,FS19,EG8)
1054 gp_Pnt ptON; Standard_Boolean ok = FUN_tool_value(parON,eON,ptON);
1055 if (!ok) return; //nyiRAISE
1056 Standard_Real d=1.; gp_Pnt2d uvFOR; ok = FUN_tool_projPonboundedF(ptON,FOR,uvFOR,d);
1057 if (!ok) return; //nyiRAISE
1058 Standard_Real tolON = Max(tolEG,tolFOR);//xpu291098 cto900L7(f7,e7on)
1059 //xpu051198 PRO12953(f6,e4on)
1060 tolON *= 1.e2;//*****CAREFULL***** : xpu040998, cto 904 A3
1061 Standard_Boolean eONFOR = (d < tolON);
1062 if (!eONFOR) return;
1063 }
1064
1065 Standard_Boolean yap1 = Standard_True;
1066 yap1 = yap1 && FFinSD;
1067 yap1 = yap1 && (!EGBoundFOR);
1068 yap1 = yap1 && EGBoundFCX;
1069 yap1 = yap1 && eghassd3dON;
1070
1071 Standard_Boolean yap2 = Standard_True;
1072 yap2 = yap2 && FFinSD;
1073 yap2 = yap2 && (!EGBoundFOR);
1074 yap2 = yap2 && EGBoundFCX;// yap2 = yap2 && !eghassdON;
1075 yap2 = yap2 && !eghassd;// yap2 = yap2 && !eghassd3dON;
1076
1077 Standard_Boolean yap1b = Standard_True;
1078 yap1b = yap1b && FFinSD;
1079 yap1b = yap1b && (!EGBoundFOR);
1080 yap1b = yap1b && EGBoundFCX;
1081 yap1b = yap1b && eghassd3d;
1082 yap1b = yap1b && !eghassd3dON;
1083 yap1b = yap1b && eONFS; //xpu240898
1084 if (yap1b) {
1085 yap2 = Standard_True; // xpu220998 : ctocylcongA1 yap1b(FOR12,FS5,EG8)
1086 }
1087
1088 Standard_Boolean yap6 = Standard_True; // cto001F3 : f18ou,EG=e23
1089 yap6 = yap6 && FFinSD;
1090 yap6 = yap6 && (!EGBoundFOR);
1091 yap6 = yap6 && EGBoundFCX;
1092 yap6 = yap6 && eghassdON;
1093 yap6 = yap6 && !eghassd3d;// yap6 = yap6 && !eghassd3dON;
1094
1095 Standard_Boolean yap6b = Standard_True;
1096 yap6b = yap6b && FFinSD;
1097 yap6b = yap6b && (!EGBoundFOR);
1098 yap6b = yap6b && EGBoundFCX;
1099 yap6b = yap6b && eghassd;
1100 yap6b = yap6b && !eghassdON;
1101 yap6b = yap6b && eONFS; //xpu240898
1102 yap6b = yap6b && !eghassd3d;// yap6b = yap6b && !eghassd3dON;
1103 if (yap6b) {
1104#ifdef DEB
1105// FUN_RaiseON();
1106#endif
1107 yap2 = Standard_True;
1108 }
1109
1110 // CTS20205 spOUT(f30), e4 = eghassd3dON
1111 // mais f30 !sdm lfcx(e4)
1112 Standard_Boolean eghassd3fcx = eghassdON;
1113 eghassd3fcx = eghassd3fcx && !FUN_ds_sdm(BDS,FOR,FS);
1114 eghassd3fcx = eghassd3fcx && !FFinSD; //!FUN_ds_sdm(BDS,FOR,FCX)
1115 Standard_Boolean yap5 = Standard_True;
1116 yap5 = yap5 && !EGBoundFOR;
1117 yap5 = yap5 && eghassd3fcx;
1118
1119 Standard_Boolean yap3 = Standard_True;
1120 yap3 = yap3 && !FFinSD;
1121 yap3 = yap3 && !EGBoundFOR;
1122 yap3 = yap3 && eghassd3dON;
1123
1124 Standard_Boolean yap4 = Standard_True;
1125 yap4 = yap4 && !FFinSD;
1126 yap4 = yap4 && isrest;
1127 yap4 = yap4 && !yap5;
1128 yap4 = yap4 && !hsdFOR; //xpu290598
1129
1130 Standard_Boolean yap3b = Standard_True;
1131 yap3b = yap3b && !FFinSD;
1132 yap3b = yap3b && !EGBoundFOR;
1133 yap3b = yap3b && eghassd3d;
1134 yap3b = yap3b && !eghassd3dON;
1135 yap3b = yap3b && eONFS; //xpu240898
1136 if (yap3b) {
1137 yap4 = Standard_True; //xpu191098 : cto016F3(yap3b(FOR7,EG4))
1138 }
1139
1140 //xpu290598
1141 Standard_Boolean yap7 = Standard_True;
1142 yap7 = yap7 && !FFinSD;
1143 yap7 = yap7 && isrest;
1144 yap7 = yap7 && !yap5;
1145 yap7 = yap7 && hsdFOR;
1146
1147 TopAbs_State staFOR = TB1;
1148 TopAbs_State staFS = (rankFS == rankFOR) ? TB1 : TB2;
1149
1150#ifdef DEB
1151// if(tEFOR) cout<<endl<<"yap1 yap2 yap3 yap4 = ";
1152// if(tEFOR) cout<<yap1<<" "<<yap2<<" "<<yap3<<" "<<yap4<<endl<<endl;
1153// if(tEFOR) debfillonfemess(iFOR,iEG);
1154#endif
1155
1156 //=========================================
1157 if ( yap1 ) {
1158#ifdef DEB
1159 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap1 GFillON");
1160 if (tE) {cout<<"yap1(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1161 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1162
1163#endif
1164
1165 // FF est samedomain avec FCX
1166 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
1167 // au lieu de la transition par rapport a la matiere 3d de la face FS
1168 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
1169 // EG a des aretes 3d same domain : le3
1170
1171 TopAbs_State staFCX = staFS; // FS et FCX connexes par EG => meme shape origine => meme etat
1172 Standard_Boolean b3d = Standard_False; Standard_Boolean b2d = Standard_False;
1173
1174 // staFOR : etat demande sur FOR
1175 Standard_Boolean b3de3 = Standard_False; Standard_Boolean b2de3 = Standard_False;
1176
1177 const TopoDS_Edge& e3 = TopoDS::Edge(le3.First()); Standard_Integer ie3 = BDS.Shape(e3);
1178 Standard_Boolean ssif = Standard_False; Handle(TopOpeBRepDS_ShapeShapeInterference) ssie3;
1179 TopOpeBRepDS_ListIteratorOfListOfInterference itssi(BDS.ShapeInterferences(FCX));
1180 for (;itssi.More();itssi.Next()) {
1181 const Handle(TopOpeBRepDS_ShapeShapeInterference)& ssi = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(itssi.Value()); if (ssi.IsNull()) continue;
1182 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(ssi,GT1,G1,ST1,S1);
1183 Standard_Boolean cond = (GT1 == TopOpeBRepDS_EDGE && ST1 == TopOpeBRepDS_FACE);
1184 cond = cond && (G1 == ie3);
1185 // NYI cond = cond && e(S1 est une face connexe a iFOR par ie3)
1186 if (cond) { ssif = Standard_True; ssie3 = ssi; break; }
1187 }
1188
1189 TopOpeBRepDS_Transition TFEe3; TopAbs_State TFEe3bef = TFEe3.Before(); TopAbs_State TFEe3aft = TFEe3.After();
96a95605 1190 TopAbs_Orientation oe3FORF = TopAbs_FORWARD;
7fd59977 1191 if (ssif) {
1192 TFEe3 = ssie3->Transition();
1193 TFEe3bef = TFEe3.Before();
96a95605 1194 FUN_tool_orientEinFFORWARD(e3,FOR,oe3FORF);
7fd59977 1195 }
1196
1197 if (FFinSDSO) {
1198 if ( oFOR != oFCX ) {
1199 oegFCXF = TopAbs::Complement(oegFCXF);
1200 oe3FORF = TopAbs::Complement(oe3FORF);
1201 }
1202 TopOpeBRepDS_Transition T1(oegFCXF); TopAbs_State T1aft = T1.After(); TopAbs_State T1bef = T1.Before();
1203 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1204 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1205 else FUN_coutmess("DEBUG GFillONPartsWES2_1 orientation != F,R\n");
1206 if (oegFCXF == TopAbs_FORWARD) b2d = (T1aft == TopAbs_IN);
1207 else if (oegFCXF == TopAbs_REVERSED) b2d = (T1bef == TopAbs_IN);
1208 else FUN_coutmess("DEBUG GFillONPartsWES2_2 orientation != F,R\n");
1209
1210 if (ssif) {
1211 TopOpeBRepDS_Transition T11(oe3FORF); TopAbs_State T11aft = T11.After(); TopAbs_State T11bef = T11.Before();
1212 if (oe3FORF == TopAbs_FORWARD) b3de3 = (TFEe3aft == staFOR);
1213 else if (oe3FORF == TopAbs_REVERSED) b3de3 = (TFEe3bef == staFOR);
1214 else FUN_coutmess("DEBUG GFillONPartsWES2_1 orientation != F,R\n");
1215 if (oe3FORF == TopAbs_FORWARD) b2de3 = (T11aft == TopAbs_IN);
1216 else if (oe3FORF == TopAbs_REVERSED) b2de3 = (T11bef == TopAbs_IN);
1217 else FUN_coutmess("DEBUG GFillONPartsWES2_2 orientation != F,R\n");
1218 }
1219 }
1220
1221 if (FFinSDDO) {
1222 if ( oFOR == oFCX ) {
1223 oegFCXF = TopAbs::Complement(oegFCXF);
1224 oe3FORF = TopAbs::Complement(oe3FORF);
1225 }
1226 TopOpeBRepDS_Transition T2(oegFCXF); TopAbs_State Taft = T2.After(); TopAbs_State Tbef = T2.Before();
1227 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1228 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1229 else FUN_coutmess("DEBUG GFillONPartsWES2_3 orientation != F,R\n");
1230 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1231 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1232 else FUN_coutmess("DEBUG GFillONPartsWES2_4 orientation != F,R\n");
1233
1234 if (ssif) {
1235 TopOpeBRepDS_Transition T22(oe3FORF); TopAbs_State T22aft = T22.After(); TopAbs_State T22bef = T22.Before();
1236 if (oe3FORF == TopAbs_FORWARD) b3de3 = (TFEe3aft == staFOR);
1237 else if (oe3FORF == TopAbs_REVERSED) b3de3 = (TFEe3bef == staFOR);
1238 else FUN_coutmess("DEBUG GFillONPartsWES2_3 orientation != F,R\n");
1239 if (oe3FORF == TopAbs_FORWARD) b2de3 = (T22aft == TopAbs_IN);
1240 else if (oe3FORF == TopAbs_REVERSED) b2de3 = (T22bef == TopAbs_IN);
1241 else FUN_coutmess("DEBUG GFillONPartsWES2_4 orientation != F,R\n");
1242 }
1243 }
1244
1245 Standard_Boolean b = (b3d && b2d && b3de3 && b2de3);
1246 if (!b) return;
1247
1248 // on garde EspON pour la reconstruction de la face FOR
1249 // si elle est IN/ON la face FOR (EGBoundFOR = 0 ==> projection)
1250 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(FOR);
1251 TopAbs_State state2d = FSC_StateEonFace(EspON,0.345,FOR,PSC);
1252 Standard_Boolean isin = (state2d == TopAbs_IN);
1253 if (!isin) return;
1254
1255 TopAbs_State TBEG = TB1;
1256 TopAbs_Orientation neworiE = TFE.Orientation(TBEG);
1257
1258 // if (FCXisref && FFinSDDO) {
1259 if (FCXisref && !EGBoundFOR) {
1260 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1261 Standard_Boolean rev = myPB->Reverse(staFCX,staFOR);
1262 neworiE = myPB->Orient(neworiE,rev);
1263 }
1264// xpu280798 : never occurs as yap1 -> !EGBoundFOR
1265// else if (FORisref && EGBoundFOR) {
1266// FUN_tool_orientEinFFORWARD(EG,FOR,neworiE);
1267// Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1268// neworiE = myPB->Orient(neworiE,rev);
1269// }
1270 else if (FORisref && !EGBoundFOR) {
1271 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1272 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1273 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1274 if (reverse) neworiE = TopAbs::Complement(neworiE);
1275 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1276 neworiE = myPB->Orient(neworiE,rev);
1277 }
1278 else if (!EGBoundFOR) { // xpu210898
1279 Standard_Integer rankrefFOR = BDS.AncestorRank(irefFOR);
1280 if (rankrefFOR == rankFCX)
1281 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1282 else if (rankrefFOR == rankFOR) {
1283 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1284 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1285 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1286 if (reverse) neworiE = TopAbs::Complement(neworiE);
1287 }
1288 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1289 neworiE = myPB->Orient(neworiE,rev);
1290 }
1291
1292 TopoDS_Shape newE = EspON;
1293 newE.Orientation(neworiE);
1294
1295#ifdef DEB
1296 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap1 GFillON","WES+ EspON ");
1297 if (tE) FUN_cout(newE);
1298#endif
1299 myPWES->AddStartElement(newE);
1300
1301 return;
1302 } // yap1
1303
1304 //=========================================
1305 if ( yap2 ) {
1306#ifdef DEB
1307 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap2 GFillON");
1308 if (tE) {cout<<"yap2(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1309 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1310#endif
1311
1312 // FF est samedomain avec FCX
1313 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
1314 // au lieu de la transition par rapport a la matiere 3d de la face FS
1315 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
1316
1317 TopAbs_State staFCX = staFS; // FS et FCX connexes par EG => meme shape origine => meme etat
1318 Standard_Boolean b3d = Standard_False; Standard_Boolean b2d = Standard_False;
1319 Standard_Boolean b = (b3d && b2d);
1320
1321 if (FFinSDSO) {
1322 if ( oFOR != oFCX ) {
1323 // orientation topologique de EG dans la face mere
1324 oegFCXF = TopAbs::Complement(oegFCXF);
1325 }
1326 TopOpeBRepDS_Transition T1(oegFCXF); TopAbs_State Taft = T1.After(); TopAbs_State Tbef = T1.Before();
1327 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1328 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1329 else FUN_coutmess("DEBUG GFillONPartsWES2_1 orientation != F,R\n");
1330 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1331 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1332 else FUN_coutmess("DEBUG GFillONPartsWES2_2 orientation != F,R\n");
1333 }
1334 if (FFinSDDO) {
1335 if ( oFOR == oFCX ) {
1336 // orientation topologique de EG dans la face mere
1337 oegFCXF = TopAbs::Complement(oegFCXF);
1338 }
1339 TopOpeBRepDS_Transition T2(oegFCXF); TopAbs_State Taft = T2.After(); TopAbs_State Tbef = T2.Before();
1340 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1341 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1342 else FUN_coutmess("DEBUG GFillONPartsWES2_3 orientation != F,R\n");
1343 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1344 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1345 else FUN_coutmess("DEBUG GFillONPartsWES2_4 orientation != F,R\n");
1346 }
1347//#ifdef DEB
1348// if(tEFOR) {cout<<endl<<"yap2 : b3d,b2d "<<b3d<<","<<b2d<<endl;debfillonfemess(iFOR,iEG);}
1349//#endif
1350
1351 // bcl1;bcl2; c12;tsp(f9),tspON(e7)
1352 if (ComOfCut) {b3d=Standard_True; b2d=Standard_True;} //xpu200598
1353
1354 gp_Vec ngFS,ngFOR;
1d47d8d0 1355 Standard_Real parEG = 0.;
7fd59977 1356 // bcl1;bcl2; tsp(f9),tspON(e7)
1357 Standard_Boolean sdm = FUN_ds_sdm(BDS,BDS.Shape(iFOR),BDS.Shape(iFS));
1358 Standard_Boolean isfafa = sdm; // such interferences are computed IN fafa case
1359 if (!isfafa ) {
1360 // parEG :
1361 Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1362 if (!ok) return;
1363 // xxFS :
1364 gp_Pnt2d uvFS; ok = FUN_tool_parF(EG,parEG,FS,uvFS,tolFS);
1365 if (!ok) return;// nyiRAISE
1366 ngFS = FUN_tool_nggeomF(uvFS,FS);
1367 gp_Dir xxFS; ok = FUN_tool_getxx(FS,EG,parEG,ngFS,xxFS);
1368 if (!ok) return;// nyiRAISE
1369 // ntFOR :
1370 gp_Pnt2d uvFOR; ok = FUN_tool_parF(EG,parEG,FOR,uvFOR,tolFOR);
1371 if (!ok) return;// nyiRAISE
1372 ngFOR = FUN_tool_nggeomF(uvFOR,FOR);
1373 gp_Dir ntFOR(ngFOR); if (M_REVERSED(oFOR)) ntFOR.Reverse();
1374
1375 Standard_Real dot = xxFS.Dot(ntFOR);
1376 //xpu040698 : FS tg to FCX at EG - CTS20578 (FOR=F8,EG=E6,FS=F4) -
1377 Standard_Boolean nulldot = (Abs(dot) < tola);
1378 if (nulldot) { // approximate xxFS :
1379 gp_Pnt2d newuvFS;
1380 gp_Vec2d dxx; ok = FUN_tool_getdxx(FS,EG,parEG,dxx);
1381 if (!ok) return;
1382 newuvFS = uvFS.Translated(dxx * 0.25);
1383 gp_Dir newngFS = FUN_tool_nggeomF(newuvFS,FS);
1384 ok = FUN_tool_getxx(FS,EG,parEG,newngFS,xxFS);
1385 if (!ok) return;
1386 dot = xxFS.Dot(ntFOR);
1387 }
1388 //xpu040698
1389
1390 TopAbs_State TBFS = FUN_build_TB(myPB,rankFS);
1391 Standard_Boolean positive = (dot > 0);
1392
1393 Standard_Boolean keep = Standard_True;
1394 if (FFinSDSO) {
1395 if (opeFus) keep = positive; //xpu090698 : PRO14033 (iFOR=15,GI=10,iFS=9)
1396 if (opeCom) keep = Standard_True;
1397 if (opeCut) {
1398 if (positive) keep = (TBFS == TopAbs_OUT); //xpu230698 cto100G1
1399 else keep = (TBFS == TopAbs_IN);
1400 }
1401 }
1402 if (FFinSDDO) {
1403 if (opeFus) {
1404 keep = positive;
1405 //xpu050698 : (fuse = OU/IN + IN/OU) -CTS20578-
1406 if (keep) {
1407 Standard_Integer rkOU = (TB1 == TopAbs_OUT) ? 1 : 2;
1408 Standard_Integer rkfspOU = (rankFOR == rkOU) ? 1 : 2;
1409 Standard_Boolean spOUFOR = (rankFOR == rkfspOU);
1410 keep = spOUFOR;
1411 }
1412 }
1413 if (opeCom) keep = !positive;
1414 if (opeCut) {
1415 Standard_Boolean FORmoinsFS = (TBFS == TopAbs_IN);
1416 if (positive) {
1417 if (FORmoinsFS) keep = Standard_True;
1418 else keep = ComOfCut;
1419// if (TBFS == TopAbs_OUT) keep = Standard_True;
1420// else keep = (rankFS == 1);
1421 }
1422 else {
1423// keep = !FORmoinsFS; // xpu230698 : cto100A1
1424// keep = Standard_False;
1425 if (!FORmoinsFS) keep = Standard_True; // xpu230698 : cto100A1
1426 else keep = ComOfCut; //xpu120898 PRO12859 (FOR26,FS12,FCX18,EG14)
1427 }
1428 }
1429 }
1430//#ifdef DEB
1431// if(tEFOR) {cout<<endl<<"yap2 : keep "<<keep<<endl;debfillonfemess(iFOR,iEG);}
1432//#endif
1433 if (!keep) return;
1434 } // !isfafa
1435 else {
1436 if (!b) return;
1437 }
1438
1439 // on garde EspON pour la reconstruction de la face FOR
1440 // si elle est IN/ON la face FOR (EGBoundFOR = 0 ==> projection)
1441 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(FOR);
1442 TopAbs_State state2d = FSC_StateEonFace(EspON,0.345,FOR,PSC);
1443 Standard_Boolean isin = (state2d == TopAbs_IN);
1444 if (!isin) return;
1445
1446 TopAbs_State TBEG = TB1;
1447 TopAbs_Orientation neworiE = TFE.Orientation(TBEG);
1448
1449 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1450 Standard_Boolean forw=M_FORWARD(neworiE), reve=M_REVERSED(neworiE);
1451 Standard_Boolean ok = forw || reve;
1452 if (FFinSDSO && ok) {
1453 if (opeCut) {
1454 neworiE = TopAbs::Complement(neworiE);
1455 }
1456 } // FFinSDSO && ok
1457
1458 // bcl1;bcl2; tsp(f9)
1459 if (FFinSDDO && ok) {
1460 if (opeCut) {
1461 if (!ComOfCut) {
1462// TopAbs_State TBEG = (rankEG == 1)? TB1 : TB2;
1463// if (TBEG == TopAbs_IN) neworiE = TopAbs::Complement(neworiE);
1464 neworiE = TopAbs::Complement(neworiE); // xpu270898 : cto905E2 (FOR33,FCX16,EG19)
1465 }
1466 else if (ComOfCut) {
1467 // rien a faire
1468 }
1469 }
1470 if (opeFus) {
1471 // en principe , l'operation locale est tjrs = OUT,IN
1472 neworiE = TopAbs::Complement(neworiE);
1473 }
1474 if (opeCom) {
1475 // SDDO et oT anti// => oG //
1476 // xxFCX :
1477 gp_Dir xxFCX; ok = FUN_tool_getxx(FCX,EG,parEG,xxFCX);
1478 if (!ok) return;// nyiRAISE
1479 // ntFS :
1480 gp_Dir ntFS(ngFS);
1481 if (M_REVERSED(oFS)) ntFS.Reverse();
1482
1483 Standard_Real dot = xxFCX.Dot(ntFS);
1484 Standard_Boolean toreverse = (dot > 0);
1485
1486 if (toreverse) neworiE = TopAbs::Complement(neworiE);
1487 }
1488 } // FFinSDDO && ok
1489
1490 Standard_Boolean reverse = Standard_False; //xpu270598 : reverse=false=>FCX has same geom ori
1491 if (!FCXisref) { //xpu270598
1492 if (cFCX == TopOpeBRepDS_DIFFORIENTED) reverse = Standard_True;
1493 if (oFCX != orefFCX) reverse = !reverse;
1494 } //xpu270598
1495 if (reverse) neworiE = TopAbs::Complement(neworiE); // xpu270598
1496
1497 TopoDS_Shape newE = EspON;
1498 newE.Orientation(neworiE);
1499
1500#ifdef DEB
1501 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap2 GFillON","WES+ EspON ");
1502 if (tE) FUN_cout(newE);
1503#endif
1504 myPWES->AddStartElement(newE);
1505
1506 return;
1507 } // yap2
1508
1509 //=========================================
1510 if ( yap6 ) {
1511#ifdef DEB
1512 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap6 GFillON");
1513 if (tE) {cout<<"yap6(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1514 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1515#endif
1516 TopAbs_Orientation neworiE;
1517 // FF est samedomain avec FCX
1518 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
1519 // au lieu de la transition par rapport a la matiere 3d de la face FS
1520 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
1521
1522 TopAbs_State staFCX = staFS; // FS et FCX connexes par EG => meme shape origine => meme etat
1523 Standard_Boolean b3d = Standard_False; Standard_Boolean b2d = Standard_False;
1524 Standard_Boolean b = Standard_False;
1525
1526 Standard_Boolean SO = FFinSDSO;//(FFinSDSO && (oFOR == oFCX)) || (FFinSDDO && (oFOR != oFCX));
1527 Standard_Boolean DO = FFinSDDO;//(FFinSDSO && (oFOR != oFCX)) || (FFinSDDO && (oFOR == oFCX));
1528
1529#ifdef DEB
1530// Standard_Integer rkToFill = BDS.AncestorRank(myFace);
1531#endif
1532// Standard_Boolean samerk = (rankEG == rkToFill);
1533
1534// TopAbs_Orientation oegFOR;
1535 Standard_Boolean shareG;
1536 Standard_Boolean ok = FUN_ds_shareG(myPB->DataStructure(),iFOR,iFCX,GI,
1537 TopoDS::Edge(EspON),shareG);
1538 if (!ok) return; // nyiFUNRAISE
1539
1540 if (SO) {
1541 // FOR and FCX share geometric domain.
1542 Standard_Boolean forcekeep = opeFus && shareG && (rankEG ==1); // newnew
1543
1544 if (opeFus) {
1545// b = shareG;
1546 // xpu231198 :PRO15946 (FOR11,EG24,FCX20)
1547 // xpu090299 (JAP60247, FOR6,FCX33,EG34)
1548 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1549 TopTools_ListOfShape lfor; FDSCNX_FaceEdgeConnexFaces(FOR,Esd,HDS,lfor);
1550 Standard_Integer nfor = lfor.Extent();
1551 if (nfor < 1) b = shareG; //Esd is FOR's closing edge
1552 else if (nfor > 1) return;//NYIRaise (unvalid shape)
1553 else {
1554 const TopoDS_Face& FF = TopoDS::Face(lfor.First());
1555 Standard_Real tola1 = Precision::Angular()*1.e2;//nyitolxpu
1556 Standard_Real parEG; Standard_Boolean ok1 = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1557 if (!ok1) return;
1558 Standard_Real matfs; ok1 = TopOpeBRepTool_TOOL::Matter(FS,FCX,EG,parEG,tola1,matfs);
1559 if (!ok1) return;
1560
1561 Standard_Real tolEsd = BRep_Tool::Tolerance(Esd)*factor; //NYITOLXPU
1562 Standard_Real parEsd; Standard_Boolean ok2 = FUN_tool_parE(eON,parON,Esd,parEsd,tolEsd);
1563 if (!ok2) return;
1564 Standard_Real matfor; ok2 = TopOpeBRepTool_TOOL::Matter(FOR,FF,Esd,parEsd,tola1,matfor);
1565 if (!ok2) return;
1566
1567 Standard_Real sum = matfs+matfor;
c6541a0c
D
1568 Standard_Boolean sumisPI = (Abs(sum-M_PI) < tola1);
1569 Standard_Boolean fsinfPI = (matfs < M_PI);
1570 Standard_Boolean forinfPI = (matfor < M_PI);
7fd59977 1571 if (sumisPI) b = Standard_False;
c6541a0c
D
1572 else if (sum < M_PI) b = Standard_True;
1573 else { //sum > M_PI
7fd59977 1574 if (fsinfPI && forinfPI) b = Standard_False;
1575 else { // (!fsinfPI) || (!forinfPI)
1576 Standard_Boolean sammat = (Abs(matfs-matfor)<tola1);
1577 if (sammat) b = Standard_False;
1578 else b = (matfs < matfor);
1579 }
1580 }
1581 if (b) forcekeep = Standard_True;
1582 }
1583 // NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYIXPU
1584 /*if (shareG) b = Standard_True;
1585 else {
1586 // xpu231198 :PRO15946 (FOR11,EG24,FCX20)
1587 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1588 if (!ok) return;
1589 gp_Dir xxFCX; ok = FUN_tool_getxx(FCX,EG,parEG,xxFCX);
1590 if (!ok) return;// nyiRAISE
1591 gp_Vec ntFS; ok = FUN_tool_nggeomF(parEG,EG,FS,ntFS,tolFS);
1592 if (!ok) return;// nyiRAISE
1593 if (M_REVERSED(oFS)) ntFS.Reverse();
1594
1595 Standard_Real dot = ntFS.Dot(xxFCX);
1596 if (Abs(dot) < tola) b = Standard_False; // xpu231198nyi tangent config
1597 else {b = (dot <0.); if (b) forcekeep=Standard_True;}
1598 }//!shareG*/
1599 }
1600 else if (opeCut) b = (!shareG);
1601 else if (opeCom) b = shareG && (rankEG ==1);
1602 if (b) { // nyi : a revoir
1603 if ( oFOR != oFCX ) {
1604 // orientation topologique de EG dans la face mere
1605 oegFCXF = TopAbs::Complement(oegFCXF);
1606 }
1607 TopOpeBRepDS_Transition T1(oegFCXF); TopAbs_State Taft = T1.After(); TopAbs_State Tbef = T1.Before();
1608 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1609 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1610 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1611 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1612 b = (b3d && b2d);
1613 }
1614 if (forcekeep) b = Standard_True; // newnew
1615 }
1616 if (DO) { // we do NOT keep the splitON
1617 if (opeFus) b = (!shareG); // cto001D2 spOU(f18)
1618 if (opeCut) {
1619 Standard_Integer rankREF = opec12? 1 : 2;
1620 Standard_Boolean binin=Standard_False, binou=Standard_False;
1621 if (TB1 == TB2) binin = (rankEG == rankREF); // partie IN/IN
1622 else {
1623 //xpu291098 cto001D3 (f17ou)
1624 binou = (rankFOR == 1)&&(TBFOR == TopAbs_OUT)&&(!shareG);
1625 if (binou) {
1626 // xpu181198 CTS21302(FOR22,EG9,FCX5)
1627 // ntOOFOR :
1628 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd)); // rkEsd=rkFOR
1629 TopTools_ListOfShape lfcFk; FDSCNX_FaceEdgeConnexFaces(FOR,Esd,HDS,lfcFk);
1630 if (lfcFk.Extent() != 1) return; // shape bizarre
1631 Standard_Real parEsd; ok = FUN_tool_parE(eON,parON,Esd,parEsd,tolEG);
1632 if (!ok) return;
1633 const TopoDS_Face& OOFOR = TopoDS::Face(lfcFk.First());
1634 gp_Pnt2d uv; Standard_Real dummy=0;
1635 ok = FUN_tool_paronEF(Esd,parEsd,OOFOR,uv,dummy); //rkEsd=rkOOFOR
1636 gp_Vec ntOOFOR = FUN_tool_nggeomF(uv,OOFOR);
1637 if (OOFOR.Orientation() == TopAbs_REVERSED) ntOOFOR.Reverse();
1638 // xxFCX :
1639#ifdef DEB
1640// Standard_Real t1 =factor*BRep_Tool::Tolerance(Esd);
1641#endif
1642 Standard_Real parEG; ok = FUN_tool_parE(Esd,parEsd,EG,parEG);
1643 if (!ok) return;
1644 gp_Dir xxFCX; ok = FUN_tool_getxx(FCX,EG,parEG,xxFCX);
1645 if (!ok) return;
1646 // dot :
1647 Standard_Real dot = ntOOFOR.Dot(xxFCX);
1648 if (Abs(dot) < tola) binou = Standard_True;// nyixpu181198
1649 else if (dot < 0.) binou = Standard_False;
1650 }
1651 }
1652 b = binin || binou;
1653 }
1654 }
1655 if (!b) return;
1656
1657 TopAbs_State TBEG = TB1;
1658 neworiE = TFE.Orientation(TBEG);
1659 if (FCXisref && !EGBoundFOR) {
1660 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1661 Standard_Boolean rev = myPB->Reverse(staFCX,staFOR);
1662 neworiE = myPB->Orient(neworiE,rev);
1663 }
1664 else if (FORisref && !EGBoundFOR) {
1665 // xpu280798 : cto902C1 (FOR=f9,FCX=f19,FS,f33,EG,e18)
1666 // as eghassdON : Esd = edge(Iesd) = bound FOR; eON is IN1d(Esd)
1667 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1668 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1669 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1670 if (reverse) neworiE = TopAbs::Complement(neworiE);
1671 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1672 neworiE = myPB->Orient(neworiE,rev);
1673 }
1674 else if (!EGBoundFOR) {
1675 // xpu210898 : CTS20875 : yap6(FOR13,GI15,FCX6), !FCXisref && !FORisref
1676 Standard_Integer rankrefFOR = BDS.AncestorRank(irefFOR);
1677 if (rankrefFOR == rankFCX)
1678 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1679 else if (rankrefFOR == rankFOR) {
1680 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1681 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1682 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1683 if (reverse) neworiE = TopAbs::Complement(neworiE);
1684 }
1685 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1686 neworiE = myPB->Orient(neworiE,rev);
1687 }
1688
1689 TopoDS_Shape newE = EspON;
1690 newE.Orientation(neworiE);
1691#ifdef DEB
1692 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap6 GFillON","WES+ EspON ");
1693 if (tE) FUN_cout(newE);
1694#endif
1695 myPWES->AddStartElement(newE);
1696
1697 // xpu290798 : cto 902 C1, f9ou,f19in, spON(e7) = spON(e18)
1698 // splits IN and OUT generated on reference surface should be diff oriented
1699 // they share same edge eON which is FORWARD in one, REVERSED in the other
1700 Standard_Boolean addtwice = SO && !shareG && opeCut;
1701 addtwice = addtwice && (M_FORWARD(neworiE) || M_REVERSED(neworiE));
1702 if (addtwice) {
1703 // we have splitIN
1704 TopoDS_Shape FtospIN = (TBFOR == TopAbs_IN) ? FOR : FCX;
1705 addtwice = Standard_False;
1706 TopExp_Explorer ex;
1707 for (ex.Init(FtospIN,TopAbs_EDGE); ex.More(); ex.Next()){
1708// for (TopExp_Explorer ex(FtospIN,TopAbs_EDGE); ex.More(); ex.Next()){
1709 const TopoDS_Shape& ee = ex.Current();
1710 if (!BDS.HasShape(ee)) continue;
1711 Standard_Boolean issp = myPB->IsSplit(ee,TopAbs_IN);
1712 if (issp) addtwice = !myPB->Splits(ee,TopAbs_IN).IsEmpty();
1713 if (addtwice) break;
1714 }
1715 }
1716 if (addtwice) {
1717 neworiE = TopAbs::Complement(neworiE);
1718 newE.Orientation(neworiE);
1719#ifdef DEB
1720 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap6 GFillON","WES+ EspON ");
1721 if (tE) FUN_cout(newE);
1722#endif
1723 myPWES->AddStartElement(newE);
1724 }
1725 return;
1726 } // yap6
1727
1728 //=========================================
1729 if ( yap3 ) {
1730#ifdef DEB
1731 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap3 GFillON");
1732 if (tE) {cout<<"yap3(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1733 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1734#endif
1735
1736 ie3d = ::FUN_findeSD(BDS,eON,EG,FOR,oe3d,3);
1737 if (ie3d == 0) return;
1738 const TopoDS_Edge& e3d = TopoDS::Edge(BDS.Shape(ie3d));
1739
1740 TopOpeBRepDS_Config cf; Standard_Boolean cfok = FDS_Config3d(EspON,e3d,cf);
1741 if (!cfok) return;
1742
1743 TopAbs_Orientation oe3dk = oe3d;
1744// Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(EG,e3d);
1745 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1746 if (!ok) return; //nyiRAISE
1747 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,e3d,samegeom);
1748 if (!ok) return; //nyiRAISE
1749#ifdef DEB
1750 if (!TopOpeBRepBuild_GetcontextNOSG()) {
1751#endif
1752 if (!samegeom) oe3dk = TopAbs::Complement(oe3dk);
1753#ifdef DEB
1754 }
1755#endif
1756
1757 Standard_Boolean keep3d = Standard_False;
1758 // l'etat a construire sur FOR est TB1,
1759 if (oe3dk == TopAbs_FORWARD) keep3d = (TFEaft == TB1);
1760 else if (oe3dk == TopAbs_REVERSED) keep3d = (TFEbef == TB1);
1761 else if (oe3dk == TopAbs_INTERNAL) keep3d = Standard_True;
1762 else if (oe3dk == TopAbs_EXTERNAL) keep3d = Standard_False;
1763
1764#ifdef DEB
1765 if(tEFOR) {cout<<endl<<"yap3 keep3d : "<<keep3d<<endl;debfillonfemess3d(iFOR,iEG);}
1766#endif
1767
1768 if (keep3d) {
1769 TopAbs_Orientation neworiE = oe3d;
1770 if (cf == TopOpeBRepDS_DIFFORIENTED) neworiE = TopAbs::Complement(neworiE);
1771 TopoDS_Shape newE = EspON;
1772 newE.Orientation(neworiE);
1773
1774#ifdef DEB
1775 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap3 GFillON","WES+ EspON ");
1776 if (tE) FUN_cout(newE);
1777#endif
1778 myPWES->AddStartElement(newE);
1779 }
1780
1781 return;
1782 } // yap3
1783
1784 //=========================================
1785 if ( yap5 ) {
1786#ifdef DEB
1787 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap5 GFillON");
1788 if (tE) {cout<<"yap5(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1789 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1790#endif
1791 ie2d = ::FUN_findeSD(BDS,eON,EG,FOR,oe2d,2);
1792 if (ie2d == 0) return;
1793
1794 const TopoDS_Edge& e2d = TopoDS::Edge(BDS.Shape(ie2d));
1795 TopOpeBRepDS_Config cf; Standard_Boolean cfok = FDS_Config3d(EspON,e2d,cf);
1796 if (!cfok) return;
1797
1798 TopAbs_Orientation oe2dk = oe2d;
1799 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1800 if (!ok) return; // nyiRAISE
1801 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,e2d,samegeom);
1802 if (!ok) return; // nyiRAISE
1803#ifdef DEB
1804 if (!TopOpeBRepBuild_GetcontextNOSG()) {
1805#endif
1806 if (!samegeom) oe2dk = TopAbs::Complement(oe2dk);
1807#ifdef DEB
1808 }
1809#endif
1810
1811 Standard_Boolean keep2d = Standard_False;
1812 // l'etat a construire sur FOR est TB1,
1813 if (oe2dk == TopAbs_FORWARD) keep2d = (TFEaft == TB1);
1814 else if (oe2dk == TopAbs_REVERSED) keep2d = (TFEbef == TB1);
1815 else if (oe2dk == TopAbs_INTERNAL) keep2d = Standard_True;
1816 else if (oe2dk == TopAbs_EXTERNAL) keep2d = Standard_False;
1817
1818 if (keep2d) {
1819 TopAbs_Orientation neworiE = oe2d;
1820 if (cf == TopOpeBRepDS_DIFFORIENTED) neworiE = TopAbs::Complement(neworiE);
1821 TopoDS_Shape newE = EspON;
1822 newE.Orientation(neworiE);
1823
1824#ifdef DEB
1825 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap5 GFillON","WES+ EspON ");
1826 if (tE) FUN_cout(newE);
1827#endif
1828 myPWES->AddStartElement(newE);
1829 }
1830
1831 return;
1832 } // yap5
1833
1834 //=========================================
1835 if ( yap4 ) {
1836#ifdef DEB
1837 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap4 GFillON");
1838 if (tE) {cout<<"yap4(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1839 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1840#endif
1841
1842 TopAbs_Orientation oTFE = TFE.Orientation(TB1);
1843
1844 TopAbs_Orientation neworiE = oTFE;
1845 TopoDS_Shape newE = EspON;
1846 newE.Orientation(neworiE);
1847#ifdef DEB
1848 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap4 GFillON","WES+ EspON ");
1849 if (tE) FUN_cout(newE);
1850#endif
1851 myPWES->AddStartElement(newE);
1852
1853 return;
1854 } // yap4
1855
1856 //=========================================
1857 if ( yap7 ) {
1858 // xpu290598 : CTS20212
1859#ifdef DEB
1860 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap7 GFillON");
1861 if (tE) {cout<<"yap7(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1862 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1863#endif
1864 Standard_Boolean isbound = Standard_False;
1865 for (TopTools_ListIteratorOfListOfShape it(BDS.ShapeSameDomain(iFOR)); it.More(); it.Next()){
1866 TopExp_Explorer ex(it.Value(), TopAbs_EDGE);
1867 for (; ex.More(); ex.Next()) {
1868 const TopoDS_Shape& E = ex.Current();
1869 if (E.IsSame(EG)) {
1870 isbound = Standard_True;
1871 break;
1872 }
1873 }
1874 }
1875 TopAbs_Orientation oTFE = TFE.Orientation(TB1);
1876 TopAbs_Orientation neworiE = oTFE;
1877
1878 if (ComOfCut) { //CTS20212 : tspIN(f7),tspON(e4)
1879 if (!EGBoundFOR) {
1880 if (!isbound) return;
1881 }
1882 }
1883
1884 //CTS20212 : tspIN(f7),tspON(e5)
1885 Standard_Boolean samegeomref = Standard_False;
1886 if (FORisref) {
1887 samegeomref = Standard_True;
1888 }
1889 else {
1890 samegeomref = (cFOR == TopOpeBRepDS_SAMEORIENTED);
1891 if (oFOR != orefFOR) samegeomref = !samegeomref;
1892 }
1893 if (!samegeomref) neworiE = TopAbs::Complement(neworiE);
1894
1895 TopoDS_Shape newE = EspON;
1896 newE.Orientation(neworiE);
1897#ifdef DEB
1898 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap7 GFillON","WES+ EspON ");
1899 if (tE) FUN_cout(newE);
1900#endif
1901 myPWES->AddStartElement(newE);
1902
1903 return;
1904 } // yap7
1905
1906} // GFillONPartsWES2