0024313: BRepAlgoAPI_Section and IntTools_FaceFace aren't written to handle Geom_Surf...
authorifv <ifv@opencascade.com>
Thu, 5 Dec 2013 11:16:11 +0000 (15:16 +0400)
committerbugmaster <bugmaster@opencascade.com>
Fri, 6 Dec 2013 09:10:39 +0000 (13:10 +0400)
Test case for issue CR24313

src/IntTools/IntTools_FaceFace.cxx
tests/bugs/modalg_5/bug24313 [new file with mode: 0755]

index bd1e4f1..2372786 100755 (executable)
@@ -1180,7 +1180,7 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
                                    const Handle(Adaptor3d_TopolTool)& dom2) 
 {
   Standard_Boolean bDone, rejectSurface, reApprox, bAvoidLineConstructor,
-                   bPCurvesOk;
+    bPCurvesOk;
   Standard_Boolean ok;
   Standard_Integer i, j, aNbParts;
   Standard_Real fprm, lprm;
@@ -1196,9 +1196,9 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
   reApprox = Standard_False;
   //
   bPCurvesOk = Standard_True;
- reapprox:;
-  
+
+reapprox:;
+
   Tolpc = myTolApprox;
   bAvoidLineConstructor = Standard_False;
   L = myIntersector.Line(Index);
@@ -1218,8 +1218,8 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
     }
     L = anewL;
 #ifdef DEB_DUMPWLINE
-      const Handle(IntPatch_WLine)& aWLineX = Handle(IntPatch_WLine)::DownCast(L);
-      DumpWLine(aWLineX);
+    const Handle(IntPatch_WLine)& aWLineX = Handle(IntPatch_WLine)::DownCast(L);
+    DumpWLine(aWLineX);
 #endif
     //
     if(!myListOfPnts.IsEmpty()) {
@@ -1250,29 +1250,29 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
     }
   }
   // Do the Curve
-  
-  
+
+
   typl=L->ArcType();
   switch (typl) {
-  //########################################  
-  // Line, Parabola, Hyperbola
-  //########################################  
+    //########################################  
+    // Line, Parabola, Hyperbola
+    //########################################  
   case IntPatch_Lin:
   case IntPatch_Parabola: 
   case IntPatch_Hyperbola: {
     if (typl == IntPatch_Lin) {
       newc = 
-       new Geom_Line (Handle(IntPatch_GLine)::DownCast(L)->Line());
+        new Geom_Line (Handle(IntPatch_GLine)::DownCast(L)->Line());
     }
 
     else if (typl == IntPatch_Parabola) {
       newc = 
-       new Geom_Parabola(Handle(IntPatch_GLine)::DownCast(L)->Parabola());
+        new Geom_Parabola(Handle(IntPatch_GLine)::DownCast(L)->Parabola());
     }
-    
+
     else if (typl == IntPatch_Hyperbola) {
       newc = 
-       new Geom_Hyperbola (Handle(IntPatch_GLine)::DownCast(L)->Hyperbola());
+        new Geom_Hyperbola (Handle(IntPatch_GLine)::DownCast(L)->Hyperbola());
     }
     //
     // myTolReached3d
@@ -1283,107 +1283,119 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
     aNbParts=myLConstruct.NbParts();
     for (i=1; i<=aNbParts; i++) {
       myLConstruct.Part(i, fprm, lprm);
-      
+
       if (!Precision::IsNegativeInfinite(fprm) && 
-         !Precision::IsPositiveInfinite(lprm)) {
-       //
-       IntTools_Curve aCurve;
-       //
-       Handle(Geom_TrimmedCurve) aCT3D=new Geom_TrimmedCurve(newc, fprm, lprm);
-       aCurve.SetCurve(aCT3D);
-       if (typl == IntPatch_Parabola) {
-         Standard_Real aTolF1, aTolF2, aTolBase;
-         
-         aTolF1 = BRep_Tool::Tolerance(myFace1);
-         aTolF2 = BRep_Tool::Tolerance(myFace2);
-         aTolBase=aTolF1+aTolF2;
-         myTolReached3d=IntTools_Tools::CurveTolerance(aCT3D, aTolBase);
-       }
-       //
-       aCurve.SetCurve(new Geom_TrimmedCurve(newc, fprm, lprm));
-       if(myApprox1) { 
-         Handle (Geom2d_Curve) C2d;
-         BuildPCurves(fprm, lprm, Tolpc, myHS1->ChangeSurface().Surface(), newc, C2d);
-         if(Tolpc>myTolReached2d || myTolReached2d==0.) { 
-           myTolReached2d=Tolpc;
-         }
-           //     
-           aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
-         }
-         else { 
-           Handle(Geom2d_BSplineCurve) H1;
-           //
-           aCurve.SetFirstCurve2d(H1);
-         }
-       
-       if(myApprox2) { 
-         Handle (Geom2d_Curve) C2d;
-         BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d);
-         if(Tolpc>myTolReached2d || myTolReached2d==0.) { 
-           myTolReached2d=Tolpc;
-         }
-         //
-         aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
-         }
-       else { 
-         Handle(Geom2d_BSplineCurve) H1;
-         //
-         aCurve.SetSecondCurve2d(H1);
-       }
-       mySeqOfCurve.Append(aCurve);
-      } // end of if (!Precision::IsNegativeInfinite(fprm) &&  !Precision::IsPositiveInfinite(lprm))
+          !Precision::IsPositiveInfinite(lprm)) {
+        //
+        IntTools_Curve aCurve;
+        //
+        Handle(Geom_TrimmedCurve) aCT3D=new Geom_TrimmedCurve(newc, fprm, lprm);
+        aCurve.SetCurve(aCT3D);
+        if (typl == IntPatch_Parabola) {
+          Standard_Real aTolF1, aTolF2, aTolBase;
+
+          aTolF1 = BRep_Tool::Tolerance(myFace1);
+          aTolF2 = BRep_Tool::Tolerance(myFace2);
+          aTolBase=aTolF1+aTolF2;
+          myTolReached3d=IntTools_Tools::CurveTolerance(aCT3D, aTolBase);
+        }
+        //
+        aCurve.SetCurve(new Geom_TrimmedCurve(newc, fprm, lprm));
+        if(myApprox1) { 
+          Handle (Geom2d_Curve) C2d;
+          BuildPCurves(fprm, lprm, Tolpc, myHS1->ChangeSurface().Surface(), newc, C2d);
+          if(Tolpc>myTolReached2d || myTolReached2d==0.) { 
+            myTolReached2d=Tolpc;
+          }
+          //      
+          aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
+        }
+        else { 
+          Handle(Geom2d_BSplineCurve) H1;
+          //
+          aCurve.SetFirstCurve2d(H1);
+        }
 
+        if(myApprox2) { 
+          Handle (Geom2d_Curve) C2d;
+          BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d);
+          if(Tolpc>myTolReached2d || myTolReached2d==0.) { 
+            myTolReached2d=Tolpc;
+          }
+          //
+          aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
+        }
+        else { 
+          Handle(Geom2d_BSplineCurve) H1;
+          //
+          aCurve.SetSecondCurve2d(H1);
+        }
+        mySeqOfCurve.Append(aCurve);
+      } // end of if (!Precision::IsNegativeInfinite(fprm) &&  !Precision::IsPositiveInfinite(lprm))
       else {
-       //  on regarde si on garde
-       //
-       Standard_Boolean bFNIt, bLPIt;
-       Standard_Real aTestPrm, dT=100.;
+        //  on regarde si on garde
+        //
+        Standard_Boolean bFNIt, bLPIt;
+        Standard_Real aTestPrm, dT=100.;
 
-       bFNIt=Precision::IsNegativeInfinite(fprm);
-       bLPIt=Precision::IsPositiveInfinite(lprm);
-       
-       aTestPrm=0.;
-       
-       if (bFNIt && !bLPIt) {
-         aTestPrm=lprm-dT;
-       }
-       else if (!bFNIt && bLPIt) {
-         aTestPrm=fprm+dT;
-       }
-       
-       gp_Pnt ptref(newc->Value(aTestPrm));
-       //
+        bFNIt=Precision::IsNegativeInfinite(fprm);
+        bLPIt=Precision::IsPositiveInfinite(lprm);
 
-       Standard_Real u1, v1, u2, v2, Tol;
-       
-       Tol = Precision::Confusion();
-       Parameters(myHS1, myHS2, ptref,  u1, v1, u2, v2);
-       ok = (dom1->Classify(gp_Pnt2d(u1, v1), Tol) != TopAbs_OUT);
-       if(ok) { 
-         ok = (dom2->Classify(gp_Pnt2d(u2,v2),Tol) != TopAbs_OUT); 
-       }
-       if (ok) {
-         Handle(Geom2d_BSplineCurve) H1;
-         mySeqOfCurve.Append(IntTools_Curve(newc, H1, H1));
-       }
+        aTestPrm=0.;
+
+        if (bFNIt && !bLPIt) {
+          aTestPrm=lprm-dT;
+        }
+        else if (!bFNIt && bLPIt) {
+          aTestPrm=fprm+dT;
+        }
+
+        gp_Pnt ptref(newc->Value(aTestPrm));
+        //
+        GeomAbs_SurfaceType typS1 = myHS1->GetType();
+        GeomAbs_SurfaceType typS2 = myHS2->GetType();
+        if( typS1 == GeomAbs_SurfaceOfExtrusion ||
+            typS1 == GeomAbs_OffsetSurface ||
+            typS1 == GeomAbs_SurfaceOfRevolution ||
+            typS2 == GeomAbs_SurfaceOfExtrusion ||
+            typS2 == GeomAbs_OffsetSurface ||
+            typS2 == GeomAbs_SurfaceOfRevolution) 
+        {
+          Handle(Geom2d_BSplineCurve) H1;
+          mySeqOfCurve.Append(IntTools_Curve(newc, H1, H1));
+          continue;
+        }
+
+        Standard_Real u1, v1, u2, v2, Tol;
+
+        Tol = Precision::Confusion();
+        Parameters(myHS1, myHS2, ptref,  u1, v1, u2, v2);
+        ok = (dom1->Classify(gp_Pnt2d(u1, v1), Tol) != TopAbs_OUT);
+        if(ok) { 
+          ok = (dom2->Classify(gp_Pnt2d(u2,v2),Tol) != TopAbs_OUT); 
+        }
+        if (ok) {
+          Handle(Geom2d_BSplineCurve) H1;
+          mySeqOfCurve.Append(IntTools_Curve(newc, H1, H1));
+        }
       }
     }// end of for (i=1; i<=myLConstruct.NbParts(); i++)
   }// case IntPatch_Lin:  case IntPatch_Parabola:  case IntPatch_Hyperbola:
-    break;
+  break;
 
-  //########################################  
-  // Circle and Ellipse
-  //########################################  
+                           //########################################  
+                           // Circle and Ellipse
+                           //########################################  
   case IntPatch_Circle: 
   case IntPatch_Ellipse: {
 
     if (typl == IntPatch_Circle) {
       newc = new Geom_Circle
-       (Handle(IntPatch_GLine)::DownCast(L)->Circle());
+        (Handle(IntPatch_GLine)::DownCast(L)->Circle());
     }
     else { //IntPatch_Ellipse
       newc = new Geom_Ellipse
-       (Handle(IntPatch_GLine)::DownCast(L)->Ellipse());
+        (Handle(IntPatch_GLine)::DownCast(L)->Ellipse());
     }
     //
     // myTolReached3d
@@ -1393,7 +1405,7 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
     //
     Standard_Real aPeriod, aNul;
     TColStd_SequenceOfReal aSeqFprm,  aSeqLprm;
-    
+
     aNul=0.;
     aPeriod=M_PI+M_PI;
 
@@ -1401,60 +1413,60 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
       myLConstruct.Part(i, fprm, lprm);
 
       if (fprm < aNul && lprm > aNul) {
-       // interval that goes through 0. is divided on two intervals;
-       while (fprm<aNul || fprm>aPeriod) fprm=fprm+aPeriod;
-       while (lprm<aNul || lprm>aPeriod) lprm=lprm+aPeriod;
-       //
-       if((aPeriod - fprm) > Tolpc) {
-         aSeqFprm.Append(fprm);
-         aSeqLprm.Append(aPeriod);
-       }
-       else {
-         gp_Pnt P1 = newc->Value(fprm);
-         gp_Pnt P2 = newc->Value(aPeriod);
-         Standard_Real aTolDist = BRep_Tool::Tolerance(myFace1) + BRep_Tool::Tolerance(myFace2);
-         aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
-
-         if(P1.Distance(P2) > aTolDist) {
-           Standard_Real anewpar = fprm;
-
-           if(ParameterOutOfBoundary(fprm, newc, myFace1, myFace2, lprm, Standard_False, anewpar, myContext)) {
-             fprm = anewpar;
-           }
-           aSeqFprm.Append(fprm);
-           aSeqLprm.Append(aPeriod);
-         }
-       }
-
-       //
-       if((lprm - aNul) > Tolpc) {
-         aSeqFprm.Append(aNul);
-         aSeqLprm.Append(lprm);
-       }
-       else {
-         gp_Pnt P1 = newc->Value(aNul);
-         gp_Pnt P2 = newc->Value(lprm);
-         Standard_Real aTolDist = BRep_Tool::Tolerance(myFace1) + BRep_Tool::Tolerance(myFace2);
-         aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
-
-         if(P1.Distance(P2) > aTolDist) {
-           Standard_Real anewpar = lprm;
+        // interval that goes through 0. is divided on two intervals;
+        while (fprm<aNul || fprm>aPeriod) fprm=fprm+aPeriod;
+        while (lprm<aNul || lprm>aPeriod) lprm=lprm+aPeriod;
+        //
+        if((aPeriod - fprm) > Tolpc) {
+          aSeqFprm.Append(fprm);
+          aSeqLprm.Append(aPeriod);
+        }
+        else {
+          gp_Pnt P1 = newc->Value(fprm);
+          gp_Pnt P2 = newc->Value(aPeriod);
+          Standard_Real aTolDist = BRep_Tool::Tolerance(myFace1) + BRep_Tool::Tolerance(myFace2);
+          aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
+
+          if(P1.Distance(P2) > aTolDist) {
+            Standard_Real anewpar = fprm;
+
+            if(ParameterOutOfBoundary(fprm, newc, myFace1, myFace2, lprm, Standard_False, anewpar, myContext)) {
+              fprm = anewpar;
+            }
+            aSeqFprm.Append(fprm);
+            aSeqLprm.Append(aPeriod);
+          }
+        }
 
-           if(ParameterOutOfBoundary(lprm, newc, myFace1, myFace2, fprm, Standard_True, anewpar, myContext)) {
-             lprm = anewpar;
-           }
-           aSeqFprm.Append(aNul);
-           aSeqLprm.Append(lprm);
-         }
-       }
+        //
+        if((lprm - aNul) > Tolpc) {
+          aSeqFprm.Append(aNul);
+          aSeqLprm.Append(lprm);
+        }
+        else {
+          gp_Pnt P1 = newc->Value(aNul);
+          gp_Pnt P2 = newc->Value(lprm);
+          Standard_Real aTolDist = BRep_Tool::Tolerance(myFace1) + BRep_Tool::Tolerance(myFace2);
+          aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
+
+          if(P1.Distance(P2) > aTolDist) {
+            Standard_Real anewpar = lprm;
+
+            if(ParameterOutOfBoundary(lprm, newc, myFace1, myFace2, fprm, Standard_True, anewpar, myContext)) {
+              lprm = anewpar;
+            }
+            aSeqFprm.Append(aNul);
+            aSeqLprm.Append(lprm);
+          }
+        }
       }
       else {
-       // usual interval 
-       aSeqFprm.Append(fprm);
-       aSeqLprm.Append(lprm);
+        // usual interval 
+        aSeqFprm.Append(fprm);
+        aSeqLprm.Append(lprm);
       }
     }
-    
+
     //
     aNbParts=aSeqFprm.Length();
     for (i=1; i<=aNbParts; i++) {
@@ -1463,227 +1475,227 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
       //
       Standard_Real aRealEpsilon=RealEpsilon();
       if (Abs(fprm) > aRealEpsilon || Abs(lprm-2.*M_PI) > aRealEpsilon) {
-       //==============================================
-       ////
-       IntTools_Curve aCurve;
-       Handle(Geom_TrimmedCurve) aTC3D=new Geom_TrimmedCurve(newc,fprm,lprm);
-       aCurve.SetCurve(aTC3D);
-       fprm=aTC3D->FirstParameter();
-       lprm=aTC3D->LastParameter ();
-       ////    
-       if (typl == IntPatch_Circle || typl == IntPatch_Ellipse) {//// 
-         if(myApprox1) { 
-           Handle (Geom2d_Curve) C2d;
-           BuildPCurves(fprm,lprm,Tolpc,myHS1->ChangeSurface().Surface(),newc,C2d);
-           if(Tolpc>myTolReached2d || myTolReached2d==0) { 
-             myTolReached2d=Tolpc;
-           }
-           //
-           aCurve.SetFirstCurve2d(C2d);
-         }
-         else { //// 
-           Handle(Geom2d_BSplineCurve) H1;
-           aCurve.SetFirstCurve2d(H1);
-         }
+        //==============================================
+        ////
+        IntTools_Curve aCurve;
+        Handle(Geom_TrimmedCurve) aTC3D=new Geom_TrimmedCurve(newc,fprm,lprm);
+        aCurve.SetCurve(aTC3D);
+        fprm=aTC3D->FirstParameter();
+        lprm=aTC3D->LastParameter ();
+        ////   
+        if (typl == IntPatch_Circle || typl == IntPatch_Ellipse) {//// 
+          if(myApprox1) { 
+            Handle (Geom2d_Curve) C2d;
+            BuildPCurves(fprm,lprm,Tolpc,myHS1->ChangeSurface().Surface(),newc,C2d);
+            if(Tolpc>myTolReached2d || myTolReached2d==0) { 
+              myTolReached2d=Tolpc;
+            }
+            //
+            aCurve.SetFirstCurve2d(C2d);
+          }
+          else { //// 
+            Handle(Geom2d_BSplineCurve) H1;
+            aCurve.SetFirstCurve2d(H1);
+          }
 
 
-         if(myApprox2) { 
-           Handle (Geom2d_Curve) C2d;
-           BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d);
-           if(Tolpc>myTolReached2d || myTolReached2d==0) { 
-             myTolReached2d=Tolpc;
-           }
-           //
-           aCurve.SetSecondCurve2d(C2d);
-         }
-         else { 
-           Handle(Geom2d_BSplineCurve) H1;
-           aCurve.SetSecondCurve2d(H1);
-         }
-       }
-       
-       else { 
-         Handle(Geom2d_BSplineCurve) H1;
-         aCurve.SetFirstCurve2d(H1);
-         aCurve.SetSecondCurve2d(H1);
-       }
-       mySeqOfCurve.Append(aCurve);
-         //==============================================      
+          if(myApprox2) { 
+            Handle (Geom2d_Curve) C2d;
+            BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d);
+            if(Tolpc>myTolReached2d || myTolReached2d==0) { 
+              myTolReached2d=Tolpc;
+            }
+            //
+            aCurve.SetSecondCurve2d(C2d);
+          }
+          else { 
+            Handle(Geom2d_BSplineCurve) H1;
+            aCurve.SetSecondCurve2d(H1);
+          }
+        }
+
+        else { 
+          Handle(Geom2d_BSplineCurve) H1;
+          aCurve.SetFirstCurve2d(H1);
+          aCurve.SetSecondCurve2d(H1);
+        }
+        mySeqOfCurve.Append(aCurve);
+        //==============================================       
       } //if (Abs(fprm) > RealEpsilon() || Abs(lprm-2.*M_PI) > RealEpsilon())
 
       else {
-       //  on regarde si on garde
-       //
-       if (aNbParts==1) {
-//       if (Abs(fprm) < RealEpsilon() &&  Abs(lprm-2.*M_PI) < RealEpsilon()) {
-         if (Abs(fprm) <= aRealEpsilon && Abs(lprm-2.*M_PI) <= aRealEpsilon) {
-           IntTools_Curve aCurve;
-           Handle(Geom_TrimmedCurve) aTC3D=new Geom_TrimmedCurve(newc,fprm,lprm);
-           aCurve.SetCurve(aTC3D);
-           fprm=aTC3D->FirstParameter();
-           lprm=aTC3D->LastParameter ();
-           
-           if(myApprox1) { 
-             Handle (Geom2d_Curve) C2d;
-             BuildPCurves(fprm,lprm,Tolpc,myHS1->ChangeSurface().Surface(),newc,C2d);
-             if(Tolpc>myTolReached2d || myTolReached2d==0) { 
-               myTolReached2d=Tolpc;
-             }
-             //
-             aCurve.SetFirstCurve2d(C2d);
-           }
-           else { //// 
-             Handle(Geom2d_BSplineCurve) H1;
-             aCurve.SetFirstCurve2d(H1);
-           }
+        //  on regarde si on garde
+        //
+        if (aNbParts==1) {
+          //     if (Abs(fprm) < RealEpsilon() &&  Abs(lprm-2.*M_PI) < RealEpsilon()) {
+          if (Abs(fprm) <= aRealEpsilon && Abs(lprm-2.*M_PI) <= aRealEpsilon) {
+            IntTools_Curve aCurve;
+            Handle(Geom_TrimmedCurve) aTC3D=new Geom_TrimmedCurve(newc,fprm,lprm);
+            aCurve.SetCurve(aTC3D);
+            fprm=aTC3D->FirstParameter();
+            lprm=aTC3D->LastParameter ();
+
+            if(myApprox1) { 
+              Handle (Geom2d_Curve) C2d;
+              BuildPCurves(fprm,lprm,Tolpc,myHS1->ChangeSurface().Surface(),newc,C2d);
+              if(Tolpc>myTolReached2d || myTolReached2d==0) { 
+                myTolReached2d=Tolpc;
+              }
+              //
+              aCurve.SetFirstCurve2d(C2d);
+            }
+            else { //// 
+              Handle(Geom2d_BSplineCurve) H1;
+              aCurve.SetFirstCurve2d(H1);
+            }
+
+            if(myApprox2) { 
+              Handle (Geom2d_Curve) C2d;
+              BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d);
+              if(Tolpc>myTolReached2d || myTolReached2d==0) { 
+                myTolReached2d=Tolpc;
+              }
+              //
+              aCurve.SetSecondCurve2d(C2d);
+            }
+            else { 
+              Handle(Geom2d_BSplineCurve) H1;
+              aCurve.SetSecondCurve2d(H1);
+            }
+            mySeqOfCurve.Append(aCurve);
+            break;
+          }
+        }
+        //
+        Standard_Real aTwoPIdiv17, u1, v1, u2, v2, Tol;
 
-           if(myApprox2) { 
-             Handle (Geom2d_Curve) C2d;
-             BuildPCurves(fprm,lprm,Tolpc,myHS2->ChangeSurface().Surface(),newc,C2d);
-             if(Tolpc>myTolReached2d || myTolReached2d==0) { 
-               myTolReached2d=Tolpc;
-             }
-             //
-             aCurve.SetSecondCurve2d(C2d);
-           }
-           else { 
-             Handle(Geom2d_BSplineCurve) H1;
-             aCurve.SetSecondCurve2d(H1);
-           }
-           mySeqOfCurve.Append(aCurve);
-           break;
-         }
-       }
-       //
-       Standard_Real aTwoPIdiv17, u1, v1, u2, v2, Tol;
+        aTwoPIdiv17=2.*M_PI/17.;
 
-       aTwoPIdiv17=2.*M_PI/17.;
+        for (j=0; j<=17; j++) {
+          gp_Pnt ptref (newc->Value (j*aTwoPIdiv17));
+          Tol = Precision::Confusion();
 
-       for (j=0; j<=17; j++) {
-         gp_Pnt ptref (newc->Value (j*aTwoPIdiv17));
-         Tol = Precision::Confusion();
+          Parameters(myHS1, myHS2, ptref, u1, v1, u2, v2);
+          ok = (dom1->Classify(gp_Pnt2d(u1,v1),Tol) != TopAbs_OUT);
+          if(ok) { 
+            ok = (dom2->Classify(gp_Pnt2d(u2,v2),Tol) != TopAbs_OUT);
+          }
+          if (ok) {
+            IntTools_Curve aCurve;
+            aCurve.SetCurve(newc);
+            //==============================================
+            if (typl == IntPatch_Circle || typl == IntPatch_Ellipse) {
+
+              if(myApprox1) { 
+                Handle (Geom2d_Curve) C2d;
+                BuildPCurves(fprm, lprm, Tolpc, myHS1->ChangeSurface().Surface(), newc, C2d);
+                if(Tolpc>myTolReached2d || myTolReached2d==0) { 
+                  myTolReached2d=Tolpc;
+                }
+                // 
+                aCurve.SetFirstCurve2d(C2d);
+              }
+              else { 
+                Handle(Geom2d_BSplineCurve) H1;
+                aCurve.SetFirstCurve2d(H1);
+              }
 
-         Parameters(myHS1, myHS2, ptref, u1, v1, u2, v2);
-         ok = (dom1->Classify(gp_Pnt2d(u1,v1),Tol) != TopAbs_OUT);
-         if(ok) { 
-           ok = (dom2->Classify(gp_Pnt2d(u2,v2),Tol) != TopAbs_OUT);
-         }
-         if (ok) {
-           IntTools_Curve aCurve;
-           aCurve.SetCurve(newc);
-           //==============================================
-           if (typl == IntPatch_Circle || typl == IntPatch_Ellipse) {
-             
-             if(myApprox1) { 
-               Handle (Geom2d_Curve) C2d;
-               BuildPCurves(fprm, lprm, Tolpc, myHS1->ChangeSurface().Surface(), newc, C2d);
-               if(Tolpc>myTolReached2d || myTolReached2d==0) { 
-                 myTolReached2d=Tolpc;
-               }
-               // 
-               aCurve.SetFirstCurve2d(C2d);
-             }
-             else { 
-               Handle(Geom2d_BSplineCurve) H1;
-               aCurve.SetFirstCurve2d(H1);
-             }
-               
-             if(myApprox2) { 
-               Handle (Geom2d_Curve) C2d;
-               BuildPCurves(fprm, lprm, Tolpc,myHS2->ChangeSurface().Surface(), newc, C2d);
-               if(Tolpc>myTolReached2d || myTolReached2d==0) { 
-                 myTolReached2d=Tolpc;
-               }
-               //              
-               aCurve.SetSecondCurve2d(C2d);
-             }
-               
-             else { 
-               Handle(Geom2d_BSplineCurve) H1;
-               aCurve.SetSecondCurve2d(H1);
-             }
-           }//  end of if (typl == IntPatch_Circle || typl == IntPatch_Ellipse)
-            
-           else { 
-             Handle(Geom2d_BSplineCurve) H1;
-             //        
-             aCurve.SetFirstCurve2d(H1);
-             aCurve.SetSecondCurve2d(H1);
-           }
-           //==============================================    
-           //
-           mySeqOfCurve.Append(aCurve);
-           break;
+              if(myApprox2) { 
+                Handle (Geom2d_Curve) C2d;
+                BuildPCurves(fprm, lprm, Tolpc,myHS2->ChangeSurface().Surface(), newc, C2d);
+                if(Tolpc>myTolReached2d || myTolReached2d==0) { 
+                  myTolReached2d=Tolpc;
+                }
+                //             
+                aCurve.SetSecondCurve2d(C2d);
+              }
+
+              else { 
+                Handle(Geom2d_BSplineCurve) H1;
+                aCurve.SetSecondCurve2d(H1);
+              }
+            }//  end of if (typl == IntPatch_Circle || typl == IntPatch_Ellipse)
+
+            else { 
+              Handle(Geom2d_BSplineCurve) H1;
+              //       
+              aCurve.SetFirstCurve2d(H1);
+              aCurve.SetSecondCurve2d(H1);
+            }
+            //==============================================   
+            //
+            mySeqOfCurve.Append(aCurve);
+            break;
+
+          }//  end of if (ok) {
+        }//  end of for (Standard_Integer j=0; j<=17; j++)
+      }//  end of else { on regarde si on garde
+    }// for (i=1; i<=myLConstruct.NbParts(); i++)
+  }// IntPatch_Circle: IntPatch_Ellipse:
+  break;
 
-           }//  end of if (ok) {
-         }//  end of for (Standard_Integer j=0; j<=17; j++)
-       }//  end of else { on regarde si on garde
-      }// for (i=1; i<=myLConstruct.NbParts(); i++)
-    }// IntPatch_Circle: IntPatch_Ellipse:
-    break;
-    
   case IntPatch_Analytic: {
     IntSurf_Quadric quad1,quad2;
     GeomAbs_SurfaceType typs = myHS1->Surface().GetType();
-    
+
     switch (typs) {
-      case GeomAbs_Plane:
-        quad1.SetValue(myHS1->Surface().Plane());
-       break;
-      case GeomAbs_Cylinder:
-       quad1.SetValue(myHS1->Surface().Cylinder());
-       break;
-      case GeomAbs_Cone:
-       quad1.SetValue(myHS1->Surface().Cone());
-       break;
-      case GeomAbs_Sphere:
-       quad1.SetValue(myHS1->Surface().Sphere());
-       break;
-      default:
-       Standard_ConstructionError::Raise("GeomInt_IntSS::MakeCurve 1");
-      }
-      
+    case GeomAbs_Plane:
+      quad1.SetValue(myHS1->Surface().Plane());
+      break;
+    case GeomAbs_Cylinder:
+      quad1.SetValue(myHS1->Surface().Cylinder());
+      break;
+    case GeomAbs_Cone:
+      quad1.SetValue(myHS1->Surface().Cone());
+      break;
+    case GeomAbs_Sphere:
+      quad1.SetValue(myHS1->Surface().Sphere());
+      break;
+    default:
+      Standard_ConstructionError::Raise("GeomInt_IntSS::MakeCurve 1");
+    }
+
     typs = myHS2->Surface().GetType();
-    
+
     switch (typs) {
-      case GeomAbs_Plane:
-        quad2.SetValue(myHS2->Surface().Plane());
-       break;
-      case GeomAbs_Cylinder:
-       quad2.SetValue(myHS2->Surface().Cylinder());
-       break;
-      case GeomAbs_Cone:
-       quad2.SetValue(myHS2->Surface().Cone());
-       break;
-      case GeomAbs_Sphere:
-       quad2.SetValue(myHS2->Surface().Sphere());
-       break;
-      default:
-       Standard_ConstructionError::Raise("GeomInt_IntSS::MakeCurve 2");
-      }
+    case GeomAbs_Plane:
+      quad2.SetValue(myHS2->Surface().Plane());
+      break;
+    case GeomAbs_Cylinder:
+      quad2.SetValue(myHS2->Surface().Cylinder());
+      break;
+    case GeomAbs_Cone:
+      quad2.SetValue(myHS2->Surface().Cone());
+      break;
+    case GeomAbs_Sphere:
+      quad2.SetValue(myHS2->Surface().Sphere());
+      break;
+    default:
+      Standard_ConstructionError::Raise("GeomInt_IntSS::MakeCurve 2");
+    }
     //
     //=========
     IntPatch_ALineToWLine convert (quad1, quad2);
-      
+
     if (!myApprox) {
       aNbParts=myLConstruct.NbParts();
       for (i=1; i<=aNbParts; i++) {
-       myLConstruct.Part(i, fprm, lprm);
-       Handle(IntPatch_WLine) WL = 
-         convert.MakeWLine(Handle(IntPatch_ALine)::DownCast(L), fprm, lprm);
-       //
-       Handle(Geom2d_BSplineCurve) H1;
-       Handle(Geom2d_BSplineCurve) H2;
+        myLConstruct.Part(i, fprm, lprm);
+        Handle(IntPatch_WLine) WL = 
+          convert.MakeWLine(Handle(IntPatch_ALine)::DownCast(L), fprm, lprm);
+        //
+        Handle(Geom2d_BSplineCurve) H1;
+        Handle(Geom2d_BSplineCurve) H2;
 
-       if(myApprox1) {
-         H1 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_True);
-       }
-       
-       if(myApprox2) {
-         H2 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_False);
-       }
-       //       
-       mySeqOfCurve.Append(IntTools_Curve(MakeBSpline(WL,1,WL->NbPnts()), H1, H2));
+        if(myApprox1) {
+          H1 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_True);
+        }
+
+        if(myApprox2) {
+          H2 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_False);
+        }
+        //      
+        mySeqOfCurve.Append(IntTools_Curve(MakeBSpline(WL,1,WL->NbPnts()), H1, H2));
       }
     } // if (!myApprox)
 
@@ -1693,107 +1705,107 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
       Standard_Real tol2d = myTolApprox;
       //       
       theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_True);
-      
+
       aNbParts=myLConstruct.NbParts();
       for (i=1; i<=aNbParts; i++) {
-       myLConstruct.Part(i, fprm, lprm);
-       Handle(IntPatch_WLine) WL = 
-         convert.MakeWLine(Handle(IntPatch_ALine):: DownCast(L),fprm,lprm);
+        myLConstruct.Part(i, fprm, lprm);
+        Handle(IntPatch_WLine) WL = 
+          convert.MakeWLine(Handle(IntPatch_ALine):: DownCast(L),fprm,lprm);
 
-       theapp3d.Perform(myHS1,myHS2,WL,Standard_True,myApprox1,myApprox2, 1, WL->NbPnts());
+        theapp3d.Perform(myHS1,myHS2,WL,Standard_True,myApprox1,myApprox2, 1, WL->NbPnts());
 
-       if (!theapp3d.IsDone()) {
-         //
-         Handle(Geom2d_BSplineCurve) H1;
-         Handle(Geom2d_BSplineCurve) H2;
+        if (!theapp3d.IsDone()) {
+          //
+          Handle(Geom2d_BSplineCurve) H1;
+          Handle(Geom2d_BSplineCurve) H2;
 
-         if(myApprox1) {
-           H1 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_True);
-         }
-         
-         if(myApprox2) {
-           H2 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_False);
-         }
-         //     
-         mySeqOfCurve.Append(IntTools_Curve(MakeBSpline(WL,1,WL->NbPnts()), H1, H2));
-       }
+          if(myApprox1) {
+            H1 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_True);
+          }
 
-       else {
-         if(myApprox1 || myApprox2) { 
-           if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0) { 
-             myTolReached2d = theapp3d.TolReached2d();
-           }
-         }
-         
-         if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0) { 
-           myTolReached3d = theapp3d.TolReached3d();
-         }
+          if(myApprox2) {
+            H2 = MakeBSpline2d(WL, 1, WL->NbPnts(), Standard_False);
+          }
+          //    
+          mySeqOfCurve.Append(IntTools_Curve(MakeBSpline(WL,1,WL->NbPnts()), H1, H2));
+        }
 
-         Standard_Integer aNbMultiCurves, nbpoles;
-         aNbMultiCurves=theapp3d.NbMultiCurves();
-         for (j=1; j<=aNbMultiCurves; j++) {
-           const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
-           nbpoles = mbspc.NbPoles();
-           
-           TColgp_Array1OfPnt tpoles(1, nbpoles);
-           mbspc.Curve(1, tpoles);
-           Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles,
-                                                              mbspc.Knots(),
-                                                              mbspc.Multiplicities(),
-                                                              mbspc.Degree());
-           
-           GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
-           Check.FixTangent(Standard_True,Standard_True);
-           // 
-           IntTools_Curve aCurve;
-           aCurve.SetCurve(BS);
-           
-           if(myApprox1) { 
-             TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
-             mbspc.Curve(2,tpoles2d);
-             Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
-                                                                     mbspc.Knots(),
-                                                                     mbspc.Multiplicities(),
-                                                                     mbspc.Degree());
-
-             GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
-             newCheck.FixTangent(Standard_True,Standard_True);
-             //                
-             aCurve.SetFirstCurve2d(BS2);
-           }
-           else {
-             Handle(Geom2d_BSplineCurve) H1;
-             aCurve.SetFirstCurve2d(H1);
-           }
-           
-           if(myApprox2) { 
-             TColgp_Array1OfPnt2d tpoles2d(1, nbpoles);
-             Standard_Integer TwoOrThree;
-             TwoOrThree=myApprox1 ? 3 : 2;
-             mbspc.Curve(TwoOrThree, tpoles2d);
-             Handle(Geom2d_BSplineCurve) BS2 =new Geom2d_BSplineCurve(tpoles2d,
-                                                                      mbspc.Knots(),
-                                                                      mbspc.Multiplicities(),
-                                                                      mbspc.Degree());
-               
-             GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
-             newCheck.FixTangent(Standard_True,Standard_True);
-             //        
-             aCurve.SetSecondCurve2d(BS2);
-           }
-           else { 
-             Handle(Geom2d_BSplineCurve) H2;
-             aCurve.SetSecondCurve2d(H2);
-           }
-           // 
-           mySeqOfCurve.Append(aCurve);
+        else {
+          if(myApprox1 || myApprox2) { 
+            if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0) { 
+              myTolReached2d = theapp3d.TolReached2d();
+            }
+          }
 
-         }// for (j=1; j<=aNbMultiCurves; j++) {
-       }// else from if (!theapp3d.IsDone())
+          if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0) { 
+            myTolReached3d = theapp3d.TolReached3d();
+          }
+
+          Standard_Integer aNbMultiCurves, nbpoles;
+          aNbMultiCurves=theapp3d.NbMultiCurves();
+          for (j=1; j<=aNbMultiCurves; j++) {
+            const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
+            nbpoles = mbspc.NbPoles();
+
+            TColgp_Array1OfPnt tpoles(1, nbpoles);
+            mbspc.Curve(1, tpoles);
+            Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles,
+              mbspc.Knots(),
+              mbspc.Multiplicities(),
+              mbspc.Degree());
+
+            GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
+            Check.FixTangent(Standard_True,Standard_True);
+            // 
+            IntTools_Curve aCurve;
+            aCurve.SetCurve(BS);
+
+            if(myApprox1) { 
+              TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
+              mbspc.Curve(2,tpoles2d);
+              Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
+                mbspc.Knots(),
+                mbspc.Multiplicities(),
+                mbspc.Degree());
+
+              GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
+              newCheck.FixTangent(Standard_True,Standard_True);
+              //               
+              aCurve.SetFirstCurve2d(BS2);
+            }
+            else {
+              Handle(Geom2d_BSplineCurve) H1;
+              aCurve.SetFirstCurve2d(H1);
+            }
+
+            if(myApprox2) { 
+              TColgp_Array1OfPnt2d tpoles2d(1, nbpoles);
+              Standard_Integer TwoOrThree;
+              TwoOrThree=myApprox1 ? 3 : 2;
+              mbspc.Curve(TwoOrThree, tpoles2d);
+              Handle(Geom2d_BSplineCurve) BS2 =new Geom2d_BSplineCurve(tpoles2d,
+                mbspc.Knots(),
+                mbspc.Multiplicities(),
+                mbspc.Degree());
+
+              GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
+              newCheck.FixTangent(Standard_True,Standard_True);
+              //       
+              aCurve.SetSecondCurve2d(BS2);
+            }
+            else { 
+              Handle(Geom2d_BSplineCurve) H2;
+              aCurve.SetSecondCurve2d(H2);
+            }
+            // 
+            mySeqOfCurve.Append(aCurve);
+
+          }// for (j=1; j<=aNbMultiCurves; j++) {
+        }// else from if (!theapp3d.IsDone())
       }// for (i=1; i<=aNbParts; i++) {
     }// else { // myApprox=TRUE
   }// case IntPatch_Analytic:
-    break;
+  break;
 
   case IntPatch_Walking:{
     Handle(IntPatch_WLine) WL = 
@@ -1804,33 +1816,33 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
     if (!myApprox) {
       aNbParts = 1;
       if(!bAvoidLineConstructor){
-       aNbParts=myLConstruct.NbParts();
+        aNbParts=myLConstruct.NbParts();
       }
       for (i=1; i<=aNbParts; ++i) {
-       Handle(Geom2d_BSplineCurve) H1, H2;
-       Handle(Geom_Curve) aBSp;
-       //
-       if(bAvoidLineConstructor) {
-         ifprm = 1;
-         ilprm = WL->NbPnts();
-       }
-       else {
-         myLConstruct.Part(i, fprm, lprm);
-         ifprm=(Standard_Integer)fprm;
-         ilprm=(Standard_Integer)lprm;
-       }
-       //
-       if(myApprox1) {
-         H1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True);
-       }
-       //
-       if(myApprox2) {
-         H2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False);
-       }
-       //        
-       aBSp=MakeBSpline(WL, ifprm, ilprm);
-       IntTools_Curve aIC(aBSp, H1, H2);
-       mySeqOfCurve.Append(aIC);
+        Handle(Geom2d_BSplineCurve) H1, H2;
+        Handle(Geom_Curve) aBSp;
+        //
+        if(bAvoidLineConstructor) {
+          ifprm = 1;
+          ilprm = WL->NbPnts();
+        }
+        else {
+          myLConstruct.Part(i, fprm, lprm);
+          ifprm=(Standard_Integer)fprm;
+          ilprm=(Standard_Integer)lprm;
+        }
+        //
+        if(myApprox1) {
+          H1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True);
+        }
+        //
+        if(myApprox2) {
+          H2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False);
+        }
+        //       
+        aBSp=MakeBSpline(WL, ifprm, ilprm);
+        IntTools_Curve aIC(aBSp, H1, H2);
+        mySeqOfCurve.Append(aIC);
       }// for (i=1; i<=aNbParts; ++i) {
     }// if (!myApprox) {
     //
@@ -1853,444 +1865,444 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
       Standard_Boolean anWithPC = Standard_True;
 
       if(typs1 == GeomAbs_Cylinder && typs2 == GeomAbs_Sphere) {
-       anWithPC = 
-         ApproxWithPCurves(myHS1->Surface().Cylinder(), myHS2->Surface().Sphere());
+        anWithPC = 
+          ApproxWithPCurves(myHS1->Surface().Cylinder(), myHS2->Surface().Sphere());
       }
       else if (typs1 == GeomAbs_Sphere && typs2 == GeomAbs_Cylinder) {
-       anWithPC = 
-         ApproxWithPCurves(myHS2->Surface().Cylinder(), myHS1->Surface().Sphere());
+        anWithPC = 
+          ApproxWithPCurves(myHS2->Surface().Cylinder(), myHS1->Surface().Sphere());
       }
       if(!anWithPC) {
-       //aParType = Approx_Centripetal; 
-       myTolApprox = 1.e-5; 
-       anApprox1 = Standard_False;
-       anApprox2 = Standard_False;
-       //      
-       tol2d = myTolApprox;
+        //aParType = Approx_Centripetal; 
+        myTolApprox = 1.e-5; 
+        anApprox1 = Standard_False;
+        anApprox2 = Standard_False;
+        //     
+        tol2d = myTolApprox;
       }
-       
+
       if(myHS1 == myHS2) { 
-       //
-       theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False, aParType);
-       rejectSurface = Standard_True;
+        //
+        theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False, aParType);
+        rejectSurface = Standard_True;
       }
       else { 
-       if(reApprox && !rejectSurface)
-         theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False, aParType);
-       else {
-         Standard_Integer iDegMax, iDegMin, iNbIter;
-         //
-         ApproxParameters(myHS1, myHS2, iDegMin, iDegMax, iNbIter);
-         theapp3d.SetParameters(myTolApprox, tol2d, iDegMin, iDegMax, iNbIter, Standard_True, aParType);
-         //
-       }
+        if(reApprox && !rejectSurface)
+          theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False, aParType);
+        else {
+          Standard_Integer iDegMax, iDegMin, iNbIter;
+          //
+          ApproxParameters(myHS1, myHS2, iDegMin, iDegMax, iNbIter);
+          theapp3d.SetParameters(myTolApprox, tol2d, iDegMin, iDegMax, iNbIter, Standard_True, aParType);
+          //
+        }
       }
       //
       Standard_Real aReachedTol = Precision::Confusion();
       bIsDecomposited=DecompositionOfWLine(WL,
-                                          myHS1, 
-                                          myHS2, 
-                                          myFace1, 
-                                          myFace2, 
-                                          myLConstruct, 
-                                          bAvoidLineConstructor, 
-                                          aSeqOfL, 
-                                          aReachedTol,
-                                          myContext);
+        myHS1, 
+        myHS2, 
+        myFace1, 
+        myFace2, 
+        myLConstruct, 
+        bAvoidLineConstructor, 
+        aSeqOfL, 
+        aReachedTol,
+        myContext);
       if ( bIsDecomposited && ( myTolReached3d < aReachedTol ) )
-       myTolReached3d = aReachedTol;
+        myTolReached3d = aReachedTol;
 
       //
       aNbSeqOfL=aSeqOfL.Length();
       //
       if (bIsDecomposited) {
-       nbiter=aNbSeqOfL;
+        nbiter=aNbSeqOfL;
       }
       else {
-       nbiter=1;
-       aNbParts=1;
-       if (!bAvoidLineConstructor) {
-         aNbParts=myLConstruct.NbParts();
-         nbiter=aNbParts;
-       }
+        nbiter=1;
+        aNbParts=1;
+        if (!bAvoidLineConstructor) {
+          aNbParts=myLConstruct.NbParts();
+          nbiter=aNbParts;
+        }
       }
       //
       // nbiter=(bIsDecomposited) ? aSeqOfL.Length() :
       //   ((bAvoidLineConstructor) ? 1 :aNbParts);
       //
       for(i = 1; i <= nbiter; ++i) {
-       if(bIsDecomposited) {
-         WL = Handle(IntPatch_WLine)::DownCast(aSeqOfL.Value(i));
-         ifprm = 1;
-         ilprm = WL->NbPnts();
-       }
-       else {
-         if(bAvoidLineConstructor) {
-           ifprm = 1;
-           ilprm = WL->NbPnts();
-         }
-         else {
-           myLConstruct.Part(i, fprm, lprm);
-           ifprm = (Standard_Integer)fprm;
-           ilprm = (Standard_Integer)lprm;
-         }
-       }
-       //-- lbr : 
-       //-- Si une des surfaces est un plan , on approxime en 2d
-       //-- sur cette surface et on remonte les points 2d en 3d.
-       if(typs1 == GeomAbs_Plane) { 
-         theapp3d.Perform(myHS1, myHS2, WL, Standard_False,Standard_True, myApprox2,ifprm,ilprm);
-       }         
-       else if(typs2 == GeomAbs_Plane) { 
-         theapp3d.Perform(myHS1,myHS2,WL,Standard_False,myApprox1,Standard_True,ifprm,ilprm);
-       }
-       else { 
-         //
-         if (myHS1 != myHS2){
-           if ((typs1==GeomAbs_BezierSurface || typs1==GeomAbs_BSplineSurface) &&
-               (typs2==GeomAbs_BezierSurface || typs2==GeomAbs_BSplineSurface)) {
-            
-             theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_True, aParType);
-             
-             Standard_Boolean bUseSurfaces;
-             bUseSurfaces=NotUseSurfacesForApprox(myFace1, myFace2, WL, ifprm,  ilprm);
-             if (bUseSurfaces) {
-               // ######
-               rejectSurface = Standard_True;
-               // ######
-               theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False, aParType);
-             }
-           }
-         }
-         //
-         theapp3d.Perform(myHS1,myHS2,WL,Standard_True,anApprox1,anApprox2,ifprm,ilprm);
-       }
-        
-       if (!theapp3d.IsDone()) {
-         //      
-         Handle(Geom2d_BSplineCurve) H1;
-         //      
-         Handle(Geom_Curve) aBSp=MakeBSpline(WL,ifprm, ilprm);
-         Handle(Geom2d_BSplineCurve) H2;
-
-         if(myApprox1) {
-           H1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True);
-         }
-         
-         if(myApprox2) {
-           H2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False);
-         }
-         //      
-         IntTools_Curve aIC(aBSp, H1, H2);
-         mySeqOfCurve.Append(aIC);
-       }
-       
-       else {
-         if(myApprox1 || myApprox2 || (typs1==GeomAbs_Plane || typs2==GeomAbs_Plane)) { 
-           if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0.) { 
-             myTolReached2d = theapp3d.TolReached2d();
-           }
-         }
-         if(typs1==GeomAbs_Plane || typs2==GeomAbs_Plane) { 
-           myTolReached3d = myTolReached2d;
-           //
-           if (typs1==GeomAbs_Torus || typs2==GeomAbs_Torus) {
-             if (myTolReached3d<1.e-6) {
-               myTolReached3d = theapp3d.TolReached3d();
-               myTolReached3d=1.e-6;
-             }
-           }
-           //
-         }
-         else  if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0.) { 
-           myTolReached3d = theapp3d.TolReached3d();
-         }
-         
-         Standard_Integer aNbMultiCurves, nbpoles;
-         aNbMultiCurves=theapp3d.NbMultiCurves(); 
-         for (j=1; j<=aNbMultiCurves; j++) {
-           if(typs1 == GeomAbs_Plane) {
-             const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
-             nbpoles = mbspc.NbPoles();
-             
-             TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
-             TColgp_Array1OfPnt   tpoles(1,nbpoles);
-             
-             mbspc.Curve(1,tpoles2d);
-             const gp_Pln&  Pln = myHS1->Surface().Plane();
-             //
-             Standard_Integer ik; 
-             for(ik = 1; ik<= nbpoles; ik++) { 
-               tpoles.SetValue(ik,
-                               ElSLib::Value(tpoles2d.Value(ik).X(),
-                                             tpoles2d.Value(ik).Y(),
-                                             Pln));
-             }
-             //
-             Handle(Geom_BSplineCurve) BS = 
-               new Geom_BSplineCurve(tpoles,
-                                     mbspc.Knots(),
-                                     mbspc.Multiplicities(),
-                                     mbspc.Degree());
-             GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
-             Check.FixTangent(Standard_True, Standard_True);
-             //        
-             IntTools_Curve aCurve;
-             aCurve.SetCurve(BS);
-
-             if(myApprox1) { 
-               Handle(Geom2d_BSplineCurve) BS1 = 
-                 new Geom2d_BSplineCurve(tpoles2d,
-                                         mbspc.Knots(),
-                                         mbspc.Multiplicities(),
-                                         mbspc.Degree());
-               GeomLib_Check2dBSplineCurve Check1(BS1,TOLCHECK,TOLANGCHECK);
-               Check1.FixTangent(Standard_True,Standard_True);
-               //
-               // ############################################
-               if(!rejectSurface && !reApprox) {
-                 Standard_Boolean isValid = IsCurveValid(BS1);
-                 if(!isValid) {
-                   reApprox = Standard_True;
-                   goto reapprox;
-                 }
-               }
-               // ############################################
-               aCurve.SetFirstCurve2d(BS1);
-             }
-             else {
-               Handle(Geom2d_BSplineCurve) H1;
-               aCurve.SetFirstCurve2d(H1);
-             }
+        if(bIsDecomposited) {
+          WL = Handle(IntPatch_WLine)::DownCast(aSeqOfL.Value(i));
+          ifprm = 1;
+          ilprm = WL->NbPnts();
+        }
+        else {
+          if(bAvoidLineConstructor) {
+            ifprm = 1;
+            ilprm = WL->NbPnts();
+          }
+          else {
+            myLConstruct.Part(i, fprm, lprm);
+            ifprm = (Standard_Integer)fprm;
+            ilprm = (Standard_Integer)lprm;
+          }
+        }
+        //-- lbr : 
+        //-- Si une des surfaces est un plan , on approxime en 2d
+        //-- sur cette surface et on remonte les points 2d en 3d.
+        if(typs1 == GeomAbs_Plane) { 
+          theapp3d.Perform(myHS1, myHS2, WL, Standard_False,Standard_True, myApprox2,ifprm,ilprm);
+        }        
+        else if(typs2 == GeomAbs_Plane) { 
+          theapp3d.Perform(myHS1,myHS2,WL,Standard_False,myApprox1,Standard_True,ifprm,ilprm);
+        }
+        else { 
+          //
+          if (myHS1 != myHS2){
+            if ((typs1==GeomAbs_BezierSurface || typs1==GeomAbs_BSplineSurface) &&
+              (typs2==GeomAbs_BezierSurface || typs2==GeomAbs_BSplineSurface)) {
+
+              theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_True, aParType);
+
+              Standard_Boolean bUseSurfaces;
+              bUseSurfaces=NotUseSurfacesForApprox(myFace1, myFace2, WL, ifprm,  ilprm);
+              if (bUseSurfaces) {
+                // ######
+                rejectSurface = Standard_True;
+                // ######
+                theapp3d.SetParameters(myTolApprox, tol2d, 4, 8, 0, Standard_False, aParType);
+              }
+            }
+          }
+          //
+          theapp3d.Perform(myHS1,myHS2,WL,Standard_True,anApprox1,anApprox2,ifprm,ilprm);
+        }
 
-             if(myApprox2) { 
-               mbspc.Curve(2, tpoles2d);
-               
-               Handle(Geom2d_BSplineCurve) BS2 = new Geom2d_BSplineCurve(tpoles2d,
-                                                                         mbspc.Knots(),
-                                                                         mbspc.Multiplicities(),
-                                                                         mbspc.Degree());
-               GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
-               newCheck.FixTangent(Standard_True,Standard_True);
-               
-               // ###########################################
-               if(!rejectSurface && !reApprox) {
-                 Standard_Boolean isValid = IsCurveValid(BS2);
-                 if(!isValid) {
-                   reApprox = Standard_True;
-                   goto reapprox;
-                 }
-               }
-               // ###########################################
-               // 
-               aCurve.SetSecondCurve2d(BS2);
-             }
-             else { 
-               Handle(Geom2d_BSplineCurve) H2;
-               //              
-                 aCurve.SetSecondCurve2d(H2);
-             }
-             //
-             mySeqOfCurve.Append(aCurve);
-           }
-           
-           else if(typs2 == GeomAbs_Plane) { 
-             const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
-             nbpoles = mbspc.NbPoles();
-             
-             TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
-             TColgp_Array1OfPnt   tpoles(1,nbpoles);
-             mbspc.Curve((myApprox1==Standard_True)? 2 : 1,tpoles2d);
-             const gp_Pln&  Pln = myHS2->Surface().Plane();
-             //
-             Standard_Integer ik; 
-             for(ik = 1; ik<= nbpoles; ik++) { 
-               tpoles.SetValue(ik,
-                               ElSLib::Value(tpoles2d.Value(ik).X(),
-                                             tpoles2d.Value(ik).Y(),
-                                             Pln));
-               
-             }
-             //
-             Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles,
-                                                                mbspc.Knots(),
-                                                                mbspc.Multiplicities(),
-                                                                mbspc.Degree());
-             GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
-             Check.FixTangent(Standard_True,Standard_True);
-             //        
-             IntTools_Curve aCurve;
-             aCurve.SetCurve(BS);
-
-             if(myApprox2) {
-               Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d,
-                                                                       mbspc.Knots(),
-                                                                       mbspc.Multiplicities(),
-                                                                       mbspc.Degree());
-               GeomLib_Check2dBSplineCurve Check1(BS1,TOLCHECK,TOLANGCHECK);
-               Check1.FixTangent(Standard_True,Standard_True);
-               //      
-               // ###########################################
-               if(!rejectSurface && !reApprox) {
-                 Standard_Boolean isValid = IsCurveValid(BS1);
-                 if(!isValid) {
-                   reApprox = Standard_True;
-                   goto reapprox;
-                 }
-               }
+        if (!theapp3d.IsDone()) {
+          //     
+          Handle(Geom2d_BSplineCurve) H1;
+          //     
+          Handle(Geom_Curve) aBSp=MakeBSpline(WL,ifprm, ilprm);
+          Handle(Geom2d_BSplineCurve) H2;
+
+          if(myApprox1) {
+            H1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True);
+          }
+
+          if(myApprox2) {
+            H2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False);
+          }
+          //     
+          IntTools_Curve aIC(aBSp, H1, H2);
+          mySeqOfCurve.Append(aIC);
+        }
+
+        else {
+          if(myApprox1 || myApprox2 || (typs1==GeomAbs_Plane || typs2==GeomAbs_Plane)) { 
+            if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0.) { 
+              myTolReached2d = theapp3d.TolReached2d();
+            }
+          }
+          if(typs1==GeomAbs_Plane || typs2==GeomAbs_Plane) { 
+            myTolReached3d = myTolReached2d;
+            //
+            if (typs1==GeomAbs_Torus || typs2==GeomAbs_Torus) {
+              if (myTolReached3d<1.e-6) {
+                myTolReached3d = theapp3d.TolReached3d();
+                myTolReached3d=1.e-6;
+              }
+            }
+            //
+          }
+          else  if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0.) { 
+            myTolReached3d = theapp3d.TolReached3d();
+          }
+
+          Standard_Integer aNbMultiCurves, nbpoles;
+          aNbMultiCurves=theapp3d.NbMultiCurves(); 
+          for (j=1; j<=aNbMultiCurves; j++) {
+            if(typs1 == GeomAbs_Plane) {
+              const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
+              nbpoles = mbspc.NbPoles();
+
+              TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
+              TColgp_Array1OfPnt   tpoles(1,nbpoles);
+
+              mbspc.Curve(1,tpoles2d);
+              const gp_Pln&  Pln = myHS1->Surface().Plane();
+              //
+              Standard_Integer ik; 
+              for(ik = 1; ik<= nbpoles; ik++) { 
+                tpoles.SetValue(ik,
+                  ElSLib::Value(tpoles2d.Value(ik).X(),
+                  tpoles2d.Value(ik).Y(),
+                  Pln));
+              }
+              //
+              Handle(Geom_BSplineCurve) BS = 
+                new Geom_BSplineCurve(tpoles,
+                mbspc.Knots(),
+                mbspc.Multiplicities(),
+                mbspc.Degree());
+              GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
+              Check.FixTangent(Standard_True, Standard_True);
+              //       
+              IntTools_Curve aCurve;
+              aCurve.SetCurve(BS);
+
+              if(myApprox1) { 
+                Handle(Geom2d_BSplineCurve) BS1 = 
+                  new Geom2d_BSplineCurve(tpoles2d,
+                  mbspc.Knots(),
+                  mbspc.Multiplicities(),
+                  mbspc.Degree());
+                GeomLib_Check2dBSplineCurve Check1(BS1,TOLCHECK,TOLANGCHECK);
+                Check1.FixTangent(Standard_True,Standard_True);
+                //
+                // ############################################
+                if(!rejectSurface && !reApprox) {
+                  Standard_Boolean isValid = IsCurveValid(BS1);
+                  if(!isValid) {
+                    reApprox = Standard_True;
+                    goto reapprox;
+                  }
+                }
+                // ############################################
+                aCurve.SetFirstCurve2d(BS1);
+              }
+              else {
+                Handle(Geom2d_BSplineCurve) H1;
+                aCurve.SetFirstCurve2d(H1);
+              }
+
+              if(myApprox2) { 
+                mbspc.Curve(2, tpoles2d);
+
+                Handle(Geom2d_BSplineCurve) BS2 = new Geom2d_BSplineCurve(tpoles2d,
+                  mbspc.Knots(),
+                  mbspc.Multiplicities(),
+                  mbspc.Degree());
+                GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
+                newCheck.FixTangent(Standard_True,Standard_True);
+
+                // ###########################################
+                if(!rejectSurface && !reApprox) {
+                  Standard_Boolean isValid = IsCurveValid(BS2);
+                  if(!isValid) {
+                    reApprox = Standard_True;
+                    goto reapprox;
+                  }
+                }
+                // ###########################################
+                // 
+                aCurve.SetSecondCurve2d(BS2);
+              }
+              else { 
+                Handle(Geom2d_BSplineCurve) H2;
+                //             
+                aCurve.SetSecondCurve2d(H2);
+              }
+              //
+              mySeqOfCurve.Append(aCurve);
+            }
+
+            else if(typs2 == GeomAbs_Plane) { 
+              const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
+              nbpoles = mbspc.NbPoles();
+
+              TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
+              TColgp_Array1OfPnt   tpoles(1,nbpoles);
+              mbspc.Curve((myApprox1==Standard_True)? 2 : 1,tpoles2d);
+              const gp_Pln&  Pln = myHS2->Surface().Plane();
+              //
+              Standard_Integer ik; 
+              for(ik = 1; ik<= nbpoles; ik++) { 
+                tpoles.SetValue(ik,
+                  ElSLib::Value(tpoles2d.Value(ik).X(),
+                  tpoles2d.Value(ik).Y(),
+                  Pln));
+
+              }
+              //
+              Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles,
+                mbspc.Knots(),
+                mbspc.Multiplicities(),
+                mbspc.Degree());
+              GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
+              Check.FixTangent(Standard_True,Standard_True);
+              //       
+              IntTools_Curve aCurve;
+              aCurve.SetCurve(BS);
+
+              if(myApprox2) {
+                Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d,
+                  mbspc.Knots(),
+                  mbspc.Multiplicities(),
+                  mbspc.Degree());
+                GeomLib_Check2dBSplineCurve Check1(BS1,TOLCHECK,TOLANGCHECK);
+                Check1.FixTangent(Standard_True,Standard_True);
+                //     
+                // ###########################################
+                if(!rejectSurface && !reApprox) {
+                  Standard_Boolean isValid = IsCurveValid(BS1);
+                  if(!isValid) {
+                    reApprox = Standard_True;
+                    goto reapprox;
+                  }
+                }
                 // ###########################################
                 bPCurvesOk = CheckPCurve(BS1, myFace2);
-               aCurve.SetSecondCurve2d(BS1);
-             }
-             else {
-               Handle(Geom2d_BSplineCurve) H2;
-               aCurve.SetSecondCurve2d(H2);
-             }
-             
-             if(myApprox1) { 
-               mbspc.Curve(1,tpoles2d);
-               Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
-                                                                       mbspc.Knots(),
-                                                                       mbspc.Multiplicities(),
-                                                                       mbspc.Degree());
-               GeomLib_Check2dBSplineCurve Check2(BS2,TOLCHECK,TOLANGCHECK);
-               Check2.FixTangent(Standard_True,Standard_True);
-               //
-               // ###########################################
-               if(!rejectSurface && !reApprox) {
-                 Standard_Boolean isValid = IsCurveValid(BS2);
-                 if(!isValid) {
-                   reApprox = Standard_True;
-                   goto reapprox;
-                 }
-               }
+                aCurve.SetSecondCurve2d(BS1);
+              }
+              else {
+                Handle(Geom2d_BSplineCurve) H2;
+                aCurve.SetSecondCurve2d(H2);
+              }
+
+              if(myApprox1) { 
+                mbspc.Curve(1,tpoles2d);
+                Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
+                  mbspc.Knots(),
+                  mbspc.Multiplicities(),
+                  mbspc.Degree());
+                GeomLib_Check2dBSplineCurve Check2(BS2,TOLCHECK,TOLANGCHECK);
+                Check2.FixTangent(Standard_True,Standard_True);
+                //
+                // ###########################################
+                if(!rejectSurface && !reApprox) {
+                  Standard_Boolean isValid = IsCurveValid(BS2);
+                  if(!isValid) {
+                    reApprox = Standard_True;
+                    goto reapprox;
+                  }
+                }
                 // ###########################################
                 bPCurvesOk = bPCurvesOk && CheckPCurve(BS2, myFace1);
-               aCurve.SetFirstCurve2d(BS2);
-             }
-             else { 
-               Handle(Geom2d_BSplineCurve) H1;
-               //              
-               aCurve.SetFirstCurve2d(H1);
-             }
-             //
+                aCurve.SetFirstCurve2d(BS2);
+              }
+              else { 
+                Handle(Geom2d_BSplineCurve) H1;
+                //             
+                aCurve.SetFirstCurve2d(H1);
+              }
+              //
               //if points of the pcurves are out of the faces bounds
               //create 3d and 2d curves without approximation
               if (!bPCurvesOk) {
                 Handle(Geom2d_BSplineCurve) H1, H2;
-               bPCurvesOk = Standard_True;
+                bPCurvesOk = Standard_True;
                 //       
                 Handle(Geom_Curve) aBSp=MakeBSpline(WL,ifprm, ilprm);
-                
+
                 if(myApprox1) {
                   H1 = MakeBSpline2d(WL, ifprm, ilprm, Standard_True);
-                 bPCurvesOk = CheckPCurve(H1, myFace1);
+                  bPCurvesOk = CheckPCurve(H1, myFace1);
                 }
-                
+
                 if(myApprox2) {
                   H2 = MakeBSpline2d(WL, ifprm, ilprm, Standard_False);
-                 bPCurvesOk = bPCurvesOk && CheckPCurve(H2, myFace2);
+                  bPCurvesOk = bPCurvesOk && CheckPCurve(H2, myFace2);
                 }
                 //
-               //if pcurves created without approximation are out of the 
-               //faces bounds, use approximated 3d and 2d curves
-               if (bPCurvesOk) {
-                 IntTools_Curve aIC(aBSp, H1, H2);
-                 mySeqOfCurve.Append(aIC);
-               } else {
-                 mySeqOfCurve.Append(aCurve);
-               }
+                //if pcurves created without approximation are out of the 
+                //faces bounds, use approximated 3d and 2d curves
+                if (bPCurvesOk) {
+                  IntTools_Curve aIC(aBSp, H1, H2);
+                  mySeqOfCurve.Append(aIC);
+                } else {
+                  mySeqOfCurve.Append(aCurve);
+                }
               } else {
                 mySeqOfCurve.Append(aCurve);
               }
-           }
-           else { 
-             const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
-             nbpoles = mbspc.NbPoles();
-             TColgp_Array1OfPnt tpoles(1,nbpoles);
-             mbspc.Curve(1,tpoles);
-             Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles,
-                                                                mbspc.Knots(),
-                                                                mbspc.Multiplicities(),
-                                                                mbspc.Degree());
-             GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
-             Check.FixTangent(Standard_True,Standard_True);
-             //                
-             IntTools_Curve aCurve;
-             aCurve.SetCurve(BS);
-             
-             if(myApprox1) { 
-               if(anApprox1) {
-                 TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
-                 mbspc.Curve(2,tpoles2d);
-                 Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d,
-                                                                       mbspc.Knots(),
-                                                                       mbspc.Multiplicities(),
-                                                                       mbspc.Degree());
-                 GeomLib_Check2dBSplineCurve newCheck(BS1,TOLCHECK,TOLANGCHECK);
-                 newCheck.FixTangent(Standard_True,Standard_True);
-                 //    
-                 aCurve.SetFirstCurve2d(BS1);
-               }
-               else {
-                 Handle(Geom2d_BSplineCurve) BS1;
-                 fprm = BS->FirstParameter();
-                 lprm = BS->LastParameter();
-
-                 Handle(Geom2d_Curve) C2d;
-                 Standard_Real aTol = myTolApprox;
-                 BuildPCurves(fprm, lprm, aTol, myHS1->ChangeSurface().Surface(), BS, C2d);
-                 BS1 = Handle(Geom2d_BSplineCurve)::DownCast(C2d);
-                 aCurve.SetFirstCurve2d(BS1);
-               }
-               
-             }
-             else {
-               Handle(Geom2d_BSplineCurve) H1;
-               //              
-               aCurve.SetFirstCurve2d(H1);
-             }
-             if(myApprox2) { 
-               if(anApprox2) {
-                 TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
-                 mbspc.Curve((myApprox1==Standard_True)? 3 : 2,tpoles2d);
-                 Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
-                                                                       mbspc.Knots(),
-                                                                       mbspc.Multiplicities(),
-                                                                       mbspc.Degree());
-                 GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
-                 newCheck.FixTangent(Standard_True,Standard_True);
-               //              
-                 aCurve.SetSecondCurve2d(BS2);
-               }
-               else {
-                 Handle(Geom2d_BSplineCurve) BS2;
-                 fprm = BS->FirstParameter();
-                 lprm = BS->LastParameter();
-
-                 Handle(Geom2d_Curve) C2d;
-                 Standard_Real aTol = myTolApprox;
-                 BuildPCurves(fprm, lprm, aTol, myHS2->ChangeSurface().Surface(), BS, C2d);
-                 BS2 = Handle(Geom2d_BSplineCurve)::DownCast(C2d);
-                 aCurve.SetSecondCurve2d(BS2);
-               }
-               
-             }
-             else { 
-               Handle(Geom2d_BSplineCurve) H2;
-               //              
-               aCurve.SetSecondCurve2d(H2);
-             }
-             //
-             mySeqOfCurve.Append(aCurve);
-           }
-         }
-       }
+            }
+            else { 
+              const AppParCurves_MultiBSpCurve& mbspc = theapp3d.Value(j);
+              nbpoles = mbspc.NbPoles();
+              TColgp_Array1OfPnt tpoles(1,nbpoles);
+              mbspc.Curve(1,tpoles);
+              Handle(Geom_BSplineCurve) BS=new Geom_BSplineCurve(tpoles,
+                mbspc.Knots(),
+                mbspc.Multiplicities(),
+                mbspc.Degree());
+              GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
+              Check.FixTangent(Standard_True,Standard_True);
+              //               
+              IntTools_Curve aCurve;
+              aCurve.SetCurve(BS);
+
+              if(myApprox1) { 
+                if(anApprox1) {
+                  TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
+                  mbspc.Curve(2,tpoles2d);
+                  Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d,
+                    mbspc.Knots(),
+                    mbspc.Multiplicities(),
+                    mbspc.Degree());
+                  GeomLib_Check2dBSplineCurve newCheck(BS1,TOLCHECK,TOLANGCHECK);
+                  newCheck.FixTangent(Standard_True,Standard_True);
+                  //   
+                  aCurve.SetFirstCurve2d(BS1);
+                }
+                else {
+                  Handle(Geom2d_BSplineCurve) BS1;
+                  fprm = BS->FirstParameter();
+                  lprm = BS->LastParameter();
+
+                  Handle(Geom2d_Curve) C2d;
+                  Standard_Real aTol = myTolApprox;
+                  BuildPCurves(fprm, lprm, aTol, myHS1->ChangeSurface().Surface(), BS, C2d);
+                  BS1 = Handle(Geom2d_BSplineCurve)::DownCast(C2d);
+                  aCurve.SetFirstCurve2d(BS1);
+                }
+
+              }
+              else {
+                Handle(Geom2d_BSplineCurve) H1;
+                //             
+                aCurve.SetFirstCurve2d(H1);
+              }
+              if(myApprox2) { 
+                if(anApprox2) {
+                  TColgp_Array1OfPnt2d tpoles2d(1,nbpoles);
+                  mbspc.Curve((myApprox1==Standard_True)? 3 : 2,tpoles2d);
+                  Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
+                    mbspc.Knots(),
+                    mbspc.Multiplicities(),
+                    mbspc.Degree());
+                  GeomLib_Check2dBSplineCurve newCheck(BS2,TOLCHECK,TOLANGCHECK);
+                  newCheck.FixTangent(Standard_True,Standard_True);
+                  //           
+                  aCurve.SetSecondCurve2d(BS2);
+                }
+                else {
+                  Handle(Geom2d_BSplineCurve) BS2;
+                  fprm = BS->FirstParameter();
+                  lprm = BS->LastParameter();
+
+                  Handle(Geom2d_Curve) C2d;
+                  Standard_Real aTol = myTolApprox;
+                  BuildPCurves(fprm, lprm, aTol, myHS2->ChangeSurface().Surface(), BS, C2d);
+                  BS2 = Handle(Geom2d_BSplineCurve)::DownCast(C2d);
+                  aCurve.SetSecondCurve2d(BS2);
+                }
+
+              }
+              else { 
+                Handle(Geom2d_BSplineCurve) H2;
+                //             
+                aCurve.SetSecondCurve2d(H2);
+              }
+              //
+              mySeqOfCurve.Append(aCurve);
+            }
+          }
+        }
       }
     }// else { // X
   }// case IntPatch_Walking:{
-    break;
-    
+  break;
+
   case IntPatch_Restriction: 
     break;
 
diff --git a/tests/bugs/modalg_5/bug24313 b/tests/bugs/modalg_5/bug24313
new file mode 100755 (executable)
index 0000000..5a27988
--- /dev/null
@@ -0,0 +1,14 @@
+puts "============"
+puts "OCC24313"
+puts "============"
+puts ""
+#######################################################################
+# BRepAlgoAPI_Section and IntTools_FaceFace aren't written to handle Geom_SurfaceOfLinearExtrusion
+#######################################################################
+
+circle c 0 0 0 0 0 1 1 0 0 100
+extsurf s1 c 0 0 1
+plane s2 0 0 0 1 0 0 0 1 0
+mkface b1 s1
+mkface b2 s2
+bopcurves b1 b2