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