1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <BOPAlgo_WireSplitter.ixx>
17 #include <Precision.hxx>
19 #include <gp_Pnt2d.hxx>
20 #include <gp_Vec2d.hxx>
21 #include <gp_Dir2d.hxx>
23 #include <Geom_Surface.hxx>
24 #include <Geom_Plane.hxx>
25 #include <Geom_RectangularTrimmedSurface.hxx>
26 #include <Geom2d_Curve.hxx>
27 #include <Geom2d_Line.hxx>
28 #include <GeomAdaptor_Surface.hxx>
29 #include <Geom2dAdaptor_Curve.hxx>
31 #include <Geom2dInt_GInter.hxx>
32 #include <IntRes2d_Domain.hxx>
33 #include <IntRes2d_IntersectionPoint.hxx>
35 #include <TopLoc_Location.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS_Vertex.hxx>
39 #include <TopoDS_Wire.hxx>
40 #include <TopoDS_Iterator.hxx>
41 #include <BRep_Tool.hxx>
42 #include <BRep_Builder.hxx>
44 #include <TopTools_ShapeMapHasher.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <BRepAdaptor_Surface.hxx>
50 #include <BOPCol_ListOfShape.hxx>
51 #include <BOPCol_SequenceOfShape.hxx>
52 #include <BOPCol_SequenceOfPnt2d.hxx>
53 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
54 #include <BOPCol_SequenceOfReal.hxx>
55 #include <BOPCol_DataMapOfShapeInteger.hxx>
56 #include <BOPCol_MapOfShape.hxx>
58 #include <BOPTools_AlgoTools2D.hxx>
60 typedef NCollection_DataMap \
61 <TopoDS_Shape, Standard_Boolean, TopTools_ShapeMapHasher> \
62 BOPCol_DataMapOfShapeBoolean;
66 Standard_Real Angle (const gp_Dir2d& aDir2D);
69 Standard_Real Angle2D (const TopoDS_Vertex& aV,
70 const TopoDS_Edge& anEdge,
71 const TopoDS_Face& myFace,
72 const GeomAdaptor_Surface& aGAS,
73 const Standard_Boolean aFlag);
76 void GetNextVertex(const TopoDS_Vertex& aV,
77 const TopoDS_Edge& aE,
81 Standard_Real AngleIn(const TopoDS_Edge& aEIn,
82 const BOPAlgo_ListOfEdgeInfo& aLEInfo);
85 Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo);
88 gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE,
89 const TopoDS_Face& aF);
92 gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1,
93 const TopoDS_Edge& aE1,
94 const TopoDS_Face& aF);
97 Standard_Real ClockWiseAngle(const Standard_Real aAngleIn,
98 const Standard_Real aAngleOut);
101 void Path (const GeomAdaptor_Surface& aGAS,
102 const TopoDS_Face& myFace,
103 const TopoDS_Vertex& aVa,
104 const TopoDS_Edge& aEOuta,
105 BOPAlgo_EdgeInfo& anEdgeInfo,
106 BOPCol_SequenceOfShape& aLS,
107 BOPCol_SequenceOfShape& aVertVa,
108 BOPCol_SequenceOfPnt2d& aCoordVa,
109 BOPTools_ConnexityBlock& aCB,
110 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap,
111 BOPCol_DataMapOfShapeBoolean aVertMap);
114 Standard_Real Angle (const gp_Dir2d& aDir2D);
117 Standard_Real Tolerance2D (const TopoDS_Vertex& aV,
118 const GeomAdaptor_Surface& aGAS);
123 Standard_Real UTolerance2D (const TopoDS_Vertex& aV,
124 const GeomAdaptor_Surface& aGAS);
126 Standard_Real VTolerance2D (const TopoDS_Vertex& aV,
127 const GeomAdaptor_Surface& aGAS);
130 void RefineAngles(const TopoDS_Face& myFace,
131 const BOPCol_ListOfShape&,
132 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo&);
136 void RefineAngles(const TopoDS_Vertex& ,
138 const BOPCol_MapOfShape& ,
139 BOPAlgo_ListOfEdgeInfo& );
142 Standard_Boolean RefineAngle2D(const TopoDS_Vertex& ,
145 const Standard_Real ,
146 const Standard_Real ,
149 //=======================================================================
150 //function : SplitBlock
152 //=======================================================================
153 void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
154 BOPTools_ConnexityBlock& aCB)
156 Standard_Boolean bNothingToDo, bIsClosed, bIsIN;
157 Standard_Integer aIx, aNb, i, aCntIn, aCntOut;
158 Standard_Real aAngle;
159 TopAbs_Orientation aOr;
160 TopoDS_Iterator aItS;
163 BOPCol_ListIteratorOfListOfShape aIt;
164 BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI;
166 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo mySmartMap(100);
167 BOPCol_DataMapOfShapeBoolean aVertMap;
169 const BOPCol_ListOfShape& myEdges=aCB.Shapes();
171 // 1.Filling mySmartMap
172 BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane(myEdges, myFace);
174 aIt.Initialize(myEdges);
175 for(; aIt.More(); aIt.Next()) {
176 const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
177 if (!BOPTools_AlgoTools2D::HasCurveOnSurface (aE, myFace)) {
181 bIsClosed = BRep_Tool::Degenerated(aE) ||
182 BRep_Tool::IsClosed(aE, myFace);
185 for(i = 0; aItS.More(); aItS.Next(), ++i) {
186 const TopoDS_Shape& aV = aItS.Value();
187 aIx = mySmartMap.FindIndex(aV);
189 BOPAlgo_ListOfEdgeInfo aLEIx;
190 aIx = mySmartMap.Add(aV, aLEIx);
193 BOPAlgo_ListOfEdgeInfo& aLEI = mySmartMap(aIx);
194 BOPAlgo_EdgeInfo aEI;
197 aOr = aV.Orientation();
198 bIsIN = (aOr == TopAbs_REVERSED);
199 aEI.SetInFlag(bIsIN);
205 bIsClosed = bIsClosed || aV1.IsSame(aV);
208 if (aVertMap.IsBound(aV)) {
210 aVertMap.ChangeFind(aV) = bIsClosed;
213 aVertMap.Bind(aV, bIsClosed);
218 aNb=mySmartMap.Extent();
220 bNothingToDo=Standard_True;
221 for (i=1; i<=aNb; i++) {
224 const BOPAlgo_ListOfEdgeInfo& aLEInfo= mySmartMap(i);
225 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo);
226 for (; anIt.More(); anIt.Next()) {
227 const BOPAlgo_EdgeInfo& aEI=anIt.Value();
235 if (aCntIn!=1 || aCntOut!=1) {
236 bNothingToDo=Standard_False;
241 // Each vertex has one edge In and one - Out. Good. But it is not enought
242 // to consider that nothing to do with this. We must check edges on TShape
243 // coinsidence. If there are such edges there is something to do with.
245 Standard_Integer aNbE, aNbMapEE;
246 Standard_Boolean bFlag;
248 BOPCol_IndexedDataMapOfShapeListOfShape aMapEE(100);
249 aNbE=myEdges.Extent();
251 aIt.Initialize(myEdges);
252 for (; aIt.More(); aIt.Next()) {
253 const TopoDS_Shape& aE = aIt.Value();
254 if (!aMapEE.Contains(aE)) {
255 BOPCol_ListOfShape aLEx;
257 aMapEE.Add(aE, aLEx);
260 BOPCol_ListOfShape& aLEx=aMapEE.ChangeFromKey(aE);
266 aNbMapEE=aMapEE.Extent();
267 for (i=1; i<=aNbMapEE; ++i) {
268 const BOPCol_ListOfShape& aLEx=aMapEE(i);
270 if (aNbE==1) {// usual case
274 const TopoDS_Shape& aE1=aLEx.First();
275 const TopoDS_Shape& aE2=aLEx.Last();
276 if (aE1.IsSame(aE2)) {
277 bFlag=Standard_False;
282 bFlag=Standard_False;
286 bNothingToDo=bNothingToDo && bFlag;
287 } // if (bNothingToDo) {
291 BOPCol_ListOfShape& aLECB=aCB.ChangeShapes();
292 BOPAlgo_WireSplitter::MakeWire(aLECB, aW);
293 BOPCol_ListOfShape& aLoops=aCB.ChangeLoops();
299 // 3. Angles in mySmartMap
300 BRepAdaptor_Surface aBAS(myFace);
301 const GeomAdaptor_Surface& aGAS=aBAS.Surface();
303 for (i=1; i<=aNb; i++) {
304 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&mySmartMap.FindKey(i)));
305 const BOPAlgo_ListOfEdgeInfo& aLEI= mySmartMap(i);
307 aItLEI.Initialize(aLEI);
308 for (; aItLEI.More(); aItLEI.Next()) {
309 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
310 const TopoDS_Edge& aE=aEI.Edge();
314 aOr = bIsIN ? TopAbs_REVERSED : TopAbs_FORWARD;
315 aVV.Orientation(aOr);
316 aAngle = Angle2D(aVV, aE, myFace, aGAS, bIsIN);
317 aEI.SetAngle(aAngle);
319 }// for (i=1; i<=aNb; i++) {
321 //Theme: The treatment p-curves convergent in node.
322 //The refining the angles of p-curves taking into account
323 //bounging curves if exist.
324 RefineAngles(myFace, myEdges, mySmartMap);
328 Standard_Boolean bIsOut, bIsNotPassed;
329 BOPCol_SequenceOfShape aLS, aVertVa;
330 BOPCol_SequenceOfPnt2d aCoordVa;
332 for (i=1; i<=aNb; ++i) {
333 const TopoDS_Vertex& aVa=(*(TopoDS_Vertex *)(&mySmartMap.FindKey(i)));
334 const BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i);
335 aItLEI.Initialize(aLEI);
336 for (; aItLEI.More(); aItLEI.Next()) {
337 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
338 const TopoDS_Edge& aEOuta=aEI.Edge();
341 bIsNotPassed=!aEI.Passed();
342 if (bIsOut && bIsNotPassed) {
348 Path(aGAS, myFace, aVa, aEOuta, aEI, aLS,
349 aVertVa, aCoordVa, aCB, mySmartMap, aVertMap);
352 }// for (i=1; i<=aNb; ++i) {
354 //=======================================================================
357 //=======================================================================
358 void Path (const GeomAdaptor_Surface& aGAS,
359 const TopoDS_Face& myFace,
360 const TopoDS_Vertex& aVFirst,
361 const TopoDS_Edge& aEFirst,
362 BOPAlgo_EdgeInfo& aEIFirst,
363 BOPCol_SequenceOfShape& aLS,
364 BOPCol_SequenceOfShape& aVertVa,
365 BOPCol_SequenceOfPnt2d& aCoordVa,
366 BOPTools_ConnexityBlock& aCB,
367 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap,
368 BOPCol_DataMapOfShapeBoolean aVertMap)
371 Standard_Integer i, j, aNb, aNbj;
372 Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle;
373 Standard_Real aTol2D, aTol2D2, aD2, aTwoPI;
374 Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed;
375 Standard_Boolean bIsClosed;
376 TopoDS_Vertex aVa, aVb;
378 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
382 BOPAlgo_EdgeInfo* anEdgeInfo = &aEIFirst;
384 aTwoPI = M_PI + M_PI;
389 // Do not escape through edge from which you enter
392 const TopoDS_Shape& anEPrev=aLS(aNb);
393 if (anEPrev.IsSame(aEOuta)) {
398 anEdgeInfo->SetPassed(Standard_True);
402 TopoDS_Vertex pVa=aVa;
403 pVa.Orientation(TopAbs_FORWARD);
404 gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace);
405 aCoordVa.Append(aPa);
407 GetNextVertex (pVa, aEOuta, aVb);
409 gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace);
411 const BOPAlgo_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb);
413 aTol2D = 2.*Tolerance2D(aVb, aGAS);
414 aTol2D2 = aTol2D * aTol2D;
416 bIsClosed = aVertMap.Find(aVb);
421 BOPCol_ListOfShape aBuf;
423 for (i=aNb; i>0; --i) {
424 const TopoDS_Shape& aVPrev=aVertVa(i);
425 const gp_Pnt2d& aPaPrev=aCoordVa(i);
426 const TopoDS_Shape& aEPrev=aLS(i);
430 anIsSameV = aVPrev.IsSame(aVb);
431 anIsSameV2d = anIsSameV;
434 aD2 = aPaPrev.SquareDistance(aPb);
435 anIsSameV2d = aD2 < aTol2D2;
437 Standard_Real udist = fabs(aPaPrev.X() - aPb.X());
438 Standard_Real vdist = fabs(aPaPrev.Y() - aPb.Y());
439 Standard_Real aTolU = 2.*UTolerance2D(aVb, aGAS);
440 Standard_Real aTolV = 2.*VTolerance2D(aVb, aGAS);
442 if((udist > aTolU) || (vdist > aTolV)) {
443 anIsSameV2d = Standard_False;
449 if (anIsSameV && anIsSameV2d) {
450 Standard_Integer iPriz;
452 if (aBuf.Extent()==2) {
453 if(aBuf.First().IsSame(aBuf.Last())) {
459 BOPAlgo_WireSplitter::MakeWire(aBuf, aW);
460 aCB.ChangeLoops().Append(aW);
473 BOPCol_SequenceOfShape aLSt, aVertVat;
474 BOPCol_SequenceOfPnt2d aCoordVat;
476 aVb=(*(TopoDS_Vertex *)(&aVertVa(i)));
478 for (j=1; j<=aNbj; ++j) {
480 aVertVat.Append(aVertVa(j));
481 aCoordVat.Append(aCoordVa(j));
498 BOPAlgo_EdgeInfo *pEdgeInfo=NULL;
500 anAngleIn = AngleIn(aEOuta, aLEInfo);
502 anIsFound = Standard_False;
503 Standard_Integer aCurIndexE = 0;
504 anIt.Initialize(aLEInfo);
505 for (; anIt.More(); anIt.Next()) {
506 BOPAlgo_EdgeInfo& anEI=anIt.ChangeValue();
507 const TopoDS_Edge& aE=anEI.Edge();
508 anIsOut=!anEI.IsIn();
509 anIsNotPassed=!anEI.Passed();
511 if (anIsOut && anIsNotPassed) {
514 // Is there one way to go out of the vertex
515 // we have to use it only.
516 Standard_Integer iCnt;
517 iCnt=NbWaysOut (aLEInfo);
520 // no way to go . (Error)
525 // the one and only way to go out .
527 anIsFound=Standard_True;
531 if (aE.IsSame(aEOuta)) {
538 aP2Dx = Coord2dVf(aE, myFace);
540 aD2 = aP2Dx.SquareDistance(aPb);
546 // Look for minimal angle and make the choice.
547 anAngleOut=anEI.Angle();
548 anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
550 if (anAngle < aMinAngle) {
553 anIsFound=Standard_True;
556 } // for (; anIt.More(); anIt.Next())
559 // no way to go . (Error)
564 aEOuta = pEdgeInfo->Edge();
565 anEdgeInfo = pEdgeInfo;
568 //=======================================================================
569 // function: ClockWiseAngle
571 //=======================================================================
572 Standard_Real ClockWiseAngle(const Standard_Real aAngleIn,
573 const Standard_Real aAngleOut)
575 Standard_Real aTwoPi=M_PI+M_PI;
576 Standard_Real dA, A1, A2, AIn, AOut ;
584 if (AOut >= aTwoPi) {
601 //else if (dA <= 1.e-15) {
602 else if (dA <= 1.e-14) {
607 //=======================================================================
610 //=======================================================================
611 gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1,
612 const TopoDS_Edge& aE1,
613 const TopoDS_Face& aF)
615 Standard_Real aT, aFirst, aLast;
616 Handle(Geom2d_Curve) aC2D;
619 aT=BRep_Tool::Parameter (aV1, aE1, aF);
620 aC2D=BRep_Tool::CurveOnSurface(aE1, aF, aFirst, aLast);
621 aC2D->D0 (aT, aP2D1);
625 //=======================================================================
626 // function: Coord2dVf
628 //=======================================================================
629 gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE,
630 const TopoDS_Face& aF)
632 Standard_Real aCoord=99.;
633 gp_Pnt2d aP2D1(aCoord, aCoord);
637 for (; aIt.More(); aIt.Next()) {
638 const TopoDS_Shape& aVx=aIt.Value();
639 if (aVx.Orientation()==TopAbs_FORWARD) {
641 const TopoDS_Vertex& aVxx=(*(TopoDS_Vertex *)(&aVx));// TopoDS::Vertex(aVx);
642 aP2D1=Coord2d(aVxx, aE, aF);
649 //=======================================================================
650 // function: NbWaysOut
652 //=======================================================================
653 Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo)
655 Standard_Boolean bIsOut, bIsNotPassed;
656 Standard_Integer iCnt=0;
657 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
659 anIt.Initialize(aLEInfo);
660 for (; anIt.More(); anIt.Next()) {
661 const BOPAlgo_EdgeInfo& anEI=anIt.Value();
664 bIsNotPassed=!anEI.Passed();
665 if (bIsOut && bIsNotPassed) {
672 //=======================================================================
675 //=======================================================================
676 Standard_Real AngleIn(const TopoDS_Edge& aEIn,
677 const BOPAlgo_ListOfEdgeInfo& aLEInfo)
679 Standard_Real anAngleIn;
680 Standard_Boolean anIsIn;
681 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
683 anIt.Initialize(aLEInfo);
684 for (; anIt.More(); anIt.Next()) {
685 const BOPAlgo_EdgeInfo& anEdgeInfo=anIt.Value();
686 const TopoDS_Edge& aE=anEdgeInfo.Edge();
687 anIsIn=anEdgeInfo.IsIn();
689 if (anIsIn && aE==aEIn) {
690 anAngleIn=anEdgeInfo.Angle();
697 //=======================================================================
698 // function: GetNextVertex
700 //=======================================================================
701 void GetNextVertex(const TopoDS_Vertex& aV,
702 const TopoDS_Edge& aE,
708 for (; aIt.More(); aIt.Next()) {
709 const TopoDS_Shape& aVx=aIt.Value();
710 if (!aVx.IsEqual(aV)) {
711 aV1=(*(TopoDS_Vertex *)(&aVx));
717 //=======================================================================
720 //=======================================================================
721 Standard_Real Angle2D (const TopoDS_Vertex& aV,
722 const TopoDS_Edge& anEdge,
723 const TopoDS_Face& myFace,
724 const GeomAdaptor_Surface& aGAS,
725 const Standard_Boolean bIsIN)
727 Standard_Real aFirst, aLast, aToler, dt, aTV, aTV1, anAngle, aTX;
730 Handle(Geom2d_Curve) aC2D;
732 aTV=BRep_Tool::Parameter (aV, anEdge, myFace);
733 if (Precision::IsInfinite(aTV)) {
737 BOPTools_AlgoTools2D::CurveOnSurface (anEdge, myFace, aC2D,
738 aFirst, aLast, aToler);
739 dt=2.*Tolerance2D(aV, aGAS);
741 //for case chl/927/r9
742 aTX=0.05*(aLast - aFirst);//aTX=0.25*(aLast - aFirst);
747 // to save direction of the curve as much as it possible
748 // in the case of big tolerances
752 GeomAbs_CurveType aType;
753 Geom2dAdaptor_Curve aGAC2D(aC2D);
754 aType=aGAC2D.GetType();
755 if (aType==GeomAbs_BSplineCurve || aType==GeomAbs_BezierCurve) {
758 if (fabs (aTV-aFirst) < fabs(aTV - aLast)) {
765 aGAC2D.D0 (aTV1, aPV1);
766 aGAC2D.D0 (aTV, aPV);
768 aV2D = bIsIN ? gp_Vec2d(aPV1, aPV) : gp_Vec2d(aPV, aPV1);
770 gp_Dir2d aDir2D(aV2D);
771 anAngle=Angle(aDir2D);
775 //=======================================================================
778 //=======================================================================
779 Standard_Real Angle (const gp_Dir2d& aDir2D)
781 gp_Dir2d aRefDir(1., 0.);
782 Standard_Real anAngle;
784 anAngle = aRefDir.Angle(aDir2D);
786 anAngle += M_PI + M_PI;
789 //=======================================================================
790 // function: Tolerance2D
792 //=======================================================================
793 Standard_Real Tolerance2D (const TopoDS_Vertex& aV,
794 const GeomAdaptor_Surface& aGAS)
796 Standard_Real aTol2D, anUr, aVr, aTolV3D;
797 GeomAbs_SurfaceType aType;
799 aType=aGAS.GetType();
800 aTolV3D=BRep_Tool::Tolerance(aV);
802 anUr=aGAS.UResolution(aTolV3D);
803 aVr =aGAS.VResolution(aTolV3D);
804 aTol2D=(aVr>anUr) ? aVr : anUr;
806 if (aTol2D < aTolV3D) {
809 if (aType==GeomAbs_BSplineSurface) {
816 //=======================================================================
817 //function : UTolerance2D
819 //=======================================================================
820 Standard_Real UTolerance2D (const TopoDS_Vertex& aV,
821 const GeomAdaptor_Surface& aGAS)
823 const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV);
824 const Standard_Real anUr = aGAS.UResolution(aTolV3D);
829 //=======================================================================
830 //function : VTolerance2D
832 //=======================================================================
833 Standard_Real VTolerance2D (const TopoDS_Vertex& aV,
834 const GeomAdaptor_Surface& aGAS)
836 const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV);
837 const Standard_Real anVr = aGAS.VResolution(aTolV3D);
842 //=======================================================================
843 //function : RefineAngles
845 //=======================================================================
846 void RefineAngles(const TopoDS_Face& myFace,
847 const BOPCol_ListOfShape& myEdges,
848 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap)
850 Standard_Integer aNb, i;
851 BOPCol_DataMapOfShapeInteger aMSI;
852 BOPCol_DataMapIteratorOfDataMapOfShapeInteger aItMSI;
853 BOPCol_MapOfShape aMBE;
854 BOPCol_ListIteratorOfListOfShape aIt;
857 aIt.Initialize(myEdges);
858 for(; aIt.More(); aIt.Next()) {
859 const TopoDS_Shape& aE=aIt.Value();
860 if(aMSI.IsBound(aE)) {
861 Standard_Integer& iCnt=aMSI.ChangeFind(aE);
865 Standard_Integer iCnt=1;
870 aItMSI.Initialize(aMSI);
871 for(; aItMSI.More(); aItMSI.Next()) {
872 Standard_Integer iCnt;
874 const TopoDS_Shape& aE=aItMSI.Key();
884 aNb=mySmartMap.Extent();
885 for (i=1; i<=aNb; ++i) {
886 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&mySmartMap.FindKey(i));
887 BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i);
889 RefineAngles(aV, myFace, aMBE, aLEI);
892 //=======================================================================
893 typedef NCollection_DataMap \
894 <TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> \
895 BOPCol_DataMapOfShapeReal;
896 typedef BOPCol_DataMapOfShapeReal::Iterator \
897 BOPCol_DataMapIteratorOfDataMapOfShapeReal;
899 //=======================================================================
900 //function : RefineAngles
902 //=======================================================================
903 void RefineAngles(const TopoDS_Vertex& aV,
904 const TopoDS_Face& myFace,
905 const BOPCol_MapOfShape& aMBE,
906 BOPAlgo_ListOfEdgeInfo& aLEI)
908 Standard_Boolean bIsIn, bIsBoundary, bRefined;
909 Standard_Integer iCntBnd, iCntInt;
910 Standard_Real aA, aA1, aA2;
911 BOPCol_DataMapOfShapeReal aDMSR;
912 BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI;
918 aItLEI.Initialize(aLEI);
919 for (; aItLEI.More(); aItLEI.Next()) {
920 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
921 const TopoDS_Edge& aE=aEI.Edge();
925 if (aMBE.Contains(aE)) {
943 aItLEI.Initialize(aLEI);
944 for (; aItLEI.More(); aItLEI.Next()) {
945 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
946 const TopoDS_Edge& aE=aEI.Edge();
948 bIsBoundary=aMBE.Contains(aE);
950 if (bIsBoundary || bIsIn) {
955 if (aA>aA1 && aA<aA2) {
959 bRefined=RefineAngle2D(aV, aE, myFace, aA1, aA2, aA);
963 else if (iCntInt == 2) {
964 aA = (aA <= aA1) ? (aA1 + Precision::Angular()) :
965 (aA2 - Precision::Angular());
970 if (aDMSR.IsEmpty()) {
975 aItLEI.Initialize(aLEI);
976 for (; aItLEI.More(); aItLEI.Next()) {
977 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
978 const TopoDS_Edge& aE=aEI.Edge();
981 if (!aDMSR.IsBound(aE)) {
993 //=======================================================================
994 //function : RefineAngle2D
996 //=======================================================================
997 Standard_Boolean RefineAngle2D(const TopoDS_Vertex& aV,
998 const TopoDS_Edge& aE,
999 const TopoDS_Face& myFace,
1000 const Standard_Real aA1,
1001 const Standard_Real aA2,
1004 Standard_Boolean bRet;
1005 Standard_Integer i, j, aNbP;
1006 Standard_Real aTV, aTol, aT1, aT2, dT, aAngle, aT, aTOp;
1007 Standard_Real aTolInt, aAi, aXi, aYi, aT1j, aT2j, aT1max, aT2max, aCf;
1008 gp_Pnt2d aPV, aP, aP1, aP2;
1009 Handle(Geom2d_Curve) aC2D;
1010 Handle(Geom2d_Line) aLi;
1011 Geom2dAdaptor_Curve aGAC1, aGAC2;
1012 Geom2dInt_GInter aGInter;
1013 IntRes2d_Domain aDomain1, aDomain2;
1019 BOPTools_AlgoTools2D::CurveOnSurface(aE, myFace, aC2D, aT1, aT2, aTol);
1020 aGAC1.Load(aC2D, aT1, aT2);
1022 aTV=BRep_Tool::Parameter (aV, aE, myFace);
1025 aTOp = (fabs(aTV-aT1) < fabs(aTV-aT2)) ? aT2 : aT1;
1029 aDomain1.SetValues(aP1, aT1, aTolInt, aP2, aT2, aTolInt);
1031 for (i=0; i<2; ++i) {
1032 aAi=(!i) ? aA1 : aA2;
1035 gp_Dir2d aDiri(aXi, aYi);
1036 aLi=new Geom2d_Line(aPV, aDiri);
1040 aGInter.Perform(aGAC1, aDomain1, aGAC2, aDomain2, aTolInt, aTolInt);
1041 if (!aGInter.IsDone()) {
1045 aNbP=aGInter.NbPoints();
1052 for (j=1; j<=aNbP; ++j) {
1053 const IntRes2d_IntersectionPoint& aIPj=aGInter.Point(j);
1054 aT1j=aIPj.ParamOnFirst();
1055 aT2j=aIPj.ParamOnSecond();
1057 if (aT2j > aT2max) {
1064 if (Abs(dT) < aTolInt) {
1070 gp_Vec2d aV2D(aPV, aP);
1071 gp_Dir2d aDir2D(aV2D);
1073 aAngle=Angle(aDir2D);
1074 if (aAngle>aA1 && aAngle<aA2) {
1078 }// for (i=0; i<2; ++i) {