0029351: Boolean Operations create invalid pcurves
[occt.git] / src / BOPTools / BOPTools_AlgoTools2D.cxx
index 90bd350..b24667e 100644 (file)
@@ -13,8 +13,6 @@
 // commercial license or contractual agreement.
 
 
-#include <BOPCol_IndexedMapOfShape.hxx>
-#include <BOPTools.hxx>
 #include <BOPTools_AlgoTools2D.hxx>
 #include <BRep_Builder.hxx>
 #include <BRep_CurveRepresentation.hxx>
@@ -46,6 +44,7 @@
 #include <GeomAdaptor_HSurface.hxx>
 #include <GeomAdaptor_Surface.hxx>
 #include <GeomInt.hxx>
+#include <GeomLib.hxx>
 #include <GeomProjLib.hxx>
 #include <gp.hxx>
 #include <gp_Cylinder.hxx>
@@ -57,6 +56,7 @@
 #include <IntTools_Tools.hxx>
 #include <Precision.hxx>
 #include <ProjLib_ProjectedCurve.hxx>
+#include <ProjLib.hxx>
 #include <Standard_ConstructionError.hxx>
 #include <Standard_NotImplemented.hxx>
 #include <TopExp.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 
-static 
-  Standard_Boolean CheckEdgeLength (const TopoDS_Edge& );
-
-static
-  Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& , 
-                                                const TopoDS_Face& ,
-                                                Standard_Real& ,
-                                                Standard_Real& ,
-                                                Standard_Boolean& );
-static
-  Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& , 
-                                                const Handle(Geom_Surface)& ,
-                                                const TopLoc_Location& ,
-                                                Standard_Real& ,
-                                                Standard_Real& ,
-                                                Standard_Boolean& );
 static
   Standard_Real MaxToleranceEdge (const TopoDS_Face& );
 
@@ -89,7 +73,8 @@ static
 //purpose  : 
 //=======================================================================
 void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
-                                                     const TopoDS_Face& aF)
+                                                     const TopoDS_Face& aF,
+                                                     const Handle(IntTools_Context)& theContext)
 {
   BRep_Builder aBB;
   Handle(Geom2d_Curve) aC2D;
@@ -104,7 +89,7 @@ void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
   }
   
 
-  BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC);
+  BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC, theContext);
   
   aTolEdge=BRep_Tool::Tolerance(aE);
 
@@ -130,9 +115,6 @@ Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent
   if (isdgE) {
     return Standard_False;
   }
-  if (!CheckEdgeLength(anEdge)) {
-    return Standard_False;
-  }
 
   Handle(Geom_Curve) aC=BRep_Tool::Curve(anEdge, first, last);
   gp_Pnt aP;
@@ -159,14 +141,14 @@ void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
                                            const TopoDS_Face& aF,
                                            const Standard_Real aParameter,
                                            Standard_Real& U,
-                                           Standard_Real& V)
+                                           Standard_Real& V,
+                                           const Handle(IntTools_Context)& theContext)
 {
   gp_Pnt2d aP2D;
   Handle(Geom2d_Curve) aC2D;
   Standard_Real aToler, aFirst, aLast;
 
-  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, 
-                                        aFirst, aLast, aToler); 
+  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, theContext);
   aC2D->D0(aParameter, aP2D);
   U=aP2D.X();
   V=aP2D.Y();
@@ -180,12 +162,12 @@ void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
 void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
                                            const TopoDS_Face& aF,
                                            Handle(Geom2d_Curve)& aC2D,
-                                           Standard_Real& aToler)
+                                           Standard_Real& aToler,
+                                           const Handle(IntTools_Context)& theContext)
 {
   Standard_Real aFirst, aLast; 
   //
-  BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, 
-                                        aFirst, aLast, aToler); 
+  BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aFirst, aLast, aToler, theContext); 
   //
   return;
 }
@@ -198,7 +180,8 @@ void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
                                            Handle(Geom2d_Curve)& aC2D,
                                            Standard_Real& aFirst,
                                            Standard_Real& aLast,
-                                           Standard_Real& aToler)
+                                           Standard_Real& aToler,
+                                           const Handle(IntTools_Context)& theContext)
 {
   Standard_Boolean aHasOld;
   Handle(Geom2d_Curve) C2D;
@@ -211,7 +194,7 @@ void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
     return;
   }
 
-  BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler);
+  BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, theContext);
   aC2D=C2D;
   return;
 }
@@ -247,7 +230,6 @@ Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface
 Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface 
   (const TopoDS_Edge& aE,
    const TopoDS_Face& aF)
-                                                   
 {
   Standard_Boolean bHasOld;
   Handle(Geom2d_Curve) aC2D;
@@ -268,45 +250,51 @@ Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface
 //function : AdjustPCurveOnFace
 //purpose  : 
 //=======================================================================
-void BOPTools_AlgoTools2D::AdjustPCurveOnFace 
-  (const TopoDS_Face& aF,
-   const Handle(Geom_Curve)&   aC3D,
-   const Handle(Geom2d_Curve)& aC2D, 
-   Handle(Geom2d_Curve)& aC2DA)
+void BOPTools_AlgoTools2D::AdjustPCurveOnFace
+  (const TopoDS_Face& theF,
+   const Handle(Geom_Curve)&   theC3D,
+   const Handle(Geom2d_Curve)& theC2D,
+   Handle(Geom2d_Curve)& theC2DA,
+   const Handle(IntTools_Context)& theContext)
 {
-  Standard_Real aT1, aT2;
+  Standard_Real aT1 = theC3D->FirstParameter();
+  Standard_Real aT2 = theC3D->LastParameter();
   //
-  aT1=aC3D->FirstParameter();
-  aT2=aC3D->LastParameter();
-  //
-  BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aT1, aT2, aC2D, aC2DA);
+  BOPTools_AlgoTools2D::AdjustPCurveOnFace (theF, aT1, aT2, theC2D, theC2DA, theContext);
 }
 //=======================================================================
 //function : AdjustPCurveOnFace
 //purpose  : 
 //=======================================================================
 void BOPTools_AlgoTools2D::AdjustPCurveOnFace 
-  (const TopoDS_Face& aF,
-   const Standard_Real aT1,
-   const Standard_Real aT2,
-   const Handle(Geom2d_Curve)& aC2D, 
-   Handle(Geom2d_Curve)& aC2DA)
+  (const TopoDS_Face& theF,
+   const Standard_Real theFirst,
+   const Standard_Real theLast,
+   const Handle(Geom2d_Curve)& theC2D, 
+   Handle(Geom2d_Curve)& theC2DA,
+   const Handle(IntTools_Context)& theContext)
 {
-  BRepAdaptor_Surface aBAS(aF, Standard_True);
+  BRepAdaptor_Surface aBASTmp;
+  const BRepAdaptor_Surface* pBAS;
+  if (!theContext.IsNull()) {
+    pBAS = &theContext->SurfaceAdaptor(theF);
+  }
+  else {
+    aBASTmp.Initialize(theF, Standard_True);
+    pBAS = &aBASTmp;
+  }
   //
-  BOPTools_AlgoTools2D::AdjustPCurveOnFace(aBAS, aT1, aT2, 
-                                          aC2D, aC2DA);
+  BOPTools_AlgoTools2D::AdjustPCurveOnSurf(*pBAS, theFirst, theLast, theC2D, theC2DA);
 }
-
 //=======================================================================
 //function : AdjustPCurveOnFace
 //purpose  : 
 //=======================================================================
-void BOPTools_AlgoTools2D::AdjustPCurveOnFace 
+void BOPTools_AlgoTools2D::AdjustPCurveOnSurf
   (const BRepAdaptor_Surface& aBAS,
    const Standard_Real aFirst,
    const Standard_Real aLast,
-   const Handle(Geom2d_Curve)& aC2D, 
+   const Handle(Geom2d_Curve)& aC2D,
    Handle(Geom2d_Curve)& aC2DA)
 {
   Standard_Boolean mincond, maxcond;
@@ -319,9 +307,6 @@ void BOPTools_AlgoTools2D::AdjustPCurveOnFace
   VMin=aBAS.FirstVParameter();
   VMax=aBAS.LastVParameter();
   //
-  //BRepAdaptor_Surface aBAS(aF, Standard_False);
-  //BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax);
-  //
   aDelta=Precision::PConfusion(); 
   
   aT =.5*(aFirst+aLast);
@@ -474,57 +459,6 @@ Standard_Real BOPTools_AlgoTools2D::IntermediatePoint
   aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2);
   return aT;
 }
-
-//=======================================================================
-//function : BuildPCurveForEdgeOnPlane
-//purpose  : 
-//=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane 
-  (const TopoDS_Edge& aE,
-   const TopoDS_Face& aF)
-{
-  Standard_Boolean bToUpdate;
-  Standard_Real aTolE, aT1, aT2;
-  Handle(Geom2d_Curve) aC2D;
-  BRep_Builder aBB;
-  //
-  aC2D=BRep_Tool_CurveOnSurface(aE, aF, aT1, aT2, bToUpdate);
-  if (bToUpdate) {
-    aTolE=BRep_Tool::Tolerance(aE);
-    aBB.UpdateEdge(aE, aC2D, aF, aTolE);
-  }
-}
-
-//=======================================================================
-//function : BuildPCurveForEdgeOnPlane
-//purpose  : 
-//=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane 
-  (const TopoDS_Edge& aE,
-   const TopoDS_Face& aF,
-   Handle(Geom2d_Curve)& aC2D,
-   Standard_Boolean& bToUpdate)
-{
-  Standard_Real aT1, aT2;
-  aC2D=BRep_Tool_CurveOnSurface(aE, aF, aT1, aT2, bToUpdate);
-}
-
-//=======================================================================
-// function: BuildPCurveForEdgesOnPlane
-// purpose: 
-//=======================================================================
-void BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane 
-  (const BOPCol_ListOfShape& aLE,
-   const TopoDS_Face& aF)
-{
-  BOPCol_ListIteratorOfListOfShape aIt;
-  //
-  aIt.Initialize(aLE);
-  for(; aIt.More(); aIt.Next()) {
-    const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
-    BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (aE, aF);
-  }
-}
 //=======================================================================
 //function : Make2D
 //purpose  : 
@@ -534,7 +468,8 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
                                    Handle(Geom2d_Curve)& aC2D,
                                    Standard_Real& aFirst,
                                    Standard_Real& aLast,
-                                   Standard_Real& aToler)
+                                   Standard_Real& aToler,
+                                   const Handle(IntTools_Context)& theContext)
 {
   Standard_Boolean aLocIdentity;
   Standard_Real f3d, l3d;
@@ -569,7 +504,7 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
   
   //
   aToler = BRep_Tool::Tolerance(aE);
-  BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D2, f3d, l3d, aC2D, aToler);
+  BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D2, f3d, l3d, aC2D, aToler, theContext);
   //
   aFirst = f3d; 
   aLast  = l3d;
@@ -582,7 +517,8 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
 void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
                                              const Handle(Geom_Curve)& aC3D,
                                              Handle(Geom2d_Curve)& aC2D, //->
-                                             Standard_Real& TolReached2d)
+                                             Standard_Real& TolReached2d,
+                                             const Handle(IntTools_Context)& theContext)
 {
   Standard_Real aFirst, aLast;
 
@@ -591,85 +527,122 @@ void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
   //
   TolReached2d=0.;
   //
-  BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst, 
-                                          aLast, aC2D, TolReached2d);
+  BOPTools_AlgoTools2D::MakePCurveOnFace
+    (aF, aC3D, aFirst, aLast, aC2D, TolReached2d, theContext);
 }
 
 //=======================================================================
 //function : MakePCurveOnFace
 //purpose  : 
 //=======================================================================
-void BOPTools_AlgoTools2D::MakePCurveOnFace 
+void BOPTools_AlgoTools2D::MakePCurveOnFace
   (const TopoDS_Face& aF,
    const Handle(Geom_Curve)& aC3D,
    const Standard_Real aT1,
    const Standard_Real aT2,
-   Handle(Geom2d_Curve)& aC2D, 
-   Standard_Real& TolReached2d)
+   Handle(Geom2d_Curve)& aC2D,
+   Standard_Real& TolReached2d,
+   const Handle(IntTools_Context)& theContext)
 {
-  Standard_Real aTolR, aT;
-  Standard_Real aUMin, aUMax, aVMin, aVMax;
-  Handle(Geom2d_Curve) aC2DA;
-  Handle(GeomAdaptor_HSurface) aBAHS;
-  Handle(GeomAdaptor_HCurve) aBAHC;
-  Handle(Geom_Surface) aS;
-  //
-  BRepAdaptor_Surface aBAS(aF, Standard_True);
-  aUMin=aBAS.FirstUParameter();
-  aUMax=aBAS.LastUParameter();
-  aVMin=aBAS.FirstVParameter();
-  aVMax=aBAS.LastVParameter();
-  aS=aBAS.Surface().Surface();
-  aS=Handle(Geom_Surface)::DownCast(aS->Transformed(aBAS.Trsf()));
-  GeomAdaptor_Surface aGAS(aS, aUMin, aUMax, aVMin, aVMax);
+  BRepAdaptor_Surface aBASTmp;
+  const BRepAdaptor_Surface* pBAS;
+  if (!theContext.IsNull()) {
+    pBAS = &theContext->SurfaceAdaptor(aF);
+  }
+  else {
+    aBASTmp.Initialize(aF, Standard_True);
+    pBAS = &aBASTmp;
+  }
   //
-  aBAHS=new GeomAdaptor_HSurface(aGAS);
-  aBAHC=new GeomAdaptor_HCurve(aC3D, aT1, aT2);
+  Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(*pBAS);
+  Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aT1, aT2);
   //
+  Standard_Real aTolR;
+  Standard_Real aTR = Precision::Confusion();//1.e-7;
+  Standard_Real aMaxTol = 1.e3 * aTR; //0.0001
+  Standard_Boolean isAnaSurf =  ProjLib::IsAnaSurf(aBAHS);
+
   //when the type of surface is GeomAbs_SurfaceOfRevolution
-  if (aGAS.GetType() == GeomAbs_SurfaceOfRevolution) {
-    Standard_Real aTR;
-    //
-    aTR=Precision::Confusion();//1.e-7;
+  if (pBAS->GetType() == GeomAbs_SurfaceOfRevolution) 
+  {
     if (TolReached2d > aTR) {
       aTR=TolReached2d;
     }
     //
     ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR);
-    BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D);
+    ProjLib::MakePCurveOfType(aProj1, aC2D);
     aTolR = aProj1.GetTolerance();
   } 
-  else {
-    ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1
-    BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurv, aC2D);
+  else 
+  {
+    ProjLib_ProjectedCurve aProjCurv(aBAHS);
+    Standard_Integer aDegMin = -1, aDegMax = -1, aMaxSegments = -1;
+    Standard_Real aMaxDist = -1;
+    AppParCurves_Constraint aBndPnt = AppParCurves_TangencyPoint;
+    if ((TolReached2d  >= 10. * aTR) && (TolReached2d <= aMaxTol || isAnaSurf))
+    {
+      aTR = Min(aMaxTol, 0.1*TolReached2d);
+      aMaxSegments = 100;
+      aMaxDist = 1.e3*TolReached2d;
+      if(!isAnaSurf || TolReached2d > 1.)
+      {
+        aBndPnt = AppParCurves_PassPoint;
+      }
+    }
+    else if(TolReached2d > aMaxTol)
+    {
+      aTR = Min(TolReached2d, 1.e3 * aMaxTol);
+      aMaxDist = 1.e2 * aTR;
+      aMaxSegments = 100;
+    }
+    aProjCurv.Load(aTR);
+    aProjCurv.SetDegree(aDegMin, aDegMax);
+    aProjCurv.SetMaxSegments(aMaxSegments);
+    aProjCurv.SetBndPnt(aBndPnt);
+    aProjCurv.SetMaxDist(aMaxDist);
+    aProjCurv.Perform(aBAHC);
+    ProjLib::MakePCurveOfType(aProjCurv, aC2D);
     aTolR=aProjCurv.GetTolerance();
   }
   //
-  if (aC2D.IsNull()) { 
-    ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2
-    BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurvAgain, aC2D);
+  if (aC2D.IsNull() && (aTR < aMaxTol || aTR < TolReached2d))
+  { 
+    aTR = Max(TolReached2d, aMaxTol);
+    ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, aTR);// 2
+    ProjLib::MakePCurveOfType(aProjCurvAgain, aC2D);
     aTolR = aProjCurvAgain.GetTolerance();
-    //
-    if (aC2D.IsNull()) { 
-      Standard_Real aTR=0.0001;
-      ProjLib_ProjectedCurve aProj3(aBAHS, aBAHC, aTR);// 3
-      BOPTools_AlgoTools2D::MakePCurveOfType(aProj3, aC2D);
-      aTolR = aProj3.GetTolerance();
-    }
   }
   //
   if(aC2D.IsNull())
   {
-    Standard_ConstructionError::Raise("BOPTools_AlgoTools2D::MakePCurveOnFace : PCurve is Null");
+    throw Standard_ConstructionError("BOPTools_AlgoTools2D::MakePCurveOnFace : PCurve is Null");
   }
   //
   TolReached2d=aTolR;
-  BOPTools_AlgoTools2D::AdjustPCurveOnFace (aBAS, aT1, aT2, 
-                                            aC2D, aC2DA);
-  //
-  aC2D=aC2DA;
-  //
+
+  // Adjust curve for periodic surface
+  Handle(Geom2d_Curve) aC2DA;
+  BOPTools_AlgoTools2D::AdjustPCurveOnSurf (*pBAS, aT1, aT2, aC2D, aC2DA);
+  aC2D = aC2DA;
+
+  // Make sure that the range of the 2D curve is sufficient for representation of the 3D curve.
+  Standard_Real aTCFirst = aC2D->FirstParameter();
+  Standard_Real aTCLast  = aC2D->LastParameter();
+  if ((aTCFirst - aT1) > Precision::PConfusion() ||
+      (aT2 - aTCLast ) > Precision::PConfusion())
+  {
+    if (aTCFirst < aT1) aTCFirst = aT1;
+    if (aTCLast  > aT2) aTCLast  = aT2;
+
+    GeomLib::SameRange(Precision::PConfusion(), aC2D,
+                       aTCFirst, aTCLast, aT1, aT2, aC2D);
+  }
+
   // compute the appropriate tolerance for the edge
+  Handle(Geom_Surface) aS = pBAS->Surface().Surface();
+  aS = Handle(Geom_Surface)::DownCast(aS->Transformed(pBAS->Trsf()));
+  //
+  Standard_Real aT;
   if (IntTools_Tools::ComputeTolerance
       (aC3D, aC2D, aS, aT1, aT2, aTolR, aT)) {
     if (aTolR > TolReached2d) {
@@ -678,199 +651,6 @@ void BOPTools_AlgoTools2D::MakePCurveOnFace
   }
 }
 
-//=======================================================================
-//function : MakePCurveOfType
-//purpose  : 
-//=======================================================================
-void  BOPTools_AlgoTools2D::MakePCurveOfType
-  (const ProjLib_ProjectedCurve& PC, 
-   Handle(Geom2d_Curve)& C2D)
-{
-  
-  switch (PC.GetType()) {
-
-  case GeomAbs_Line : 
-    C2D = new Geom2d_Line(PC.Line()); 
-    break;
-  case GeomAbs_Circle : 
-    C2D = new Geom2d_Circle(PC.Circle());
-    break;
-  case GeomAbs_Ellipse :
-    C2D = new Geom2d_Ellipse(PC.Ellipse());
-    break;
-  case GeomAbs_Parabola : 
-    C2D = new Geom2d_Parabola(PC.Parabola()); 
-    break;
-  case GeomAbs_Hyperbola : 
-    C2D = new Geom2d_Hyperbola(PC.Hyperbola()); 
-    break;
-  case GeomAbs_BSplineCurve :
-    C2D = PC.BSpline(); 
-    break;
-  case GeomAbs_BezierCurve : 
-  case GeomAbs_OtherCurve : 
-    default :
-    Standard_NotImplemented::Raise
-      ("BOPTools_AlgoTools2D::MakePCurveOfType");
-    break;
-  }
-}
-//=======================================================================
-//function : CheckEdgeLength
-//purpose  : 
-//=======================================================================
-Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
-{
-  BRepAdaptor_Curve BC(E);
-
-  BOPCol_IndexedMapOfShape aM;
-  BOPTools::MapShapes(E, TopAbs_VERTEX, aM);
-  Standard_Integer i, anExtent, aN=10;
-  Standard_Real ln=0., d, t, f, l, dt; 
-  anExtent=aM.Extent();
-
-  if (anExtent!=1) 
-    return Standard_True;
-    
-  gp_Pnt p1, p2;
-  f = BC.FirstParameter();
-  l = BC.LastParameter();
-  dt=(l-f)/aN;
-  
-  BC.D0(f, p1);
-  for (i=1; i<=aN; i++) {
-    t=f+i*dt;
-    
-    if (i==aN) 
-      BC.D0(l, p2);
-    else 
-      BC.D0(t, p2);
-    
-    d=p1.Distance(p2);
-    ln+=d;
-    p1=p2;
-  }
-  //
-  return (ln > Precision::Confusion()); 
-}
-//=======================================================================
-//function : BRep_Tool_CurveOnSurface
-//purpose  : 
-//=======================================================================
-Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& E, 
-                                              const TopoDS_Face& F,
-                                              Standard_Real& First,
-                                              Standard_Real& Last,
-                                              Standard_Boolean& bToUpdate)
-{
-  TopLoc_Location l;
-  const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
-  TopoDS_Edge aLocalEdge = E;
-  if (F.Orientation() == TopAbs_REVERSED) {
-    aLocalEdge.Reverse();
-  }
-  //
-  return BRep_Tool_CurveOnSurface(aLocalEdge,S,l,First,Last,bToUpdate);
-}
-//=======================================================================
-//function : BRep_Tool_CurveOnSurface
-//purpose  : 
-//=======================================================================
-Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface
-       (const TopoDS_Edge& E, 
-        const Handle(Geom_Surface)& S,
-        const TopLoc_Location& L,
-        Standard_Real& First,
-        Standard_Real& Last,
-        Standard_Boolean& bToUpdate)
-{
-  static const Handle(Geom2d_Curve) nullPCurve;
-  bToUpdate=Standard_False;
-  TopLoc_Location loc = L.Predivided(E.Location());
-  Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
-
-  // find the representation
-  BRep_ListIteratorOfListOfCurveRepresentation itcr
-    ((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
-
-  while (itcr.More()) {
-    const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
-    if (cr->IsCurveOnSurface(S,loc)) {
-      Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (cr));
-      GC->Range(First,Last);
-      if (GC->IsCurveOnClosedSurface() && Eisreversed)
-        return GC->PCurve2();
-      else
-        return GC->PCurve();
-    }
-    itcr.Next();
-  }
-
-  // for planar surface and 3d curve try a projection
-  // modif 21-05-97 : for RectangularTrimmedSurface, try a projection
-  Handle(Geom_Plane) GP;
-  Handle(Geom_RectangularTrimmedSurface) GRTS;
-  GRTS = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
-  if(!GRTS.IsNull())
-    GP = Handle(Geom_Plane)::DownCast(GRTS->BasisSurface());
-  else
-    GP = Handle(Geom_Plane)::DownCast(S);
-  //fin modif du 21-05-97
-
-  if (!GP.IsNull()) {
-
-    Handle(GeomAdaptor_HCurve) HC;
-    Handle(GeomAdaptor_HSurface) HS;
-
-    HC = new GeomAdaptor_HCurve();
-    HS = new GeomAdaptor_HSurface();
-
-    TopLoc_Location LC;
-
-    Standard_Real f, l;// for those who call with (u,u).
-    Handle(Geom_Curve) C3d =
-      BRep_Tool::Curve(E,/*LC,*/f,l); // transforming plane instead of curve
-    // we can loose scale factor of Curve transformation (eap 13 May 2002)
-
-    LC = L/*.Predivided(LC)*/;
-
-    if (C3d.IsNull()) return nullPCurve;
-
-    Handle(Geom_Plane) Plane = GP;
-    if (!LC.IsIdentity()) {
-      const gp_Trsf& T = LC.Transformation();
-      Handle(Geom_Geometry) GPT = GP->Transformed(T);
-      Plane = Handle(Geom_Plane)::DownCast (GPT);
-    }
-    GeomAdaptor_Surface& GAS = HS->ChangeSurface();
-    GAS.Load(Plane);
-    
-    Handle(Geom_Curve) ProjOnPlane = 
-      GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l),
-                                  Plane,
-                                  Plane->Position().Direction(),
-                                  Standard_True);
-    
-    GeomAdaptor_Curve& GAC = HC->ChangeCurve();
-    GAC.Load(ProjOnPlane);
-
-    ProjLib_ProjectedCurve Proj(HS,HC);
-    Handle(Geom2d_Curve) pc = Geom2dAdaptor::MakeCurve(Proj);
-
-    if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
-      Handle(Geom2d_TrimmedCurve) TC = 
-        Handle(Geom2d_TrimmedCurve)::DownCast (pc);
-      pc = TC->BasisCurve();
-    }
-    First = f; Last = l;
-    //
-    bToUpdate=Standard_True;
-    //
-    return pc;
-  }
-  
-  return nullPCurve;
-}
 //=======================================================================
 //function : MaxToleranceEdge
 //purpose  : 
@@ -926,4 +706,4 @@ void BOPTools_AlgoTools2D::IsEdgeIsoline( const TopoDS_Edge& theE,
 
   isTheUIso = (aDPv <= aTol);
   isTheVIso = (aDPu <= aTol);
-}
\ No newline at end of file
+}