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_WireEdgeSet.hxx>
16 #include <BOPAlgo_WireSplitter.hxx>
17 #include <BOPCol_IndexedDataMapOfShapeInteger.hxx>
18 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
19 #include <BOPCol_ListOfShape.hxx>
20 #include <BOPCol_MapOfShape.hxx>
21 #include <BOPCol_SequenceOfPnt2d.hxx>
22 #include <BOPCol_SequenceOfReal.hxx>
23 #include <BOPCol_SequenceOfShape.hxx>
24 #include <BOPTools_AlgoTools2D.hxx>
25 #include <BRep_Builder.hxx>
26 #include <BRep_Tool.hxx>
27 #include <BRepAdaptor_Surface.hxx>
28 #include <Geom2d_Curve.hxx>
29 #include <Geom2d_Line.hxx>
30 #include <Geom2dAdaptor_Curve.hxx>
31 #include <Geom2dInt_GInter.hxx>
32 #include <Geom_Plane.hxx>
33 #include <Geom_RectangularTrimmedSurface.hxx>
34 #include <Geom_Surface.hxx>
35 #include <GeomAdaptor_Surface.hxx>
36 #include <gp_Dir2d.hxx>
37 #include <gp_Pnt2d.hxx>
38 #include <gp_Vec2d.hxx>
39 #include <IntRes2d_Domain.hxx>
40 #include <IntRes2d_IntersectionPoint.hxx>
41 #include <Precision.hxx>
43 #include <TopExp_Explorer.hxx>
44 #include <TopLoc_Location.hxx>
45 #include <TopoDS_Edge.hxx>
46 #include <TopoDS_Face.hxx>
47 #include <TopoDS_Iterator.hxx>
48 #include <TopoDS_Vertex.hxx>
49 #include <TopoDS_Wire.hxx>
50 #include <TopTools_ShapeMapHasher.hxx>
51 typedef NCollection_DataMap \
52 <TopoDS_Shape, Standard_Boolean, TopTools_ShapeMapHasher> \
53 BOPCol_DataMapOfShapeBoolean;
57 Standard_Real Angle (const gp_Dir2d& aDir2D);
60 Standard_Real Angle2D (const TopoDS_Vertex& aV,
61 const TopoDS_Edge& anEdge,
62 const TopoDS_Face& myFace,
63 const GeomAdaptor_Surface& aGAS,
64 const Standard_Boolean aFlag);
67 void GetNextVertex(const TopoDS_Vertex& aV,
68 const TopoDS_Edge& aE,
72 Standard_Real AngleIn(const TopoDS_Edge& aEIn,
73 const BOPAlgo_ListOfEdgeInfo& aLEInfo);
76 Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo);
79 gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE,
80 const TopoDS_Face& aF);
83 gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1,
84 const TopoDS_Edge& aE1,
85 const TopoDS_Face& aF);
88 Standard_Real ClockWiseAngle(const Standard_Real aAngleIn,
89 const Standard_Real aAngleOut);
92 void Path (const GeomAdaptor_Surface& aGAS,
93 const TopoDS_Face& myFace,
94 const TopoDS_Vertex& aVa,
95 const TopoDS_Edge& aEOuta,
96 BOPAlgo_EdgeInfo& anEdgeInfo,
97 BOPCol_SequenceOfShape& aLS,
98 BOPCol_SequenceOfShape& aVertVa,
99 BOPCol_SequenceOfPnt2d& aCoordVa,
100 BOPTools_ConnexityBlock& aCB,
101 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap,
102 BOPCol_DataMapOfShapeBoolean aVertMap);
105 Standard_Real Angle (const gp_Dir2d& aDir2D);
108 Standard_Real Tolerance2D (const TopoDS_Vertex& aV,
109 const GeomAdaptor_Surface& aGAS);
114 Standard_Real UTolerance2D (const TopoDS_Vertex& aV,
115 const GeomAdaptor_Surface& aGAS);
117 Standard_Real VTolerance2D (const TopoDS_Vertex& aV,
118 const GeomAdaptor_Surface& aGAS);
121 void RefineAngles(const TopoDS_Face& myFace,
122 const BOPCol_ListOfShape&,
123 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo&);
127 void RefineAngles(const TopoDS_Vertex& ,
129 const BOPCol_MapOfShape& ,
130 BOPAlgo_ListOfEdgeInfo& );
133 Standard_Boolean RefineAngle2D(const TopoDS_Vertex& ,
136 const Standard_Real ,
137 const Standard_Real ,
140 //=======================================================================
141 //function : SplitBlock
143 //=======================================================================
144 void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
145 BOPTools_ConnexityBlock& aCB)
147 Standard_Boolean bNothingToDo, bIsClosed, bIsIN;
148 Standard_Integer aIx, aNb, i, aCntIn, aCntOut;
149 Standard_Real aAngle;
150 TopAbs_Orientation aOr;
151 TopoDS_Iterator aItS;
154 BOPCol_ListIteratorOfListOfShape aIt;
155 BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI;
157 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo mySmartMap(100);
158 BOPCol_DataMapOfShapeBoolean aVertMap;
160 const BOPCol_ListOfShape& myEdges=aCB.Shapes();
162 // 1.Filling mySmartMap
163 BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane(myEdges, myFace);
165 aIt.Initialize(myEdges);
166 for(; aIt.More(); aIt.Next()) {
167 const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
168 if (!BOPTools_AlgoTools2D::HasCurveOnSurface (aE, myFace)) {
172 bIsClosed = BRep_Tool::Degenerated(aE) ||
173 BRep_Tool::IsClosed(aE, myFace);
176 for(i = 0; aItS.More(); aItS.Next(), ++i) {
177 const TopoDS_Shape& aV = aItS.Value();
178 aIx = mySmartMap.FindIndex(aV);
180 BOPAlgo_ListOfEdgeInfo aLEIx;
181 aIx = mySmartMap.Add(aV, aLEIx);
184 BOPAlgo_ListOfEdgeInfo& aLEI = mySmartMap(aIx);
185 BOPAlgo_EdgeInfo aEI;
188 aOr = aV.Orientation();
189 bIsIN = (aOr == TopAbs_REVERSED);
190 aEI.SetInFlag(bIsIN);
196 bIsClosed = bIsClosed || aV1.IsSame(aV);
199 if (aVertMap.IsBound(aV)) {
201 aVertMap.ChangeFind(aV) = bIsClosed;
204 aVertMap.Bind(aV, bIsClosed);
209 aNb=mySmartMap.Extent();
211 bNothingToDo=Standard_True;
212 for (i=1; i<=aNb; i++) {
215 const BOPAlgo_ListOfEdgeInfo& aLEInfo= mySmartMap(i);
216 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo);
217 for (; anIt.More(); anIt.Next()) {
218 const BOPAlgo_EdgeInfo& aEI=anIt.Value();
226 if (aCntIn!=1 || aCntOut!=1) {
227 bNothingToDo=Standard_False;
232 // Each vertex has one edge In and one - Out. Good. But it is not enought
233 // to consider that nothing to do with this. We must check edges on TShape
234 // coinsidence. If there are such edges there is something to do with.
236 Standard_Integer aNbE, aNbMapEE;
237 Standard_Boolean bFlag;
239 BOPCol_IndexedDataMapOfShapeListOfShape aMapEE(100);
240 aNbE=myEdges.Extent();
242 aIt.Initialize(myEdges);
243 for (; aIt.More(); aIt.Next()) {
244 const TopoDS_Shape& aE = aIt.Value();
245 if (!aMapEE.Contains(aE)) {
246 BOPCol_ListOfShape aLEx;
248 aMapEE.Add(aE, aLEx);
251 BOPCol_ListOfShape& aLEx=aMapEE.ChangeFromKey(aE);
257 aNbMapEE=aMapEE.Extent();
258 for (i=1; i<=aNbMapEE; ++i) {
259 const BOPCol_ListOfShape& aLEx=aMapEE(i);
261 if (aNbE==1) {// usual case
265 const TopoDS_Shape& aE1=aLEx.First();
266 const TopoDS_Shape& aE2=aLEx.Last();
267 if (aE1.IsSame(aE2)) {
268 bFlag=Standard_False;
273 bFlag=Standard_False;
277 bNothingToDo=bNothingToDo && bFlag;
278 } // if (bNothingToDo) {
282 BOPCol_ListOfShape& aLECB=aCB.ChangeShapes();
283 BOPAlgo_WireSplitter::MakeWire(aLECB, aW);
284 BOPCol_ListOfShape& aLoops=aCB.ChangeLoops();
290 // 3. Angles in mySmartMap
291 BRepAdaptor_Surface aBAS(myFace);
292 const GeomAdaptor_Surface& aGAS=aBAS.Surface();
294 for (i=1; i<=aNb; i++) {
295 const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&mySmartMap.FindKey(i)));
296 const BOPAlgo_ListOfEdgeInfo& aLEI= mySmartMap(i);
298 aItLEI.Initialize(aLEI);
299 for (; aItLEI.More(); aItLEI.Next()) {
300 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
301 const TopoDS_Edge& aE=aEI.Edge();
305 aOr = bIsIN ? TopAbs_REVERSED : TopAbs_FORWARD;
306 aVV.Orientation(aOr);
307 aAngle = Angle2D(aVV, aE, myFace, aGAS, bIsIN);
308 aEI.SetAngle(aAngle);
310 }// for (i=1; i<=aNb; i++) {
312 //Theme: The treatment p-curves convergent in node.
313 //The refining the angles of p-curves taking into account
314 //bounging curves if exist.
315 RefineAngles(myFace, myEdges, mySmartMap);
319 Standard_Boolean bIsOut, bIsNotPassed;
320 BOPCol_SequenceOfShape aLS, aVertVa;
321 BOPCol_SequenceOfPnt2d aCoordVa;
323 for (i=1; i<=aNb; ++i) {
324 const TopoDS_Vertex& aVa=(*(TopoDS_Vertex *)(&mySmartMap.FindKey(i)));
325 const BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i);
326 aItLEI.Initialize(aLEI);
327 for (; aItLEI.More(); aItLEI.Next()) {
328 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
329 const TopoDS_Edge& aEOuta=aEI.Edge();
332 bIsNotPassed=!aEI.Passed();
333 if (bIsOut && bIsNotPassed) {
339 Path(aGAS, myFace, aVa, aEOuta, aEI, aLS,
340 aVertVa, aCoordVa, aCB, mySmartMap, aVertMap);
343 }// for (i=1; i<=aNb; ++i) {
345 //=======================================================================
348 //=======================================================================
349 void Path (const GeomAdaptor_Surface& aGAS,
350 const TopoDS_Face& myFace,
351 const TopoDS_Vertex& aVFirst,
352 const TopoDS_Edge& aEFirst,
353 BOPAlgo_EdgeInfo& aEIFirst,
354 BOPCol_SequenceOfShape& aLS,
355 BOPCol_SequenceOfShape& aVertVa,
356 BOPCol_SequenceOfPnt2d& aCoordVa,
357 BOPTools_ConnexityBlock& aCB,
358 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap,
359 BOPCol_DataMapOfShapeBoolean aVertMap)
362 Standard_Integer i, j, aNb, aNbj;
363 Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle;
364 Standard_Real aTol2D, aTol2D2, aD2, aTwoPI;
365 Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed;
366 Standard_Boolean bIsClosed;
367 TopoDS_Vertex aVa, aVb;
369 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
373 BOPAlgo_EdgeInfo* anEdgeInfo = &aEIFirst;
375 aTwoPI = M_PI + M_PI;
380 // Do not escape through edge from which you enter
383 const TopoDS_Shape& anEPrev=aLS(aNb);
384 if (anEPrev.IsSame(aEOuta)) {
389 anEdgeInfo->SetPassed(Standard_True);
393 TopoDS_Vertex pVa=aVa;
394 pVa.Orientation(TopAbs_FORWARD);
395 gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace);
396 aCoordVa.Append(aPa);
398 GetNextVertex (pVa, aEOuta, aVb);
400 gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace);
402 const BOPAlgo_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb);
404 aTol2D = 2.*Tolerance2D(aVb, aGAS);
405 aTol2D2 = aTol2D * aTol2D;
407 bIsClosed = aVertMap.Find(aVb);
412 BOPCol_ListOfShape aBuf;
414 for (i=aNb; i>0; --i) {
415 const TopoDS_Shape& aVPrev=aVertVa(i);
416 const gp_Pnt2d& aPaPrev=aCoordVa(i);
417 const TopoDS_Shape& aEPrev=aLS(i);
421 anIsSameV = aVPrev.IsSame(aVb);
422 anIsSameV2d = anIsSameV;
425 aD2 = aPaPrev.SquareDistance(aPb);
426 anIsSameV2d = aD2 < aTol2D2;
428 Standard_Real udist = fabs(aPaPrev.X() - aPb.X());
429 Standard_Real vdist = fabs(aPaPrev.Y() - aPb.Y());
430 Standard_Real aTolU = 2.*UTolerance2D(aVb, aGAS);
431 Standard_Real aTolV = 2.*VTolerance2D(aVb, aGAS);
433 if((udist > aTolU) || (vdist > aTolV)) {
434 anIsSameV2d = Standard_False;
440 if (anIsSameV && anIsSameV2d) {
441 Standard_Integer iPriz;
443 if (aBuf.Extent()==2) {
444 if(aBuf.First().IsSame(aBuf.Last())) {
450 BOPAlgo_WireSplitter::MakeWire(aBuf, aW);
451 aCB.ChangeLoops().Append(aW);
464 BOPCol_SequenceOfShape aLSt, aVertVat;
465 BOPCol_SequenceOfPnt2d aCoordVat;
467 aVb=(*(TopoDS_Vertex *)(&aVertVa(i)));
469 for (j=1; j<=aNbj; ++j) {
471 aVertVat.Append(aVertVa(j));
472 aCoordVat.Append(aCoordVa(j));
489 BOPAlgo_EdgeInfo *pEdgeInfo=NULL;
491 anAngleIn = AngleIn(aEOuta, aLEInfo);
493 anIsFound = Standard_False;
494 Standard_Integer aCurIndexE = 0;
495 anIt.Initialize(aLEInfo);
496 for (; anIt.More(); anIt.Next()) {
497 BOPAlgo_EdgeInfo& anEI=anIt.ChangeValue();
498 const TopoDS_Edge& aE=anEI.Edge();
499 anIsOut=!anEI.IsIn();
500 anIsNotPassed=!anEI.Passed();
502 if (anIsOut && anIsNotPassed) {
505 // Is there one way to go out of the vertex
506 // we have to use it only.
507 Standard_Integer iCnt;
508 iCnt=NbWaysOut (aLEInfo);
511 // no way to go . (Error)
516 // the one and only way to go out .
518 anIsFound=Standard_True;
522 if (aE.IsSame(aEOuta)) {
529 aP2Dx = Coord2dVf(aE, myFace);
531 aD2 = aP2Dx.SquareDistance(aPb);
537 // Look for minimal angle and make the choice.
538 anAngleOut=anEI.Angle();
539 anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
541 if (anAngle < aMinAngle) {
544 anIsFound=Standard_True;
547 } // for (; anIt.More(); anIt.Next())
550 // no way to go . (Error)
555 aEOuta = pEdgeInfo->Edge();
556 anEdgeInfo = pEdgeInfo;
559 //=======================================================================
560 // function: ClockWiseAngle
562 //=======================================================================
563 Standard_Real ClockWiseAngle(const Standard_Real aAngleIn,
564 const Standard_Real aAngleOut)
566 Standard_Real aTwoPi=M_PI+M_PI;
567 Standard_Real dA, A1, A2, AIn, AOut ;
575 if (AOut >= aTwoPi) {
592 //else if (dA <= 1.e-15) {
593 else if (dA <= 1.e-14) {
598 //=======================================================================
601 //=======================================================================
602 gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1,
603 const TopoDS_Edge& aE1,
604 const TopoDS_Face& aF)
606 Standard_Real aT, aFirst, aLast;
607 Handle(Geom2d_Curve) aC2D;
610 aT=BRep_Tool::Parameter (aV1, aE1, aF);
611 aC2D=BRep_Tool::CurveOnSurface(aE1, aF, aFirst, aLast);
612 aC2D->D0 (aT, aP2D1);
616 //=======================================================================
617 // function: Coord2dVf
619 //=======================================================================
620 gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE,
621 const TopoDS_Face& aF)
623 Standard_Real aCoord=99.;
624 gp_Pnt2d aP2D1(aCoord, aCoord);
628 for (; aIt.More(); aIt.Next()) {
629 const TopoDS_Shape& aVx=aIt.Value();
630 if (aVx.Orientation()==TopAbs_FORWARD) {
632 const TopoDS_Vertex& aVxx=(*(TopoDS_Vertex *)(&aVx));// TopoDS::Vertex(aVx);
633 aP2D1=Coord2d(aVxx, aE, aF);
640 //=======================================================================
641 // function: NbWaysOut
643 //=======================================================================
644 Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo)
646 Standard_Boolean bIsOut, bIsNotPassed;
647 Standard_Integer iCnt=0;
648 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
650 anIt.Initialize(aLEInfo);
651 for (; anIt.More(); anIt.Next()) {
652 const BOPAlgo_EdgeInfo& anEI=anIt.Value();
655 bIsNotPassed=!anEI.Passed();
656 if (bIsOut && bIsNotPassed) {
663 //=======================================================================
666 //=======================================================================
667 Standard_Real AngleIn(const TopoDS_Edge& aEIn,
668 const BOPAlgo_ListOfEdgeInfo& aLEInfo)
670 Standard_Real anAngleIn;
671 Standard_Boolean anIsIn;
672 BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
674 anIt.Initialize(aLEInfo);
675 for (; anIt.More(); anIt.Next()) {
676 const BOPAlgo_EdgeInfo& anEdgeInfo=anIt.Value();
677 const TopoDS_Edge& aE=anEdgeInfo.Edge();
678 anIsIn=anEdgeInfo.IsIn();
680 if (anIsIn && aE==aEIn) {
681 anAngleIn=anEdgeInfo.Angle();
688 //=======================================================================
689 // function: GetNextVertex
691 //=======================================================================
692 void GetNextVertex(const TopoDS_Vertex& aV,
693 const TopoDS_Edge& aE,
699 for (; aIt.More(); aIt.Next()) {
700 const TopoDS_Shape& aVx=aIt.Value();
701 if (!aVx.IsEqual(aV)) {
702 aV1=(*(TopoDS_Vertex *)(&aVx));
708 //=======================================================================
711 //=======================================================================
712 Standard_Real Angle2D (const TopoDS_Vertex& aV,
713 const TopoDS_Edge& anEdge,
714 const TopoDS_Face& myFace,
715 const GeomAdaptor_Surface& aGAS,
716 const Standard_Boolean bIsIN)
718 Standard_Real aFirst, aLast, aToler, dt, aTV, aTV1, anAngle, aTX;
721 Handle(Geom2d_Curve) aC2D;
723 aTV=BRep_Tool::Parameter (aV, anEdge, myFace);
724 if (Precision::IsInfinite(aTV)) {
728 BOPTools_AlgoTools2D::CurveOnSurface (anEdge, myFace, aC2D,
729 aFirst, aLast, aToler);
730 dt=2.*Tolerance2D(aV, aGAS);
732 //for case chl/927/r9
733 aTX=0.05*(aLast - aFirst);//aTX=0.25*(aLast - aFirst);
738 // to save direction of the curve as much as it possible
739 // in the case of big tolerances
743 GeomAbs_CurveType aType;
744 Geom2dAdaptor_Curve aGAC2D(aC2D);
745 aType=aGAC2D.GetType();
746 if (aType==GeomAbs_BSplineCurve ||
747 aType==GeomAbs_BezierCurve) {
750 if (fabs (aTV-aFirst) < fabs(aTV - aLast)) {
757 if (aType==GeomAbs_Circle) {
759 TopAbs_Orientation aOrE;
764 aGAC2D.D1(aTM, aPM, aV2D);
765 aOrE=anEdge.Orientation();
766 if (aOrE==TopAbs_REVERSED) {
771 aGAC2D.D0 (aTV1, aPV1);
772 aGAC2D.D0 (aTV, aPV);
774 aV2D = bIsIN ? gp_Vec2d(aPV1, aPV) : gp_Vec2d(aPV, aPV1);
777 gp_Dir2d aDir2D(aV2D);
778 anAngle=Angle(aDir2D);
782 //=======================================================================
785 //=======================================================================
786 Standard_Real Angle (const gp_Dir2d& aDir2D)
788 gp_Dir2d aRefDir(1., 0.);
789 Standard_Real anAngle;
791 anAngle = aRefDir.Angle(aDir2D);
793 anAngle += M_PI + M_PI;
796 //=======================================================================
797 // function: Tolerance2D
799 //=======================================================================
800 Standard_Real Tolerance2D (const TopoDS_Vertex& aV,
801 const GeomAdaptor_Surface& aGAS)
803 Standard_Real aTol2D, anUr, aVr, aTolV3D;
804 GeomAbs_SurfaceType aType;
806 aType=aGAS.GetType();
807 aTolV3D=BRep_Tool::Tolerance(aV);
809 anUr=aGAS.UResolution(aTolV3D);
810 aVr =aGAS.VResolution(aTolV3D);
811 aTol2D=(aVr>anUr) ? aVr : anUr;
813 if (aTol2D < aTolV3D) {
816 if (aType==GeomAbs_BSplineSurface) {
823 //=======================================================================
824 //function : UTolerance2D
826 //=======================================================================
827 Standard_Real UTolerance2D (const TopoDS_Vertex& aV,
828 const GeomAdaptor_Surface& aGAS)
830 const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV);
831 const Standard_Real anUr = aGAS.UResolution(aTolV3D);
836 //=======================================================================
837 //function : VTolerance2D
839 //=======================================================================
840 Standard_Real VTolerance2D (const TopoDS_Vertex& aV,
841 const GeomAdaptor_Surface& aGAS)
843 const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV);
844 const Standard_Real anVr = aGAS.VResolution(aTolV3D);
849 //=======================================================================
850 //function : RefineAngles
852 //=======================================================================
853 void RefineAngles(const TopoDS_Face& myFace,
854 const BOPCol_ListOfShape& myEdges,
855 BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap)
857 Standard_Integer aNb, i;
858 BOPCol_IndexedDataMapOfShapeInteger aMSI;
859 BOPCol_MapOfShape aMBE;
860 BOPCol_ListIteratorOfListOfShape aIt;
863 aIt.Initialize(myEdges);
864 for(; aIt.More(); aIt.Next()) {
865 const TopoDS_Shape& aE=aIt.Value();
866 if(aMSI.Contains(aE)) {
867 Standard_Integer& iCnt = aMSI.ChangeFromKey(aE);
871 Standard_Integer iCnt = 1;
877 for (i = 1; i <= aNb; ++i) {
878 Standard_Integer iCnt = aMSI(i);
880 const TopoDS_Shape& aE = aMSI.FindKey(i);
887 aNb = mySmartMap.Extent();
888 for (i = 1; i <= aNb; ++i) {
889 const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&mySmartMap.FindKey(i));
890 BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i);
892 RefineAngles(aV, myFace, aMBE, aLEI);
895 //=======================================================================
896 typedef NCollection_DataMap \
897 <TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> \
898 BOPCol_DataMapOfShapeReal;
899 typedef BOPCol_DataMapOfShapeReal::Iterator \
900 BOPCol_DataMapIteratorOfDataMapOfShapeReal;
902 //=======================================================================
903 //function : RefineAngles
905 //=======================================================================
906 void RefineAngles(const TopoDS_Vertex& aV,
907 const TopoDS_Face& myFace,
908 const BOPCol_MapOfShape& aMBE,
909 BOPAlgo_ListOfEdgeInfo& aLEI)
911 Standard_Boolean bIsIn, bIsBoundary, bRefined;
912 Standard_Integer iCntBnd, iCntInt;
913 Standard_Real aA, aA1, aA2;
914 BOPCol_DataMapOfShapeReal aDMSR;
915 BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI;
921 aItLEI.Initialize(aLEI);
922 for (; aItLEI.More(); aItLEI.Next()) {
923 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
924 const TopoDS_Edge& aE=aEI.Edge();
928 if (aMBE.Contains(aE)) {
946 aItLEI.Initialize(aLEI);
947 for (; aItLEI.More(); aItLEI.Next()) {
948 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
949 const TopoDS_Edge& aE=aEI.Edge();
951 bIsBoundary=aMBE.Contains(aE);
953 if (bIsBoundary || bIsIn) {
958 if (aA>aA1 && aA<aA2) {
962 bRefined=RefineAngle2D(aV, aE, myFace, aA1, aA2, aA);
966 else if (iCntInt == 2) {
967 aA = (aA <= aA1) ? (aA1 + Precision::Angular()) :
968 (aA2 - Precision::Angular());
973 if (aDMSR.IsEmpty()) {
978 aItLEI.Initialize(aLEI);
979 for (; aItLEI.More(); aItLEI.Next()) {
980 BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
981 const TopoDS_Edge& aE=aEI.Edge();
984 if (!aDMSR.IsBound(aE)) {
996 //=======================================================================
997 //function : RefineAngle2D
999 //=======================================================================
1000 Standard_Boolean RefineAngle2D(const TopoDS_Vertex& aV,
1001 const TopoDS_Edge& aE,
1002 const TopoDS_Face& myFace,
1003 const Standard_Real aA1,
1004 const Standard_Real aA2,
1007 Standard_Boolean bRet;
1008 Standard_Integer i, j, aNbP;
1009 Standard_Real aTV, aTol, aT1, aT2, dT, aAngle, aT, aTOp;
1010 Standard_Real aTolInt, aAi, aXi, aYi, aT1j, aT2j, aT1max, aT2max, aCf;
1011 gp_Pnt2d aPV, aP, aP1, aP2;
1012 Handle(Geom2d_Curve) aC2D;
1013 Handle(Geom2d_Line) aLi;
1014 Geom2dAdaptor_Curve aGAC1, aGAC2;
1015 Geom2dInt_GInter aGInter;
1016 IntRes2d_Domain aDomain1, aDomain2;
1022 BOPTools_AlgoTools2D::CurveOnSurface(aE, myFace, aC2D, aT1, aT2, aTol);
1023 aGAC1.Load(aC2D, aT1, aT2);
1025 aTV=BRep_Tool::Parameter (aV, aE, myFace);
1028 aTOp = (fabs(aTV-aT1) < fabs(aTV-aT2)) ? aT2 : aT1;
1032 aDomain1.SetValues(aP1, aT1, aTolInt, aP2, aT2, aTolInt);
1034 for (i=0; i<2; ++i) {
1035 aAi=(!i) ? aA1 : aA2;
1038 gp_Dir2d aDiri(aXi, aYi);
1039 aLi=new Geom2d_Line(aPV, aDiri);
1043 aGInter.Perform(aGAC1, aDomain1, aGAC2, aDomain2, aTolInt, aTolInt);
1044 if (!aGInter.IsDone()) {
1048 aNbP=aGInter.NbPoints();
1055 for (j=1; j<=aNbP; ++j) {
1056 const IntRes2d_IntersectionPoint& aIPj=aGInter.Point(j);
1057 aT1j=aIPj.ParamOnFirst();
1058 aT2j=aIPj.ParamOnSecond();
1060 if (aT2j > aT2max) {
1067 if (Abs(dT) < aTolInt) {
1073 gp_Vec2d aV2D(aPV, aP);
1074 gp_Dir2d aDir2D(aV2D);
1076 aAngle=Angle(aDir2D);
1077 if (aAngle>aA1 && aAngle<aA2) {
1081 }// for (i=0; i<2; ++i) {