1 // Created on: 1999-09-29
2 // Created by: Maxim ZVEREV
3 // Copyright (c) 1999-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 <BRepTopAdaptor_FClass2d.hxx>
21 #include <Geom2d_Curve.hxx>
22 #include <Geom2dAPI_ProjectPointOnCurve.hxx>
23 #include <TColStd_MapOfInteger.hxx>
24 #include <TopAbs_Orientation.hxx>
25 #include <TopAbs_ShapeEnum.hxx>
28 #include <TopoDS_Edge.hxx>
29 #include <TopoDS_Face.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopOpeBRepBuild_Builder1.hxx>
32 #include <TopOpeBRepBuild_GTopo.hxx>
33 #include <TopOpeBRepBuild_HBuilder.hxx>
34 #include <TopOpeBRepBuild_PaveSet.hxx>
35 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
36 #include <TopOpeBRepBuild_Tools.hxx>
37 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
38 #include <TopOpeBRepDS_BuildTool.hxx>
39 #include <TopOpeBRepDS_EXPORT.hxx>
40 #include <TopOpeBRepDS_HDataStructure.hxx>
41 #include <TopOpeBRepDS_Interference.hxx>
42 #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
43 #include <TopOpeBRepDS_ListOfInterference.hxx>
44 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
45 #include <TopOpeBRepDS_ShapeWithState.hxx>
46 #include <TopOpeBRepDS_Transition.hxx>
47 #include <TopOpeBRepTool_2d.hxx>
48 #include <TopOpeBRepTool_ShapeExplorer.hxx>
50 //define parameter division number as 10*e^(-PI) = 0.43213918
51 const Standard_Real PAR_T = 0.43213918;
53 static TopTools_IndexedMapOfShape mySDEdgeMap;
55 static TopAbs_State ClassifyEdgeToFaceByOnePoint(const TopoDS_Edge& E,
56 const TopoDS_Face& F);
58 //modified by NIZHNY-MZV Thu Apr 20 09:58:59 2000
60 //this variable used to separate old algo from the new one
61 //because new algo can not be used in LocOpe and Mechanical Features (for the moment)
62 //that's why we use new algo only in BRepAlgoAPI_BooleanOperation
63 //in all other cases old algo is called (see the methods GFillSolidSFS, GFillShellSFS, etc.);
64 Standard_Boolean GLOBAL_USE_NEW_BUILDER = Standard_False;
66 //=======================================================================
67 //function : Constructor
69 //=======================================================================
70 TopOpeBRepBuild_Builder1::TopOpeBRepBuild_Builder1(const TopOpeBRepDS_BuildTool& BT)
71 : TopOpeBRepBuild_Builder(BT)
74 myMapOfEdgeFaces.Clear();
75 mySplitsONtoKeep.Clear();
76 myProcessedPartsOut2d.Clear();
77 myProcessedPartsON2d.Clear();
80 //modified by NIZNHY-PKV Mon Dec 16 11:37:59 2002 f
82 //=======================================================================
85 //=======================================================================
86 void TopOpeBRepBuild_Builder1::Destroy()
90 //modified by NIZNHY-PKV Mon Dec 16 11:38:05 2002 t
91 //=======================================================================
94 //=======================================================================
95 void TopOpeBRepBuild_Builder1::Clear()
97 TopOpeBRepBuild_Builder::Clear();
99 // mySameDomMap.Clear();
100 // myMapOfEdgeFaces.Clear();
101 // mySplitsONtoKeep.Clear();
102 // myProcessedPartsOut2d.Clear();
103 // myProcessedPartsON2d.Clear();
104 // myDataStructure -> ChangeDS().ChangeMapOfShapeWithStateObj().Clear();
105 // myDataStructure -> ChangeDS().ChangeMapOfShapeWithStateTool().Clear();
109 //=======================================================================
112 //=======================================================================
113 void TopOpeBRepBuild_Builder1::Perform(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
115 TopOpeBRepBuild_Builder::Perform(HDS);
118 //=======================================================================
121 //=======================================================================
122 void TopOpeBRepBuild_Builder1::Perform(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
123 const TopoDS_Shape& S1,
124 const TopoDS_Shape& S2)
126 //modified by NIZHNY-MZV Wed Apr 19 17:23:12 2000
127 //see the comments at the top of file about this global variable
128 if(!GLOBAL_USE_NEW_BUILDER) {
129 TopOpeBRepBuild_Builder::Perform(HDS, S1, S2);
134 mySameDomMap.Clear();
135 myMapOfEdgeFaces.Clear();
136 mySplitsONtoKeep.Clear();
137 myProcessedPartsOut2d.Clear();
138 myProcessedPartsON2d.Clear();
140 myShape1 = S1; myShape2 = S2;
143 myIsKPart = FindIsKPart();
144 if((myIsKPart == 1) || (myIsKPart == 5))
148 // For the moment States will be calculated in case SOLID/SOLID only
149 PerformShapeWithStates();
153 //=======================================================================
154 //function : MergeKPart
156 //=======================================================================
157 void TopOpeBRepBuild_Builder1::MergeKPart(const TopAbs_State TB1,
158 const TopAbs_State TB2)
160 TopOpeBRepBuild_Builder::MergeKPart(TB1, TB2);
163 //=======================================================================
164 //function : MergeKPart
166 //=======================================================================
167 void TopOpeBRepBuild_Builder1::MergeKPart()
169 if ( myIsKPart == 1 ) { // iskole
172 else if ( myIsKPart == 5 ) { // iskoletge
173 MergeKPartiskoletge();
175 else if (myIsKPart == 2) { // isdisj
178 else if ( myIsKPart == 3 ) { // isfafa
181 else if ( myIsKPart == 4 ) { // issoso
184 TopTools_ListIteratorOfListOfShape its(Merged(myShape1,myState1));
185 for (; its.More(); its.Next()) {
186 CorrectResult2d(its.Value());
194 //=======================================================================
195 //function : GFillSolidSFS
197 //=======================================================================
198 void TopOpeBRepBuild_Builder1::GFillSolidSFS(const TopoDS_Shape& SO1,
199 const TopTools_ListOfShape& LSO2,
200 const TopOpeBRepBuild_GTopo& G1,
201 TopOpeBRepBuild_ShellFaceSet& SFS)
203 //modified by NIZHNY-MZV Wed Apr 19 17:23:12 2000
204 //see the comments at the top of file about this global variable
205 if(!GLOBAL_USE_NEW_BUILDER) {
206 TopOpeBRepBuild_Builder::GFillSolidSFS(SO1, LSO2, G1, SFS);
210 myMapOfEdgeFaces.Clear();
212 TopExp::MapShapesAndAncestors(myShape1, TopAbs_EDGE, TopAbs_FACE, myMapOfEdgeFaces);
213 TopExp::MapShapesAndAncestors(myShape2, TopAbs_EDGE, TopAbs_FACE, myMapOfEdgeFaces);
215 TopAbs_State TB1,TB2;
216 G1.StatesON(TB1,TB2);
218 // printf("TB1 =%d, TB2 = %d\n", TB1, TB2);
220 Standard_Boolean RevOri1 = G1.IsToReverse1();
222 TopoDS_Shape SOF = SO1;
223 mySolidToFill = TopoDS::Solid(SOF);
225 TopOpeBRepTool_ShapeExplorer exShell(SOF,TopAbs_SHELL);
226 for (; exShell.More(); exShell.Next()) {
227 TopoDS_Shape SH = exShell.Current();
228 Standard_Boolean hasshape = myDataStructure->HasShape(SH);
231 // shell SH is not in DS : Get its state (to the LS02) from map and define to keep or not
232 TopAbs_State shSt = myDataStructure -> DS().GetShapeWithState(SH).State();
233 Standard_Boolean keep = (shSt == TB1) ? Standard_True : Standard_False;
235 TopAbs_Orientation oriSH = SH.Orientation();
236 TopAbs_Orientation neworiSH = Orient(oriSH,RevOri1);
237 SH.Orientation(neworiSH);
242 else { // shell SH has faces(s) with geometry : split SH faces
243 GFillShellSFS(SH,LSO2,G1,SFS);
248 //=======================================================================
249 //function : GFillShellSFS
251 //=======================================================================
252 void TopOpeBRepBuild_Builder1::GFillShellSFS (const TopoDS_Shape& SH,
253 const TopTools_ListOfShape& LSO2,
254 const TopOpeBRepBuild_GTopo& G1,
255 TopOpeBRepBuild_ShellFaceSet& SFS)
257 //modified by NIZHNY-MZV Wed Apr 19 17:23:12 2000
258 //see the comments at the top of file about this global variable
259 if(!GLOBAL_USE_NEW_BUILDER) {
260 TopOpeBRepBuild_Builder::GFillShellSFS(SH, LSO2, G1, SFS);
264 TopAbs_State TB1,TB2;
265 G1.StatesON(TB1,TB2);
266 Standard_Boolean RevOri1 = G1.IsToReverse1();
268 TopOpeBRepTool_ShapeExplorer exFace;
270 TopoDS_Shape SH1 = SH;// SH1.Orientation(TopAbs_FORWARD);
272 //1) process firstly same domain faces and non-interference faces
273 for (exFace.Init(SH1,TopAbs_FACE); exFace.More(); exFace.Next()) {
274 TopoDS_Shape FOR = exFace.Current();
275 if(!myDataStructure -> HasShape(FOR)) {
276 //DS doesn't contain FACE , get its state and define to keep or not
277 TopAbs_State shSt = myDataStructure -> DS().GetShapeWithState(FOR).State();
278 Standard_Boolean keep = (shSt == TB1) ? Standard_True : Standard_False;
280 TopAbs_Orientation oriF = FOR.Orientation();
281 TopAbs_Orientation neworiF = Orient(oriF,RevOri1);
282 FOR.Orientation(neworiF);
287 Standard_Boolean hsd = myDataStructure->HasSameDomain(FOR);
288 if ( hsd && !mySameDomMap.Contains(FOR))
289 GFillFaceSameDomSFS(FOR,LSO2,G1,SFS);
292 //2 Process all other faces
293 for (exFace.Init(SH1,TopAbs_FACE); exFace.More(); exFace.Next()) {
294 TopoDS_Shape FOR = exFace.Current();
295 if(!myDataStructure -> HasShape(FOR)
297 myDataStructure->HasSameDomain(FOR))
299 GFillFaceNotSameDomSFS(FOR, LSO2, G1, SFS);
303 //=======================================================================
304 //function : GFillFaceNotSameDomSFS
306 //=======================================================================
307 void TopOpeBRepBuild_Builder1::GFillFaceNotSameDomSFS(const TopoDS_Shape& FOR,
308 const TopTools_ListOfShape& LSO2,
309 const TopOpeBRepBuild_GTopo& Gin,
310 TopOpeBRepBuild_ShellFaceSet& SFS)
312 TopOpeBRepBuild_GTopo G1 = Gin;
313 Standard_Boolean RevOri = Standard_False;
314 G1.SetReverse(RevOri);
316 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
318 // work on a FORWARD face <FForward>
319 TopoDS_Shape FF = FOR; FF.Orientation(TopAbs_FORWARD);
321 // make a WireEdgeSet WES on face FF
322 TopOpeBRepBuild_WireEdgeSet WES(FF,this);
324 // Add ON parts (edges ON solid)
325 GFillONPartsWES(FOR,G1,LSO2,WES);
328 TopTools_ListOfShape anEdgesON;
329 TopTools_ListIteratorOfListOfShape it;
331 Standard_Boolean toRevOri = Opefus();
332 for (it.Initialize(WES.StartElements()); it.More(); it.Next())
333 anEdgesON.Append(toRevOri ? it.Value().Reversed() : it.Value());
337 // split the edges of FF : add split edges to WES
338 GFillFaceNotSameDomWES(FF,LSO2,G1,WES);
340 // add edges built on curves supported by FF
341 GFillCurveTopologyWES(FF,G1,WES);
345 // mark FF as split TB1
348 // build the new faces LOF on FF from the Wire/Edge set WES
349 TopTools_ListOfShape LOF;
350 GWESMakeFaces(FF,WES,LOF);
352 if (myProcessON && (!anEdgesON.IsEmpty() || !myONElemMap.IsEmpty())) {
353 // try to make patches with only ON parts.
354 // prepare the map of used edges to not take the same matter two times
355 TopTools_IndexedMapOfOrientedShape aMapOE;
356 for (it.Initialize(LOF); it.More(); it.Next())
357 for (TopExp_Explorer ex(it.Value(),TopAbs_EDGE); ex.More(); ex.Next())
358 aMapOE.Add(ex.Current());
360 FillOnPatches(anEdgesON,FOR,aMapOE);
364 // LOFS : LOF faces located TB1 / LSclass = split faces of state TB1 of FF
365 TopTools_ListOfShape& LOFS = ChangeSplit(FF,TB1);
367 GKeepShapes(FF,myEmptyShapeList,TB1,LOF,LOFS);
369 GSplitFaceSFS(FOR, LSO2, Gin, SFS);
372 //=======================================================================
373 //function : GFillFaceNotSameDomWES
375 //=======================================================================
376 void TopOpeBRepBuild_Builder1::GFillFaceNotSameDomWES(const TopoDS_Shape& FOR1,
377 const TopTools_ListOfShape& LFclass,
378 const TopOpeBRepBuild_GTopo& G1,
379 TopOpeBRepBuild_WireEdgeSet& WES)
381 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
382 Standard_Boolean RevOri1 = G1.IsToReverse1();
384 mySourceShapes.Clear();
386 // work on a FORWARD face FF
387 TopoDS_Shape FF = FOR1; FF.Orientation(TopAbs_FORWARD);
389 TopOpeBRepTool_ShapeExplorer exWire(FF,TopAbs_WIRE);
390 for (; exWire.More(); exWire.Next()) {
391 TopoDS_Shape W = exWire.Current();
392 Standard_Boolean hasshape = myDataStructure->HasShape(W);
395 // wire W is not in DS : get its state and define to keep or not
396 TopAbs_State shSt = myDataStructure -> DS().GetShapeWithState(W).State();
397 Standard_Boolean keep = (shSt == TB1) ? Standard_True : Standard_False;
398 if (keep || (myProcessON && shSt == TopAbs_ON)) {
399 TopAbs_Orientation oriW = W.Orientation();
400 TopAbs_Orientation neworiW = Orient(oriW,RevOri1);
401 W.Orientation(neworiW);
402 if (keep) WES.AddShape(W);
403 else myONElemMap.Add(W);
404 mySourceShapes.Add(W);
407 else { // wire W has edges(s) with geometry : split W edges
408 GFillWireNotSameDomWES(W,LFclass,G1,WES);
414 //=======================================================================
415 //function : GFillWireNotSameDomWES
417 //=======================================================================
418 void TopOpeBRepBuild_Builder1::GFillWireNotSameDomWES(const TopoDS_Shape& W,
419 const TopTools_ListOfShape& LSclass,
420 const TopOpeBRepBuild_GTopo& G1,
421 TopOpeBRepBuild_WireEdgeSet& WES)
423 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
424 Standard_Boolean RevOri1 = G1.IsToReverse1();
426 TopoDS_Shape WW = W; //WW.Orientation(TopAbs_FORWARD);
428 TopOpeBRepTool_ShapeExplorer exEdge(WW,TopAbs_EDGE);
429 for (; exEdge.More(); exEdge.Next()) {
430 TopoDS_Shape EOR = exEdge.Current();
431 Standard_Boolean hasshape = myDataStructure->HasShape(EOR);
434 // edge EOR is not in DS : get its state and define to keep or not
435 TopAbs_State shSt = myDataStructure -> DS().GetShapeWithState(EOR).State();
436 Standard_Boolean keep = (shSt == TB1) ? Standard_True : Standard_False;
437 if (keep || (myProcessON && shSt == TopAbs_ON)) {
438 TopAbs_Orientation oriE = EOR.Orientation();
439 TopAbs_Orientation neworiE = Orient(oriE,RevOri1);
440 EOR.Orientation(neworiE);
441 if (keep) WES.AddElement(EOR);
442 else myONElemMap.Add(EOR);
443 mySourceShapes.Add(EOR);
446 else { // wire W has edges(s) with geometry : split W edges
447 GFillEdgeNotSameDomWES(EOR,LSclass,G1,WES);
453 //=======================================================================
454 //function : GFillEdgeNotSameDomWES
456 //=======================================================================
457 void TopOpeBRepBuild_Builder1::GFillEdgeNotSameDomWES(const TopoDS_Shape& EOR,
458 const TopTools_ListOfShape& /*LSclass*/,
459 const TopOpeBRepBuild_GTopo& G1,
460 TopOpeBRepBuild_WireEdgeSet& WES)
462 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
463 Standard_Boolean RevOri1 = G1.IsToReverse1();
467 TopAbs_Orientation oriE = EOR.Orientation();
468 TopAbs_Orientation neworiE = Orient(oriE,RevOri1);
469 //1) Get split parts of edge with state TB1
470 const TopTools_ListOfShape& LSE = myDataStructure -> DS().GetShapeWithState(EOR).Part(TB1);
471 TopTools_ListIteratorOfListOfShape it (LSE);
473 for(; it.More(); it.Next()) {
474 TopoDS_Edge newE = TopoDS::Edge(it.Value());
475 newE.Orientation(neworiE);
476 WES.AddStartElement(newE);
477 mySourceShapes.Add(newE);
480 //2) Get ON parts of the edge and define to keep it or not
481 const TopTools_ListOfShape& LSEOn = myDataStructure -> DS().GetShapeWithState(EOR).Part(TopAbs_ON);
482 TopTools_ListIteratorOfListOfShape itON (LSEOn);
483 for(; itON.More(); itON.Next()) {
484 TopoDS_Edge newE = TopoDS::Edge(itON.Value());
485 newE.Orientation(neworiE);
486 if(mySplitsONtoKeep.Contains(newE)) {
487 WES.AddStartElement(newE);
490 // we keep all degenerated edges here because FillONPartsWES can not process them
491 if(BRep_Tool::Degenerated(newE)) {
492 WES.AddStartElement(newE);
493 mySourceShapes.Add(newE);
496 myONElemMap.Add(newE);
497 mySourceShapes.Add(newE);
503 /////////////////// ALL FUNCTIONS FOR SAME DOMAIN FACES
504 //=======================================================================
505 //function : GFillFaceSameDomSFS
507 //=======================================================================
508 void TopOpeBRepBuild_Builder1::GFillFaceSameDomSFS(const TopoDS_Shape& FOR,
509 const TopTools_ListOfShape& LSO2,
510 const TopOpeBRepBuild_GTopo& Gin,
511 TopOpeBRepBuild_ShellFaceSet& SFS)
513 myProcessedPartsOut2d.Clear();
514 myProcessedPartsON2d.Clear();
515 myMapOfEdgeWithFaceState.Clear();
517 mySourceShapes.Clear();
519 //we process all same domain faces during cycling throught the Shape1
520 if(myDataStructure -> DS().AncestorRank(FOR) != 1)
523 TopOpeBRepBuild_GTopo G1 = Gin;
525 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
527 // work on a FORWARD face <FForward>
528 TopoDS_Shape FF = FOR; FF.Orientation(TopAbs_FORWARD);
530 // make a WireEdgeSet WES on face FF
531 TopOpeBRepBuild_WireEdgeSet WES(FF,this);
533 // split the edges of FF : add split edges to WES
534 GFillFaceSameDomWES(FOR,LSO2,G1,WES);
538 // mark FF as split TB1
541 // build the new faces LOF on FF from the Wire/Edge set WES
542 TopTools_ListOfShape LOF, oriLOF;
543 GWESMakeFaces(FF,WES,LOF);
545 // LOFS : LOF faces located TB1 / LSclass = split faces of state TB1 of FF
546 TopTools_ListOfShape& LOFS = ChangeSplit(FF,TB1);
548 //orientate new faces by the right way
549 Standard_Boolean OrigRev = (FOR.Orientation() == TopAbs_FORWARD ? Standard_False : Standard_True);
550 TopTools_ListIteratorOfListOfShape LOFit(LOF);
551 for(; LOFit.More(); LOFit.Next()) {
552 TopoDS_Shape aFace = LOFit.Value();
553 TopTools_IndexedMapOfShape aEM;
554 TopExp::MapShapes(aFace, TopAbs_EDGE, aEM);
555 Standard_Boolean rev = Standard_False;
556 for(Standard_Integer i = 1; i <= aEM.Extent(); i++) {
557 const TopoDS_Shape& anEdge = aEM(i);
558 if (myMapOfEdgeWithFaceState.Find (anEdge, rev)) {
568 oriLOF.Append(aFace);
569 SFS.AddStartElement(aFace);
573 GKeepShapes(FF,myEmptyShapeList,TB1,oriLOF,LOFS);
576 //=======================================================================
577 //function : GFillFaceSameDomWES
579 //=======================================================================
580 void TopOpeBRepBuild_Builder1::GFillFaceSameDomWES(const TopoDS_Shape& FOR1,
581 const TopTools_ListOfShape& /*LFclass*/,
582 const TopOpeBRepBuild_GTopo& G1,
583 TopOpeBRepBuild_WireEdgeSet& WES)
585 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
587 myBaseFaceToFill = TopoDS::Face(FOR1);
589 TopTools_IndexedMapOfShape curSameDomMap;
590 curSameDomMap.Add(FOR1);
592 Standard_Integer i, nF;
593 for(i = 1; i <= curSameDomMap.Extent(); i++) {
594 TopTools_ListIteratorOfListOfShape it = myDataStructure -> SameDomain(curSameDomMap(i));
595 for(; it.More(); it.Next()) {
596 const TopoDS_Shape& SDF = it.Value();
597 curSameDomMap.Add(SDF);
598 mySameDomMap.Add(SDF);
600 TopExp::MapShapes(SDF, TopAbs_EDGE, mySDEdgeMap);
604 nF = curSameDomMap.Extent();
605 for(i = 1; i<= nF; i++) {
606 TopoDS_Shape curF = curSameDomMap(i);
608 TopoDS_Shape curFF = curF;
609 curFF.Orientation(TopAbs_FORWARD);
611 mySDFaceToFill = TopoDS::Face(curF);
612 Standard_Integer iref = myDataStructure -> DS().AncestorRank(curFF);
615 Standard_Boolean RevOri = Standard_False;
616 TopOpeBRepBuild_GTopo GFTW = G1;
617 if(iref == 1) {//object
619 RevOri = G1.IsToReverse1();
622 RevOri = G1.IsToReverse2();
625 GFTW = G1.CopyPermuted();
627 //we need to pass GTopo according to ancestor rank
628 GFillCurveTopologyWES(curFF,GFTW,WES);
630 //process ON parts from not SD faces
631 PerformONParts(curFF, curSameDomMap, G1, WES);
633 const TopTools_ListOfShape& LSF = myDataStructure -> DS().ShapeSameDomain(curFF);
635 TopOpeBRepTool_ShapeExplorer exWire(curFF,TopAbs_WIRE);
636 for (; exWire.More(); exWire.Next()) {
637 TopoDS_Shape W = exWire.Current();
638 Standard_Boolean hasshape = myDataStructure->HasShape(W);
639 TopAbs_State shSt = myDataStructure -> DS().GetShapeWithState(W).State();
641 if ( ! hasshape && (shSt != TopAbs_ON)) {
642 // wire W is not in DS : get its state and define to keep or not
643 Standard_Boolean keep = (shSt == TB) ? Standard_True : Standard_False;
645 TopAbs_Orientation oriW = W.Orientation();
646 TopAbs_Orientation neworiW = Orient(oriW,RevOri);
648 if(myBaseFaceToFill != mySDFaceToFill)
649 TopOpeBRepBuild_Tools::UpdatePCurves(TopoDS::Wire(W),
650 TopoDS::Face(mySDFaceToFill),
651 TopoDS::Face(myBaseFaceToFill));
653 mySourceShapes.Add(W);
656 TopExp_Explorer we(W, TopAbs_EDGE);
657 Standard_Boolean stateOfFaceOri = Standard_False;
658 Standard_Boolean UseEdges = Standard_False;
659 for(; we.More(); we.Next()) {
660 TopoDS_Edge EOR = TopoDS::Edge(we.Current());
662 TopAbs_Orientation oldori = EOR.Orientation();
663 OrientateEdgeOnFace(EOR,TopoDS::Face(myBaseFaceToFill),
664 TopoDS::Face(mySDFaceToFill), G1, stateOfFaceOri);
666 // OrientateEdgeOnFace(TopoDS::Edge(EOR), TopoDS::Face(myBaseFaceToFill),
667 // TopoDS::Face(mySDFaceToFill), G1, stateOfFaceOri);
668 if(EOR.Orientation() != oldori) {
669 UseEdges = Standard_True;
670 WES.AddStartElement(EOR);
673 myMapOfEdgeWithFaceState.Bind (EOR, stateOfFaceOri);
677 W.Orientation(neworiW);
682 else { // wire W has edges(s) with geometry : split W edges
683 GFillWireSameDomWES(W, LSF,G1,WES);
690 //=======================================================================
691 //function : GFillWireSameDomWES
693 //=======================================================================
694 void TopOpeBRepBuild_Builder1::GFillWireSameDomWES(const TopoDS_Shape& W,
695 const TopTools_ListOfShape& LSclass,
696 const TopOpeBRepBuild_GTopo& G1,
697 TopOpeBRepBuild_WireEdgeSet& WES)
699 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
701 TopoDS_Shape WW = W; //WW.Orientation(TopAbs_FORWARD);
703 Standard_Integer iref = myDataStructure -> DS().AncestorRank(W);
705 Standard_Boolean RevOri;
707 if(iref == 1) {//object
709 RevOri = G1.IsToReverse1();
712 RevOri = G1.IsToReverse2();
717 TopOpeBRepTool_ShapeExplorer exEdge(WW,TopAbs_EDGE);
718 for (; exEdge.More(); exEdge.Next()) {
719 TopoDS_Shape EOR = exEdge.Current();
720 Standard_Boolean hasshape = myDataStructure->HasShape(EOR);
722 // edge EOR is not in DS : get its state and define to keep or not
723 TopAbs_State shSt = myDataStructure -> DS().GetShapeWithState(EOR).State();
724 Standard_Boolean keep = (shSt == TB) ? Standard_True : Standard_False;
726 TopAbs_Orientation oriE = EOR.Orientation();
729 if(mySDFaceToFill != myBaseFaceToFill) {
730 TopOpeBRepBuild_Tools::UpdateEdgeOnFace(TopoDS::Edge(EOR),
731 TopoDS::Face(mySDFaceToFill),
732 TopoDS::Face(myBaseFaceToFill));
735 mySourceShapes.Add(EOR);
738 Standard_Boolean stateOfFaceOri = Standard_False;
740 OrientateEdgeOnFace(TopoDS::Edge(EOR), TopoDS::Face(myBaseFaceToFill),
741 TopoDS::Face(mySDFaceToFill), G1, stateOfFaceOri);
742 myMapOfEdgeWithFaceState.Bind (EOR, stateOfFaceOri);
746 else { // wire W has edges(s) with geometry : split W edges
747 GFillEdgeSameDomWES(EOR,LSclass,G1,WES);
752 //=======================================================================
753 //function : GFillEdgeSameDomWES
755 //=======================================================================
756 void TopOpeBRepBuild_Builder1::GFillEdgeSameDomWES(const TopoDS_Shape& EOR,
757 const TopTools_ListOfShape& LSclass,
758 const TopOpeBRepBuild_GTopo& G1,
759 TopOpeBRepBuild_WireEdgeSet& WES)
761 TopAbs_State TB1,TB2, TB; G1.StatesON(TB1,TB2);
763 Standard_Integer iref = myDataStructure -> DS().AncestorRank(EOR);
765 Standard_Boolean RevOri;
766 if(iref == 1) {//object
768 RevOri = G1.IsToReverse1();
771 RevOri = G1.IsToReverse2();
775 TopAbs_Orientation oriE = EOR.Orientation();
778 //1) Get split parts of edge with state TB
779 const TopTools_ListOfShape& LSE = myDataStructure -> DS().GetShapeWithState(EOR).Part(TB);
780 TopTools_ListIteratorOfListOfShape it (LSE);
781 for(; it.More(); it.Next()) {
783 TopoDS_Edge newE = TopoDS::Edge(it.Value());
784 newE.Orientation(oriE);
786 if(mySDFaceToFill != myBaseFaceToFill) {
787 TopOpeBRepBuild_Tools::UpdateEdgeOnFace(newE,
788 TopoDS::Face(mySDFaceToFill),
789 TopoDS::Face(myBaseFaceToFill));
792 mySourceShapes.Add(newE);
795 Standard_Boolean stateOfFaceOri = Standard_False;
796 OrientateEdgeOnFace(newE, TopoDS::Face(myBaseFaceToFill),
797 TopoDS::Face(mySDFaceToFill), G1, stateOfFaceOri);
798 myMapOfEdgeWithFaceState.Bind (newE, stateOfFaceOri);
800 WES.AddStartElement(newE);
803 //2) Get ON parts of the edge and define to keep it or not
804 const TopTools_ListOfShape& LSEOn = myDataStructure -> DS().GetShapeWithState(EOR).Part(TopAbs_ON);
805 it.Initialize(LSEOn);
806 for(; it.More(); it.Next()) {
808 TopoDS_Edge aSplitPart = TopoDS::Edge(it.Value());
809 aSplitPart.Orientation(EOR.Orientation());
812 //do ON 2D computation
813 if(myDataStructure -> HasSameDomain(aSplitPart) || myDataStructure -> HasSameDomain(EOR)) {
814 Standard_Integer flag = 0;
815 //First of All : if SDFaceToFill is REVERSED we need to reverse aSplitPart
816 TopoDS_Shape eON = aSplitPart;
817 TopoDS_Shape nEOR = EOR;
818 if(mySDFaceToFill.Orientation() == TopAbs_REVERSED) {
822 TopTools_ListOfShape aListOfPieces, aListOfFaces, aListOfPieceOut2d;
823 //Out 2d pieces we compute only one time : for the Object
824 if(myProcessedPartsOut2d.Contains(eON))
826 flag = PerformPieceOn2D (eON, mySDFaceToFill, nEOR, aListOfPieces, aListOfFaces, aListOfPieceOut2d);
827 TopTools_ListIteratorOfListOfShape aPIt2d(aListOfPieceOut2d);
828 for(; aPIt2d.More(); aPIt2d.Next()) {
829 TopoDS_Shape aFP = aPIt2d.Value();
830 TopoDS_Shape aRP = aPIt2d.Value();
832 WES.AddStartElement(aFP);
833 WES.AddStartElement(aRP);
834 myProcessedPartsOut2d.Add(aFP);
836 TopTools_ListIteratorOfListOfShape aPIt(aListOfPieces), aFIt(aListOfFaces);
837 for(; aPIt.More(); aPIt.Next()) {
838 TopoDS_Shape aPieceToKeep = aPIt.Value();
839 const TopoDS_Shape& aPieceFace = aFIt.Value();
840 if(aPieceFace == mySDFaceToFill) {
841 Standard_Boolean IsRev = (aPieceToKeep.Orientation() == nEOR.Orientation());
843 Standard_Boolean stateOfFaceOri = Standard_False;
844 aPieceToKeep.Orientation(oriE);
845 OrientateEdgeOnFace(TopoDS::Edge(aPieceToKeep), TopoDS::Face(myBaseFaceToFill),
846 TopoDS::Face(mySDFaceToFill), G1, stateOfFaceOri);
847 //if edge was in not the right orientation we need to reverse it
849 aPieceToKeep.Reverse();
851 myMapOfEdgeWithFaceState.Bind (aPieceToKeep, stateOfFaceOri);
853 WES.AddStartElement(aPieceToKeep);
857 if(flag) //if flag == 0 we should go to the IN2D or OUT2D
861 //do IN 2D computation
862 TopoDS_Shape aSDShape;
863 TopAbs_State aState = TopAbs_UNKNOWN;
865 if(LSclass.Extent() == 1) {
866 aSDShape = LSclass.First();
867 aState = ClassifyEdgeToFaceByOnePoint(aSplitPart, TopoDS::Face(aSDShape));
869 else { //if face has more than one same domain faces we need to detect for each part complement same domain face
870 TopTools_ListIteratorOfListOfShape LSClassIt(LSclass);
871 for(; LSClassIt.More(); LSClassIt.Next()) {
872 TopoDS_Face curSD = TopoDS::Face(LSClassIt.Value());
873 aState = ClassifyEdgeToFaceByOnePoint(aSplitPart,curSD);
874 // aState = ClassifyEdgeToFaceByOnePoint(aSplitPart, TopoDS::Face(curSD));
875 if(aState == TopAbs_IN || aState == TopAbs_ON) {
882 //we should process all same domain edges (ON2D) in the code above
883 //and we can not proceess edges with UNKNOWN state
884 if(aState == TopAbs_ON || aState == TopAbs_UNKNOWN)
888 if(aState == TopAbs_OUT || aSDShape.IsNull()) {
889 //it means that SplitPart is ON
890 //comparing with myShape2 but Out of all this SD faces
891 //so we need to find adjacent faces and they also MUST be SameDomain and compute all in reverse order
893 Standard_Boolean keep = Standard_False;
895 if(aSDShape.IsNull()) {
896 aSDShape = LSclass.First();
900 TopoDS_Shape aAdjSDFace;
901 const TopTools_ListOfShape& aFEL = myMapOfEdgeFaces.FindFromKey(EOR);
902 TopTools_ListIteratorOfListOfShape aEFIt(aFEL);
903 if(aFEL.Extent() <= 2) { //we don't compute adjacent if we have more than one adjacent face
904 for(; aEFIt.More(); aEFIt.Next()) {
905 if(mySDFaceToFill.IsSame(aEFIt.Value()))
908 if(myDataStructure -> HasSameDomain(aEFIt.Value())) {
909 aAdjSDFace = aEFIt.Value();
916 if(!aAdjSDFace.IsNull()) {
917 TopTools_IndexedMapOfShape aEAdjMap;
918 TopExp::MapShapes(aAdjSDFace, TopAbs_EDGE, aEAdjMap);
920 Standard_Integer index = aEAdjMap.FindIndex(EOR);
921 TopoDS_Shape AdjEOR = aEAdjMap.FindKey(index);
923 TopTools_ListIteratorOfListOfShape it1 = myDataStructure -> SameDomain(aAdjSDFace);
924 TopoDS_Shape aSDToAdjFace = it1.Value();
926 TopoDS_Edge aSplitP = aSplitPart;
927 aSplitP.Orientation(AdjEOR.Orientation());
929 gp_Vec aTg, aN1, aN2,aN3, aBiN;
930 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(aSDToAdjFace), aSplitP, aN2);
931 if(aSDToAdjFace.Orientation() == TopAbs_REVERSED)
934 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(aAdjSDFace), aSplitP, aN3);
935 if(aAdjSDFace.Orientation() == TopAbs_REVERSED)
938 TopOpeBRepBuild_Tools::GetTangentToEdge(aSplitP, aTg);
939 if (aSplitP.Orientation() == TopAbs_REVERSED) {
945 Standard_Real scalarPr = 0.;
947 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(mySDFaceToFill), aSplitP, aN1);
948 if(mySDFaceToFill.Orientation() == TopAbs_REVERSED)
952 if (fabs (scalarPr) <= 1e-10) //try to step inside
954 TopOpeBRepBuild_Tools::GetNormalInNearestPoint (TopoDS::Face (mySDFaceToFill), aSplitP, aN1);
955 if (mySDFaceToFill.Orientation () == TopAbs_REVERSED)
960 if (fabs (scalarPr) <= 1e-10) // this can not be
962 keep = (TB == TopAbs_IN); //just to do something
966 TopAbs_State aPartState = (scalarPr > 0) ? TopAbs_IN : TopAbs_OUT;
968 keep = (aPartState == TB) ? Standard_True : Standard_False;
970 else { //if aAdjFace.IsNull() - it must not happen
971 keep = (TB == TopAbs_IN);
975 if(mySDFaceToFill != myBaseFaceToFill) {
976 TopOpeBRepBuild_Tools::UpdateEdgeOnFace(aSplitPart,
977 TopoDS::Face(mySDFaceToFill),
978 TopoDS::Face(myBaseFaceToFill));
981 mySourceShapes.Add(aSplitPart);
984 Standard_Boolean stateOfFaceOri = Standard_False;
985 OrientateEdgeOnFace(aSplitPart, TopoDS::Face(myBaseFaceToFill),
986 TopoDS::Face(mySDFaceToFill), G1, stateOfFaceOri);
987 myMapOfEdgeWithFaceState.Bind (aSplitPart, stateOfFaceOri);
989 WES.AddStartElement(aSplitPart);
996 TopoDS_Edge aSplitP = aSplitPart;
997 aSplitP.Orientation(EOR.Orientation());
998 TopoDS_Face aSDFace = TopoDS::Face(aSDShape);
1000 Standard_Boolean keep = Standard_False;
1001 PerformPieceIn2D(aSplitPart, TopoDS::Edge(EOR),
1002 TopoDS::Face(mySDFaceToFill), aSDFace, G1, keep);
1005 mySplitsONtoKeep.Add(aSplitPart);
1007 //compute orientation of the future face
1008 Standard_Boolean stateOfFaceOri = Standard_False;
1009 OrientateEdgeOnFace(aSplitPart, TopoDS::Face(myBaseFaceToFill), aSDFace, G1, stateOfFaceOri);
1010 myMapOfEdgeWithFaceState.Bind (aSplitPart, stateOfFaceOri);
1012 if(myBaseFaceToFill == mySDFaceToFill) {
1013 mySourceShapes.Add(aSplitPart);
1016 WES.AddStartElement(aSplitPart);
1021 extern Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
1023 //=======================================================================
1024 //function : PerformONParts
1026 //=======================================================================
1027 void TopOpeBRepBuild_Builder1::PerformONParts(const TopoDS_Shape& FOR1,
1028 const TopTools_IndexedMapOfShape& /*SDFaces*/,
1029 const TopOpeBRepBuild_GTopo& G1,
1030 TopOpeBRepBuild_WireEdgeSet& WES)
1032 TopAbs_State ETB1,ETB2, ETB; G1.StatesON(ETB1,ETB2);
1033 TopAbs_State FTB1,FTB2, FTB; G1.StatesON(FTB1,FTB2);
1035 Standard_Integer iref = myDataStructure -> DS().AncestorRank(FOR1);
1037 if(iref == 1) {//object
1044 //3 Process parts that can not be found on SD faces but must be included because they are ON the SD faces
1045 const TopOpeBRepDS_ListOfInterference& LI = myDataStructure -> DS().ShapeInterferences(FOR1);
1046 for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI);ILI.More();ILI.Next() ) {
1047 const Handle(TopOpeBRepDS_Interference)& I=ILI.Value();
1048 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI
1049 = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
1054 TopOpeBRepDS_Kind GT,ST;
1055 Standard_Integer GI,SI;
1056 FDS_data(SSI,GT,GI,ST,SI);
1057 if (GT != TopOpeBRepDS_EDGE || ST != TopOpeBRepDS_FACE)
1060 const TopoDS_Edge& EG=TopoDS::Edge(myDataStructure -> DS().Shape(GI, Standard_False));
1061 //we process only the edges which are not from the current SD faces
1062 if(mySDEdgeMap.Contains(EG))
1065 //take ON splits of the edge
1066 const TopTools_ListOfShape& splON = myDataStructure -> DS().GetShapeWithState(EG).Part(TopAbs_ON);
1070 const TopOpeBRepDS_Transition& aTr = SSI -> Transition();
1072 Standard_Integer irefE = myDataStructure -> DS().AncestorRank(EG);
1074 Standard_Boolean RevOriE;
1075 if(irefE == 1) {//object
1077 RevOriE = G1.IsToReverse1();
1080 RevOriE = G1.IsToReverse2();
1085 //take list of edge faces
1086 const TopTools_ListOfShape& EdgeFaces = myMapOfEdgeFaces.FindFromKey(EG);
1087 TopExp_Explorer Exp;
1089 for(TopTools_ListIteratorOfListOfShape itON(splON); itON.More(); itON.Next()) {
1090 TopoDS_Shape newE = itON.Value();
1092 TopoDS_Shape aSDShape = FOR1;
1093 TopAbs_State aState = TopAbs_UNKNOWN;
1095 aState = ClassifyEdgeToFaceByOnePoint(TopoDS::Edge(newE), TopoDS::Face(FOR1));
1096 if(!(aState == TopAbs_IN || aState == TopAbs_ON))
1099 Standard_Boolean keep = Standard_False;
1100 TopoDS_Face aSDFace = TopoDS::Face(aSDShape);
1102 TopAbs_Orientation oriE;
1103 TopAbs_Orientation neworiE;
1105 for(TopTools_ListIteratorOfListOfShape it(EdgeFaces); it.More(); it.Next()) {
1106 const TopoDS_Shape& FOR = it.Value();
1107 Exp.Init(FOR, TopAbs_EDGE);
1109 for(; Exp.More(); Exp.Next()) {
1110 EOR = Exp.Current();
1118 //else we have found a face , we process it
1119 oriE = EOR.Orientation();
1120 neworiE = Orient(oriE,RevOriE);
1122 newE.Orientation(oriE);
1123 gp_Vec aTg, aN2,aN3, aBiN;
1124 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(FOR), TopoDS::Edge(newE), aN2);
1125 if(FOR.Orientation() == TopAbs_REVERSED)
1127 TopOpeBRepBuild_Tools::GetTangentToEdge(TopoDS::Edge(newE), aTg);
1128 if (newE.Orientation() == TopAbs_REVERSED) {
1131 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(aSDFace, TopoDS::Edge(newE), aN3);
1132 if(aSDFace.Orientation() == TopAbs_REVERSED)
1134 keep = Standard_False;
1136 Standard_Real scalarPr = 0.;
1137 scalarPr = aBiN*aN3;
1139 if(fabs(scalarPr) <= 1e-10) {//try to step inside
1140 TopOpeBRepBuild_Tools::GetNormalInNearestPoint(TopoDS::Face(FOR), TopoDS::Edge(newE), aN2);
1141 if(FOR.Orientation() == TopAbs_REVERSED)
1144 scalarPr = aBiN*aN3;
1145 if(fabs(scalarPr) <= 1e-10)
1148 TopAbs_State aPartState = (scalarPr > 0) ? TopAbs_IN : TopAbs_OUT;
1149 keep = (aPartState == ETB) ? Standard_True : Standard_False;
1155 //compute orientation of the future face
1156 Standard_Boolean stateOfFaceOri = Standard_False;
1157 gp_Vec aNbf, aNsf , OrigNormalbf; //aTg, aBiN, aOut;
1158 TopoDS_Edge aLocalEdge = TopoDS::Edge(newE);
1159 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(aSDFace,aLocalEdge, aNsf);
1160 // TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(aSDFace), TopoDS::Edge(newE), aNsf);
1161 if(aSDFace.Orientation() == TopAbs_REVERSED)
1163 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(TopoDS::Face(myBaseFaceToFill), TopoDS::Edge(newE), OrigNormalbf);
1164 aNbf = OrigNormalbf;
1165 if(myBaseFaceToFill.Orientation() == TopAbs_REVERSED)
1169 stateOfFaceOri = Standard_True;
1172 if(myDataStructure -> DS().AncestorRank(aSDFace) == 2) {//for tool we need to reverse face in cut
1173 if(Opec12() || Opec21()) {
1174 stateOfFaceOri = !stateOfFaceOri;
1178 //adjust orientation of the edge
1179 neworiE = aTr.Orientation(FTB);
1180 Standard_Boolean samegeom = TopOpeBRepBuild_FUN_aresamegeom(FOR1,myBaseFaceToFill);
1182 neworiE = TopAbs::Complement(neworiE);
1184 newE.Orientation(neworiE);
1186 myMapOfEdgeWithFaceState.Bind (newE, stateOfFaceOri);
1187 WES.AddStartElement(newE);
1189 }//end iteration on splON
1190 }//end iteration of interferences
1193 //=======================================================================
1194 //function : GWESMakeFaces
1196 //=======================================================================
1197 void TopOpeBRepBuild_Builder1::GWESMakeFaces(const TopoDS_Shape& FF,
1198 TopOpeBRepBuild_WireEdgeSet& WES,
1199 TopTools_ListOfShape& LOF)
1201 TopOpeBRepBuild_Builder::GWESMakeFaces(FF, WES, LOF);
1202 TopTools_ListIteratorOfListOfShape aLOFit(LOF);
1203 TopTools_ListOfShape corrLOF;
1204 if(myIsKPart == 4) {
1205 for(; aLOFit.More(); aLOFit.Next()) {
1206 const TopoDS_Shape& ff = aLOFit.Value();
1207 TopoDS_Shape corrFF;
1208 TopOpeBRepBuild_Tools::NormalizeFace(ff, corrFF);
1209 corrLOF.Append(corrFF);
1213 corrLOF.Assign(LOF);
1215 LOF.Clear(); LOF.Assign(corrLOF);
1218 aLOFit.Initialize(corrLOF);
1219 TopTools_ListOfShape corrLOF1;
1220 for(; aLOFit.More(); aLOFit.Next()) {
1221 const TopoDS_Shape& ff = aLOFit.Value();
1222 TopoDS_Shape corrFF;
1223 TopOpeBRepBuild_Tools::CorrectFace2d(ff, corrFF, mySourceShapes, myMapOfCorrect2dEdges);
1224 corrLOF1.Append(corrFF);
1227 LOF.Clear(); LOF.Assign(corrLOF1);
1230 //=======================================================================
1231 //function : PerformPieceIN2d
1233 //=======================================================================
1234 void TopOpeBRepBuild_Builder1::PerformPieceIn2D(const TopoDS_Edge& EdgeToPerform,
1235 const TopoDS_Edge& EOR,
1236 const TopoDS_Face& edgeFace,
1237 const TopoDS_Face& toFace,
1238 const TopOpeBRepBuild_GTopo& G1,
1239 Standard_Boolean& keep)
1241 keep = Standard_False;
1243 TopAbs_State TB1,TB2, TB; G1.StatesON(TB1,TB2);
1245 Standard_Integer iref = myDataStructure -> DS().AncestorRank(EOR);
1247 TB = (iref == 1) ? TB1 : TB2;
1249 gp_Vec aTg, aN1, aN2,aN3, aBiN;
1251 TopAbs_Orientation O1 = edgeFace.Orientation();
1252 TopAbs_Orientation O2 = toFace.Orientation();
1253 TopAbs_Orientation oriE = EdgeToPerform.Orientation();
1255 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(toFace, EdgeToPerform, aN2);
1256 if(O2 == TopAbs_REVERSED)
1259 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(edgeFace, EdgeToPerform, aN3);
1260 if(O1 == TopAbs_REVERSED)
1263 TopOpeBRepBuild_Tools::GetTangentToEdge(EdgeToPerform, aTg);
1264 if (oriE == TopAbs_REVERSED)
1266 if(O1 == TopAbs_REVERSED)
1271 const TopTools_ListOfShape& aFEL = myMapOfEdgeFaces.FindFromKey(EOR);
1272 TopTools_ListIteratorOfListOfShape aEFIt(aFEL);
1273 Standard_Real scalarPr = 0.;
1275 /// Why ????? Need to be checked
1276 if(aFEL.Extent() <= 2) { //we don't compute adjacent if we have more than one adjacent face
1277 for(; aEFIt.More(); aEFIt.Next()) {
1278 if(edgeFace.IsSame(aEFIt.Value()))
1280 else { //compute bi-normal state
1281 TopoDS_Face aAdjF = TopoDS::Face(aEFIt.Value());
1282 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(aAdjF, EdgeToPerform, aN1);
1283 if(aAdjF.Orientation() == TopAbs_REVERSED)
1285 scalarPr = aBiN*aN1;
1287 if(fabs(scalarPr) <= 1e-10) { //try to step inside
1288 TopOpeBRepBuild_Tools::GetNormalInNearestPoint(aAdjF, EdgeToPerform, aN1);
1289 // TopOpeBRepBuild_Tools::GetNormalInNearestPoint(TopoDS::Face(aAdjF), EdgeToPerform, aN1);
1290 if(aAdjF.Orientation() == TopAbs_REVERSED)
1293 scalarPr = aBiN*aN1;
1294 if(fabs(scalarPr) <= 1e-10)
1298 TopAbs_State aPartState = (scalarPr > 0) ? TopAbs_IN : TopAbs_OUT;
1299 keep = (aPartState == TB) ? Standard_True : Standard_False;
1306 //if scalar can not be found that means that adjacent face doesn't exist
1307 //WARNING !!! May be this code is not good but for the moment it is only one solution
1308 if(fabs(scalarPr) <= 1e-10) {
1312 if(Opec12() || Opec21())
1319 //=======================================================================
1320 //function : PerformPieceOn2D
1322 //=======================================================================
1323 Standard_Integer TopOpeBRepBuild_Builder1::PerformPieceOn2D (const TopoDS_Shape& aPieceObj,
1324 const TopoDS_Shape& aFaceObj,
1325 const TopoDS_Shape& anEdgeObj,
1326 TopTools_ListOfShape& aListOfPieces,
1327 TopTools_ListOfShape& aListOfFaces,
1328 TopTools_ListOfShape& aListOfPiecesOut2d)
1330 // eap 30 May occ417, aCasesMap instead of aCase14 and aCase12
1331 Standard_Integer i, j, k, flag=0, priz;//, aCase14=0, aCase12=0;
1332 TColStd_MapOfInteger aCasesMap;
1334 Standard_Integer iRef = myDataStructure -> DS().AncestorRank(aFaceObj);
1336 if(!myDataStructure -> HasSameDomain(aFaceObj))
1338 // Main DataStructure
1339 TopOpeBRepDS_DataStructure& aDS= myDataStructure-> ChangeDS();
1341 // Main Map for Tool (relative Tool)
1342 TopOpeBRepDS_IndexedDataMapOfShapeWithState& aMapOfShapeWithStateTool=
1343 (iRef == 1) ? aDS.ChangeMapOfShapeWithStateTool() : aDS.ChangeMapOfShapeWithStateObj();
1344 // Loop on faces same domain to aFaceObj
1345 TopTools_ListIteratorOfListOfShape anIt(myDataStructure->SameDomain(aFaceObj));
1346 for (i=1; anIt.More(); anIt.Next(), i++) {
1347 const TopoDS_Shape& aFaceTool=anIt.Value();
1349 TopTools_IndexedMapOfShape anEdgesToolMap;
1350 TopExp::MapShapes(aFaceTool, TopAbs_EDGE, anEdgesToolMap);
1352 if(myDataStructure -> HasSameDomain(anEdgeObj)) {
1353 TopTools_ListIteratorOfListOfShape anItE=myDataStructure->SameDomain(anEdgeObj);
1354 for (j=1; anItE.More(); anItE.Next(), j++) {
1355 TopoDS_Shape anEdgeTool=anItE.Value();
1357 if (anEdgesToolMap.Contains (anEdgeTool)) {
1359 TopExp_Explorer anExpEdges;
1360 for (anExpEdges.Init (aFaceTool, TopAbs_EDGE); anExpEdges.More(); anExpEdges.Next()) {
1361 const TopoDS_Shape& anExpEdgeTool=anExpEdges.Current();
1362 if (!anExpEdgeTool.IsSame(anEdgeTool)) continue;
1364 anEdgeTool.Orientation(anExpEdgeTool.Orientation());
1366 const TopOpeBRepDS_ShapeWithState& aSWSTool=
1367 aMapOfShapeWithStateTool.FindFromKey(anEdgeTool);
1369 const TopTools_ListOfShape& aPartOnTool=aSWSTool.Part(TopAbs_ON);
1371 // we are looking for the same piece as aPieceObj among aPartOnTool
1372 TopTools_ListIteratorOfListOfShape anItTool(aPartOnTool);
1373 for (k=1; anItTool.More(); anItTool.Next(), k++) {
1374 TopoDS_Shape& aPieceTool=anItTool.Value();
1375 aPieceTool.Orientation(anEdgeTool.Orientation());
1377 Standard_Boolean aIsSameCnd, IsDegFlag;
1380 BRep_Tool::Degenerated (TopoDS::Edge(aPieceObj)) &&
1381 BRep_Tool::Degenerated (TopoDS::Edge(aPieceTool)) ;
1383 aIsSameCnd=IsDegFlag ? TopOpeBRepBuild_Tools::IsDegEdgesTheSame(aPieceObj, aPieceTool) : aPieceObj.IsSame(aPieceTool);
1387 TopTools_SequenceOfShape aSeq;
1388 aSeq.Append(aFaceObj) ; aSeq.Append(anEdgeObj) ; aSeq.Append(aPieceObj) ;
1389 aSeq.Append(aFaceTool); aSeq.Append(anEdgeTool); aSeq.Append(aPieceTool);
1392 priz=TwoPiecesON (aSeq, aListOfPieces, aListOfFaces, aListOfPiecesOut2d);
1394 //if (priz==14) aCase14=1;
1395 //if (priz==12) aCase12=1;
1396 aCasesMap.Add(priz);
1402 //printf("Warning : => aPieceTool is not found\n");
1403 //modified by NIZHNY-MZV Thu Dec 23 17:30:20 1999
1411 //this case dedicated for the computation then edge has sim (F and R at one time) SD edge
1413 if ( aCasesMap.Contains(14) && aCasesMap.Contains(12) && Opefus() )
1414 aListOfPieces.Clear();
1415 // eap 30 May occ417, add :
1416 if ( aCasesMap.Contains(11) && aCasesMap.Contains(13) && (Opec12() || Opec21()) )
1417 aListOfPieces.Clear();
1422 //=======================================================================
1423 //function : TwoPiecesON
1425 //=======================================================================
1426 Standard_Integer TopOpeBRepBuild_Builder1::TwoPiecesON (const TopTools_SequenceOfShape& aSeq,
1427 TopTools_ListOfShape& aListOfPieces,
1428 TopTools_ListOfShape& aListOfFaces,
1429 TopTools_ListOfShape& aListOfPiecesOut2d)
1432 if (aSeq.Length() < 6)
1434 TopoDS_Shape aFaceObj =aSeq(1);
1435 TopoDS_Shape anEObj =aSeq(2);
1436 TopoDS_Shape aPieceObj =aSeq(3);
1437 TopoDS_Shape aFaceTool =aSeq(4);
1438 TopoDS_Shape anETool =aSeq(5);
1439 TopoDS_Shape aPieceTool=aSeq(6);
1441 // The two Maps for adjacent faces
1442 Standard_Integer iRef = myDataStructure -> DS().AncestorRank(aFaceObj);
1444 TopTools_IndexedDataMapOfShapeListOfShape anEdgeFaceMapObj, anEdgeFaceMapTool;
1447 TopExp::MapShapesAndAncestors(myShape1, TopAbs_EDGE, TopAbs_FACE, anEdgeFaceMapObj );
1448 TopExp::MapShapesAndAncestors(myShape2, TopAbs_EDGE, TopAbs_FACE, anEdgeFaceMapTool);
1451 TopExp::MapShapesAndAncestors(myShape1, TopAbs_EDGE, TopAbs_FACE, anEdgeFaceMapObj );
1452 TopExp::MapShapesAndAncestors(myShape2, TopAbs_EDGE, TopAbs_FACE, anEdgeFaceMapTool);
1453 TopoDS_Shape tmpFace = aFaceObj, tmpPiece = aPieceObj, tmpEdge = anEObj;
1454 aFaceObj = aFaceTool; aPieceObj = aPieceTool; anEObj = anETool;
1455 aFaceTool = tmpFace; aPieceTool = tmpPiece; anETool = tmpEdge;
1458 Standard_Boolean IsFacesDifOriented , IsEdgesRevSense,
1459 anAd1=Standard_False , anAd2=Standard_False,
1460 aScPrFlag1=Standard_False, aScPrFlag2=Standard_False,
1461 Rejected1=Standard_True , Rejected2=Standard_True;
1463 TopAbs_State aStateObj =TopAbs_UNKNOWN, aStateTool=TopAbs_UNKNOWN;
1464 Standard_Real aScProductObj =0. , aScProductTool=0.,
1468 Standard_Real aScPrObj=0., aScPrTool=0.;
1471 TopoDS_Shape anAdjFaceObj, anAdjFaceTool;
1475 TopoDS_Face aFObj = TopoDS::Face(aFaceObj);
1476 TopoDS_Face aFTool = TopoDS::Face(aFaceTool);
1478 TopoDS_Edge anEdgeObj = TopoDS::Edge(aPieceObj);
1479 TopoDS_Edge anEdgeTool= TopoDS::Edge(aPieceTool);
1482 TopoDS_Edge aOriEObj = TopoDS::Edge(anEObj);
1483 TopoDS_Edge aOriETool = TopoDS::Edge(anETool);
1485 // Normals to the Faces
1486 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge (aFObj, anEdgeObj, anyN);
1487 if(aFObj.Orientation() == TopAbs_REVERSED)
1489 gp_Dir aDNObj(anyN);
1492 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge (aFTool, anEdgeTool, anyN);
1493 if(aFTool.Orientation() == TopAbs_REVERSED)
1495 gp_Dir aDNTool (anyN);
1497 // are aFaceObj & aFaceTool different oriented faces or not ?
1498 IsFacesDifOriented=aDNObj*aDNTool < 0.;
1499 // Sense of the Pieces
1500 Standard_Boolean RevObj = TopOpeBRepBuild_Tools::GetTangentToEdgeEdge (aFObj, anEdgeObj, aOriEObj, anyN);
1502 aPieceObj.Reverse();
1503 anEdgeObj.Reverse();
1506 gp_Dir aDTObj(anyN);
1507 Standard_Boolean RevTool = TopOpeBRepBuild_Tools::GetTangentToEdgeEdge (aFTool, anEdgeTool, aOriETool, anyN);
1509 aPieceTool.Reverse();
1510 anEdgeTool.Reverse();
1512 gp_Dir aDTTool(anyN);
1514 IsEdgesRevSense= aDTObj*aDTTool < 0.;
1516 // try to get adjacent faces for Obj and Tool. Ad1, Ad2 indicate that the face exists.
1517 anAd1=TopOpeBRepBuild_Tools::GetAdjacentFace (aFaceObj, anEObj, anEdgeFaceMapObj, anAdjFaceObj);
1518 anAd2=TopOpeBRepBuild_Tools::GetAdjacentFace (aFaceTool, anETool, anEdgeFaceMapTool, anAdjFaceTool);
1520 if (anAd1 && anAd2) {
1521 // both adjacents are found , so we can calculate the scalar products
1522 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge (TopoDS::Face(anAdjFaceObj), anEdgeObj, anyN);
1523 if(anAdjFaceObj.Orientation() == TopAbs_REVERSED)
1525 gp_Dir aDNAObj (anyN);
1527 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge (TopoDS::Face(anAdjFaceTool), anEdgeTool, anyN);
1528 if(anAdjFaceTool.Orientation() == TopAbs_REVERSED)
1530 gp_Dir aDNATool (anyN);
1532 aScPrObj =(aDTObj^aDNTool)*aDNAObj;
1533 aScPrTool=(aDTTool^aDNObj)*aDNATool;
1535 if(fabs(aScPrObj) <= aTol) {//if scalar product is == 0 try to move a little from this point
1536 TopOpeBRepBuild_Tools::GetNormalInNearestPoint (TopoDS::Face(anAdjFaceObj), anEdgeObj, anyN);
1537 if(anAdjFaceObj.Orientation() == TopAbs_REVERSED)
1539 aDNAObj.SetXYZ (anyN.XYZ());
1540 aScPrObj =(aDTObj^aDNTool)*aDNAObj;
1543 if(fabs(aScPrTool) <= aTol) {//if scalar product is == 0 try to move a little from this point
1544 TopOpeBRepBuild_Tools::GetNormalInNearestPoint (TopoDS::Face(anAdjFaceTool), anEdgeTool, anyN);
1545 if(anAdjFaceTool.Orientation() == TopAbs_REVERSED)
1547 aDNATool.SetXYZ (anyN.XYZ());
1548 aScPrTool =(aDTTool^aDNObj)*aDNATool;
1551 // Scalar prouducts must not have too small value:
1552 aScProductObj=aScPrObj;
1553 aScProductTool=aScPrTool;
1556 gp_Dir aDBNObj(aDNObj^aDTObj);
1557 aScProductObj=aDBNObj*aDNATool;
1558 gp_Dir aDBNTool(aDNTool^aDTTool);
1559 aScProductTool=aDBNTool*aDNAObj;
1561 // Scalar prouducts must not have too small value:
1562 if (fabs(aScProductTool) > aTol) aScPrFlag1=Standard_True;
1563 if (fabs(aScProductObj ) > aTol) aScPrFlag2=Standard_True;
1567 if (!anAd1 || !anAd2 || !aScPrFlag1 || !aScPrFlag2) {
1568 // manage without adjacents.
1569 // case a. No==Nt , To!=Tt
1570 if (IsEdgesRevSense && !IsFacesDifOriented ) {
1572 Standard_Boolean poisc = BRep_Tool::IsClosed(anEdgeObj,aFObj);
1575 aListOfPieces.Append (aPieceObj);
1576 aListOfFaces.Append (aFaceObj);
1582 // case b. No!=Nt , To!=Tt
1583 if (IsEdgesRevSense && IsFacesDifOriented) {
1585 aListOfPieces.Append (aPieceObj);
1586 aListOfFaces.Append (aFaceObj);
1588 if(!anAd1 || !anAd2)
1591 return 10; //10 doesn't mean anything just to retutn something
1594 // case c. No==Nt , To==Tt
1595 if (!IsEdgesRevSense && !IsFacesDifOriented) {
1596 //Begin modified by NIZHNY-MZV Mon Jan 24 10:03:58 2000
1598 if(anAd1 && anAd2) {
1601 aListOfPieces.Append (aPieceObj);
1602 aListOfFaces.Append (aFaceObj);
1605 aListOfPieces.Append (aPieceTool);
1606 aListOfFaces.Append (aFaceTool);
1612 aListOfPieces.Append (aPieceObj);
1613 aListOfFaces.Append (aFaceObj);
1615 //End modified by NIZHNY-MZV Mon Jan 24 11:21:17 2000
1620 // case d. No!=Nt , To==Tt
1621 if (!IsEdgesRevSense && IsFacesDifOriented) {
1622 //modified by NIZHNY-MZV Fri Jan 21 18:16:01 2000
1624 if(anAd1 && anAd2) {
1627 aListOfPieces.Append (aPieceObj);
1628 aListOfFaces.Append (aFaceObj);
1631 aListOfPieces.Append (aPieceTool);
1632 aListOfFaces.Append (aFaceTool);
1638 aListOfPieces.Append (aPieceObj);
1639 aListOfFaces.Append (aFaceObj);
1642 if(!anAd1 || !anAd2)
1645 return 10; //10 doesn't mean anything just to retutn something
1648 } // end of if (!anAd1 || !anAd2 || !aScPrFlag1 || !aScPrFlag2)
1651 // We can use adjacents .
1654 aStateObj =aScProductObj < 0. ? TopAbs_IN: TopAbs_OUT ;
1655 aStateTool=aScProductTool < 0. ? TopAbs_IN: TopAbs_OUT ;
1657 aStateObj =aScProductObj > 0. ? TopAbs_IN: TopAbs_OUT ;
1658 aStateTool=aScProductTool > 0. ? TopAbs_IN: TopAbs_OUT ;
1659 // case I RevSense && DifOriented
1660 if (IsEdgesRevSense && IsFacesDifOriented) {
1662 aListOfPieces.Append (aPieceObj);
1663 aListOfFaces.Append (aFaceObj);
1668 // case III SameSense && !DifOriented
1669 if (!IsEdgesRevSense && !IsFacesDifOriented) {
1671 aListOfPieces.Append (aPieceObj);
1672 aListOfFaces.Append (aFaceObj);
1677 // case II RevSense && !DifOriented
1678 if (IsEdgesRevSense && !IsFacesDifOriented) {
1679 if (Opefus()) { // Fusion
1680 if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_IN) {
1681 Rejected1=Standard_False;
1683 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_OUT) {
1684 Rejected2=Standard_False;
1687 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_IN) {
1688 if(!myProcessedPartsON2d.Contains(aPieceObj)) {//we proceed IsSame only if we didn't it before
1689 myProcessedPartsON2d.Add(aPieceObj);
1690 IsSame2d (aSeq, aListOfPiecesOut2d); //Perform IsSame 2d and keep periodic parts
1693 else if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_OUT) {
1694 if(!myProcessedPartsON2d.Contains(aPieceObj)) {//we proceed IsSame only if we didn't it before
1695 myProcessedPartsON2d.Add(aPieceObj);
1696 IsSame2d (aSeq, aListOfPiecesOut2d); //Perform IsSame 2d and keep periodic parts
1701 if (Opecom()) {// Common
1702 if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_IN) {
1703 Rejected2=Standard_False;
1705 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_OUT) {
1706 Rejected1=Standard_False;
1710 if (Opec12()) {// Cut
1711 if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_OUT) {
1712 Rejected2=Standard_False;
1714 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_IN) {
1715 Rejected1=Standard_False;
1717 else if (aStateObj==TopAbs_OUT && aStateTool == TopAbs_IN) {
1718 Rejected1=Standard_False;
1719 Rejected2=Standard_False;
1723 aListOfPieces.Append(aPieceObj);
1724 aListOfFaces.Append (aFaceObj);
1727 aListOfPieces.Append(aPieceTool);
1728 aListOfFaces.Append (aFaceTool);
1733 // case IV !RevSense && DifOriented
1734 if (!IsEdgesRevSense && IsFacesDifOriented) {
1735 if (Opefus()) {// Fusion
1736 if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_OUT) {
1737 Rejected1=Standard_False;
1738 Rejected2=Standard_False;
1740 else if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_IN) {
1741 Rejected2=Standard_False;
1743 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_OUT) {
1744 Rejected1=Standard_False;
1746 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_IN) {
1747 if(!myProcessedPartsON2d.Contains(aPieceObj)) {//we proceed IsSame only if we didn't it before
1748 myProcessedPartsON2d.Add(aPieceObj);
1749 IsSame2d (aSeq, aListOfPiecesOut2d); //Perform IsSame 2d and keep periodic parts
1754 if (Opecom()) {// Common
1755 if (aStateObj==TopAbs_IN && aStateTool==TopAbs_IN) {
1756 Rejected1=Standard_False;
1757 Rejected2=Standard_False;
1759 else if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_IN) {
1760 Rejected1=Standard_False;
1762 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_OUT) {
1763 Rejected2=Standard_False;
1767 if (Opec12()) { //Cut
1768 if (aStateObj==TopAbs_OUT && aStateTool==TopAbs_OUT) {
1769 Rejected1=Standard_False;
1771 else if (aStateObj==TopAbs_IN && aStateTool==TopAbs_IN) {
1772 Rejected2=Standard_False;
1776 aListOfPieces.Append(aPieceObj);
1777 aListOfFaces.Append (aFaceObj);
1780 aListOfPieces.Append(aPieceTool);
1781 aListOfFaces.Append (aFaceTool);
1785 // Unknowm case for existing adjacents
1790 //=======================================================================
1791 //function : IsSame2d
1793 //=======================================================================
1794 Standard_Integer TopOpeBRepBuild_Builder1::IsSame2d (const TopTools_SequenceOfShape& aSeq,
1795 TopTools_ListOfShape& aListOfPiecesOut2d)
1797 if (aSeq.Length() < 6) return 0;
1799 TopoDS_Shape aFaceObj =aSeq(1); TopoDS_Shape anEdgeObj =aSeq(2);
1800 TopoDS_Shape aPieceObj =aSeq(3); TopoDS_Shape aFaceTool =aSeq(4);
1801 TopoDS_Shape anEdgeTool=aSeq(5); TopoDS_Shape aPieceTool=aSeq(6);
1803 TopoDS_Face aFObj =TopoDS::Face(aFaceObj) ; TopoDS_Face aFTool =TopoDS::Face(aFaceTool) ;
1804 TopoDS_Edge anEObj =TopoDS::Edge(anEdgeObj) ; TopoDS_Edge anETool=TopoDS::Edge(anEdgeTool);
1805 TopoDS_Edge aPObj =TopoDS::Edge(aPieceObj) ; TopoDS_Edge aPTool =TopoDS::Edge(aPieceTool);
1807 BRepAdaptor_Surface aBAS(aFObj);
1808 if (!(aBAS.IsUPeriodic() || aBAS.IsVPeriodic())) return 1;
1810 //we process here only fully closed edges (Vf == Vl)
1811 if(!BRep_Tool::IsClosed(anEdgeObj) || !BRep_Tool::IsClosed(anEdgeTool))
1814 Standard_Real f = 0., l = 0., tolpc = 0. ,
1815 par = 0., parOri = 0., f1 = 0., l1 = 0., parP = 0., gp_Resolution = 1.e-10;
1818 Handle(Geom2d_Curve) C2D;
1820 Handle(Geom2d_Curve) C2DPieceTool = FC2D_CurveOnSurface (aPTool, aFObj, f1, l1, tolpc, Standard_True);
1822 parP= f1*PAR_T + (1 - PAR_T)*l1;
1824 C2DPieceTool -> D0(parP, aPPiece);
1827 C2D=FC2D_CurveOnSurface (anETool, aFObj, f, l, tolpc, Standard_True);
1828 Geom2dAPI_ProjectPointOnCurve aPP2d(aPPiece, C2D);
1829 parOri = aPP2d.LowerDistanceParameter();
1831 Standard_Boolean IsTrFirst = Standard_True;
1833 parOri = 2*M_PI + parOri;
1836 parOri = parOri - 2*M_PI;
1840 C2D -> D0(parOri, aUV2);
1842 Handle(Geom2d_Curve) C2DPieceObj=FC2D_CurveOnSurface (aPObj, aFObj, f, l, tolpc, Standard_True);
1844 par=f*PAR_T + (1 - PAR_T)*l;
1845 C2DPieceObj->D0 (par, aUV1);
1846 gp_Vec2d aTranslateV (aUV1, aUV2);
1847 if(aTranslateV.Magnitude() >= gp_Resolution) {
1849 Handle(Geom2d_Curve) aTrC2D = Handle(Geom2d_Curve)::DownCast(C2DPieceTool->Copy());
1850 aTrC2D->Translate(aTranslateV);
1851 gp_Pnt2d aTFuv, aTLuv;
1852 aTrC2D -> D0(f1, aTFuv);
1853 aTrC2D -> D0(l1, aTLuv);
1854 gp_Vec2d aTrVec (aTFuv, aTLuv);
1856 Standard_Real fo = 0., lo = 0.;
1857 Handle(Geom2d_Curve) C2DEdgeObj = FC2D_CurveOnSurface(anEObj, aFObj, fo, lo, tolpc, Standard_True);
1858 gp_Pnt2d aOFuv, aOLuv;
1859 C2DEdgeObj -> D0(fo, aOFuv);
1860 C2DEdgeObj -> D0(lo, aOLuv);
1861 gp_Vec2d aOVec (aOFuv, aOLuv);
1862 if(anEObj.Orientation() == TopAbs_REVERSED)
1864 IsTrFirst = (aTrVec*aOVec > 0) ? Standard_False : Standard_True;
1867 Standard_Real tolE = BRep_Tool::Tolerance(aPTool);
1870 BB.UpdateEdge(aPTool , aTrC2D, C2DPieceTool, aFObj , tolE);
1872 BB.UpdateEdge(aPTool ,C2DPieceTool, aTrC2D, aFObj , tolE);
1874 aListOfPiecesOut2d.Append (aPTool);
1881 //=======================================================================
1882 //function : OrientateEdgeOnFace
1884 //=======================================================================
1885 void TopOpeBRepBuild_Builder1::OrientateEdgeOnFace(TopoDS_Edge& EdgeToPerform,
1886 const TopoDS_Face& baseFace,
1887 const TopoDS_Face& edgeFace,
1888 const TopOpeBRepBuild_GTopo& G1,
1889 Standard_Boolean& stateOfFaceOri) const
1893 stateOfFaceOri = Standard_False;
1895 Standard_Integer currRef = myDataStructure -> DS().AncestorRank(mySDFaceToFill);
1896 Standard_Integer faceRef = myDataStructure -> DS().AncestorRank(edgeFace);
1897 Standard_Boolean RevOri = Standard_False;
1899 if(currRef == 1) {//object
1900 RevOri = G1.IsToReverse1();
1903 RevOri = G1.IsToReverse2();
1906 TopAbs_Orientation oriE = EdgeToPerform.Orientation();
1907 TopAbs_Orientation neworiE = Orient(oriE, RevOri);
1908 TopAbs_Orientation faceOri = edgeFace.Orientation();
1909 TopAbs_Orientation baseOri = baseFace.Orientation();
1910 TopAbs_Orientation currOri = mySDFaceToFill.Orientation();
1912 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(edgeFace, EdgeToPerform, aN1);
1913 if(faceOri == TopAbs_REVERSED)
1916 TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(baseFace, EdgeToPerform, aN2);
1917 if(baseOri == TopAbs_REVERSED)
1921 stateOfFaceOri = Standard_True;
1923 if(faceRef == 2) //for tool we need to reverse face in cut
1924 if(Opec12() || Opec21())
1925 stateOfFaceOri = !stateOfFaceOri;
1927 //orientate edge with neworiE
1928 EdgeToPerform.Orientation(neworiE);
1930 if(currOri != baseOri)
1931 EdgeToPerform.Reverse();
1934 EdgeToPerform.Reverse();
1939 /////////////// STATIC FUNCTIONS
1940 static TopAbs_State ClassifyEdgeToFaceByOnePoint(const TopoDS_Edge& E,
1941 const TopoDS_Face& F)
1943 Standard_Real f2 = 0., l2 = 0., tolpc = 0. , par = 0.;
1944 Handle(Geom2d_Curve) C2D = FC2D_CurveOnSurface(E, F, f2, l2, tolpc, Standard_True);
1946 par = f2*PAR_T + (1 - PAR_T)*l2;
1951 return TopAbs_UNKNOWN;
1953 C2D -> D0(par, aP2d);
1955 BRepTopAdaptor_FClass2d FC(F, 1e-7);
1956 TopAbs_State aState = FC.Perform(aP2d);