1 // Created on: 1996-03-07
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRep_Tool.hxx>
19 #include <BRepAdaptor_Surface.hxx>
20 #include <BRepLProp_SLProps.hxx>
21 #include <BRepLProp_SurfaceTool.hxx>
22 #include <GeomAbs_SurfaceType.hxx>
23 #include <Precision.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <TopOpeBRepBuild_BuilderON.hxx>
27 #include <TopOpeBRepBuild_define.hxx>
28 #include <TopOpeBRepDS_connex.hxx>
29 #include <TopOpeBRepDS_EXPORT.hxx>
30 #include <TopOpeBRepDS_Interference.hxx>
31 #include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
32 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
33 #include <TopOpeBRepTool_EXPORT.hxx>
34 #include <TopOpeBRepTool_SC.hxx>
35 #include <TopOpeBRepTool_TOOL.hxx>
38 Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEINTERNAL();
39 Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEEXTERNAL();
40 Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOSG();
41 Standard_EXPORT void debON(const Standard_Integer iF)
42 {cout<<"++ debON "<<iF<<" "<<endl;}
43 Standard_EXPORT void debON(const Standard_Integer iF, const TopAbs_State TB1,const TopAbs_State TB2)
44 {cout<<"++ debON "<<iF<<" :TB1=";TopAbs::Print(TB1,cout);cout<<",TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
45 Standard_EXPORT void debfillonf(const Standard_Integer iF)
46 {cout<<"++ debfillonf "<<iF<<" "<<endl;}
47 Standard_EXPORT void debfillone(const Standard_Integer iE)
48 {cout<<"++ debfillone "<<iE<<" "<<endl;}
49 Standard_EXPORT void debfillonfe(){}
50 Standard_EXPORT void debfillonfemess(const Standard_Integer f,const Standard_Integer e)
51 {cout<<"++ debfillonfe f"<<f<<" e"<<e<<endl;debfillonfe();}
52 Standard_EXPORT void debfillonfe3d(){}
53 Standard_EXPORT void debfillonfemess3d(const Standard_Integer f,const Standard_Integer e)
54 {cout<<"++ debfillonfe3d f"<<f<<" e"<<e<<endl;debfillonfe3d();}
55 Standard_EXPORT void debfillonfemess(const Standard_Integer iFOR,const Standard_Integer iEG,const TopOpeBRepBuild_PBuilder& PB,const TopOpeBRepBuild_PWireEdgeSet& PWES,const TCollection_AsciiString& str)
56 {PB->GdumpSHASTA(iEG,TopAbs_ON,*PWES,str); debfillonfemess(iFOR,iEG); }
57 Standard_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)
58 {PB->GdumpSHASTA(iFOR,TB1,*PWES,str1,str2);cout<<iEG<<" : 1 edge ";TopAbs::Print(neworiE,cout);cout<<endl; }
59 Standard_EXPORT Standard_Boolean DEBTEFOR(const TopOpeBRepBuild_Builder& B,const Standard_Integer iFOR,const Standard_Integer GI)
60 {return B.GtraceSPS(iFOR,GI); }
64 Standard_EXPORT void FUN_RaiseON()
65 {Standard_Failure::Raise("BuilderON");}
66 static void FUN_cout(const TopoDS_Shape& eON)
68 TopAbs_Orientation oE = eON.Orientation();
69 if (oE == TopAbs_FORWARD) cout<<"-> + eONF"<<endl;
70 if (oE == TopAbs_REVERSED) cout<<"-> + eONR"<<endl;
71 if (oE == TopAbs_INTERNAL) cout<<"-> + eONI"<<endl;
72 if (oE == TopAbs_EXTERNAL) cout<<"-> + eONE"<<endl;
76 #define M_FORWARD(st) (st == TopAbs_FORWARD)
77 #define M_REVERSED(st) (st == TopAbs_REVERSED)
78 #define M_INTERNAL(st) (st == TopAbs_INTERNAL)
79 #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
81 // NYI : TopOpeBRepTool_ShapeTool::ShapesSameOriented -> CurvesSameOriented NYI for E !line
82 //Standard_IMPORT Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
84 //=======================================================================
85 //function : TopOpeBRepBuild_BuilderON
87 //=======================================================================
88 TopOpeBRepBuild_BuilderON::TopOpeBRepBuild_BuilderON()
92 //=======================================================================
93 //function : TopOpeBRepBuild_BuilderON
95 //=======================================================================
96 TopOpeBRepBuild_BuilderON::TopOpeBRepBuild_BuilderON(const TopOpeBRepBuild_PBuilder& PB, const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG,
97 const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES)
99 Perform(PB,FOR,PG,PLSclass,PWES);
102 //=======================================================================
105 //=======================================================================
106 void TopOpeBRepBuild_BuilderON::Perform(const TopOpeBRepBuild_PBuilder& PB,const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG,
107 const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES)
112 myPLSclass = PLSclass;
116 Standard_Integer iFOR;Standard_Boolean tFOR=myPB->GtraceSPS(FOR,iFOR);
117 if (tFOR) debfillonf(iFOR);
120 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
121 const TopOpeBRepDS_ListOfInterference& LI=BDS.ShapeInterferences(myFace);
122 for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI);ILI.More();ILI.Next() ) {
123 const Handle(TopOpeBRepDS_Interference)& I=ILI.Value();
128 //=======================================================================
129 //function : GFillONCheckI
131 //=======================================================================
132 Standard_Boolean TopOpeBRepBuild_BuilderON::GFillONCheckI(const Handle(TopOpeBRepDS_Interference)& I) const
134 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
136 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI=Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
137 if (SSI.IsNull()) return Standard_False;
139 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
140 if (GT != TopOpeBRepDS_EDGE || ST != TopOpeBRepDS_FACE) return Standard_False;
142 // Standard_Integer iFOR=BDS.Shape(myFace);
144 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI, Standard_False));
146 // Standard_Integer iEG=BDS.Shape(EG, Standard_False);
148 const TopoDS_Shape& FS=BDS.Shape(SI, Standard_False);
150 // Standard_Integer iFS=BDS.Shape(FS, Standard_False);
152 TopAbs_ShapeEnum ShapeInterf=TopAbs_FACE;
153 const TopOpeBRepDS_Transition& TFE=SSI->Transition();
154 TopAbs_ShapeEnum shab=TFE.ShapeBefore(),shaa=TFE.ShapeAfter();
155 if (shaa != ShapeInterf || shab != ShapeInterf) return Standard_False;
157 Standard_Boolean isrest=BDS.IsSectionEdge(EG);
158 Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON);
159 Standard_Boolean keep=(isrest && issplit);
160 if ( !keep ) return Standard_False;
162 const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON);
163 if (lEspON.Extent() == 0) return Standard_False;
166 // const TopoDS_Shape& EspON=lEspON.First();
168 Standard_Integer rankFS=myPB->GShapeRank(FS);
169 Standard_Integer rankFOR=myPB->GShapeRank(myFace);
170 if (rankFS == 0 || rankFOR == 0) return Standard_False;
172 return Standard_True;
175 //=======================================================================
176 //function : GFillONPartsWES1
178 //=======================================================================
179 void TopOpeBRepBuild_BuilderON::GFillONPartsWES1(const Handle(TopOpeBRepDS_Interference)& I)
181 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
183 Standard_Integer iFOR=
186 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(I,GT,GI,ST,SI);
188 Standard_Boolean Iok=GFillONCheckI(I);
191 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
192 // const TopoDS_Shape& FS=BDS.Shape(SI);
194 // Standard_Integer iEG=BDS.Shape(EG);
195 // Standard_Integer iFS=BDS.Shape(FS);
199 Standard_Boolean tEFOR=DEBTEFOR(*myPB,iFOR,GI);
200 if (tEFOR) debfillonfemess(iFOR,GI,myPB,myPWES,"--- GFillONPartsWES1");
203 const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON);
205 // Standard_Integer nEspON=lEspON.Extent();
207 for(TopTools_ListIteratorOfListOfShape it(lEspON);it.More();it.Next()) {
208 const TopoDS_Shape& EspON=it.Value();
209 GFillONPartsWES2(I,EspON);
211 } // GFillONPartsWES1
214 Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString& m)
219 Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString&)
224 //------------------------------------------------------
226 Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder& B,
228 Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder&,
230 const TopoDS_Shape& sEG,
231 const TopoDS_Shape& sFOR,
232 const TopoDS_Shape& sFS,
234 const Standard_Boolean EGBoundFOR,
236 const Standard_Boolean,
238 const TopOpeBRepDS_Transition& TFE,
239 const TopAbs_State TB1,
241 //------------------------------------------------------
243 // on construit l'etat TB1 de FOR par rapport a FS.
244 // sur face FOR,on transitionne (TFE) en l'arete EG par rapport a la face FS.
245 // TFE est defini sur la geometrie naturelle de la face orientee FOR,
246 // c'est a dire sur FF=FOR orientee FORWARD,par rapport a la matiere
247 // definie par la face orientee FS.
248 // on cherche oEGFF=orientation de EG dans FF
249 TopoDS_Edge EG=TopoDS::Edge(sEG);
250 TopoDS_Face FF=TopoDS::Face(sFOR);FF.Orientation(TopAbs_FORWARD);
251 TopoDS_Face FS=TopoDS::Face(sFS);
254 Standard_Integer iEG;/*Standard_Boolean tEG=*/B.GtraceSPS(EG,iEG);
255 Standard_Integer iFF;/*Standard_Boolean tFF=*/B.GtraceSPS(FF,iFF);
256 Standard_Integer iFS;/*Standard_Boolean tFS=*/B.GtraceSPS(FS,iFS);
257 Standard_Boolean tFFEG=DEBTEFOR(B,iFF,iEG);if (tFFEG) debfillonfemess(iFF,iEG);
258 Standard_Boolean tFSEG=DEBTEFOR(B,iFS,iEG);if (tFSEG) debfillonfemess(iFS,iEG);
262 Standard_Boolean keep1=Standard_True;
263 Standard_Boolean keep2=Standard_True;
265 Standard_Boolean keep3=Standard_True;
266 Standard_Boolean isclosedFF=BRep_Tool::IsClosed(EG,FF);
275 TopAbs_Orientation oEGFF=TopAbs_FORWARD;
276 FUN_tool_orientEinF(EG,FF,oEGFF);
279 TopAbs_Orientation omatFS1=TFE.Orientation(TB1);
280 if (oEGFF == TopAbs_REVERSED) omatFS1=TopAbs::Complement(omatFS1);
281 keep1=(omatFS1 == TopAbs_FORWARD);
283 TopAbs_Orientation omatFS2=TFE.Orientation(TB1);
284 keep2=(omatFS2 == oEGFF);
287 TopAbs_State tfeb=TFE.Before();
288 TopAbs_State tfea=TFE.After();
289 if (oEGFF == TopAbs_FORWARD ) keep3=(tfea == TB1);
290 else if (oEGFF == TopAbs_REVERSED) keep3=(tfeb == TB1);
291 else if (oEGFF == TopAbs_EXTERNAL) keep3=(tfea == TB1 || tfeb == TB1);
292 else if (oEGFF == TopAbs_INTERNAL) keep3=(tfea == TB1 || tfeb == TB1);
296 if (tFFEG || tFSEG) {
297 if ( keep1 != keep2 || keep1 != keep3 || keep2 != keep3 ) {
298 cout<<"\nkeepEON : EGB "<<EGBoundFOR<<" EG "<<iEG<<" FOR "<<iFF<<" FS "<<iFS;
299 cout<<" keep1 "<<keep1<<" keep2 "<<keep2<<" keep3 "<<keep3;
300 cout<<" !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=";
309 Standard_EXPORT TopAbs_State FUN_build_TB(const TopOpeBRepBuild_PBuilder& PB,const Standard_Integer rank)
311 Standard_Boolean opeFus = PB->Opefus();
312 Standard_Boolean opec12 = PB->Opec12();
313 Standard_Boolean opec21 = PB->Opec21();
314 Standard_Boolean opeCom = PB->Opecom();
315 TopAbs_State sta = TopAbs_UNKNOWN;
316 if (opeFus) sta = TopAbs_OUT;
317 if (opeCom) sta = TopAbs_IN;
318 if (opec12) sta = (rank == 1) ? TopAbs_OUT : TopAbs_IN;
319 if (opec21) sta = (rank == 2) ? TopAbs_OUT : TopAbs_IN;
323 static Standard_Boolean FUN_Kpart0(const GeomAbs_SurfaceType& ST1, const GeomAbs_SurfaceType& ST2)
325 Standard_Boolean plane1 = (ST1 == GeomAbs_Plane);
326 Standard_Boolean cyli1 = (ST1 == GeomAbs_Cylinder);
327 Standard_Boolean cone1 = (ST1 == GeomAbs_Cone);
329 Standard_Boolean cyli2 = (ST2 == GeomAbs_Cylinder);
330 Standard_Boolean cone2 = (ST2 == GeomAbs_Cone);
331 Standard_Boolean sphe2 = (ST2 == GeomAbs_Sphere);
332 Standard_Boolean quad2 = cyli2 || cone2 || sphe2 || (ST2 == GeomAbs_Torus);
334 if (plane1 && quad2) return Standard_True;
335 if (cyli1 && sphe2) return Standard_True;
336 if (cone1 && sphe2) return Standard_True;
337 return Standard_False;
339 static Standard_Integer FUN_Kpart(const GeomAbs_SurfaceType& ST1, const GeomAbs_SurfaceType& ST2)
341 Standard_Boolean kpart0 = FUN_Kpart0(ST1,ST2);
342 if (kpart0) return 1;
343 kpart0 = FUN_Kpart0(ST2,ST1);
344 if (kpart0) return 2;
348 static Standard_Integer FUN_findeSD
349 (const TopOpeBRepDS_DataStructure& BDS, const TopoDS_Edge& EspON, const TopoDS_Edge& EG, const TopoDS_Face& FOR,
350 TopAbs_Orientation& oeSD, const Standard_Integer D)
352 // chercher eSD = SameDomain3d/2d de EG, arete de FOR, qui contient EspON
353 gp_Pnt ptON; Standard_Real parON;
354 FUN_tool_findPinE(EspON,ptON,parON);
355 TopTools_ListOfShape lesdSD;
356 if (D == 3) FDS_HasSameDomain3d(BDS,EG,&lesdSD);
357 if (D == 2) FDS_HasSameDomain2d(BDS,EG,&lesdSD);
358 for(TopTools_ListIteratorOfListOfShape it(lesdSD);it.More();it.Next()) {
359 TopoDS_Edge eSD = TopoDS::Edge(it.Value());
360 TopAbs_Orientation oesd; Standard_Boolean eSDofFOR = FUN_tool_orientEinFFORWARD(eSD,FOR,oesd);
361 if (!eSDofFOR) continue;
362 TopAbs_State staeSD = FUN_tool_staPinE(ptON,eSD);
363 if (staeSD == TopAbs_IN) {
364 Standard_Integer i = BDS.Shape(eSD); oeSD = oesd;
371 static Standard_Boolean ComputeFaceCrvtInSec(const TopoDS_Face& aFace,
372 const gp_Pnt2d& aP2d,
373 const gp_Dir& aSecDir,
374 Standard_Real& aCrvt)
376 BRepAdaptor_Surface aSurf(aFace);
377 Standard_Integer cn = BRepLProp_SurfaceTool::Continuity(aSurf);
378 if (cn < 2) return Standard_False;
379 BRepLProp_SLProps aProp(aSurf, aP2d.X(), aP2d.Y(), 2, Precision::Confusion());
380 if (!aProp.IsCurvatureDefined()) return Standard_False;
382 if (aProp.IsUmbilic()) {
383 aCrvt = aProp.MaxCurvature();
384 return Standard_True;
387 Standard_Real maxCrv = aProp.MaxCurvature();
388 Standard_Real minCrv = aProp.MinCurvature();
389 gp_Dir maxDir, minDir;
390 aProp.CurvatureDirections(maxDir, minDir);
391 Standard_Real cosMax = aSecDir * maxDir;
392 Standard_Real cosMin = aSecDir * minDir;
393 aCrvt = maxCrv * cosMax + minCrv * cosMin;
394 return Standard_True;
397 //=======================================================================
398 //function : GFillONPartsWES2
400 //=======================================================================
401 void TopOpeBRepBuild_BuilderON::GFillONPartsWES2(const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& EspON)
403 const Handle(TopOpeBRepDS_HDataStructure)& HDS=myPB->DataStructure();
404 const TopOpeBRepDS_DataStructure& BDS= HDS->DS();
405 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI (Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I));
406 TopAbs_State TB1,TB2;myPG->StatesON(TB1,TB2); TopAbs_State TB=TB1;
407 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
408 const TopOpeBRepDS_Transition& TFE=SSI->Transition(); Standard_Boolean EGBoundFOR=SSI->GBound();
409 const TopoDS_Face& FOR=TopoDS::Face(myFace); Standard_Integer iFOR=BDS.Shape(FOR);
410 const TopoDS_Edge& eON=TopoDS::Edge(EspON);
411 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
413 Standard_Integer iEG=
416 const TopoDS_Face& FS=TopoDS::Face(BDS.Shape(SI)); Standard_Integer iFS=BDS.Shape(FS);
418 Standard_Real tola = Precision::Angular()*1.e3;//nyitol
420 TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation();
421 TopAbs_Orientation oFS = BDS.Shape(iFS).Orientation();
423 Standard_Boolean isclosedFF=FUN_tool_IsClosingE(EG,FOR,FOR); //xpu240898 : cto900J5 faulty yapc2(FOR17,FS18,EG15)
424 Standard_Boolean isclosedFS=FUN_tool_IsClosingE(EG,FS,FS); //xpu240898
425 Standard_Boolean isclosed=(isclosedFF || isclosedFS);
426 Standard_Boolean isrest=BDS.IsSectionEdge(EG);
428 // Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON);
430 Standard_Integer rankFS=myPB->GShapeRank(FS);
431 Standard_Integer rankEG=myPB->GShapeRank(EG);
432 Standard_Integer rankFOR=myPB->GShapeRank(FOR);
433 TopAbs_Orientation OTFE = TFE.Orientation(TopAbs_IN);
434 TopAbs_State TFEbef = TFE.Before();
435 TopAbs_State TFEaft = TFE.After();
437 // Standard_Boolean EGboundFOR =
438 // Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I)->GBound();
440 Standard_Boolean eghassd = HDS->HasSameDomain(EG);
441 TopTools_ListOfShape le3;Standard_Boolean eghassd3d = FDS_HasSameDomain3d(BDS,EG,&le3);
442 Standard_Integer ie3d = 0; TopAbs_Orientation oe3d = TopAbs_EXTERNAL;
443 Standard_Integer ie2d = 0; TopAbs_Orientation oe2d = TopAbs_EXTERNAL;
444 TopTools_ListOfShape lfcx; FDSCNX_FaceEdgeConnexFaces(FS,EG,HDS,lfcx);
445 Standard_Integer nlfcx=lfcx.Extent();
447 Standard_Boolean hsdFOR = HDS->HasSameDomain(FOR);
448 TopOpeBRepDS_Config cFOR = TopOpeBRepDS_UNSHGEOMETRY;
449 Standard_Integer irefFOR = 0;
450 TopAbs_Orientation orefFOR = TopAbs_EXTERNAL;
451 Standard_Boolean FORisref = Standard_False;
453 cFOR = BDS.SameDomainOri(iFOR);
454 if (hsdFOR) irefFOR = BDS.SameDomainRef(FOR);
455 if (irefFOR != 0) orefFOR = BDS.Shape(irefFOR).Orientation();
456 FORisref = (irefFOR == iFOR);
459 Standard_Boolean opeFus = myPB->Opefus();
460 Standard_Boolean opec12 = myPB->Opec12();
462 // Standard_Boolean opec21 = myPB->Opec21();
464 Standard_Boolean opeCut = myPB->Opec12() || myPB->Opec21();
465 Standard_Boolean opeCom = myPB->Opecom();
466 Standard_Boolean ComOfCut = opeCut && (TB1 == TB2) && (TB1 == TopAbs_IN); //xpu200598 only if FFSDSO
468 TopAbs_State TBFOR = FUN_build_TB(myPB,rankFOR);
471 Standard_Boolean tFOR=myPB->GtraceSPS(iFOR);Standard_Boolean tE=myPB->GtraceSPS(GI);
472 Standard_Boolean tEFOR=DEBTEFOR(*myPB,iFOR,GI);
473 if (tFOR) debON(iFOR);
476 Standard_Real factor = 1.e2;
477 Standard_Real tolEG = BRep_Tool::Tolerance(EG)*factor; //NYITOLXPU
478 Standard_Real tolFOR = BRep_Tool::Tolerance(FOR)*factor; //NYITOLXPU
479 Standard_Real tolFS = BRep_Tool::Tolerance(FS)*factor; //NYITOLXPU
481 Standard_Real f,l; FUN_tool_bounds(eON,f,l); Standard_Real x=0.456189; Standard_Real parON = (1-x)*f + x*l;
484 // xpu150698 : spON(EG)=spON1+spON2+.., spON1 ON EsdEG, spON2 shares no
485 // geometry with any other edge.
486 // FRA11018 (FOR=f5,EG=e18,EsdEG=e7)
487 Standard_Boolean espONesd = Standard_False; Standard_Integer Iesd=0;// xpu150698
488 if (eghassd) espONesd = FUN_ds_ONesd(BDS,GI,EspON,Iesd);// xpu150698
489 Standard_Boolean eONsoEsd = Standard_False;
490 if (eghassd && (Iesd != 0)) {
491 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
492 Standard_Boolean ok = FUN_tool_curvesSO(eON,Esd,eONsoEsd);
496 Standard_Boolean eONFS = Standard_True; // xpu240898
497 if (eghassd && (!espONesd)) {
498 gp_Pnt pON; Standard_Boolean ok = FUN_tool_value(parON,eON,pON);
500 gp_Pnt2d uvFS; Standard_Real d=1.; ok = FUN_tool_projPonboundedF(pON,FS,uvFS,d);
502 Standard_Real tolF = FUN_tool_maxtol(FS); eONFS = (d < tolF);
504 // ------------------------------------
505 Standard_Boolean eghassdON = eghassd && espONesd;
506 Standard_Boolean eghassd3dON = eghassd3d && espONesd;
507 // ------------------------------------
509 Standard_Boolean yap00 = Standard_True; //xpu180998 : cto900Q2
510 yap00 = yap00 && (!isclosed);
511 yap00 = yap00 && (EGBoundFOR);
512 yap00 = yap00 && (espONesd);
513 yap00 = yap00 && (!hsdFOR); //xpu280998 : PRO14892 (FOR16,FS30,GI20)
515 const TopOpeBRepDS_ListOfInterference& lI = BDS.ShapeInterferences(FOR);
516 TopOpeBRepDS_ListOfInterference lIcopy; FDS_assign(lI,lIcopy);
517 TopOpeBRepDS_ListOfInterference lIGesd; Standard_Integer nGesd = FUN_selectGIinterference(lIcopy,Iesd,lIGesd);
518 if (nGesd != 0) yap00=Standard_False; // ES has interference on G=edge(Iesd)
521 Standard_Boolean yap0 = Standard_True;
522 yap0 = yap0 && (!isclosed);
523 yap0 = yap0 && (EGBoundFOR);
524 yap0 = yap0 && (!eghassd);
526 Standard_Boolean yap0bis = Standard_True; // xpu160698
527 yap0bis = yap0bis && (!isclosed);
528 yap0bis = yap0bis && (EGBoundFOR);
529 yap0bis = yap0bis && (eghassd); // xpu300798 : cto 902 B7
530 yap0bis = yap0bis && (!eghassdON);
531 yap0bis = yap0bis && eONFS; //xpu240898 : cto900J3 (e7on_2 NOT ON FS, FOR18,FS17,EG7)
532 yap0bis = yap0bis && !ComOfCut; // xpu270798 : boxes240798, f14in,GI=34
534 yap0 = Standard_True;
537 Standard_Boolean hassd3dON = Standard_False;
538 // if (isclosed && !EGBoundFOR && eghassd3d) { -xpu110898 -> yapc3
539 if (!EGBoundFOR && eghassd3d) {
540 ie3d = ::FUN_findeSD(BDS,eON,EG,FOR,oe3d,3);
541 hassd3dON = (ie3d != 0);
544 Standard_Boolean yapc1 = Standard_True;
545 yapc1 = yapc1 && (isclosed);
546 yapc1 = yapc1 && (!EGBoundFOR);
547 yapc1 = yapc1 && (eghassd3d);
548 yapc1 = yapc1 && hassd3dON; //xpu230798
550 Standard_Boolean yapc2a = Standard_True;
551 yapc2a = yapc2a && (isclosed);
552 yapc2a = yapc2a && (!eghassd3d);
554 //xpu240798 cto902A3 (iFOR=5,GI=3,iFCX=6) : complement yapc1
555 Standard_Boolean yapc2b = Standard_True;
556 yapc2b = yapc2b && (isclosed);
557 yapc2b = yapc2b && (!EGBoundFOR);
558 yapc2b = yapc2b && (eghassd3d);
559 yapc2b = yapc2b && (!hassd3dON);
561 Standard_Boolean yapc2c = Standard_True;
562 yapc2c = yapc2c && (isclosed);
563 yapc2c = yapc2c && (EGBoundFOR);
564 yapc2c = yapc2c && (eghassd3d);
566 Standard_Boolean yapc2 = yapc2a;
567 yapc2 = yapc2 || yapc2b || yapc2c; //xpu240798
569 Standard_Boolean yapc3 = Standard_True;
570 yapc3 = yapc3 && (!isclosed);
571 yapc3 = yapc3 && (eghassd3d);
572 yapc3 = yapc3 && (hassd3dON);
573 Standard_Boolean e3closedFOR = Standard_False;
575 const TopoDS_Edge& e3d = TopoDS::Edge(BDS.Shape(ie3d));
576 e3closedFOR = BRep_Tool::IsClosed(e3d,FOR);
578 yapc3 = yapc3 && e3closedFOR; // => !EGBoundFOR
580 //=========================================
583 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap0 GFillON");
584 if (tE) {cout<<"yap00(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
585 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
588 TopAbs_Orientation oeff;
589 FUN_tool_orientEinFFORWARD(EG,FOR,oeff);
590 Standard_Boolean add = Standard_False;
591 if (oeff == TopAbs_FORWARD) add = (TFEaft == TB);
592 else if (oeff == TopAbs_REVERSED) add = (TFEbef == TB);
593 else if (oeff == TopAbs_INTERNAL) add = Standard_True;
594 else if (oeff == TopAbs_EXTERNAL) add = Standard_True;
597 const TopoDS_Shape& Esd = BDS.Shape(Iesd);
598 Standard_Boolean isONFS=Standard_False; TopExp_Explorer ex(FS, TopAbs_EDGE);
599 for (; ex.More(); ex.Next())
600 if (ex.Current().IsSame(Esd)) {isONFS=Standard_True;break;}
603 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
605 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,eON,samegeom);
607 TopAbs_Orientation neworiE = oeff;
608 if (!samegeom && (M_FORWARD(neworiE) || M_REVERSED(neworiE))) neworiE = TopAbs::Complement(neworiE);
610 TopoDS_Shape newE = EspON;
611 newE.Orientation(neworiE);
613 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap00 GFillON","WES+ EspON ");
614 if (tE) FUN_cout(newE);
616 myPWES->AddStartElement(newE);
620 //=========================================
623 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap0 GFillON");
624 if (tE) {cout<<"yap0(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
625 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
628 TopAbs_Orientation oeff;
629 FUN_tool_orientEinFFORWARD(EG,FOR,oeff);
630 Standard_Boolean add = Standard_False;
631 if (oeff == TopAbs_FORWARD) add = (TFEaft == TB);
632 else if (oeff == TopAbs_REVERSED) add = (TFEbef == TB);
633 else if (oeff == TopAbs_INTERNAL) add = Standard_True;
634 else if (oeff == TopAbs_EXTERNAL) add = Standard_True;
635 if (!add) return; //xpu100698
638 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
640 // ngFS, ngFOR, xxFOR :
641 Standard_Real tolON = Max(tolFS,tolEG);
642 tolON *= 1.e2;//*****CAREFULL***** : xpu040998, cto 904 A3
643 gp_Vec ngFS; ok = FUN_tool_nggeomF(parEG,EG,FS,ngFS,tolON);
645 tolON = Max(tolFOR,tolEG);
646 tolON *= 1.e2;//*****CAREFULL***** : xpu040998, cto 904 A3
647 gp_Vec ngFOR; ok = FUN_tool_nggeomF(parEG,EG,FOR,ngFOR,tolON);
649 gp_Dir xxFOR; ok = FUN_tool_getxx(FOR,EG,parEG,ngFOR,xxFOR);
651 // ntFS, ntFOR, ntdot :
652 gp_Dir ntFS(ngFS); if (M_REVERSED(oFS)) ntFS.Reverse();
653 gp_Dir ntFOR(ngFOR); if (M_REVERSED(oFOR)) ntFOR.Reverse();
654 Standard_Real ntdot = ntFOR.Dot(ntFS);
656 // xpu180698 : Kpart=FOR tangent to FS at EG
657 Standard_Boolean Kpart = (OTFE == TopAbs_EXTERNAL) || (OTFE == TopAbs_INTERNAL);
659 Standard_Boolean Ktg = (Abs(1-Abs(ntdot)) < tola*1.e2);
663 gp_Pnt2d UVfor,UVfs; ok = FUN_tool_paronEF(EG,parEG,FOR,UVfor,tolFOR);
665 gp_Pnt Pfor,Pfs; FUN_tool_value(UVfor,FOR,Pfor);
666 tolON = Max(Max(tolFOR,tolFS),tolEG) * 10.;
669 BRepAdaptor_Surface BSfor(FOR); GeomAbs_SurfaceType STfor = BSfor.GetType();
670 BRepAdaptor_Surface BSfs(FS); GeomAbs_SurfaceType STfs = BSfs.GetType();
671 Standard_Integer kpart = FUN_Kpart(STfor,STfs);
673 // MSV: general case, such as BSpline or Bezier surface or two cylinders.
674 // We should detect if FOR and FS have different curvature in section
675 // by plane perpendicular to EG at point parEG.
676 Standard_Real crvFOR,crvFS;
677 if (!ComputeFaceCrvtInSec(FOR,UVfor,xxFOR,crvFOR)) return;
678 if (!FUN_tool_projPonF(Pfor,FS,UVfs,d)) return;
679 if (!ComputeFaceCrvtInSec(FS,UVfs,xxFOR,crvFS)) return;
680 if (M_REVERSED(oFOR)) crvFOR = -crvFOR;
681 if (M_REVERSED(oFS)) crvFS = -crvFS;
682 if (ntdot < 0.) crvFS = -crvFS;
683 Standard_Real eps = Precision::Confusion();
684 Standard_Real absCrvFOR = Abs(crvFOR), absCrvFS = Abs(crvFS);
685 if (absCrvFOR <= eps && absCrvFS <= eps) return;
686 if (absCrvFOR > eps && absCrvFS > eps) {
687 Standard_Real tolR = tolON;
688 Standard_Real rcrvFOR = 1./crvFOR, rcrvFS = 1./crvFS;
689 if (Abs(rcrvFOR - rcrvFS) <= tolR) return;
691 // if we are here the curvatures are different
694 Standard_Boolean SO = (ntdot > 0.);
696 Pfor.Translate(xxFOR.XYZ()*tolON*10.);
697 ok = FUN_tool_projPonF(Pfor,FOR,UVfor,d);
699 FUN_tool_value(UVfor,FOR,Pfor);
701 ok = FUN_tool_projPonF(Pfor,FS,UVfs,d);
703 FUN_tool_value(UVfs,FS,Pfs);
705 gp_Dir Dforfs(gp_Vec(Pfor,Pfs));
707 Standard_Boolean keep = Standard_True;
708 Standard_Real dot = Dforfs.Dot(ntFOR); // xpu250698
710 Standard_Boolean so2and3 = (dot > 0); // xpu250698
711 Standard_Boolean so2 = so2and3; // xpu250698
713 if (opeFus) keep = !so2;
714 if (opeCom) keep = so2;
716 if (TBFOR == TopAbs_OUT) keep = !so2;
721 Standard_Boolean do1and2 = (dot > 0); // xpu250698
722 Standard_Boolean do1 = do1and2; // xpu250698
724 if (opeFus) keep = do1;
725 if (opeCom) keep = !do1;
727 if (TBFOR == TopAbs_OUT) keep = do1;
735 Standard_Real dot = ntFS.Dot(xxFOR);
736 Standard_Boolean positive = (dot > 0);
738 Standard_Boolean keep = Standard_True;
746 if (positive) keep = (TBFOR == TopAbs_OUT);
747 else keep = (TBFOR != TopAbs_OUT);
752 TopoDS_Face newF = FOR;
753 TopoDS_Shape newE = EspON;
754 TopAbs_Orientation neworiE; FUN_tool_orientEinFFORWARD(EG,newF,neworiE);
757 //xpu260698 : cto902A5 : fonds de poche (FOR=f14,GI=e24,refFOR=f13)
758 Standard_Boolean reverse = Standard_False;
760 // xpu170698 : PRO13555 (FOR=f19,GI=e10,FS=f15)
761 Standard_Boolean FORDO = (cFOR == TopOpeBRepDS_DIFFORIENTED);
762 if (FORDO) reverse = !reverse;
763 if (oFOR != orefFOR) reverse = !reverse;
766 if (opeFus) {//nyixpu260698
768 if (opeCom) {//nyixpu260698
771 if (TBFOR == TopAbs_IN) {
772 // xpu290798 : cto902C1 (FOR19,FS16,GI22) f9ou is DO f19in
773 // sp(f9)+sp(f19) are in same WES, e22on is OUT f9 =>
774 // do NOT reverse neworiE
775 // reverse = Standard_True;
779 if (reverse) neworiE = TopAbs::Complement(neworiE);
782 newE.Orientation(neworiE);
784 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap0 GFillON","WES+ EspON ");
785 if (tE) FUN_cout(newE);
787 myPWES->AddStartElement(newE);
791 //=========================================
794 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yapc1 GFillON");
795 if (tE) {cout<<"yapc1(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
796 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
798 const TopoDS_Edge& e3d = TopoDS::Edge(BDS.Shape(ie3d));
800 // e3d = SameDomain3d de EG, arete de FOR, qui contient EspON
801 TopOpeBRepDS_Config cf; Standard_Boolean cfok = FDS_Config3d(EspON,e3d,cf);
804 TopAbs_Orientation oe3dk = oe3d;
805 // Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(EG,e3d);
806 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
807 if (!ok) return; //nyiRAISE
808 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,e3d,samegeom);
809 if (!ok) return; //nyiRAISE
811 if (!TopOpeBRepBuild_GetcontextNOSG()) {
813 if (!samegeom) oe3dk = TopAbs::Complement(oe3dk);
818 Standard_Boolean keep3d = Standard_False;
819 if (oe3dk == TopAbs_FORWARD) keep3d = (TFEaft == TB1);
820 else if (oe3dk == TopAbs_REVERSED) keep3d = (TFEbef == TB1);
821 else if (oe3dk == TopAbs_INTERNAL) keep3d = Standard_True;
822 else if (oe3dk == TopAbs_EXTERNAL) keep3d = Standard_False;
825 // if(tEFOR) {cout<<endl<<"yapc1 keep3d : "<<keep3d<<endl;debfillonfemess3d(iFOR,iEG);}
829 TopAbs_Orientation neworiE = oe3d;
830 if (cf == TopOpeBRepDS_DIFFORIENTED) neworiE = TopAbs::Complement(neworiE);
831 TopoDS_Shape newE = EspON;
832 newE.Orientation(neworiE);
835 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yapc1 GFillON","WES+ EspON ");
836 if (tE) FUN_cout(newE);
838 myPWES->AddStartElement(newE);
844 //=========================================
847 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yapc2 GFillON");
848 if (tE) {cout<<"yapc2(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
849 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
852 Standard_Boolean keep = Standard_False;
853 if (EGBoundFOR) keep=FUN_keepEON(*myPB,EG,FOR,FS,EGBoundFOR,TFE,TB1,TB2);
854 else keep=Standard_True;
857 TopAbs_Orientation neworiE = TFE.Orientation(TB1);
858 Standard_Boolean giveoEinFOR = EGBoundFOR && (!isclosedFF) && (M_EXTERNAL(neworiE) || M_INTERNAL(neworiE));
859 if (giveoEinFOR) FUN_tool_orientEinFFORWARD(EG,FOR,neworiE);
861 // xpu230798 : cto902A3 (iFOR=5,GI=3,iFCX=6)
862 // (iFOR=20,GI=3,iFCX=6)
863 if (yapc2b && (!M_EXTERNAL(neworiE))){
864 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(FOR);
865 TopAbs_State state2d = FSC_StateEonFace(EspON,0.345,FOR,PSC);
866 if (state2d != TopAbs_IN) return;
869 TopoDS_Shape newE=EspON;
870 Standard_Boolean addFORREV = Standard_False;
871 TopAbs_Orientation neworiEk = TopAbs_EXTERNAL;
872 if (!isclosedFF) neworiEk = neworiE;
873 else if (M_FORWARD(neworiE) || M_REVERSED(neworiE)) neworiEk = neworiE;
874 else if (M_INTERNAL(neworiE)) addFORREV = Standard_True;
875 newE.Orientation(neworiEk);
880 debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yapc2 GFillON","WES+ EspON not closed");
881 else if (M_FORWARD(neworiE) || M_REVERSED(neworiE))
882 debaddpwes(iFOR,TB1,iEG,neworiEk,myPB,myPWES,"yapc2 GFillON closed","WES+ EspON F|R");
883 else if (M_INTERNAL(neworiE)) {
884 debaddpwes(iFOR,TB1,iEG,TopAbs_FORWARD, myPB,myPWES,"yapc2 GFillON closed","WES+ EspON INTERNAL");
885 debaddpwes(iFOR,TB1,iEG,TopAbs_REVERSED,myPB,myPWES,"yapc2 GFillON closed","WES+ EspON INTERNAL");
890 newE.Orientation(TopAbs_FORWARD); FUN_cout(newE);
891 newE.Orientation(TopAbs_REVERSED); FUN_cout(newE);
898 newE.Orientation(TopAbs_FORWARD);
899 // Standard_Boolean ok = FUN_tool_correctCLO(TopoDS::Edge(newE),FOR); // xpu201198 cto016*
900 myPWES->AddStartElement(newE);
902 newE.Orientation(TopAbs_REVERSED);
903 // ok = FUN_tool_correctCLO(TopoDS::Edge(newE),FOR); // xpu201198 cto016*
904 myPWES->AddStartElement(newE);
907 // Standard_Boolean ok = FUN_tool_correctCLO(TopoDS::Edge(newE),FOR); // xpu201198 cto016*
908 myPWES->AddStartElement(newE);
913 //=========================================
916 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yapc3 GFillON");
917 if (tE) {cout<<"yapc3(FOR"<<iFOR<<" FS"<<iFS<<" EG"<<GI<<") ";
918 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
921 Standard_Boolean keep = Standard_False;
922 if (EGBoundFOR) keep=FUN_keepEON(*myPB,EG,FOR,FS,EGBoundFOR,TFE,TB1,TB2);
923 else keep=Standard_True;
926 TopAbs_Orientation neworiE = TFE.Orientation(TB1);
927 Standard_Boolean giveoEinFOR = EGBoundFOR && !isclosedFF && (M_EXTERNAL(neworiE) || M_INTERNAL(neworiE));
928 if (giveoEinFOR) FUN_tool_orientEinFFORWARD(EG,FOR,neworiE);
930 TopoDS_Shape newE=EspON;
931 Standard_Boolean addFORREV = Standard_False;
932 TopAbs_Orientation neworiEk = TopAbs_EXTERNAL;
934 // xpu110798 : cto902B4 (FOR6,EG15,FS17)
935 if (M_INTERNAL(OTFE) || M_EXTERNAL(OTFE)) {
936 Standard_Boolean SO = Standard_False; // "approximate same oriented (FOR,FS)"
938 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
939 if (!ok) return;// nyiRAISE
941 gp_Pnt2d uvFS; ok = FUN_tool_paronEF(EG,parEG,FS,uvFS,tolFS); // !EGBoundFOR
942 if (!ok) return;// nyiRAISE
943 gp_Vec ngFS = FUN_tool_nggeomF(uvFS,FS);
944 gp_Dir ntFS(ngFS); if (M_REVERSED(oFS)) ntFS.Reverse();
946 gp_Pnt2d uvFOR; ok = FUN_tool_parF(EG,parEG,FOR,uvFOR,tolFOR);
947 if (!ok) return;// nyiRAISE
948 gp_Vec ngFOR = FUN_tool_nggeomF(uvFOR,FOR);
949 gp_Dir ntFOR(ngFOR); if (M_REVERSED(oFOR)) ntFOR.Reverse();
951 Standard_Real dot = ntFOR.Dot(ntFS);
952 Standard_Boolean nulldot = (Abs(dot) < tola);
955 gp_Dir xxFS; ok = FUN_tool_getxx(FS,EG,parEG,ngFS,xxFS);
956 if (!ok) return;// nyiRAISE
957 Standard_Real dot2 = ntFOR.Dot(xxFS);
964 Standard_Boolean unkeepclo = Standard_False;
965 if (SO && M_EXTERNAL(OTFE) && opeCom) unkeepclo = Standard_True;
966 if (SO && M_INTERNAL(OTFE) && opeFus) unkeepclo = Standard_True;
967 addFORREV = !unkeepclo;
972 Standard_Boolean samegeom; Standard_Boolean ok = FUN_tool_curvesSO(eON,EG,samegeom);
973 if (!ok) return; // nyiRAISE
974 Standard_Boolean reverse = (!samegeom);
976 if (TopOpeBRepBuild_GetcontextNOSG())
977 // MSV 21.03.2002: restore the genaral behaviour, since the function
978 // FUN_UNKFstasta was corrected.
979 reverse = Standard_False; //we exclude this line from #ifdef OCCT_DEBUG because
980 //in optimised mode this line will never be included , and that follows to regressions
984 if (reverse) neworiEk = TopAbs::Complement(neworiEk);
985 newE.Orientation(neworiEk);
991 debaddpwes(iFOR,TB1,iEG,neworiEk,myPB,myPWES,"yapc3 GFillON","WES+ EspON ");
993 debaddpwes(iFOR,TB1,iEG,TopAbs_FORWARD, myPB,myPWES,"yapc3 GFillON closed","WES+ EspON ");
994 debaddpwes(iFOR,TB1,iEG,TopAbs_REVERSED,myPB,myPWES,"yapc3 GFillON closed","WES+ EspON ");
1000 newE.Orientation(TopAbs_FORWARD); myPWES->AddStartElement(newE);
1001 newE.Orientation(TopAbs_REVERSED); myPWES->AddStartElement(newE);
1004 myPWES->AddStartElement(newE);
1009 if (nlfcx == 0) return;
1010 const TopoDS_Face& FCX=TopoDS::Face(lfcx.First()); Standard_Integer iFCX=BDS.Shape(FCX);
1012 // faces samedomain de FCX
1013 TopTools_ListOfShape LFSO,LFDO,LFSO1,LFDO1,LFSO2,LFDO2;
1014 myPB->GFindSamDomSODO(FCX,LFSO,LFDO);
1015 Standard_Integer rankFCX=myPB->GShapeRank(FCX),rankX=(rankFCX)?((rankFCX==1)?2:1):0;
1016 // DEB : rankFCX doit etre=rankFS
1018 // LFSO2,LFDO2=faces samedomain de FCX dans le shape oppose (rankX)
1019 // rankX=shape oppose=shape de FOR.
1020 myPB->GFindSameRank(LFSO,rankFCX,LFSO1); myPB->GFindSameRank(LFDO,rankFCX,LFDO1);
1021 myPB->GFindSameRank(LFSO,rankX,LFSO2); myPB->GFindSameRank(LFDO,rankX,LFDO2);
1023 // FFinSO=appartenance de FOR a l'ensemble des faces sameoriented de FCX=LFSO2
1024 Standard_Boolean FFinSDSO=Standard_False;
1026 for(TopTools_ListIteratorOfListOfShape i(LFSO2);i.More();i.Next()) {
1027 const TopoDS_Shape& F=i.Value();
1028 if (F.IsSame(FOR)) {FFinSDSO=Standard_True;break;}
1031 // FFinDO=appartenance de FOR a l'ensemble des faces difforiented de FCX=LFDO2
1032 Standard_Boolean FFinSDDO=Standard_False;
1034 for(TopTools_ListIteratorOfListOfShape i(LFDO2);i.More();i.Next()) {
1035 const TopoDS_Shape& F=i.Value();
1036 if (F.IsSame(FOR)) {FFinSDDO=Standard_True;break;}
1039 // FFinSD=appartenance de FOR a l'ensemble des faces samedomain de FCX
1040 Standard_Boolean FFinSD=(FFinSDSO || FFinSDDO);
1042 TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation();
1043 TopOpeBRepDS_Config cFCX = BDS.SameDomainOri(iFCX);
1044 Standard_Integer irefFCX = BDS.SameDomainRef(FCX);
1045 TopAbs_Orientation orefFCX = BDS.Shape(irefFCX).Orientation();
1046 Standard_Boolean FCXisref = (irefFCX == iFCX);
1049 // Standard_Real tolFCX = factor*BRep_Tool::Tolerance(FCX); //NYITOLXPU
1052 TopAbs_Orientation oegFCXF;Standard_Boolean EGBoundFCX = FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF);
1053 TopAbs_Orientation oegFCX ;
1054 FUN_tool_orientEinF(EG,FCX,oegFCX);
1056 if (!EGBoundFOR && !espONesd) { //xpu220998 : ctocylcongA1 (FOR10,FS19,EG8)
1057 gp_Pnt ptON; Standard_Boolean ok = FUN_tool_value(parON,eON,ptON);
1058 if (!ok) return; //nyiRAISE
1059 Standard_Real d=1.; gp_Pnt2d uvFOR; ok = FUN_tool_projPonboundedF(ptON,FOR,uvFOR,d);
1060 if (!ok) return; //nyiRAISE
1061 Standard_Real tolON = Max(tolEG,tolFOR);//xpu291098 cto900L7(f7,e7on)
1062 //xpu051198 PRO12953(f6,e4on)
1063 tolON *= 1.e2;//*****CAREFULL***** : xpu040998, cto 904 A3
1064 Standard_Boolean eONFOR = (d < tolON);
1065 if (!eONFOR) return;
1068 Standard_Boolean yap1 = Standard_True;
1069 yap1 = yap1 && FFinSD;
1070 yap1 = yap1 && (!EGBoundFOR);
1071 yap1 = yap1 && EGBoundFCX;
1072 yap1 = yap1 && eghassd3dON;
1074 Standard_Boolean yap2 = Standard_True;
1075 yap2 = yap2 && FFinSD;
1076 yap2 = yap2 && (!EGBoundFOR);
1077 yap2 = yap2 && EGBoundFCX;// yap2 = yap2 && !eghassdON;
1078 yap2 = yap2 && !eghassd;// yap2 = yap2 && !eghassd3dON;
1080 Standard_Boolean yap1b = Standard_True;
1081 yap1b = yap1b && FFinSD;
1082 yap1b = yap1b && (!EGBoundFOR);
1083 yap1b = yap1b && EGBoundFCX;
1084 yap1b = yap1b && eghassd3d;
1085 yap1b = yap1b && !eghassd3dON;
1086 yap1b = yap1b && eONFS; //xpu240898
1088 yap2 = Standard_True; // xpu220998 : ctocylcongA1 yap1b(FOR12,FS5,EG8)
1091 Standard_Boolean yap6 = Standard_True; // cto001F3 : f18ou,EG=e23
1092 yap6 = yap6 && FFinSD;
1093 yap6 = yap6 && (!EGBoundFOR);
1094 yap6 = yap6 && EGBoundFCX;
1095 yap6 = yap6 && eghassdON;
1096 yap6 = yap6 && !eghassd3d;// yap6 = yap6 && !eghassd3dON;
1098 Standard_Boolean yap6b = Standard_True;
1099 yap6b = yap6b && FFinSD;
1100 yap6b = yap6b && (!EGBoundFOR);
1101 yap6b = yap6b && EGBoundFCX;
1102 yap6b = yap6b && eghassd;
1103 yap6b = yap6b && !eghassdON;
1104 yap6b = yap6b && eONFS; //xpu240898
1105 yap6b = yap6b && !eghassd3d;// yap6b = yap6b && !eghassd3dON;
1110 yap2 = Standard_True;
1113 // CTS20205 spOUT(f30), e4 = eghassd3dON
1114 // mais f30 !sdm lfcx(e4)
1115 Standard_Boolean eghassd3fcx = eghassdON;
1116 eghassd3fcx = eghassd3fcx && !FUN_ds_sdm(BDS,FOR,FS);
1117 eghassd3fcx = eghassd3fcx && !FFinSD; //!FUN_ds_sdm(BDS,FOR,FCX)
1118 Standard_Boolean yap5 = Standard_True;
1119 yap5 = yap5 && !EGBoundFOR;
1120 yap5 = yap5 && eghassd3fcx;
1122 Standard_Boolean yap3 = Standard_True;
1123 yap3 = yap3 && !FFinSD;
1124 yap3 = yap3 && !EGBoundFOR;
1125 yap3 = yap3 && eghassd3dON;
1127 Standard_Boolean yap4 = Standard_True;
1128 yap4 = yap4 && !FFinSD;
1129 yap4 = yap4 && isrest;
1130 yap4 = yap4 && !yap5;
1131 yap4 = yap4 && !hsdFOR; //xpu290598
1133 Standard_Boolean yap3b = Standard_True;
1134 yap3b = yap3b && !FFinSD;
1135 yap3b = yap3b && !EGBoundFOR;
1136 yap3b = yap3b && eghassd3d;
1137 yap3b = yap3b && !eghassd3dON;
1138 yap3b = yap3b && eONFS; //xpu240898
1140 yap4 = Standard_True; //xpu191098 : cto016F3(yap3b(FOR7,EG4))
1144 Standard_Boolean yap7 = Standard_True;
1145 yap7 = yap7 && !FFinSD;
1146 yap7 = yap7 && isrest;
1147 yap7 = yap7 && !yap5;
1148 yap7 = yap7 && hsdFOR;
1150 TopAbs_State staFOR = TB1;
1151 TopAbs_State staFS = (rankFS == rankFOR) ? TB1 : TB2;
1154 // if(tEFOR) cout<<endl<<"yap1 yap2 yap3 yap4 = ";
1155 // if(tEFOR) cout<<yap1<<" "<<yap2<<" "<<yap3<<" "<<yap4<<endl<<endl;
1156 // if(tEFOR) debfillonfemess(iFOR,iEG);
1159 //=========================================
1162 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap1 GFillON");
1163 if (tE) {cout<<"yap1(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1164 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1168 // FF est samedomain avec FCX
1169 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
1170 // au lieu de la transition par rapport a la matiere 3d de la face FS
1171 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
1172 // EG a des aretes 3d same domain : le3
1174 TopAbs_State staFCX = staFS; // FS et FCX connexes par EG => meme shape origine => meme etat
1175 Standard_Boolean b3d = Standard_False; Standard_Boolean b2d = Standard_False;
1177 // staFOR : etat demande sur FOR
1178 Standard_Boolean b3de3 = Standard_False; Standard_Boolean b2de3 = Standard_False;
1180 const TopoDS_Edge& e3 = TopoDS::Edge(le3.First()); Standard_Integer ie3 = BDS.Shape(e3);
1181 Standard_Boolean ssif = Standard_False; Handle(TopOpeBRepDS_ShapeShapeInterference) ssie3;
1182 TopOpeBRepDS_ListIteratorOfListOfInterference itssi(BDS.ShapeInterferences(FCX));
1183 for (;itssi.More();itssi.Next()) {
1184 Handle(TopOpeBRepDS_ShapeShapeInterference) ssi (Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(itssi.Value())); if (ssi.IsNull()) continue;
1185 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(ssi,GT1,G1,ST1,S1);
1186 Standard_Boolean cond = (GT1 == TopOpeBRepDS_EDGE && ST1 == TopOpeBRepDS_FACE);
1187 cond = cond && (G1 == ie3);
1188 // NYI cond = cond && e(S1 est une face connexe a iFOR par ie3)
1189 if (cond) { ssif = Standard_True; ssie3 = ssi; break; }
1192 TopOpeBRepDS_Transition TFEe3; TopAbs_State TFEe3bef = TFEe3.Before(); TopAbs_State TFEe3aft = TFEe3.After();
1193 TopAbs_Orientation oe3FORF = TopAbs_FORWARD;
1195 TFEe3 = ssie3->Transition();
1196 TFEe3bef = TFEe3.Before();
1197 FUN_tool_orientEinFFORWARD(e3,FOR,oe3FORF);
1201 if ( oFOR != oFCX ) {
1202 oegFCXF = TopAbs::Complement(oegFCXF);
1203 oe3FORF = TopAbs::Complement(oe3FORF);
1205 TopOpeBRepDS_Transition T1(oegFCXF); TopAbs_State T1aft = T1.After(); TopAbs_State T1bef = T1.Before();
1206 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1207 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1208 else FUN_coutmess("DEBUG GFillONPartsWES2_1 orientation != F,R\n");
1209 if (oegFCXF == TopAbs_FORWARD) b2d = (T1aft == TopAbs_IN);
1210 else if (oegFCXF == TopAbs_REVERSED) b2d = (T1bef == TopAbs_IN);
1211 else FUN_coutmess("DEBUG GFillONPartsWES2_2 orientation != F,R\n");
1214 TopOpeBRepDS_Transition T11(oe3FORF); TopAbs_State T11aft = T11.After(); TopAbs_State T11bef = T11.Before();
1215 if (oe3FORF == TopAbs_FORWARD) b3de3 = (TFEe3aft == staFOR);
1216 else if (oe3FORF == TopAbs_REVERSED) b3de3 = (TFEe3bef == staFOR);
1217 else FUN_coutmess("DEBUG GFillONPartsWES2_1 orientation != F,R\n");
1218 if (oe3FORF == TopAbs_FORWARD) b2de3 = (T11aft == TopAbs_IN);
1219 else if (oe3FORF == TopAbs_REVERSED) b2de3 = (T11bef == TopAbs_IN);
1220 else FUN_coutmess("DEBUG GFillONPartsWES2_2 orientation != F,R\n");
1225 if ( oFOR == oFCX ) {
1226 oegFCXF = TopAbs::Complement(oegFCXF);
1227 oe3FORF = TopAbs::Complement(oe3FORF);
1229 TopOpeBRepDS_Transition T2(oegFCXF); TopAbs_State Taft = T2.After(); TopAbs_State Tbef = T2.Before();
1230 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1231 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1232 else FUN_coutmess("DEBUG GFillONPartsWES2_3 orientation != F,R\n");
1233 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1234 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1235 else FUN_coutmess("DEBUG GFillONPartsWES2_4 orientation != F,R\n");
1238 TopOpeBRepDS_Transition T22(oe3FORF); TopAbs_State T22aft = T22.After(); TopAbs_State T22bef = T22.Before();
1239 if (oe3FORF == TopAbs_FORWARD) b3de3 = (TFEe3aft == staFOR);
1240 else if (oe3FORF == TopAbs_REVERSED) b3de3 = (TFEe3bef == staFOR);
1241 else FUN_coutmess("DEBUG GFillONPartsWES2_3 orientation != F,R\n");
1242 if (oe3FORF == TopAbs_FORWARD) b2de3 = (T22aft == TopAbs_IN);
1243 else if (oe3FORF == TopAbs_REVERSED) b2de3 = (T22bef == TopAbs_IN);
1244 else FUN_coutmess("DEBUG GFillONPartsWES2_4 orientation != F,R\n");
1248 Standard_Boolean b = (b3d && b2d && b3de3 && b2de3);
1251 // on garde EspON pour la reconstruction de la face FOR
1252 // si elle est IN/ON la face FOR (EGBoundFOR = 0 ==> projection)
1253 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(FOR);
1254 TopAbs_State state2d = FSC_StateEonFace(EspON,0.345,FOR,PSC);
1255 Standard_Boolean isin = (state2d == TopAbs_IN);
1258 TopAbs_State TBEG = TB1;
1259 TopAbs_Orientation neworiE = TFE.Orientation(TBEG);
1261 // if (FCXisref && FFinSDDO) {
1262 if (FCXisref && !EGBoundFOR) {
1263 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1264 Standard_Boolean rev = myPB->Reverse(staFCX,staFOR);
1265 neworiE = myPB->Orient(neworiE,rev);
1267 // xpu280798 : never occurs as yap1 -> !EGBoundFOR
1268 // else if (FORisref && EGBoundFOR) {
1269 // FUN_tool_orientEinFFORWARD(EG,FOR,neworiE);
1270 // Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1271 // neworiE = myPB->Orient(neworiE,rev);
1273 else if (FORisref && !EGBoundFOR) {
1274 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1275 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1276 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1277 if (reverse) neworiE = TopAbs::Complement(neworiE);
1278 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1279 neworiE = myPB->Orient(neworiE,rev);
1281 else if (!EGBoundFOR) { // xpu210898
1282 Standard_Integer rankrefFOR = BDS.AncestorRank(irefFOR);
1283 if (rankrefFOR == rankFCX)
1284 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1285 else if (rankrefFOR == rankFOR) {
1286 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1287 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1288 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1289 if (reverse) neworiE = TopAbs::Complement(neworiE);
1291 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1292 neworiE = myPB->Orient(neworiE,rev);
1295 TopoDS_Shape newE = EspON;
1296 newE.Orientation(neworiE);
1299 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap1 GFillON","WES+ EspON ");
1300 if (tE) FUN_cout(newE);
1302 myPWES->AddStartElement(newE);
1307 //=========================================
1310 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap2 GFillON");
1311 if (tE) {cout<<"yap2(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1312 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1315 // FF est samedomain avec FCX
1316 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
1317 // au lieu de la transition par rapport a la matiere 3d de la face FS
1318 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
1320 TopAbs_State staFCX = staFS; // FS et FCX connexes par EG => meme shape origine => meme etat
1321 Standard_Boolean b3d = Standard_False; Standard_Boolean b2d = Standard_False;
1322 Standard_Boolean b = (b3d && b2d);
1325 if ( oFOR != oFCX ) {
1326 // orientation topologique de EG dans la face mere
1327 oegFCXF = TopAbs::Complement(oegFCXF);
1329 TopOpeBRepDS_Transition T1(oegFCXF); TopAbs_State Taft = T1.After(); TopAbs_State Tbef = T1.Before();
1330 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1331 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1332 else FUN_coutmess("DEBUG GFillONPartsWES2_1 orientation != F,R\n");
1333 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1334 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1335 else FUN_coutmess("DEBUG GFillONPartsWES2_2 orientation != F,R\n");
1338 if ( oFOR == oFCX ) {
1339 // orientation topologique de EG dans la face mere
1340 oegFCXF = TopAbs::Complement(oegFCXF);
1342 TopOpeBRepDS_Transition T2(oegFCXF); TopAbs_State Taft = T2.After(); TopAbs_State Tbef = T2.Before();
1343 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1344 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1345 else FUN_coutmess("DEBUG GFillONPartsWES2_3 orientation != F,R\n");
1346 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1347 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1348 else FUN_coutmess("DEBUG GFillONPartsWES2_4 orientation != F,R\n");
1351 // if(tEFOR) {cout<<endl<<"yap2 : b3d,b2d "<<b3d<<","<<b2d<<endl;debfillonfemess(iFOR,iEG);}
1354 // bcl1;bcl2; c12;tsp(f9),tspON(e7)
1355 if (ComOfCut) {b3d=Standard_True; b2d=Standard_True;} //xpu200598
1358 Standard_Real parEG = 0.;
1359 // bcl1;bcl2; tsp(f9),tspON(e7)
1360 Standard_Boolean sdm = FUN_ds_sdm(BDS,BDS.Shape(iFOR),BDS.Shape(iFS));
1361 Standard_Boolean isfafa = sdm; // such interferences are computed IN fafa case
1364 Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1367 gp_Pnt2d uvFS; ok = FUN_tool_parF(EG,parEG,FS,uvFS,tolFS);
1368 if (!ok) return;// nyiRAISE
1369 ngFS = FUN_tool_nggeomF(uvFS,FS);
1370 gp_Dir xxFS; ok = FUN_tool_getxx(FS,EG,parEG,ngFS,xxFS);
1371 if (!ok) return;// nyiRAISE
1373 gp_Pnt2d uvFOR; ok = FUN_tool_parF(EG,parEG,FOR,uvFOR,tolFOR);
1374 if (!ok) return;// nyiRAISE
1375 ngFOR = FUN_tool_nggeomF(uvFOR,FOR);
1376 gp_Dir ntFOR(ngFOR); if (M_REVERSED(oFOR)) ntFOR.Reverse();
1378 Standard_Real dot = xxFS.Dot(ntFOR);
1379 //xpu040698 : FS tg to FCX at EG - CTS20578 (FOR=F8,EG=E6,FS=F4) -
1380 Standard_Boolean nulldot = (Abs(dot) < tola);
1381 if (nulldot) { // approximate xxFS :
1383 gp_Vec2d dxx; ok = FUN_tool_getdxx(FS,EG,parEG,dxx);
1385 newuvFS = uvFS.Translated(dxx * 0.25);
1386 gp_Dir newngFS = FUN_tool_nggeomF(newuvFS,FS);
1387 ok = FUN_tool_getxx(FS,EG,parEG,newngFS,xxFS);
1389 dot = xxFS.Dot(ntFOR);
1393 TopAbs_State TBFS = FUN_build_TB(myPB,rankFS);
1394 Standard_Boolean positive = (dot > 0);
1396 Standard_Boolean keep = Standard_True;
1398 if (opeFus) keep = positive; //xpu090698 : PRO14033 (iFOR=15,GI=10,iFS=9)
1399 if (opeCom) keep = Standard_True;
1401 if (positive) keep = (TBFS == TopAbs_OUT); //xpu230698 cto100G1
1402 else keep = (TBFS == TopAbs_IN);
1408 //xpu050698 : (fuse = OU/IN + IN/OU) -CTS20578-
1410 Standard_Integer rkOU = (TB1 == TopAbs_OUT) ? 1 : 2;
1411 Standard_Integer rkfspOU = (rankFOR == rkOU) ? 1 : 2;
1412 Standard_Boolean spOUFOR = (rankFOR == rkfspOU);
1416 if (opeCom) keep = !positive;
1418 Standard_Boolean FORmoinsFS = (TBFS == TopAbs_IN);
1420 if (FORmoinsFS) keep = Standard_True;
1421 else keep = ComOfCut;
1422 // if (TBFS == TopAbs_OUT) keep = Standard_True;
1423 // else keep = (rankFS == 1);
1426 // keep = !FORmoinsFS; // xpu230698 : cto100A1
1427 // keep = Standard_False;
1428 if (!FORmoinsFS) keep = Standard_True; // xpu230698 : cto100A1
1429 else keep = ComOfCut; //xpu120898 PRO12859 (FOR26,FS12,FCX18,EG14)
1434 // if(tEFOR) {cout<<endl<<"yap2 : keep "<<keep<<endl;debfillonfemess(iFOR,iEG);}
1442 // on garde EspON pour la reconstruction de la face FOR
1443 // si elle est IN/ON la face FOR (EGBoundFOR = 0 ==> projection)
1444 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(FOR);
1445 TopAbs_State state2d = FSC_StateEonFace(EspON,0.345,FOR,PSC);
1446 Standard_Boolean isin = (state2d == TopAbs_IN);
1449 TopAbs_State TBEG = TB1;
1450 TopAbs_Orientation neworiE = TFE.Orientation(TBEG);
1452 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1453 Standard_Boolean forw=M_FORWARD(neworiE), reve=M_REVERSED(neworiE);
1454 Standard_Boolean ok = forw || reve;
1455 if (FFinSDSO && ok) {
1457 neworiE = TopAbs::Complement(neworiE);
1461 // bcl1;bcl2; tsp(f9)
1462 if (FFinSDDO && ok) {
1465 // TopAbs_State TBEG = (rankEG == 1)? TB1 : TB2;
1466 // if (TBEG == TopAbs_IN) neworiE = TopAbs::Complement(neworiE);
1467 neworiE = TopAbs::Complement(neworiE); // xpu270898 : cto905E2 (FOR33,FCX16,EG19)
1469 else if (ComOfCut) {
1474 // en principe , l'operation locale est tjrs = OUT,IN
1475 neworiE = TopAbs::Complement(neworiE);
1478 // SDDO et oT anti// => oG //
1480 gp_Dir xxFCX; ok = FUN_tool_getxx(FCX,EG,parEG,xxFCX);
1481 if (!ok) return;// nyiRAISE
1484 if (M_REVERSED(oFS)) ntFS.Reverse();
1486 Standard_Real dot = xxFCX.Dot(ntFS);
1487 Standard_Boolean toreverse = (dot > 0);
1489 if (toreverse) neworiE = TopAbs::Complement(neworiE);
1493 Standard_Boolean reverse = Standard_False; //xpu270598 : reverse=false=>FCX has same geom ori
1494 if (!FCXisref) { //xpu270598
1495 if (cFCX == TopOpeBRepDS_DIFFORIENTED) reverse = Standard_True;
1496 if (oFCX != orefFCX) reverse = !reverse;
1498 if (reverse) neworiE = TopAbs::Complement(neworiE); // xpu270598
1500 TopoDS_Shape newE = EspON;
1501 newE.Orientation(neworiE);
1504 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap2 GFillON","WES+ EspON ");
1505 if (tE) FUN_cout(newE);
1507 myPWES->AddStartElement(newE);
1512 //=========================================
1515 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap6 GFillON");
1516 if (tE) {cout<<"yap6(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1517 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1519 TopAbs_Orientation neworiE;
1520 // FF est samedomain avec FCX
1521 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
1522 // au lieu de la transition par rapport a la matiere 3d de la face FS
1523 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
1525 TopAbs_State staFCX = staFS; // FS et FCX connexes par EG => meme shape origine => meme etat
1526 Standard_Boolean b3d = Standard_False; Standard_Boolean b2d = Standard_False;
1527 Standard_Boolean b = Standard_False;
1529 Standard_Boolean SO = FFinSDSO;//(FFinSDSO && (oFOR == oFCX)) || (FFinSDDO && (oFOR != oFCX));
1530 Standard_Boolean DO = FFinSDDO;//(FFinSDSO && (oFOR != oFCX)) || (FFinSDDO && (oFOR == oFCX));
1533 // Standard_Integer rkToFill = BDS.AncestorRank(myFace);
1535 // Standard_Boolean samerk = (rankEG == rkToFill);
1537 // TopAbs_Orientation oegFOR;
1538 Standard_Boolean shareG;
1539 Standard_Boolean ok = FUN_ds_shareG(myPB->DataStructure(),iFOR,iFCX,GI,
1540 TopoDS::Edge(EspON),shareG);
1541 if (!ok) return; // nyiFUNRAISE
1544 // FOR and FCX share geometric domain.
1545 Standard_Boolean forcekeep = opeFus && shareG && (rankEG ==1); // newnew
1549 // xpu231198 :PRO15946 (FOR11,EG24,FCX20)
1550 // xpu090299 (JAP60247, FOR6,FCX33,EG34)
1551 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1552 TopTools_ListOfShape lfor; FDSCNX_FaceEdgeConnexFaces(FOR,Esd,HDS,lfor);
1553 Standard_Integer nfor = lfor.Extent();
1554 if (nfor < 1) b = shareG; //Esd is FOR's closing edge
1555 else if (nfor > 1) return;//NYIRaise (unvalid shape)
1557 const TopoDS_Face& FF = TopoDS::Face(lfor.First());
1558 Standard_Real tola1 = Precision::Angular()*1.e2;//nyitolxpu
1559 Standard_Real parEG; Standard_Boolean ok1 = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1561 Standard_Real matfs; ok1 = TopOpeBRepTool_TOOL::Matter(FS,FCX,EG,parEG,tola1,matfs);
1564 Standard_Real tolEsd = BRep_Tool::Tolerance(Esd)*factor; //NYITOLXPU
1565 Standard_Real parEsd; Standard_Boolean ok2 = FUN_tool_parE(eON,parON,Esd,parEsd,tolEsd);
1567 Standard_Real matfor; ok2 = TopOpeBRepTool_TOOL::Matter(FOR,FF,Esd,parEsd,tola1,matfor);
1570 Standard_Real sum = matfs+matfor;
1571 Standard_Boolean sumisPI = (Abs(sum-M_PI) < tola1);
1572 Standard_Boolean fsinfPI = (matfs < M_PI);
1573 Standard_Boolean forinfPI = (matfor < M_PI);
1574 if (sumisPI) b = Standard_False;
1575 else if (sum < M_PI) b = Standard_True;
1577 if (fsinfPI && forinfPI) b = Standard_False;
1578 else { // (!fsinfPI) || (!forinfPI)
1579 Standard_Boolean sammat = (Abs(matfs-matfor)<tola1);
1580 if (sammat) b = Standard_False;
1581 else b = (matfs < matfor);
1584 if (b) forcekeep = Standard_True;
1586 // NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYIXPU
1587 /*if (shareG) b = Standard_True;
1589 // xpu231198 :PRO15946 (FOR11,EG24,FCX20)
1590 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1592 gp_Dir xxFCX; ok = FUN_tool_getxx(FCX,EG,parEG,xxFCX);
1593 if (!ok) return;// nyiRAISE
1594 gp_Vec ntFS; ok = FUN_tool_nggeomF(parEG,EG,FS,ntFS,tolFS);
1595 if (!ok) return;// nyiRAISE
1596 if (M_REVERSED(oFS)) ntFS.Reverse();
1598 Standard_Real dot = ntFS.Dot(xxFCX);
1599 if (Abs(dot) < tola) b = Standard_False; // xpu231198nyi tangent config
1600 else {b = (dot <0.); if (b) forcekeep=Standard_True;}
1603 else if (opeCut) b = (!shareG);
1604 else if (opeCom) b = shareG && (rankEG ==1);
1605 if (b) { // nyi : a revoir
1606 if ( oFOR != oFCX ) {
1607 // orientation topologique de EG dans la face mere
1608 oegFCXF = TopAbs::Complement(oegFCXF);
1610 TopOpeBRepDS_Transition T1(oegFCXF); TopAbs_State Taft = T1.After(); TopAbs_State Tbef = T1.Before();
1611 if (oegFCXF == TopAbs_FORWARD) b3d = (TFEaft == staFCX);
1612 else if (oegFCXF == TopAbs_REVERSED) b3d = (TFEbef == staFCX);
1613 if (oegFCXF == TopAbs_FORWARD) b2d = (Taft == TopAbs_IN);
1614 else if (oegFCXF == TopAbs_REVERSED) b2d = (Tbef == TopAbs_IN);
1617 if (forcekeep) b = Standard_True; // newnew
1619 if (DO) { // we do NOT keep the splitON
1620 if (opeFus) b = (!shareG); // cto001D2 spOU(f18)
1622 Standard_Integer rankREF = opec12? 1 : 2;
1623 Standard_Boolean binin=Standard_False, binou=Standard_False;
1624 if (TB1 == TB2) binin = (rankEG == rankREF); // partie IN/IN
1626 //xpu291098 cto001D3 (f17ou)
1627 binou = (rankFOR == 1)&&(TBFOR == TopAbs_OUT)&&(!shareG);
1629 // xpu181198 CTS21302(FOR22,EG9,FCX5)
1631 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd)); // rkEsd=rkFOR
1632 TopTools_ListOfShape lfcFk; FDSCNX_FaceEdgeConnexFaces(FOR,Esd,HDS,lfcFk);
1633 if (lfcFk.Extent() != 1) return; // shape bizarre
1634 Standard_Real parEsd; ok = FUN_tool_parE(eON,parON,Esd,parEsd,tolEG);
1636 const TopoDS_Face& OOFOR = TopoDS::Face(lfcFk.First());
1637 gp_Pnt2d uv; Standard_Real dummy=0;
1638 ok = FUN_tool_paronEF(Esd,parEsd,OOFOR,uv,dummy); //rkEsd=rkOOFOR
1639 gp_Vec ntOOFOR = FUN_tool_nggeomF(uv,OOFOR);
1640 if (OOFOR.Orientation() == TopAbs_REVERSED) ntOOFOR.Reverse();
1643 // Standard_Real t1 =factor*BRep_Tool::Tolerance(Esd);
1645 Standard_Real parEG; ok = FUN_tool_parE(Esd,parEsd,EG,parEG);
1647 gp_Dir xxFCX; ok = FUN_tool_getxx(FCX,EG,parEG,xxFCX);
1650 Standard_Real dot = ntOOFOR.Dot(xxFCX);
1651 if (Abs(dot) < tola) binou = Standard_True;// nyixpu181198
1652 else if (dot < 0.) binou = Standard_False;
1660 TopAbs_State TBEG = TB1;
1661 neworiE = TFE.Orientation(TBEG);
1662 if (FCXisref && !EGBoundFOR) {
1663 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1664 Standard_Boolean rev = myPB->Reverse(staFCX,staFOR);
1665 neworiE = myPB->Orient(neworiE,rev);
1667 else if (FORisref && !EGBoundFOR) {
1668 // xpu280798 : cto902C1 (FOR=f9,FCX=f19,FS,f33,EG,e18)
1669 // as eghassdON : Esd = edge(Iesd) = bound FOR; eON is IN1d(Esd)
1670 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1671 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1672 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1673 if (reverse) neworiE = TopAbs::Complement(neworiE);
1674 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1675 neworiE = myPB->Orient(neworiE,rev);
1677 else if (!EGBoundFOR) {
1678 // xpu210898 : CTS20875 : yap6(FOR13,GI15,FCX6), !FCXisref && !FORisref
1679 Standard_Integer rankrefFOR = BDS.AncestorRank(irefFOR);
1680 if (rankrefFOR == rankFCX)
1681 FUN_tool_orientEinFFORWARD(EG,FCX,neworiE);
1682 else if (rankrefFOR == rankFOR) {
1683 const TopoDS_Edge& Esd = TopoDS::Edge(BDS.Shape(Iesd));
1684 FUN_tool_orientEinFFORWARD(Esd,TopoDS::Face(FOR),neworiE);
1685 Standard_Boolean reverse = (M_FORWARD(neworiE) || M_REVERSED(neworiE)) && (!eONsoEsd);
1686 if (reverse) neworiE = TopAbs::Complement(neworiE);
1688 Standard_Boolean rev = myPB->Reverse(staFOR,staFCX);
1689 neworiE = myPB->Orient(neworiE,rev);
1692 TopoDS_Shape newE = EspON;
1693 newE.Orientation(neworiE);
1695 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap6 GFillON","WES+ EspON ");
1696 if (tE) FUN_cout(newE);
1698 myPWES->AddStartElement(newE);
1700 // xpu290798 : cto 902 C1, f9ou,f19in, spON(e7) = spON(e18)
1701 // splits IN and OUT generated on reference surface should be diff oriented
1702 // they share same edge eON which is FORWARD in one, REVERSED in the other
1703 Standard_Boolean addtwice = SO && !shareG && opeCut;
1704 addtwice = addtwice && (M_FORWARD(neworiE) || M_REVERSED(neworiE));
1707 TopoDS_Shape FtospIN = (TBFOR == TopAbs_IN) ? FOR : FCX;
1708 addtwice = Standard_False;
1710 for (ex.Init(FtospIN,TopAbs_EDGE); ex.More(); ex.Next()){
1711 // for (TopExp_Explorer ex(FtospIN,TopAbs_EDGE); ex.More(); ex.Next()){
1712 const TopoDS_Shape& ee = ex.Current();
1713 if (!BDS.HasShape(ee)) continue;
1714 Standard_Boolean issp = myPB->IsSplit(ee,TopAbs_IN);
1715 if (issp) addtwice = !myPB->Splits(ee,TopAbs_IN).IsEmpty();
1716 if (addtwice) break;
1720 neworiE = TopAbs::Complement(neworiE);
1721 newE.Orientation(neworiE);
1723 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap6 GFillON","WES+ EspON ");
1724 if (tE) FUN_cout(newE);
1726 myPWES->AddStartElement(newE);
1731 //=========================================
1734 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap3 GFillON");
1735 if (tE) {cout<<"yap3(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1736 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1739 ie3d = ::FUN_findeSD(BDS,eON,EG,FOR,oe3d,3);
1740 if (ie3d == 0) return;
1741 const TopoDS_Edge& e3d = TopoDS::Edge(BDS.Shape(ie3d));
1743 TopOpeBRepDS_Config cf; Standard_Boolean cfok = FDS_Config3d(EspON,e3d,cf);
1746 TopAbs_Orientation oe3dk = oe3d;
1747 // Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(EG,e3d);
1748 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1749 if (!ok) return; //nyiRAISE
1750 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,e3d,samegeom);
1751 if (!ok) return; //nyiRAISE
1753 if (!TopOpeBRepBuild_GetcontextNOSG()) {
1755 if (!samegeom) oe3dk = TopAbs::Complement(oe3dk);
1760 Standard_Boolean keep3d = Standard_False;
1761 // l'etat a construire sur FOR est TB1,
1762 if (oe3dk == TopAbs_FORWARD) keep3d = (TFEaft == TB1);
1763 else if (oe3dk == TopAbs_REVERSED) keep3d = (TFEbef == TB1);
1764 else if (oe3dk == TopAbs_INTERNAL) keep3d = Standard_True;
1765 else if (oe3dk == TopAbs_EXTERNAL) keep3d = Standard_False;
1768 if(tEFOR) {cout<<endl<<"yap3 keep3d : "<<keep3d<<endl;debfillonfemess3d(iFOR,iEG);}
1772 TopAbs_Orientation neworiE = oe3d;
1773 if (cf == TopOpeBRepDS_DIFFORIENTED) neworiE = TopAbs::Complement(neworiE);
1774 TopoDS_Shape newE = EspON;
1775 newE.Orientation(neworiE);
1778 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap3 GFillON","WES+ EspON ");
1779 if (tE) FUN_cout(newE);
1781 myPWES->AddStartElement(newE);
1787 //=========================================
1790 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap5 GFillON");
1791 if (tE) {cout<<"yap5(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1792 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1794 ie2d = ::FUN_findeSD(BDS,eON,EG,FOR,oe2d,2);
1795 if (ie2d == 0) return;
1797 const TopoDS_Edge& e2d = TopoDS::Edge(BDS.Shape(ie2d));
1798 TopOpeBRepDS_Config cf; Standard_Boolean cfok = FDS_Config3d(EspON,e2d,cf);
1801 TopAbs_Orientation oe2dk = oe2d;
1802 Standard_Real parEG; Standard_Boolean ok = FUN_tool_parE(eON,parON,EG,parEG,tolEG);
1803 if (!ok) return; // nyiRAISE
1804 Standard_Boolean samegeom; ok = FUN_tool_curvesSO(EG,parEG,e2d,samegeom);
1805 if (!ok) return; // nyiRAISE
1807 if (!TopOpeBRepBuild_GetcontextNOSG()) {
1809 if (!samegeom) oe2dk = TopAbs::Complement(oe2dk);
1814 Standard_Boolean keep2d = Standard_False;
1815 // l'etat a construire sur FOR est TB1,
1816 if (oe2dk == TopAbs_FORWARD) keep2d = (TFEaft == TB1);
1817 else if (oe2dk == TopAbs_REVERSED) keep2d = (TFEbef == TB1);
1818 else if (oe2dk == TopAbs_INTERNAL) keep2d = Standard_True;
1819 else if (oe2dk == TopAbs_EXTERNAL) keep2d = Standard_False;
1822 TopAbs_Orientation neworiE = oe2d;
1823 if (cf == TopOpeBRepDS_DIFFORIENTED) neworiE = TopAbs::Complement(neworiE);
1824 TopoDS_Shape newE = EspON;
1825 newE.Orientation(neworiE);
1828 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap5 GFillON","WES+ EspON ");
1829 if (tE) FUN_cout(newE);
1831 myPWES->AddStartElement(newE);
1837 //=========================================
1840 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap4 GFillON");
1841 if (tE) {cout<<"yap4(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1842 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1845 TopAbs_Orientation oTFE = TFE.Orientation(TB1);
1847 TopAbs_Orientation neworiE = oTFE;
1848 TopoDS_Shape newE = EspON;
1849 newE.Orientation(neworiE);
1851 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap4 GFillON","WES+ EspON ");
1852 if (tE) FUN_cout(newE);
1854 myPWES->AddStartElement(newE);
1859 //=========================================
1861 // xpu290598 : CTS20212
1863 if (tEFOR) debfillonfemess(iFOR,iEG,myPB,myPWES,"yap7 GFillON");
1864 if (tE) {cout<<"yap7(FOR"<<iFOR<<" FCX"<<iFCX<<" EG"<<GI<<") ";
1865 cout<<"TB1=";TopAbs::Print(TB1,cout);cout<<" TB2=";TopAbs::Print(TB2,cout);cout<<endl;}
1867 Standard_Boolean isbound = Standard_False;
1868 for (TopTools_ListIteratorOfListOfShape it(BDS.ShapeSameDomain(iFOR)); it.More(); it.Next()){
1869 TopExp_Explorer ex(it.Value(), TopAbs_EDGE);
1870 for (; ex.More(); ex.Next()) {
1871 const TopoDS_Shape& E = ex.Current();
1873 isbound = Standard_True;
1878 TopAbs_Orientation oTFE = TFE.Orientation(TB1);
1879 TopAbs_Orientation neworiE = oTFE;
1881 if (ComOfCut) { //CTS20212 : tspIN(f7),tspON(e4)
1883 if (!isbound) return;
1887 //CTS20212 : tspIN(f7),tspON(e5)
1888 Standard_Boolean samegeomref = Standard_False;
1890 samegeomref = Standard_True;
1893 samegeomref = (cFOR == TopOpeBRepDS_SAMEORIENTED);
1894 if (oFOR != orefFOR) samegeomref = !samegeomref;
1896 if (!samegeomref) neworiE = TopAbs::Complement(neworiE);
1898 TopoDS_Shape newE = EspON;
1899 newE.Orientation(neworiE);
1901 if (tEFOR) debaddpwes(iFOR,TB1,iEG,neworiE,myPB,myPWES,"yap7 GFillON","WES+ EspON ");
1902 if (tE) FUN_cout(newE);
1904 myPWES->AddStartElement(newE);
1909 } // GFillONPartsWES2