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.
16 #include <Bnd_Box.hxx>
17 #include <BOPTools_AlgoTools2D.hxx>
18 #include <BOPTools_AlgoTools3D.hxx>
19 #include <BRep_Builder.hxx>
20 #include <BRep_CurveRepresentation.hxx>
21 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
22 #include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
23 #include <BRep_PointRepresentation.hxx>
24 #include <BRep_TEdge.hxx>
25 #include <BRep_TFace.hxx>
26 #include <BRep_Tool.hxx>
27 #include <BRep_TVertex.hxx>
28 #include <BRepBndLib.hxx>
29 #include <BRepGProp.hxx>
30 #include <BRepTools.hxx>
31 #include <Geom2d_Curve.hxx>
32 #include <Geom2d_Line.hxx>
33 #include <Geom2d_TrimmedCurve.hxx>
34 #include <Geom2dAdaptor_Curve.hxx>
35 #include <Geom2dHatch_Hatcher.hxx>
36 #include <Geom_BezierSurface.hxx>
37 #include <Geom_BSplineSurface.hxx>
38 #include <Geom_Curve.hxx>
39 #include <Geom_RectangularTrimmedSurface.hxx>
40 #include <Geom_Surface.hxx>
41 #include <GeomAdaptor_Surface.hxx>
42 #include <gp_Cylinder.hxx>
44 #include <gp_Dir2d.hxx>
45 #include <gp_Lin2d.hxx>
48 #include <gp_Pnt2d.hxx>
50 #include <gp_Vec2d.hxx>
51 #include <GProp_GProps.hxx>
52 #include <HatchGen_Domain.hxx>
53 #include <IntTools_Context.hxx>
54 #include <IntTools_Tools.hxx>
55 #include <Poly_Triangulation.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <TopoDS_Edge.hxx>
60 #include <TopoDS_Face.hxx>
61 #include <TopoDS_Shape.hxx>
62 #include <TopoDS_Vertex.hxx>
63 #include <TopTools_IndexedMapOfShape.hxx>
65 static void Add(const TopoDS_Shape& aS,
66 TopTools_IndexedMapOfShape& myShapes,
67 Standard_Boolean& bHasGeometry);
69 Standard_Boolean HasGeometry(const TopoDS_Shape& aS);
71 //=======================================================================
72 //function : DoSplitSEAMOnFace
74 //=======================================================================
75 void BOPTools_AlgoTools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit,
76 const TopoDS_Face& aF)
78 Standard_Boolean bIsUPeriodic, bIsVPeriodic, bIsLeft;
79 Standard_Real aTol, a, b, anUPeriod, anVPeriod, aT, anU, dU, anU1;
80 Standard_Real aScPr, anV, dV, anV1;
81 Standard_Real aUmin, aUmax, aVmin, aVmax;
84 Handle(Geom2d_Curve) aTmpC1, aTmpC2;
85 Handle(Geom2d_Curve) C2D1;
86 Handle(Geom2d_Line) aLD1;
87 Handle(Geom_Surface) aS;
91 bIsLeft = Standard_False;
93 aSp.Orientation(TopAbs_FORWARD);
94 aTol=BRep_Tool::Tolerance(aSp);
96 aS=BRep_Tool::Surface(aF);
98 aS->Bounds(aUmin, aUmax, aVmin, aVmax);
100 bIsUPeriodic=aS->IsUPeriodic();
101 bIsVPeriodic=aS->IsVPeriodic();
103 anUPeriod = bIsUPeriodic ? aS->UPeriod() : 0.;
104 anVPeriod = bIsVPeriodic ? aS->VPeriod() : 0.;
106 if (!bIsUPeriodic && !bIsVPeriodic) {
107 Standard_Boolean bIsUClosed, bIsVClosed;
108 Handle(Geom_BSplineSurface) aBS;
109 Handle(Geom_BezierSurface) aBZ;
110 Handle(Geom_RectangularTrimmedSurface) aRTS;
112 bIsUClosed=Standard_False;
113 bIsVClosed=Standard_False;
114 aBS=Handle(Geom_BSplineSurface)::DownCast(aS);
115 aBZ=Handle(Geom_BezierSurface) ::DownCast(aS);
116 aRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
119 bIsUClosed=aBS->IsUClosed();
120 bIsVClosed=aBS->IsVClosed();
122 else if (!aBZ.IsNull()) {
123 bIsUClosed=aBZ->IsUClosed();
124 bIsVClosed=aBZ->IsVClosed();
126 else if (!aRTS.IsNull()) {
127 Handle(Geom_Surface) aSB;
129 aSB=aRTS->BasisSurface();
130 bIsUPeriodic=aSB->IsUPeriodic();
131 bIsVPeriodic=aSB->IsVPeriodic();
133 if (!(bIsUPeriodic || bIsVPeriodic)) {
136 anUPeriod = bIsUPeriodic ? aSB->UPeriod() : 0.;
137 anVPeriod = bIsVPeriodic ? aSB->VPeriod() : 0.;
141 if (!bIsUClosed && !bIsVClosed) {
146 anUPeriod=aUmax-aUmin;
149 anVPeriod=aVmax-aVmin;
154 //---------------------------------------------------
155 C2D1=BRep_Tool::CurveOnSurface(aSp, aF, a, b);
157 aT=BOPTools_AlgoTools2D::IntermediatePoint(a, b);
158 C2D1->D1(aT, aP2D, aVec2D);
159 gp_Dir2d aDir2D1(aVec2D), aDOX(-1.,0.), aDOY(0.,1.);
167 GeomAdaptor_Surface aGAS(aS);
168 dU = aGAS.UResolution(aTol);
169 dV = aGAS.VResolution(aTol);
172 if (fabs (anU-aUmin) < dU) {
173 bIsLeft=Standard_True;
176 else if (fabs (anU-aUmax) < dU) {
177 bIsLeft=Standard_False;
182 if (anVPeriod > 0.) {
183 if (fabs (anV-aVmin) < dV) {
184 bIsLeft=Standard_True;
187 else if (fabs (anV-aVmax) < dV) {
188 bIsLeft=Standard_False;
193 if (anU1==anU && anV1==anV) {
197 aScPr = (anU1==anU) ? aDir2D1*aDOX : aDir2D1*aDOY;
199 aTmpC1=Handle(Geom2d_Curve)::DownCast(C2D1->Copy());
200 Handle(Geom2d_TrimmedCurve) aC1 =
201 new Geom2d_TrimmedCurve(aTmpC1, a, b);
203 aTmpC2=Handle(Geom2d_Curve)::DownCast(C2D1->Copy());
204 Handle(Geom2d_TrimmedCurve) aC2 =
205 new Geom2d_TrimmedCurve(aTmpC2, a, b);
206 gp_Vec2d aTrV(anU1-anU, anV1-anV);
207 aC2->Translate(aTrV);
211 BB.UpdateEdge(aSp, aC2, aC1, aF, aTol);
214 BB.UpdateEdge(aSp, aC1, aC2, aF, aTol);
219 BB.UpdateEdge(aSp, aC1, aC2, aF, aTol);
222 BB.UpdateEdge(aSp, aC2, aC1, aF, aTol);
226 //=======================================================================
227 //function : GetNormalToFaceOnEdge
229 //=======================================================================
230 void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE,
231 const TopoDS_Face& aF,
233 const Handle(IntTools_Context)& theContext)
235 Standard_Real aT, aT1, aT2;
237 BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
238 aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2);
240 BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF, theContext);
242 if (aF.Orientation()==TopAbs_REVERSED){
246 //=======================================================================
247 //function : GetNormalToFaceOnEdge
249 //=======================================================================
250 void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE,
251 const TopoDS_Face& aF1,
252 const Standard_Real aT,
254 const Handle(IntTools_Context)& theContext)
256 Standard_Real U, V, aTolPC;
261 Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
263 Handle(Geom2d_Curve)aC2D1;
264 BOPTools_AlgoTools2D::CurveOnSurface(aE, aF1, aC2D1, aTolPC, theContext);
270 aS1->D1(U, V, aP, aD1U, aD1V);
276 //=======================================================================
277 //function : SenseFlag
279 //=======================================================================
280 Standard_Integer BOPTools_AlgoTools3D::SenseFlag (const gp_Dir& aDNF1,
283 Standard_Boolean bIsDirsCoinside;
285 bIsDirsCoinside=IntTools_Tools::IsDirsCoinside(aDNF1, aDNF2);
286 if (!bIsDirsCoinside) {
301 //=======================================================================
302 //function : GetNormalToSurface
304 //=======================================================================
305 Standard_Boolean BOPTools_AlgoTools3D::GetNormalToSurface
306 (const Handle(Geom_Surface)& aS,
307 const Standard_Real U,
308 const Standard_Real V,
314 aS->D1(U, V, aP, aD1U, aD1V);
316 Standard_Real aLenU = aD1U.SquareMagnitude();
317 if (aLenU < gp::Resolution())
318 return Standard_False;
320 Standard_Real aLenV = aD1V.SquareMagnitude();
321 if (aLenV < gp::Resolution())
322 return Standard_False;
327 Standard_Boolean bFlag = IntTools_Tools::IsDirsCoinside(aDD1U, aDD1U);
334 //=======================================================================
335 //function : GetApproxNormalToFaceOnEdge
337 //=======================================================================
338 Standard_Boolean BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge
339 (const TopoDS_Edge& aE,
340 const TopoDS_Face& aF,
341 const Standard_Real aT,
347 Standard_Integer iErr = BOPTools_AlgoTools3D::PointNearEdge
348 (aE, aF, aT, aDt2D, aPx2DNear, aPNear);
350 Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
352 BOPTools_AlgoTools3D::GetNormalToSurface
353 (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF);
355 if (aF.Orientation()==TopAbs_REVERSED){
362 //=======================================================================
363 //function : GetApproxNormalToFaceOnEdge
365 //=======================================================================
366 Standard_Boolean BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge
367 (const TopoDS_Edge& aE,
368 const TopoDS_Face& aF,
369 const Standard_Real aT,
372 const Handle(IntTools_Context)& theContext)
375 Standard_Integer iErr = BOPTools_AlgoTools3D::PointNearEdge
376 (aE, aF, aT, aPx2DNear, aPNear, theContext);
378 Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
380 BOPTools_AlgoTools3D::GetNormalToSurface
381 (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF);
383 if (aF.Orientation()==TopAbs_REVERSED){
390 //=======================================================================
391 //function : GetApproxNormalToFaceOnEdge
393 //=======================================================================
394 Standard_Boolean BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge
395 (const TopoDS_Edge& aE,
396 const TopoDS_Face& aF,
397 const Standard_Real aT,
398 const Standard_Real theStep,
401 const Handle(IntTools_Context)& theContext)
404 Standard_Integer iErr = BOPTools_AlgoTools3D::PointNearEdge
405 (aE, aF, aT, theStep, aPx2DNear, aPNear, theContext);
407 Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
409 BOPTools_AlgoTools3D::GetNormalToSurface
410 (aS, aPx2DNear.X(), aPx2DNear.Y(), aDNF);
412 if (aF.Orientation()==TopAbs_REVERSED){
419 //=======================================================================
420 //function : PointNearEdge
422 //=======================================================================
423 Standard_Integer BOPTools_AlgoTools3D::PointNearEdge
424 (const TopoDS_Edge& aE,
425 const TopoDS_Face& aF,
426 const Standard_Real aT,
427 const Standard_Real aDt2D,
431 Standard_Real aFirst, aLast, aETol, aFTol, transVal;
432 GeomAbs_SurfaceType aTS;
433 Handle(Geom2d_Curve) aC2D;
434 Handle(Geom_Surface) aS;
436 aC2D= BRep_Tool::CurveOnSurface (aE, aF, aFirst, aLast);
437 Standard_Integer iErr = aC2D.IsNull() ? 1 : 0;
442 aS=BRep_Tool::Surface(aF);
446 aC2D->D1 (aT, aPx2D, aVx2D);
447 gp_Dir2d aDx2D(aVx2D);
450 aDP.SetCoord (-aDx2D.Y(), aDx2D.X());
452 if (aE.Orientation()==TopAbs_REVERSED){
456 if (aF.Orientation()==TopAbs_REVERSED) {
460 aETol = BRep_Tool::Tolerance(aE);
461 aFTol = BRep_Tool::Tolerance(aF);
463 GeomAdaptor_Surface aGAS(aS);
465 if (aTS==GeomAbs_BSplineSurface) {
470 if( aETol > 1.e-5 || aFTol > 1.e-5 ) {
472 if(aTS!=GeomAbs_Sphere) {
473 gp_Vec2d transVec( aDP );
474 transVal = aDt2D + aETol + aFTol;
475 if (aTS==GeomAbs_Cylinder) {// pkv/909/F8
476 Standard_Real aR, dT;
478 gp_Cylinder aCyl=aGAS.Cylinder();
481 if (dT>=-1 && dT<=1) {
487 transVec.Multiply(transVal);
488 aPx2DNear = aPx2D.Translated( transVec );
492 (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y());
497 (aPx2D.X()+aDt2D*aDP.X(), aPx2D.Y()+aDt2D*aDP.Y());
500 aS->D0(aPx2DNear.X(), aPx2DNear.Y(), aPxNear);
503 //=======================================================================
504 //function : PointNearEdge
506 //=======================================================================
507 Standard_Integer BOPTools_AlgoTools3D::PointNearEdge
508 (const TopoDS_Edge& aE,
509 const TopoDS_Face& aF,
510 const Standard_Real aT,
513 const Handle(IntTools_Context)& theContext)
515 Standard_Real aTolE, aTolF, dTx, dT2D;
516 Handle(Geom_Surface) aS;
517 GeomAdaptor_Surface aGAS;
519 dT2D=10.*BOPTools_AlgoTools3D::MinStepIn2d();//~1.e-5;
521 aS = BRep_Tool::Surface(aF);
523 if (aGAS.GetType()==GeomAbs_Cylinder ||
524 aGAS.GetType()==GeomAbs_Sphere) {
528 aTolE = BRep_Tool::Tolerance(aE);
529 aTolF = BRep_Tool::Tolerance(aF);
530 dTx = 2.*(aTolE + aTolF);
535 Standard_Integer iErr = BOPTools_AlgoTools3D::PointNearEdge
536 (aE, aF, aT, dT2D, aPx2DNear, aPxNear);
537 if ((iErr != 1) && !theContext->IsPointInOnFace(aF, aPx2DNear)) {
541 iErr = BOPTools_AlgoTools3D::PointInFace
542 (aF, aE, aT, dT2D, aP, aP2d, theContext);
548 iErr = 2; // point is out of the face
555 //=======================================================================
556 //function : PointNearEdge
558 //=======================================================================
559 Standard_Integer BOPTools_AlgoTools3D::PointNearEdge
560 (const TopoDS_Edge& aE,
561 const TopoDS_Face& aF,
562 const Standard_Real aT,
563 const Standard_Real theStep,
566 const Handle(IntTools_Context)& theContext)
568 Standard_Integer iErr = BOPTools_AlgoTools3D::PointNearEdge
569 (aE, aF, aT, theStep, aPx2DNear, aPxNear);
570 if ((iErr != 1) && !theContext->IsPointInOnFace(aF, aPx2DNear)) {
574 iErr = BOPTools_AlgoTools3D::PointInFace
575 (aF, aE, aT, theStep, aP, aP2d, theContext);
581 iErr = 2; // point is out of the face
587 //=======================================================================
588 // function: PointNearEdge
590 //=======================================================================
591 Standard_Integer BOPTools_AlgoTools3D::PointNearEdge
592 (const TopoDS_Edge& aE,
593 const TopoDS_Face& aF,
594 gp_Pnt2d& aPInFace2D,
596 const Handle(IntTools_Context)& theContext)
598 Standard_Real aT, aT1, aT2;
600 // 1. compute parameter on edge
601 BRep_Tool::Range(aE, aT1, aT2);
602 aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2);
604 // 2. compute point inside the face near the edge
607 aFF.Orientation(TopAbs_FORWARD);
608 BOPTools_AlgoTools3D::OrientEdgeOnFace (aE, aFF, aERight);
610 Standard_Integer iErr = BOPTools_AlgoTools3D::PointNearEdge
611 (aERight, aFF, aT, aPInFace2D, aPInFace, theContext);
615 //=======================================================================
616 //function : MinStepIn2d
618 //=======================================================================
619 Standard_Real BOPTools_AlgoTools3D::MinStepIn2d()
621 Standard_Real dt=1.e-5;
624 //=======================================================================
625 //function : IsEmptyShape
627 //=======================================================================
628 Standard_Boolean BOPTools_AlgoTools3D::IsEmptyShape
629 (const TopoDS_Shape& aS)
631 Standard_Boolean bHasGeometry=Standard_False;
633 TopTools_IndexedMapOfShape myShapes;
635 Add(aS, myShapes, bHasGeometry);
637 return !bHasGeometry;
639 //=======================================================================
642 //=======================================================================
643 void Add(const TopoDS_Shape& aS,
644 TopTools_IndexedMapOfShape& myShapes,
645 Standard_Boolean& bHasGeometry)
647 Standard_Integer anIndex;
657 TopoDS_Shape aSx = aS;
659 anIndex=myShapes.FindIndex(aSx);
661 bHasGeometry=HasGeometry (aSx);
666 TopoDS_Iterator anIt(aSx, Standard_False, Standard_False);
667 for(; anIt.More(); anIt.Next()) {
668 const TopoDS_Shape& aSy=anIt.Value();
669 Add(aSy, myShapes, bHasGeometry);
679 //=======================================================================
680 //function : HasGeometry
682 //=======================================================================
683 Standard_Boolean HasGeometry(const TopoDS_Shape& aS)
685 Standard_Boolean bHasGeometry=Standard_True;
686 TopAbs_ShapeEnum aType= aS.ShapeType();
688 if (aType == TopAbs_VERTEX) {
692 else if (aType == TopAbs_EDGE) {
693 Handle(BRep_TEdge) TE = Handle(BRep_TEdge)::DownCast(aS.TShape());
694 BRep_ListIteratorOfListOfCurveRepresentation itrc(TE->Curves());
696 while (itrc.More()) {
697 const Handle(BRep_CurveRepresentation)& CR = itrc.Value();
698 if (CR->IsCurve3D()) {
699 if (!CR->Curve3D().IsNull()) {
703 else if (CR->IsCurveOnSurface()) {
706 else if (CR->IsRegularity()) {
709 else if (!CR->Polygon3D().IsNull()) {
712 else if (CR->IsPolygonOnTriangulation()) {
715 else if (CR->IsPolygonOnSurface()) {
722 else if (aType == TopAbs_FACE) {
723 Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(aS.TShape());
724 if (!TF->Surface().IsNull()) {
727 Handle(Poly_Triangulation) Tr = TF->Triangulation();
733 return !bHasGeometry;
735 //=======================================================================
736 //function : OrientEdgeOnFace
738 //=======================================================================
739 void BOPTools_AlgoTools3D::OrientEdgeOnFace (const TopoDS_Edge& aE,
740 const TopoDS_Face& aF,
741 TopoDS_Edge& aERight)
743 if (BRep_Tool::IsClosed(aE, aF)) {
745 aERight.Orientation(aE.Orientation());
747 Standard_Integer iFoundCount = 0;
748 TopoDS_Edge anEdge = aE;
749 TopExp_Explorer anExp(aF, TopAbs_EDGE);
751 for (; anExp.More(); anExp.Next()) {
752 const TopoDS_Shape& aSS=anExp.Current();
754 if (aSS.IsSame(aE)) {
755 anEdge = TopoDS::Edge(aSS);
760 if(iFoundCount == 1) {
766 TopExp_Explorer anExp(aF, TopAbs_EDGE);
767 for (; anExp.More(); anExp.Next()) {
768 const TopoDS_Shape& aSS=anExp.Current();
769 if (aSS.IsSame(aE)) {
771 aERight.Orientation(aSS.Orientation());
776 aERight.Orientation(aE.Orientation());
778 //=======================================================================
779 //function : PointInFace
781 //=======================================================================
782 Standard_Integer BOPTools_AlgoTools3D::PointInFace
783 (const TopoDS_Face& theF,
786 const Handle(IntTools_Context)& theContext)
788 Standard_Integer i, iErr = 1;
789 Standard_Real aUMin, aUMax, aVMin, aVMax, aUx;
791 theContext->UVBounds(theF, aUMin, aUMax, aVMin, aVMax);
793 gp_Dir2d aD2D(0. , 1.);
794 aUx = IntTools_Tools::IntermediatePoint(aUMin, aUMax);
796 for (i = 0; i < 2; ++i) {
797 gp_Pnt2d aP2D(aUx, 0.);
798 Handle(Geom2d_Line) aL2D = new Geom2d_Line (aP2D, aD2D);
799 iErr = BOPTools_AlgoTools3D::PointInFace
800 (theF, aL2D, theP, theP2D, theContext);
806 // possible reason - incorrect computation of the 2d box of the face.
807 // try to compute the point with the translated line.
808 aUx = aUMax - (aUx - aUMin);
814 //=======================================================================
815 //function : PointInFace
817 //=======================================================================
818 Standard_Integer BOPTools_AlgoTools3D::PointInFace
819 (const TopoDS_Face& theF,
820 const TopoDS_Edge& theE,
821 const Standard_Real theT,
822 const Standard_Real theDt2D,
825 const Handle(IntTools_Context)& theContext)
827 Standard_Integer iErr;
829 Handle(Geom2d_Curve) aC2D;
832 aC2D = BRep_Tool::CurveOnSurface (theE, theF, f, l);
841 aC2D->D1(theT, aP2D, aV2D);
842 gp_Dir2d aD2Dx(aV2D);
845 aD2D.SetCoord (-aD2Dx.Y(), aD2Dx.X());
847 if (theE.Orientation()==TopAbs_REVERSED){
851 if (theF.Orientation()==TopAbs_REVERSED) {
855 Handle(Geom2d_Line) aL2D = new Geom2d_Line(aP2D, aD2D);
856 Handle(Geom2d_TrimmedCurve) aL2DTrim =
857 new Geom2d_TrimmedCurve(aL2D, 0., Precision::Infinite());
859 iErr = BOPTools_AlgoTools3D::PointInFace
860 (theF, aL2DTrim, theP, theP2D, theContext, theDt2D);
864 //=======================================================================
865 //function : PointInFace
867 //=======================================================================
868 Standard_Integer BOPTools_AlgoTools3D::PointInFace
869 (const TopoDS_Face& theF,
870 const Handle(Geom2d_Curve)& theL2D,
873 const Handle(IntTools_Context)& theContext,
874 const Standard_Real theDt2D)
876 Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
877 Standard_Integer iErr, aIH, aNbDomains;
878 Standard_Real aVx, aV1, aV2;
880 Geom2dHatch_Hatcher& aHatcher = theContext->Hatcher(theF);
882 Geom2dAdaptor_Curve aHCur(theL2D);
884 aHatcher.ClrHatchings();
885 aIH = aHatcher.AddHatching(aHCur);
890 bIsDone = aHatcher.TrimDone(aIH);
896 aHatcher.ComputeDomains(aIH);
897 bIsDone = aHatcher.IsDone(aIH);
903 aNbDomains = aHatcher.NbDomains(aIH);
904 if (aNbDomains == 0) {
909 const HatchGen_Domain& aDomain = aHatcher.Domain (aIH, 1);
910 bHasFirstPoint = aDomain.HasFirstPoint();
911 if (!bHasFirstPoint) {
916 bHasSecondPoint = aDomain.HasSecondPoint();
917 if (!bHasSecondPoint) {
922 aV1 = aDomain.FirstPoint().Parameter();
923 aV2 = aDomain.SecondPoint().Parameter();
925 aVx = (theDt2D > 0. && (aV2 - aV1) > theDt2D) ? (aV1 + theDt2D) :
926 IntTools_Tools::IntermediatePoint(aV1, aV2);
928 Handle(Geom_Surface) aS = BRep_Tool::Surface(theF);
930 theL2D->D0(aVx, theP2D);
931 aS->D0(theP2D.X(), theP2D.Y(), theP);
935 aHatcher.RemHatching(aIH);