]> OCCT Git - occt-copy.git/commitdiff
0023914: Intersection algorithm produced too many intersection points
authornbv <nbv@opencascade.com>
Wed, 2 Mar 2016 14:14:05 +0000 (17:14 +0300)
committernbv <nbv@opencascade.com>
Fri, 17 Mar 2017 14:25:04 +0000 (17:25 +0300)
This is draft version.

1. External step limitation has been eliminated.
2. Interfaces of GeomInt_IntSS, IntPatch_Intersection and IntPatch_PrmPrmIntersection classes has been changed.
3. Syntax of "intersect" DRAW-command has been changed (see help for detail information).
4. New statuses have been added in IntWalk_StatusDeflection.hxx file.

Main changes are made in IntWalk_PWalking class.

Creation of test case for this issue.

18 files changed:
src/ChFi3d/ChFi3d_Builder_0.cxx
src/GeomInt/GeomInt_IntSS.cxx
src/GeomInt/GeomInt_IntSS.hxx
src/GeomInt/GeomInt_IntSS.lxx
src/GeometryTest/GeometryTest_CurveCommands.cxx
src/IntPatch/IntPatch_Intersection.cxx
src/IntPatch/IntPatch_Intersection.hxx
src/IntPatch/IntPatch_PrmPrmIntersection.cxx
src/IntPatch/IntPatch_PrmPrmIntersection.hxx
src/IntTools/IntTools_FaceFace.cxx
src/IntWalk/IntWalk_PWalking.cxx
src/IntWalk/IntWalk_PWalking.hxx
src/IntWalk/IntWalk_StatusDeflection.hxx
src/TopOpeBRep/TopOpeBRep_FacesIntersector.cxx
tests/boolean/bcut_complex/G7
tests/boolean/bcut_complex/Q9
tests/bugs/modalg_6/bug23914 [new file with mode: 0644]
tests/bugs/moddata_2/bug271

index 9cf33a42ad78b7d7eeb270323296a2727174d243..1c50dfeae1f9ca030c2c0ed0fdbe9f9995184bfd 100644 (file)
@@ -3319,15 +3319,14 @@ Standard_Boolean ChFi3d_ComputeCurves(const Handle(Adaptor3d_HSurface)&   S1,
   // At this stage : 
   // classic intersections have failed, the path is approached in vain.
 
-  Standard_Real Step = 0.1;
-  for(;;) {
+  for(Standard_Integer aNbIter = 20;;) {
     //Attention the parameters of arrow for the path and
     //the tolerance for the approximation can't be taken as those of the  
     //Builder, so they are reestimated as much as possible.
     Standard_Real fleche = 1.e-3 * pdeb.Distance(pfin);
     Standard_Real tolap = 1.e-7;
     IntWalk_PWalking
-      IntKK(S1,S2,tol3d,tol3d,fleche,Step);
+      IntKK(S1,S2,tol3d,tol3d,fleche);
 
     //The extremities of the intersection (Pardeb,Parfin) are known,
     //one tries to find the start point at the 
@@ -3351,8 +3350,7 @@ Standard_Boolean ChFi3d_ComputeCurves(const Handle(Adaptor3d_HSurface)&   S1,
     IntKK.Perform(depart);
     if (!IntKK.IsDone()) return Standard_False;
     if (IntKK.NbPoints() <= 30) {
-      Step *= 0.5;
-      if (Step <= 0.0001) {
+      if (--aNbIter <= 0) {
         return Standard_False;
       }
     }
index 0e2d7c9bcc433362b0ac474404a23e9e5b859517..a74e028eaeb47b705fa2b2f069efbaeaac2edce6 100644 (file)
@@ -28,14 +28,15 @@ void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
                               const Standard_Real Tol,
                               const Standard_Boolean Approx,
                               const Standard_Boolean ApproxS1,
-                              const Standard_Boolean ApproxS2)
+                              const Standard_Boolean ApproxS2,
+                              const Standard_Boolean theIsReqToPostWLProc)
 {
   myHS1 = new GeomAdaptor_HSurface(S1);
   if (S1==S2)
     myHS2 = myHS1;
   else
     myHS2 = new GeomAdaptor_HSurface(S2);
-  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.);
+  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.,theIsReqToPostWLProc);
 }
 
 //=======================================================================
@@ -49,14 +50,15 @@ void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
                               const Standard_Real U2, const Standard_Real V2,
                               const Standard_Boolean Approx,
                               const Standard_Boolean ApproxS1,
-                              const Standard_Boolean ApproxS2)
+                              const Standard_Boolean ApproxS2,
+                              const Standard_Boolean theIsReqToPostWLProc)
 {
   myHS1 = new GeomAdaptor_HSurface(S1);
   if (S1==S2)
     myHS2 = myHS1;
   else
     myHS2 = new GeomAdaptor_HSurface(S2);
-  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2);
+  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2,theIsReqToPostWLProc);
 }
 
 //=======================================================================
@@ -71,7 +73,8 @@ void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
                                       const Standard_Real U1,
                                       const Standard_Real V1,
                                       const Standard_Real U2,
-                                      const Standard_Real V2)
+                                      const Standard_Real V2,
+                                      const Standard_Boolean theIsReqToPostWLProc)
 {
   myTolReached2d = myTolReached3d = 0.0;
   myNbrestr = 0;
@@ -82,16 +85,15 @@ void GeomInt_IntSS::Perform(const Handle(Geom_Surface)& S1,
 
   Standard_Real TolArc = Tol;
   Standard_Real TolTang = Tol;
-  Standard_Real UVMaxStep = 0.001;
   Standard_Real Deflection = 0.1;
 
-  myIntersector.SetTolerances(TolArc,TolTang,UVMaxStep,Deflection);
+  myIntersector.SetTolerances(TolArc,TolTang,Deflection);
 
   if(myHS1 == myHS2) {
     myIntersector.Perform(myHS1,dom1,TolArc,TolTang);
   }
   else if (!useStart) {
-    myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang);
+    myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang,Standard_True, Standard_False, theIsReqToPostWLProc);
   }
   else {
     myIntersector.Perform(myHS1,dom1,myHS2,dom2,U1,V1,U2,V2,TolArc,TolTang);
index 40ed65331b0a49d1ab7d0fbf1d2716d60a6e6720..efa6c9eb3ff50fddf465ebd4252d2b759a2d74db 100644 (file)
@@ -57,16 +57,16 @@ public:
     GeomInt_IntSS(const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
   
   //! general intersection of two surfaces
-  Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
+  Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
   
   //! intersection of adapted surfaces
-    void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
+    void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
   
   //! general intersection using a starting point
-  Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
+  Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
   
   //! intersection of adapted surfaces using a starting point
-    void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
+    void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
   
     Standard_Boolean IsDone() const;
   
@@ -119,7 +119,7 @@ public:
 protected:
 
   
-  Standard_EXPORT void InternalPerform (const Standard_Real Tol, const Standard_Boolean Approx, const Standard_Boolean ApproxS1, const Standard_Boolean ApproxS2, const Standard_Boolean useStart, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2);
+  Standard_EXPORT void InternalPerform (const Standard_Real Tol, const Standard_Boolean Approx, const Standard_Boolean ApproxS1, const Standard_Boolean ApproxS2, const Standard_Boolean useStart, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean theIsReqToPostWLProc);
   
   Standard_EXPORT void MakeCurve (const Standard_Integer Ind, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real Tol, const Standard_Boolean Approx, const Standard_Boolean Approx1, const Standard_Boolean Approx2);
 
index 95455a68978902cecea1292e35e065c0e2e36cf3..78b2a36ecab5c6e9c21407b26a4ab60183771059 100644 (file)
@@ -58,11 +58,12 @@ inline GeomInt_IntSS::GeomInt_IntSS ()
                                      const Standard_Real Tol,
                                      const Standard_Boolean Approx,
                                      const Standard_Boolean ApproxS1,
-                                     const Standard_Boolean ApproxS2)
+                                     const Standard_Boolean ApproxS2,
+                                     const Standard_Boolean theIsReqToPostWLProc)
 {
   myHS1 = HS1;
   myHS2 = HS2;
-  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.);
+  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.,theIsReqToPostWLProc);
 }
 
 //=======================================================================
@@ -76,11 +77,12 @@ inline GeomInt_IntSS::GeomInt_IntSS ()
                                      const Standard_Real U2, const Standard_Real V2,
                                      const Standard_Boolean Approx,
                                      const Standard_Boolean ApproxS1,
-                                     const Standard_Boolean ApproxS2)
+                                     const Standard_Boolean ApproxS2,
+                                     const Standard_Boolean theIsReqToPostWLProc)
 {
   myHS1 = HS1;
   myHS2 = HS2;
-  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2);
+  InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2,theIsReqToPostWLProc);
 }
 
 //=======================================================================
index cf8b541c37386be5b230e1ee69136560bdbac092..f3580b12a7740ac855d57c59727a56466e4b5625 100644 (file)
@@ -1496,11 +1496,45 @@ static Standard_Integer intersection (Draw_Interpretor& di,
   if (GS2.IsNull())
     return 1;
 
-  //
+  Handle(GeomAdaptor_HSurface) AS1,AS2;
   Standard_Real tol = Precision::Confusion();
-  if (n == 5 || n == 9 || n == 13 || n == 17)
-    tol = Draw::Atof(a[n-1]);
+  Standard_Real UVsta[4];
+  Standard_Boolean useStart = Standard_False, useBnd = Standard_False, isPostProcessingReq = Standard_True;
+
+  for(Standard_Integer i = 4; i < n; i++)
+  {
+    if(!strcmp(a[i], "-sp"))
+    {
+      useStart = Standard_True;
+      for(Standard_Integer j = 0; j < 4; j++)
+      {
+        UVsta[j] = Draw::Atof(a[++i]);
+      }
+    }
+
+    if(!strcmp(a[i], "-b"))
+    {
+      Standard_Real UVbnd[8];
+      useBnd = Standard_True;
+      for(Standard_Integer j = 0; j < 4; j++)
+      {
+        UVbnd[j] = Draw::Atof(a[++i]);
+      }
+
+      AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
+      AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
+    }
+
+    if(!strcmp(a[i], "-t"))
+    {
+      tol = Draw::Atof(a[++i]);
+    }
 
+    if(!strcmp(a[i], "-npp"))
+    {
+      isPostProcessingReq = Standard_False;
+    }
+  }
   //
   Handle(Geom_Curve) Result;
   gp_Pnt             Point;
@@ -1509,76 +1543,24 @@ static Standard_Integer intersection (Draw_Interpretor& di,
   if (GC1.IsNull())
   {
     GeomInt_IntSS Inters;
-    //
-    // Surface Surface
-    if (n <= 5)
+
+    if(!useStart && !useBnd)
     {
       // General case
-      Inters.Perform(GS1,GS2,tol,Standard_True);
+      Inters.Perform(GS1,GS2,tol,Standard_True, Standard_False, Standard_False, isPostProcessingReq);
     }
-    else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
+    else if (useStart && !useBnd)
     {
-      Standard_Boolean useStart = Standard_True, useBnd = Standard_True;
-      Standard_Integer ista1=0,ista2=0,ibnd1=0,ibnd2=0;
-      Standard_Real UVsta[4];
-      Handle(GeomAdaptor_HSurface) AS1,AS2;
-
-      //
-      if (n <= 9)          // user starting point
-      {
-        useBnd = Standard_False;
-        ista1 = 4;
-        ista2 = 7;
-      }
-      else if (n <= 13)   // user bounding
-      {
-        useStart = Standard_False;
-        ibnd1 = 4; ibnd2 = 11;
-      }
-      else        // both user starting point and bounding
-      {
-        ista1 = 4; ista2 = 7;
-        ibnd1 = 8; ibnd2 = 15;
-      }
-
-      if (useStart)
-      {
-        for (Standard_Integer i=ista1; i <= ista2; i++)
-        {
-          UVsta[i-ista1] = Draw::Atof(a[i]);
-        }
-      }
-
-      if (useBnd)
-      {
-        Standard_Real UVbnd[8];
-        for (Standard_Integer i=ibnd1; i <= ibnd2; i++)
-          UVbnd[i-ibnd1] = Draw::Atof(a[i]);
-
-        AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
-        AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
-      }
-
-      //
-      if (useStart && !useBnd)
-      {
-        Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
-      }
-      else if (!useStart && useBnd)
-      {
-        Inters.Perform(AS1,AS2,tol);
-      }
-      else
-      {
-        Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
-      }
-    }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
+      Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3], Standard_True, Standard_False, Standard_False, Standard_True);
+    }
+    else if (!useStart && useBnd)
+    {
+      Inters.Perform(AS1,AS2,tol,Standard_True, Standard_False, Standard_False, Standard_True);
+    }
     else
     {
-      di<<"incorrect number of arguments\n";
-      return 1;
+      Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3], Standard_True, Standard_False, Standard_False, Standard_True);
     }
-
     //
     if (!Inters.IsDone())
     {
@@ -1798,8 +1780,9 @@ void  GeometryTest::CurveCommands(Draw_Interpretor& theCommands)
   g = "GEOMETRY intersections";
 
   theCommands.Add("intersect",
-                 "intersect result surf1/curv1 surf2 [tolerance]\n\t\t  "
-                  "intersect result surf1 surf2 [u1 v1 u2 v2] [U1F U1L V1F V1L U2F U2L V2F V2L] [tolerance]",
+                  "intersect result surf1 surf2 [-sp u1 v1 u2 v2] [-b U1F U1L V1F V1L U2F U2L V2F V2L] [-t tolerance] [-npp] : "
+                  "Use:\n -sp option for setting start point;\n -b option for setting bounds;\n "
+                  "-t option for setting tolerance;\n -npp option for switching off post-processing intersection line (e.g. avoid purger)",
                  __FILE__,
                  intersection,g);
 
index 6213b3541a0c61595ad35f29275081f216432a4b..61eab53d422acbdb2a57cf61636b8777f747b15d 100644 (file)
@@ -47,7 +47,7 @@ IntPatch_Intersection::IntPatch_Intersection ()
  : done(Standard_False),
    //empt, tgte, oppo,
    myTolArc(0.0), myTolTang(0.0),
-   myUVMaxStep(0.0), myFleche(0.0),
+   myFleche(0.0),
    myIsStartPnt(Standard_False)
    //myU1Start, myV1Start, myU2Start, myV2Start
 {
@@ -65,7 +65,7 @@ IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)&
  : done(Standard_False),
    //empt, tgte, oppo,
    myTolArc(TolArc), myTolTang(TolTang),
-   myUVMaxStep(0.0), myFleche(0.0),
+   myFleche(0.0),
    myIsStartPnt(Standard_False)
    //myU1Start, myV1Start, myU2Start, myV2Start
 {
@@ -86,7 +86,7 @@ IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)&
  : done(Standard_False),
    //empt, tgte, oppo,
    myTolArc(TolArc), myTolTang(TolTang),
-   myUVMaxStep(0.0), myFleche(0.0),
+   myFleche(0.0),
    myIsStartPnt(Standard_False)
    //myU1Start, myV1Start, myU2Start, myV2Start
 {
@@ -98,21 +98,17 @@ IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)&
 //======================================================================
 void IntPatch_Intersection::SetTolerances(const Standard_Real TolArc,
                                           const Standard_Real TolTang,
-                                          const Standard_Real UVMaxStep,
                                           const Standard_Real Fleche)
 { 
   myTolArc     = TolArc;
   myTolTang    = TolTang;
-  myUVMaxStep  = UVMaxStep;
   myFleche     = Fleche;
   if(myTolArc<1e-8) myTolArc=1e-8;
   if(myTolTang<1e-8) myTolTang=1e-8;
   if(myTolArc>0.5) myTolArc=0.5;
   if(myTolTang>0.5) myTolTang=0.5;  
   if(myFleche<1.0e-3) myFleche=1e-3;
-  if(myUVMaxStep<1.0e-3) myUVMaxStep=1e-3;
   if(myFleche>10) myFleche=10;
-  if(myUVMaxStep>0.5) myUVMaxStep=0.5;
 }
 
 //======================================================================
@@ -126,7 +122,6 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
   myTolArc = TolArc;
   myTolTang = TolTang;
   if(myFleche == 0.0)  myFleche = 0.01;
-  if(myUVMaxStep==0.0) myUVMaxStep = 0.01;
 
   done = Standard_True;
   spnt.Clear();
@@ -169,7 +164,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
   default:
     {
       IntPatch_PrmPrmIntersection interpp;
-      interpp.Perform(S1,D1,TolTang,TolArc,myFleche,myUVMaxStep);
+      interpp.Perform(S1,D1,TolTang,TolArc,myFleche);
       if (interpp.IsDone())
       {
         done = Standard_True;
@@ -746,8 +741,6 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)&  theS1,
   myTolTang = TolTang;
   if(myFleche <= Precision::PConfusion())
     myFleche = 0.01;
-  if(myUVMaxStep <= Precision::PConfusion())
-    myUVMaxStep = 0.01;
 
   done = Standard_False;
   spnt.Clear();
@@ -1008,8 +1001,6 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)&  theS1,
   myTolTang = TolTang;
   if(myFleche <= Precision::PConfusion())
     myFleche = 0.01;
-  if(myUVMaxStep <= Precision::PConfusion())
-    myUVMaxStep = 0.01;
     
   done = Standard_False;
   spnt.Clear();
@@ -1245,10 +1236,10 @@ void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)&
     Standard_Boolean ClearFlag = Standard_True;
     if(!ListOfPnts.IsEmpty())
     {
-      interpp.Perform(theS1,theD1,theS2,theD2,TolTang,TolArc,myFleche,myUVMaxStep, ListOfPnts, RestrictLine);
+      interpp.Perform(theS1,theD1,theS2,theD2,TolTang,TolArc,myFleche, ListOfPnts, RestrictLine);
       ClearFlag = Standard_False;
     }
-    interpp.Perform(theS1,theD1,theS2,theD2,TolTang,TolArc,myFleche,myUVMaxStep,ClearFlag);   //double call!!!!!!!
+    interpp.Perform(theS1,theD1,theS2,theD2,TolTang,TolArc,myFleche,ClearFlag);   //double call!!!!!!!
   }
   else if((theD1->DomainIsInfinite()) ^ (theD2->DomainIsInfinite()))
   {
@@ -1261,7 +1252,7 @@ void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)&
       const Standard_Real AP = Max(MU, MV);
       Handle(Adaptor3d_HSurface) SS;
       FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, theS1, AP, SS);
-      interpp.Perform(SS,theD1,theS2,theD2,TolTang,TolArc,myFleche,myUVMaxStep);
+      interpp.Perform(SS,theD1,theS2,theD2,TolTang,TolArc,myFleche);
     }
     else
     {
@@ -1271,7 +1262,7 @@ void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)&
       const Standard_Real AP = Max(MU, MV);
       Handle(Adaptor3d_HSurface) SS;
       FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, theS2, AP, SS);
-      interpp.Perform(theS1, theD1, SS, theD2,TolTang, TolArc,myFleche,myUVMaxStep);
+      interpp.Perform(theS1, theD1, SS, theD2,TolTang, TolArc,myFleche);
     }
   }//(theD1->DomainIsInfinite()) ^ (theD2->DomainIsInfinite())
   else
@@ -1310,7 +1301,7 @@ void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)&
       Handle(Adaptor3d_HSurface) nS1 = theS1;
       Handle(Adaptor3d_HSurface) nS2 = theS2;
       FUN_TrimBothSurf(theS1,typs1,theS2,typs2,1.e+8,nS1,nS2);
-      interpp.Perform(nS1,theD1,nS2,theD2,TolTang,TolArc,myFleche,myUVMaxStep);
+      interpp.Perform(nS1,theD1,nS2,theD2,TolTang,TolArc,myFleche);
     }// 'NON - COLLINEAR LINES'
   }// both domains are infinite
 
@@ -1505,11 +1496,11 @@ void IntPatch_Intersection::
       Handle(Adaptor3d_HSurface) nS1 = theS1;
       Handle(Adaptor3d_HSurface) nS2 = theS2;
       FUN_TrimBothSurf(theS1,typs1,theS2,typs2,1.e+5,nS1,nS2);
-      interip.Perform(nS1,theD1,nS2,theD2,myTolArc,myTolTang,myFleche,myUVMaxStep);
+      interip.Perform(nS1,theD1,nS2,theD2,myTolArc,myTolTang,myFleche, 0.001);
     }
   }
   else
-    interip.Perform(theS1,theD1,theS2,theD2,myTolArc,myTolTang,myFleche,myUVMaxStep);
+    interip.Perform(theS1,theD1,theS2,theD2,myTolArc,myTolTang,myFleche, 0.001);
 
   if (interip.IsDone()) 
   {
@@ -1557,13 +1548,6 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
 #endif
     myFleche = 0.01;
   }
-  if(myUVMaxStep==0.0) {
-#if DEBUG
-    //cout<<" -- IntPatch_Intersection::myUVMaxStep fixe par defaut a 0.01 --"<<endl;
-    //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl;
-#endif
-    myUVMaxStep = 0.01;
-  }
 
   done = Standard_False;
   spnt.Clear();
@@ -1593,7 +1577,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)&  S1,
   else
   {
     IntPatch_PrmPrmIntersection interpp;
-    interpp.Perform(S1,D1,S2,D2,U1,V1,U2,V2,TolTang,TolArc,myFleche,myUVMaxStep);
+    interpp.Perform(S1,D1,S2,D2,U1,V1,U2,V2,TolTang,TolArc,myFleche);
     if (interpp.IsDone())
     {
       done = Standard_True;
index 96a4dac4b42e7e7a8f73e062abd2a0cb045d72d1..178afdf9c893743bb57e019988b8bac22014d15c 100644 (file)
@@ -71,7 +71,7 @@ public:
   //! UVMaxStep is  a  parameter   used in  the  walking
   //! algorithms  to    compute the  distance between to
   //! points in their respective parametrtic spaces.
-  Standard_EXPORT void SetTolerances (const Standard_Real TolArc, const Standard_Real TolTang, const Standard_Real UVMaxStep, const Standard_Real Fleche);
+  Standard_EXPORT void SetTolerances (const Standard_Real TolArc, const Standard_Real TolTang, const Standard_Real Fleche);
   
   //! Flag theIsReqToKeepRLine has been enterred only for
   //! compatibility with TopOpeBRep package. It shall be deleted
@@ -178,7 +178,6 @@ private:
   IntPatch_SequenceOfLine slin;
   Standard_Real myTolArc;
   Standard_Real myTolTang;
-  Standard_Real myUVMaxStep;
   Standard_Real myFleche;
   Standard_Boolean myIsStartPnt;
   Standard_Real myU1Start;
index 571c700d160011613743ee297a328aa03c5b829d..299d0dca6409c586cc490345240d7eb888269c2c 100644 (file)
@@ -313,11 +313,10 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   S
                                            const Handle(Adaptor3d_TopolTool)& D1,
                                            const Standard_Real  TolTangency,
                                            const Standard_Real  Epsilon,
-                                           const Standard_Real  Deflection,
-                                           const Standard_Real  Increment)
+                                           const Standard_Real  Deflection)
 { 
   IntPatch_Polyhedron Poly1( Surf1, D1->NbSamplesU(), D1->NbSamplesV() );
-  Perform( Surf1, Poly1, D1, TolTangency, Epsilon, Deflection, Increment );
+  Perform( Surf1, Poly1, D1, TolTangency, Epsilon, Deflection);
 }
 
 //==================================================================================
@@ -331,11 +330,10 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   S
                                            const Handle(Adaptor3d_TopolTool)& D2,
                                            const Standard_Real  TolTangency,
                                            const Standard_Real  Epsilon,
-                                           const Standard_Real  Deflection,
-                                           const Standard_Real  Increment)
+                                           const Standard_Real  Deflection)
 { 
   IntPatch_Polyhedron Poly2( Surf2 );
-  Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection, Increment);
+  Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection);
 }
 
 //==================================================================================
@@ -349,11 +347,10 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   S
                                            const Handle(Adaptor3d_TopolTool)& D2,
                                            const Standard_Real  TolTangency,
                                            const Standard_Real  Epsilon,
-                                           const Standard_Real  Deflection,
-                                           const Standard_Real  Increment)
+                                           const Standard_Real  Deflection)
 { 
   IntPatch_Polyhedron Poly1( Surf1 );    
-  Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection, Increment );
+  Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection);
 }
 
 //==================================================================================
@@ -368,8 +365,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                                            const Handle(Adaptor3d_TopolTool)& D2,
                                            const Standard_Real   TolTangency,
                                            const Standard_Real   Epsilon,
-                                           const Standard_Real   Deflection,
-                                           const Standard_Real   Increment)
+                                           const Standard_Real   Deflection)
 { 
   IntPatch_InterferencePolyhedron Interference(Poly1,Poly2);
   empt = Standard_True;
@@ -386,13 +382,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
   TColStd_Array1OfReal StartParams(1,4);
 
-  IntWalk_PWalking PW( Surf1, Surf2, TolTangency, Epsilon, Deflection, Increment );
-
-  Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
-  Standard_Real    incidence;
-  Standard_Real    dminiPointLigne;
+  IntWalk_PWalking PW( Surf1, Surf2, TolTangency, Epsilon, Deflection);
 
-  Standard_Boolean HasStartPoint,RejetLigne;
+  Standard_Real    SeuildPointLigne = 4.0*PW.MaxStep(); //-- 10 est insuffisant
+  Standard_Real    incidence, dminiPointLigne;
+  Standard_Boolean HasStartPoint, RejetLigne;
 
   IntSurf_PntOn2S StartPOn2S;
 
@@ -400,6 +394,8 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
   gp_Pnt Point3dDebut,Point3dFin;
 
+  SeuildPointLigne *= SeuildPointLigne;
+
   if( nbLigSec >= 1 ) {
     Standard_Integer *TabL = new Standard_Integer [nbLigSec+1];
     Standard_Integer ls;
@@ -775,8 +771,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                                            const Handle(Adaptor3d_TopolTool)& D1,
                                            const Standard_Real   TolTangency,
                                            const Standard_Real   Epsilon,
-                                           const Standard_Real   Deflection,
-                                           const Standard_Real   Increment)
+                                           const Standard_Real   Deflection)
 { 
   IntPatch_InterferencePolyhedron Interference(Poly1);
   empt = Standard_True;
@@ -793,9 +788,9 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
   Standard_Real pu1,pu2,pv1,pv2;
 
   TColStd_Array1OfReal StartParams(1,4);
-  IntWalk_PWalking PW(Surf1,Surf1,TolTangency,Epsilon,Deflection,Increment);
+  IntWalk_PWalking PW(Surf1,Surf1,TolTangency,Epsilon,Deflection);
 
-  Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
+  Standard_Real    SeuildPointLigne = 4.0*PW.MaxStep(); //-- 10 est insuffisant
   Standard_Real    incidence;
   Standard_Real    dminiPointLigne;
 
@@ -806,6 +801,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
   Standard_Integer ver;
 
   gp_Pnt Point3dDebut,Point3dFin;
+  SeuildPointLigne *= SeuildPointLigne;
 
   if(nbLigSec>=1) {
     Standard_Integer ls;
@@ -1245,7 +1241,7 @@ Handle(IntPatch_Line) IntPatch_PrmPrmIntersection::NewLine (const Handle(Adaptor
   V2(Low) = v2;
   AC(Low) =0.0;
 
-  IntWalk_PWalking PW(Surf1,Surf2,0.000001,0.000001,0.001,0.001);
+  IntWalk_PWalking PW(Surf1,Surf2,0.000001,0.000001,0.001);
 
   Standard_Integer i;
   for(i=Low+1; i<=High; i++)
@@ -1534,7 +1530,6 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                                            const Standard_Real   TolTangency,
                                            const Standard_Real   Epsilon,
                                            const Standard_Real   Deflection,
-                                           const Standard_Real   Increment,
                                            IntSurf_ListOfPntOn2S& LOfPnts,
                                            const Standard_Boolean RestrictLine)
 {
@@ -1675,7 +1670,6 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
     if(V2<VminLig2) VminLig2=V2; 
   }
 
-  Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
 
   Standard_Integer NbLigCalculee = 0, ver;
   Standard_Real pu1,pu2,pv1,pv2, dminiPointLigne;
@@ -1684,7 +1678,9 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
   gp_Pnt Point3dDebut,Point3dFin;
 
   TColStd_Array1OfReal StartParams(1,4);
-  IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);  
+  IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection);  
+  Standard_Real SeuildPointLigne = 4.0 * PW.MaxStep();
+  SeuildPointLigne *= SeuildPointLigne;
 
   IntSurf_ListIteratorOfListOfPntOn2S IterLOP2(LOfPnts);
   for(; IterLOP2.More(); IterLOP2.Next() ){
@@ -1795,8 +1791,8 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
               }              
 
               SeveralWlinesProcessing(Surf1, Surf2, SLin, Periods, trans1, trans2,
-                                      TolTang, Max(PW.MaxStep(0), PW.MaxStep(1)),
-                                      Max(PW.MaxStep(2), PW.MaxStep(3)), wline);
+                                      TolTang, Max(PW.Step(0), PW.Step(1)),
+                                      Max(PW.Step(2), PW.Step(3)), wline);
 
               AddWLine(SLin, wline, Deflection);
               empt = Standard_False;
@@ -1823,8 +1819,7 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
                                           const Standard_Real   V2Depart,
                                           const Standard_Real   TolTangency,
                                           const Standard_Real   Epsilon,
-                                          const Standard_Real   Deflection,
-                                          const Standard_Real   Increment)
+                                          const Standard_Real   Deflection)
 {
   //    Standard_Integer NbU1 = D1->NbSamplesU();
   //    Standard_Integer NbV1 = D1->NbSamplesV();
@@ -1858,8 +1853,7 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
   IntWalk_PWalking PW(Surf1,Surf2,
     TolTangency,
     Epsilon,
-    Deflection,
-    Increment); //nIncrement);
+    Deflection); //nIncrement);
 
 
   //Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
@@ -2098,7 +2092,6 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
                                            const Standard_Real   TolTangency,
                                            const Standard_Real   Epsilon,
                                            const Standard_Real   Deflection,
-                                           const Standard_Real   Increment,
                                            const Standard_Boolean ClearFlag) 
 {
   Standard_Integer Limit = 2500;
@@ -2169,7 +2162,6 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
 
     Standard_Integer nbLigSec = Interference.NbSectionLines();
     Standard_Integer nbTanZon = Interference.NbTangentZones();
-    Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
 
     Standard_Integer NbLigCalculee = 0, ver;
     Standard_Real pu1,pu2,pv1,pv2, incidence, dminiPointLigne;
@@ -2178,7 +2170,9 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
     gp_Pnt Point3dDebut,Point3dFin;
 
     TColStd_Array1OfReal StartParams(1,4);
-    IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
+    IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection);
+    Standard_Real SeuildPointLigne = 4.0 * PW.MaxStep();
+    SeuildPointLigne *= SeuildPointLigne;
 
     if(nbLigSec>=1)
     {
@@ -2345,10 +2339,10 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
                     PW.PutToBoundary(Surf1, Surf2);
 
                     const Standard_Integer aMinNbPoints = 40;
-                    if(PW.NbPoints() < aMinNbPoints)
-                    {
-                      hasBeenAdded = PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
-                    }
+                    //if(PW.NbPoints() < aMinNbPoints)
+                    //{
+                    //  hasBeenAdded = PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
+                    //}
                     
                     Standard_Integer iPWNbPoints = PW.NbPoints(), aNbPointsVer = 0;
                     RejectLine = Standard_False;
@@ -2473,8 +2467,8 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
                       lignetrouvee = Standard_True;
 
                       SeveralWlinesProcessing(Surf1, Surf2, SLin, Periods, trans1, trans2,
-                                              TolTang, Max(PW.MaxStep(0), PW.MaxStep(1)),
-                                              Max(PW.MaxStep(2), PW.MaxStep(3)), wline);
+                                              TolTang, Max(PW.Step(0), PW.Step(1)),
+                                              Max(PW.Step(2), PW.Step(3)), wline);
 
                       AddWLine(SLin, wline, Deflection);
                       empt = Standard_False;
@@ -2586,11 +2580,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
             Standard_Boolean hasBeenAdded = Standard_False;
             if(PW.NbPoints()>2)
             { 
-              const Standard_Integer aMinNbPoints = 40;
-              if(PW.NbPoints() < aMinNbPoints)
-              {
-                hasBeenAdded = PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
-              }
+              //const Standard_Integer aMinNbPoints = 40;
+              //if(PW.NbPoints() < aMinNbPoints)
+              //{
+              //  PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
+              //}
 
               //-----------------------------------------------
               //-- Verification a posteriori : 
@@ -2721,12 +2715,14 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
   if(MaxOscill < NbV1) MaxOscill=NbV1;
   if(MaxOscill < NbV2) MaxOscill=NbV2;
 
-  Standard_Real nIncrement=Increment;
+  //Standard_Real nIncrement=Increment;
   //if(MaxOscill>10)
   //nIncrement/=0.5*MaxOscill;
 
-  IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement);
-  Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
+  IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection);
+  Standard_Real    SeuildPointLigne = 4.0 * PW.MaxStep(); //-- 10 est insuffisant
+  SeuildPointLigne *= SeuildPointLigne;
+
   Standard_Real    dminiPointLigne;
   Standard_Boolean HasStartPoint,RejetLigne;
   IntSurf_PntOn2S StartPOn2S;
index 3293792cf82d9b431adc53e51ae064990f707ac0..ba0a1caa9cd6dfc6b1872fffa1ec43ab1a81cfc9 100644 (file)
@@ -56,29 +56,29 @@ public:
   //! Performs the intersection between <Caro1>  and
   //! <Caro2>.  Associated Polyhedrons <Polyhedron1>
   //! and <Polyhedron2> are given.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const IntPatch_Polyhedron& Polyhedron1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const IntPatch_Polyhedron& Polyhedron2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const IntPatch_Polyhedron& Polyhedron1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const IntPatch_Polyhedron& Polyhedron2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const IntPatch_Polyhedron& Polyhedron1, const Handle(Adaptor3d_TopolTool)& Domain1, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const IntPatch_Polyhedron& Polyhedron1, const Handle(Adaptor3d_TopolTool)& Domain1, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
   //! Performs the intersection between <Caro1>  and
   //! <Caro2>. The method computes the polyhedron on
   //! each surface.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment, const Standard_Boolean ClearFlag = Standard_True);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Boolean ClearFlag = Standard_True);
   
   //! Performs the intersection between <Caro1>  and
   //! <Caro2>. The method computes the polyhedron on
   //! each surface.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment, IntSurf_ListOfPntOn2S& ListOfPnts, const Standard_Boolean RestrictLine);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, IntSurf_ListOfPntOn2S& ListOfPnts, const Standard_Boolean RestrictLine);
   
   //! Performs the intersection between <Caro1>  and
   //! <Caro2>. The method computes the polyhedron on
   //! each surface.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
   //! Performs the intersection between <Caro1>  and
   //! <Caro2>. The method computes the polyhedron on
   //! each surface.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
   //! Performs  the intersection between <Caro1> and
   //! <Caro2>.
@@ -86,7 +86,7 @@ public:
   //! The polyhedron which approximates     <Caro2>,
   //! <Polyhedron2> is given. The other one is
   //! computed.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const IntPatch_Polyhedron& Polyhedron2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const IntPatch_Polyhedron& Polyhedron2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
   //! Performs  the intersection between <Caro1> and
   //! <Caro2>.
@@ -94,7 +94,7 @@ public:
   //! The polyhedron which approximates     <Caro1>,
   //! <Polyhedron1> is given. The other one is
   //! computed.
-  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const IntPatch_Polyhedron& Polyhedron1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& Caro1, const IntPatch_Polyhedron& Polyhedron1, const Handle(Adaptor3d_TopolTool)& Domain1, const Handle(Adaptor3d_HSurface)& Caro2, const Handle(Adaptor3d_TopolTool)& Domain2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
   //! Returns true if the calculus was succesfull.
     Standard_Boolean IsDone() const;
index e802a09299307d0a14ac696ab09a420883ce7186..bee84a949ace45319742afd20333edddc9bb6c76 100644 (file)
@@ -521,7 +521,7 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
     myContext->UVBounds(myFace2, umin, umax, vmin, vmax);
     CorrectSurfaceBoundaries(myFace2, myTol * 2., umin, umax, vmin, vmax);
     myHS2->ChangeSurface().Load(S2, umin, umax, vmin, vmax);
-  }
+    }
   else if ((aType2==GeomAbs_Plane) && isFace1Quad)
   {
     Standard_Real umin, umax, vmin, vmax;
@@ -533,7 +533,7 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
     myContext->UVBounds(myFace2, umin, umax, vmin, vmax);
     CorrectPlaneBoundaries(umin, umax, vmin, vmax);
     myHS2->ChangeSurface().Load(S2, umin, umax, vmin, vmax);
-  }
+    }
   else
   {
     Standard_Real umin, umax, vmin, vmax;
@@ -553,12 +553,8 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
 
   Tolerances(myHS1, myHS2, TolTang);
 
-  {
-    const Standard_Real UVMaxStep = 0.001;
-    const Standard_Real Deflection = 0.1;
-    myIntersector.SetTolerances(TolArc, TolTang, UVMaxStep, Deflection); 
-  }
-  
+  myIntersector.SetTolerances(TolArc, TolTang, 0.1); 
+
   if((myHS1->IsUClosed() && !myHS1->IsUPeriodic()) || 
      (myHS1->IsVClosed() && !myHS1->IsVPeriodic()) ||
      (myHS2->IsUClosed() && !myHS2->IsUPeriodic()) || 
index f6234e1e5b9b8e4a83dd79980e505e484d2f7b8f..398fec3a1e4af86f12e03c3d8c48c0967e393cb2 100644 (file)
@@ -42,54 +42,30 @@ void IntWalk_PWalking::ComputePasInit(const Standard_Real theDeltaU1,
                                       const Standard_Real theDeltaU2,
                                       const Standard_Real theDeltaV2)
 {
-  const Standard_Real aRangePart = 0.01;
-  const Standard_Real Increment = 2.0*pasMax;
   const Handle(Adaptor3d_HSurface)& 
           Caro1 = myIntersectionOn2S.Function().AuxillarSurface1();
   const Handle(Adaptor3d_HSurface)& 
           Caro2 = myIntersectionOn2S.Function().AuxillarSurface2();
 
-  const Standard_Real aDeltaU1=Abs(UM1-Um1);
-  const Standard_Real aDeltaV1=Abs(VM1-Vm1);
-  const Standard_Real aDeltaU2=Abs(UM2-Um2);
-  const Standard_Real aDeltaV2=Abs(VM2-Vm2);
+  const Standard_Real aDeltaPar[] = {theDeltaU1, theDeltaV1, theDeltaU2, theDeltaV2};
 
-  //-- limit the reduction of uv box estimate to 0.01 natural box
-  //--  theDeltaU1 : On box of Inter
-  //-- aDeltaU1 : On parametric space
-  if(!Precision::IsInfinite(aDeltaU1))
-    pasuv[0]=Max(Increment*Max(theDeltaU1, aRangePart*aDeltaU1), pasuv[0]);
-  else
-    pasuv[0]=Max(Increment*theDeltaU1, pasuv[0]);
-
-  if(!Precision::IsInfinite(aDeltaV1))
-    pasuv[1]=Max(Increment*Max(theDeltaV1, aRangePart*aDeltaV1), pasuv[1]);
-  else
-    pasuv[1]=Max(Increment*theDeltaV1, pasuv[1]);
-
-  if(!Precision::IsInfinite(aDeltaU2))
-    pasuv[2]=Max(Increment*Max(theDeltaU2, aRangePart*aDeltaU2), pasuv[2]);
-  else
-    pasuv[2]=Max(Increment*theDeltaU2, pasuv[2]);
-
-  if(!Precision::IsInfinite(aDeltaV2))
-    pasuv[3]=Max(Increment*Max(theDeltaV2, aRangePart*aDeltaV2), pasuv[3]);
-  else
-    pasuv[3]=Max(Increment*theDeltaV2, pasuv[3]);
+  for(Standard_Integer i = 0; i < 4; i++)
+  {
+    if(Precision::IsInfinite(aDeltaPar[i]))
+      continue;
 
-  const Standard_Real ResoU1tol = Adaptor3d_HSurfaceTool::UResolution(Caro1, tolconf);
-  const Standard_Real ResoV1tol = Adaptor3d_HSurfaceTool::VResolution(Caro1, tolconf);
-  const Standard_Real ResoU2tol = Adaptor3d_HSurfaceTool::UResolution(Caro2, tolconf);
-  const Standard_Real ResoV2tol = Adaptor3d_HSurfaceTool::VResolution(Caro2, tolconf);
+    pasuv[i] = Max(myRelMaxStep*Min(pasInit[i], aDeltaPar[i]), pasuv[i]);
+  }
 
-  myStepMin[0] = Max(myStepMin[0], 2.0*ResoU1tol);
-  myStepMin[1] = Max(myStepMin[1], 2.0*ResoV1tol);
-  myStepMin[2] = Max(myStepMin[2], 2.0*ResoU2tol);
-  myStepMin[3] = Max(myStepMin[3], 2.0*ResoV2tol);
+  const Standard_Real aResoTol[] = {Adaptor3d_HSurfaceTool::UResolution(Caro1, tolconf),
+                                    Adaptor3d_HSurfaceTool::VResolution(Caro1, tolconf),
+                                    Adaptor3d_HSurfaceTool::UResolution(Caro2, tolconf),
+                                    Adaptor3d_HSurfaceTool::VResolution(Caro2, tolconf)};
 
   for(Standard_Integer i  = 0; i < 4; i++)
   {
-    pasuv[i]=Max(myStepMin[i], pasuv[i]);
+    myStepMin[i] = Max(myStepMin[i], 2.0*aResoTol[i]);
+    pasInit[i] = Max(pasInit[i], myStepMin[i]);
   }
 }
 
@@ -167,8 +143,7 @@ IntWalk_PWalking::IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1,
                                    const Handle(Adaptor3d_HSurface)& Caro2,
                                    const Standard_Real TolTangency,
                                    const Standard_Real Epsilon,
-                                   const Standard_Real Deflection,
-                                   const Standard_Real Increment ) 
+                                   const Standard_Real Deflection) 
                                    :
 
 done(Standard_True),
@@ -176,130 +151,113 @@ close(Standard_False),
 fleche(Deflection),
 tolconf(Epsilon),
 myTolTang(TolTangency),
+myRelMaxStep(0.1),
+myIncMultiplier(1.5),
+myDecMultiplier(0.5),
 sensCheminement(1),
-myIntersectionOn2S(Caro1,Caro2,TolTangency),
-STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
-STATIC_PRECEDENT_INFLEXION(0)
+myIntersectionOn2S(Caro1,Caro2,TolTangency)
 {
   Standard_Real KELARG=20.;
   //
-  pasMax=Increment*0.2; //-- June 25 99 after problems with precision 
-  Um1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
-  Vm1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
-  UM1 = Adaptor3d_HSurfaceTool::LastUParameter(Caro1);
-  VM1 = Adaptor3d_HSurfaceTool::LastVParameter(Caro1);
+  myMinParam[0] = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
+  myMinParam[1] = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
+  myMaxParam[0] = Adaptor3d_HSurfaceTool::LastUParameter(Caro1);
+  myMaxParam[1] = Adaptor3d_HSurfaceTool::LastVParameter(Caro1);
 
-  Um2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
-  Vm2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
-  UM2 = Adaptor3d_HSurfaceTool::LastUParameter(Caro2);
-  VM2 = Adaptor3d_HSurfaceTool::LastVParameter(Caro2);
+  myMinParam[2] = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
+  myMinParam[3] = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
+  myMaxParam[2] = Adaptor3d_HSurfaceTool::LastUParameter(Caro2);
+  myMaxParam[3] = Adaptor3d_HSurfaceTool::LastVParameter(Caro2);
 
-  ResoU1 = Adaptor3d_HSurfaceTool::UResolution(Caro1,Precision::Confusion());
-  ResoV1 = Adaptor3d_HSurfaceTool::VResolution(Caro1,Precision::Confusion());
+  myReso[0] = Adaptor3d_HSurfaceTool::UResolution(Caro1,Precision::Confusion());
+  myReso[1] = Adaptor3d_HSurfaceTool::VResolution(Caro1,Precision::Confusion());
 
-  ResoU2 = Adaptor3d_HSurfaceTool::UResolution(Caro2,Precision::Confusion());
-  ResoV2 = Adaptor3d_HSurfaceTool::VResolution(Caro2,Precision::Confusion());
+  myReso[2] = Adaptor3d_HSurfaceTool::UResolution(Caro2,Precision::Confusion());
+  myReso[3] = Adaptor3d_HSurfaceTool::VResolution(Caro2,Precision::Confusion());
 
   Standard_Real NEWRESO;
   Standard_Real MAXVAL;
   Standard_Real MAXVAL2;
   //
-  MAXVAL  = Abs(Um1);  MAXVAL2 = Abs(UM1);
+  MAXVAL  = Abs(myMinParam[0]);  MAXVAL2 = Abs(myMaxParam[0]);
   if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
-  NEWRESO = ResoU1 * MAXVAL ;
-  if(NEWRESO > ResoU1 &&NEWRESO<10) {    ResoU1 = NEWRESO;  }
+  NEWRESO = myReso[0] * MAXVAL ;
+  if(NEWRESO > myReso[0] &&NEWRESO<10) {    myReso[0] = NEWRESO;  }
 
 
-  MAXVAL  = Abs(Um2);   MAXVAL2 = Abs(UM2);
+  MAXVAL  = Abs(myMinParam[2]);   MAXVAL2 = Abs(myMaxParam[2]);
   if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
-  NEWRESO = ResoU2 * MAXVAL ;
-  if(NEWRESO > ResoU2 && NEWRESO<10) {     ResoU2 = NEWRESO;  }
+  NEWRESO = myReso[2] * MAXVAL ;
+  if(NEWRESO > myReso[2] && NEWRESO<10) {     myReso[2] = NEWRESO;  }
 
 
-  MAXVAL  = Abs(Vm1);  MAXVAL2 = Abs(VM1);
+  MAXVAL  = Abs(myMinParam[1]);  MAXVAL2 = Abs(myMaxParam[1]);
   if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
-  NEWRESO = ResoV1 * MAXVAL ;
-  if(NEWRESO > ResoV1 && NEWRESO<10) {     ResoV1 = NEWRESO;  }
+  NEWRESO = myReso[1] * MAXVAL ;
+  if(NEWRESO > myReso[1] && NEWRESO<10) {     myReso[1] = NEWRESO;  }
 
 
-  MAXVAL  = Abs(Vm2);  MAXVAL2 = Abs(VM2);
+  MAXVAL  = Abs(myMinParam[3]);  MAXVAL2 = Abs(myMaxParam[3]);
   if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
-  NEWRESO = ResoV2 * MAXVAL ;
-  if(NEWRESO > ResoV2 && NEWRESO<10) {     ResoV2 = NEWRESO;  }
-
-  pasuv[0]=pasMax*Abs(UM1-Um1);
-  pasuv[1]=pasMax*Abs(VM1-Vm1);
-  pasuv[2]=pasMax*Abs(UM2-Um2);
-  pasuv[3]=pasMax*Abs(VM2-Vm2);
-
-  if(ResoU1>0.0001*pasuv[0]) ResoU1=0.00001*pasuv[0];
-  if(ResoV1>0.0001*pasuv[1]) ResoV1=0.00001*pasuv[1];
-  if(ResoU2>0.0001*pasuv[2]) ResoU2=0.00001*pasuv[2];
-  if(ResoV2>0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3];
+  NEWRESO = myReso[3] * MAXVAL ;
+  if(NEWRESO > myReso[3] && NEWRESO<10) {     myReso[3] = NEWRESO;  }
 
+  for(Standard_Integer i = 0; i < 4; i++)
+  {
+    //We enter 1.0e10 constant in order to process infinite surfaces
+    pasInit[i]=Min(Abs(myMaxParam[i]-myMinParam[i]), 1.0e10);
+    myReso[i] = Min(myReso[i], 0.0001*pasInit[i]);
+    myStepMin[i] = 100.0*myReso[i];
+    pasSav[i] = pasuv[i] = Max(myRelMaxStep*pasInit[i], myStepMin[i]);
+  }
 
   if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)==Standard_False) { 
-    //UM1+=KELARG*pasuv[0];  Um1-=KELARG*pasuv[0];
+    //UM1+=KELARG*pasInit[0];  Um1-=KELARG*pasInit[0];
   }
   else { 
-    Standard_Real t = UM1-Um1
+    Standard_Real t = myMaxParam[0]-myMinParam[0]
     if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro1)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro1)-t);
-      t=(t>KELARG*pasuv[0])? KELARG*pasuv[0] : t;
-      UM1+=t;  Um1-=t;
+      t=(t>KELARG*pasInit[0])? KELARG*pasInit[0] : t;
+      myMaxParam[0]+=t;  myMinParam[0]-=t;
     }
   }
 
   if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro1)==Standard_False) { 
-    //VM1+=KELARG*pasuv[1];  Vm1-=KELARG*pasuv[1];
+    //VM1+=KELARG*pasInit[1];  Vm1-=KELARG*pasInit[1];
   }
   else { 
-    Standard_Real t = VM1-Vm1
+    Standard_Real t = myMaxParam[1]-myMinParam[1]
     if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro1)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro1)-t);
-      t=(t>KELARG*pasuv[1])? KELARG*pasuv[1] : t;
-      VM1+=t;  Vm1-=t;
+      t=(t>KELARG*pasInit[1])? KELARG*pasInit[1] : t;
+      myMaxParam[1]+=t;  myMinParam[1]-=t;
     }
   }
 
   if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro2)==Standard_False) { 
-    //UM2+=KELARG*pasuv[2];  Um2-=KELARG*pasuv[2];
+    //UM2+=KELARG*pasInit[2];  Um2-=KELARG*pasInit[2];
   }
   else { 
-    Standard_Real t = UM2-Um2
+    Standard_Real t = myMaxParam[2]-myMinParam[2]
     if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro2)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro2)-t);
-      t=(t>KELARG*pasuv[2])? KELARG*pasuv[2] : t;
-      UM2+=t;  Um2-=t;
+      t=(t>KELARG*pasInit[2])? KELARG*pasInit[2] : t;
+      myMaxParam[2]+=t;  myMinParam[2]-=t;
     }
   }
 
   if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {   
-    //VM2+=KELARG*pasuv[3];  Vm2-=KELARG*pasuv[3];
+    //VM2+=KELARG*pasInit[3];  Vm2-=KELARG*pasInit[3];
   }
   else { 
-    Standard_Real t = VM2-Vm2
+    Standard_Real t = myMaxParam[3]-myMinParam[3]
     if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro2)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro2)-t);
-      t=(t>KELARG*pasuv[3])? KELARG*pasuv[3] : t;
-      VM2+=t;  Vm2-=t;
+      t=(t>KELARG*pasInit[3])? KELARG*pasInit[3] : t;
+      myMaxParam[3]+=t;  myMinParam[3]-=t;
     }
   }
-
-  myStepMin[0] = 100.0*ResoU1;
-  myStepMin[1] = 100.0*ResoV1;
-  myStepMin[2] = 100.0*ResoU2;
-  myStepMin[3] = 100.0*ResoV2;
-
-  //-- ComputePasInit(pasuv,Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2);
-
-  for (Standard_Integer i = 0; i<=3;i++) {
-    if(pasuv[i]>10) 
-      pasuv[i] = 10; 
-    pasInit[i] = pasSav[i] = pasuv[i]; 
-  }
-
-
 }
 //==================================================================================
 // function : IntWalk_PWalking
@@ -310,7 +268,6 @@ IntWalk_PWalking::IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1,
                                    const Standard_Real TolTangency,
                                    const Standard_Real Epsilon,
                                    const Standard_Real Deflection,
-                                   const Standard_Real Increment, 
                                    const Standard_Real U1,
                                    const Standard_Real V1,
                                    const Standard_Real U2, 
@@ -322,148 +279,136 @@ close(Standard_False),
 fleche(Deflection),
 tolconf(Epsilon),
 myTolTang(TolTangency),
+myRelMaxStep(0.1),
+myIncMultiplier(1.5),
+myDecMultiplier(0.5),
 sensCheminement(1),
-myIntersectionOn2S(Caro1,Caro2,TolTangency),
-STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
-STATIC_PRECEDENT_INFLEXION(0)
+myIntersectionOn2S(Caro1,Caro2,TolTangency)
 {
   Standard_Real KELARG=20.;
   //
-  pasMax=Increment*0.2; //-- June 25 99 after problems with precision 
-  //
-  Um1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
-  Vm1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
-  UM1 = Adaptor3d_HSurfaceTool::LastUParameter(Caro1);
-  VM1 = Adaptor3d_HSurfaceTool::LastVParameter(Caro1);
+  myMinParam[0] = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
+  myMinParam[1] = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
+  myMaxParam[0] = Adaptor3d_HSurfaceTool::LastUParameter(Caro1);
+  myMaxParam[1] = Adaptor3d_HSurfaceTool::LastVParameter(Caro1);
 
-  Um2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
-  Vm2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
-  UM2 = Adaptor3d_HSurfaceTool::LastUParameter(Caro2);
-  VM2 = Adaptor3d_HSurfaceTool::LastVParameter(Caro2);
+  myMinParam[2] = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
+  myMinParam[3] = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
+  myMaxParam[2] = Adaptor3d_HSurfaceTool::LastUParameter(Caro2);
+  myMaxParam[3] = Adaptor3d_HSurfaceTool::LastVParameter(Caro2);
 
-  ResoU1 = Adaptor3d_HSurfaceTool::UResolution(Caro1,Precision::Confusion());
-  ResoV1 = Adaptor3d_HSurfaceTool::VResolution(Caro1,Precision::Confusion());
+  myReso[0] = Adaptor3d_HSurfaceTool::UResolution(Caro1,Precision::Confusion());
+  myReso[1] = Adaptor3d_HSurfaceTool::VResolution(Caro1,Precision::Confusion());
 
-  ResoU2 = Adaptor3d_HSurfaceTool::UResolution(Caro2,Precision::Confusion());
-  ResoV2 = Adaptor3d_HSurfaceTool::VResolution(Caro2,Precision::Confusion());
+  myReso[2] = Adaptor3d_HSurfaceTool::UResolution(Caro2,Precision::Confusion());
+  myReso[3] = Adaptor3d_HSurfaceTool::VResolution(Caro2,Precision::Confusion());
   //
   Standard_Real NEWRESO, MAXVAL, MAXVAL2;
   //
-  MAXVAL  = Abs(Um1);  
-  MAXVAL2 = Abs(UM1);
+  MAXVAL  = Abs(myMinParam[0]);  
+  MAXVAL2 = Abs(myMaxParam[0]);
   if(MAXVAL2 > MAXVAL) {
     MAXVAL = MAXVAL2;
   }
-  NEWRESO = ResoU1 * MAXVAL ;
-  if(NEWRESO > ResoU1) {
-    ResoU1 = NEWRESO;  
+  NEWRESO = myReso[0] * MAXVAL ;
+  if(NEWRESO > myReso[0]) {
+    myReso[0] = NEWRESO;  
   }
   //
-  MAXVAL  = Abs(Um2);   
-  MAXVAL2 = Abs(UM2);
+  MAXVAL  = Abs(myMinParam[2]);   
+  MAXVAL2 = Abs(myMaxParam[2]);
   if(MAXVAL2 > MAXVAL){
     MAXVAL = MAXVAL2;
   }  
-  NEWRESO = ResoU2 * MAXVAL ;
-  if(NEWRESO > ResoU2) {
-    ResoU2 = NEWRESO;  
+  NEWRESO = myReso[2] * MAXVAL ;
+  if(NEWRESO > myReso[2]) {
+    myReso[2] = NEWRESO;  
   }
   //
-  MAXVAL  = Abs(Vm1);  
-  MAXVAL2 = Abs(VM1);
+  MAXVAL  = Abs(myMinParam[1]);  
+  MAXVAL2 = Abs(myMaxParam[1]);
   if(MAXVAL2 > MAXVAL) {
     MAXVAL = MAXVAL2;
   }
-  NEWRESO = ResoV1 * MAXVAL ;
-  if(NEWRESO > ResoV1) {    
-    ResoV1 = NEWRESO; 
+  NEWRESO = myReso[1] * MAXVAL ;
+  if(NEWRESO > myReso[1]) {    
+    myReso[1] = NEWRESO; 
   }
   //
-  MAXVAL  = Abs(Vm2);  
-  MAXVAL2 = Abs(VM2);
+  MAXVAL  = Abs(myMinParam[3]);  
+  MAXVAL2 = Abs(myMaxParam[3]);
   if(MAXVAL2 > MAXVAL){
     MAXVAL = MAXVAL2;
   }  
-  NEWRESO = ResoV2 * MAXVAL ;
-  if(NEWRESO > ResoV2) {  
-    ResoV2 = NEWRESO;
+  NEWRESO = myReso[3] * MAXVAL ;
+  if(NEWRESO > myReso[3]) {  
+    myReso[3] = NEWRESO;
   }
   //
-  pasuv[0]=pasMax*Abs(UM1-Um1);
-  pasuv[1]=pasMax*Abs(VM1-Vm1);
-  pasuv[2]=pasMax*Abs(UM2-Um2);
-  pasuv[3]=pasMax*Abs(VM2-Vm2);
+  for(Standard_Integer i = 0; i < 4; i++)
+  {
+    //We enter 1.0e10 constant in order to process infinite surfaces
+    pasInit[i]=Min(Abs(myMaxParam[i]-myMinParam[i]), 1.0e10);
+    myReso[i] = Min(myReso[i], 0.0001*pasInit[i]);
+    myStepMin[i] = 100.0*myReso[i];
+    pasSav[i] = pasuv[i] = Max(myRelMaxStep*pasInit[i], myStepMin[i]);
+  }
+
   //
   if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)==Standard_False) { 
-    UM1+=KELARG*pasuv[0];  
-    Um1-=KELARG*pasuv[0];
+    myMaxParam[0]+=KELARG*pasInit[0];  
+    myMinParam[0]-=KELARG*pasInit[0];
   }
   else { 
-    Standard_Real t = UM1-Um1
+    Standard_Real t = myMaxParam[0]-myMinParam[0]
     if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro1)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro1)-t);
-      t=(t>KELARG*pasuv[0])? KELARG*pasuv[0] : t;
-      UM1+=t;  
-      Um1-=t;
+      t=(t>KELARG*pasInit[0])? KELARG*pasInit[0] : t;
+      myMaxParam[0]+=t;  
+      myMinParam[0]-=t;
     }
   }
   //
   if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro1)==Standard_False) { 
-    VM1+=KELARG*pasuv[1];
-    Vm1-=KELARG*pasuv[1];
+    myMaxParam[1]+=KELARG*pasInit[1];
+    myMinParam[1]-=KELARG*pasInit[1];
   }
   else { 
-    Standard_Real t = VM1-Vm1
+    Standard_Real t = myMaxParam[1]-myMinParam[1]
     if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro1)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro1)-t);
-      t=(t>KELARG*pasuv[1])? KELARG*pasuv[1] : t;
-      VM1+=t;  Vm1-=t;
+      t=(t>KELARG*pasInit[1])? KELARG*pasInit[1] : t;
+      myMaxParam[1]+=t;  myMinParam[1]-=t;
     }
   }
   //
   if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro2)==Standard_False) { 
-    UM2+=KELARG*pasuv[2];  
-    Um2-=KELARG*pasuv[2];
+    myMaxParam[2]+=KELARG*pasInit[2];  
+    myMinParam[2]-=KELARG*pasInit[2];
   }
   else { 
-    Standard_Real t = UM2-Um2
+    Standard_Real t = myMaxParam[2]-myMinParam[2]
     if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro2)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro2)-t);
-      t=(t>KELARG*pasuv[2])? KELARG*pasuv[2] : t;
-      UM2+=t;  
-      Um2-=t;
+      t=(t>KELARG*pasInit[2])? KELARG*pasInit[2] : t;
+      myMaxParam[2]+=t;  
+      myMinParam[2]-=t;
     }
   }
 
   if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {   
-    VM2+=KELARG*pasuv[3];  
-    Vm2-=KELARG*pasuv[3];
+    myMaxParam[3]+=KELARG*pasInit[3];  
+    myMinParam[3]-=KELARG*pasInit[3];
   }
   else { 
-    Standard_Real t = VM2-Vm2
+    Standard_Real t = myMaxParam[3]-myMinParam[3]
     if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro2)) { 
       t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro2)-t);
-      t=(t>KELARG*pasuv[3])? KELARG*pasuv[3] : t;
-      VM2+=t;  
-      Vm2-=t;
+      t=(t>KELARG*pasInit[3])? KELARG*pasInit[3] : t;
+      myMaxParam[3]+=t;  
+      myMinParam[3]-=t;
     }
   }
-  //-- ComputePasInit(pasuv,Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2);
-
-  for (Standard_Integer i = 0; i<=3;i++) {
-    pasInit[i] = pasSav[i] = pasuv[i]; 
-  }  
-
-  if(ResoU1>0.0001*pasuv[0]) ResoU1=0.00001*pasuv[0];
-  if(ResoV1>0.0001*pasuv[1]) ResoV1=0.00001*pasuv[1];
-  if(ResoU2>0.0001*pasuv[2]) ResoU2=0.00001*pasuv[2];
-  if(ResoV2>0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3];
-  
-  myStepMin[0] = 100.0*ResoU1;
-  myStepMin[1] = 100.0*ResoV1;
-  myStepMin[2] = 100.0*ResoU2;
-  myStepMin[3] = 100.0*ResoV2;
-
   //
   TColStd_Array1OfReal Par(1,4);
   Par(1) = U1;
@@ -510,7 +455,7 @@ Standard_Boolean IntWalk_PWalking::PerformFirstPoint  (const TColStd_Array1OfRea
 //==================================================================================
 void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep)    
 {
-  Perform(ParDep,Um1,Vm1,Um2,Vm2,UM1,VM1,UM2,VM2);
+  Perform(ParDep,myMinParam[0],myMinParam[1],myMinParam[2],myMinParam[3],myMaxParam[0],myMaxParam[1],myMaxParam[2],myMaxParam[3]);
 }
 
 //=======================================================================
@@ -603,6 +548,388 @@ static Standard_Boolean IsTangentExtCheck(const Handle(Adaptor3d_HSurface)& theS
   return Standard_True;
 }
 
+//==================================================================================
+// function : IntersPerform
+// purpose  :
+//==================================================================================
+IntWalk_StatusDeflection IntWalk_PWalking::IntersPerform(const Standard_Boolean theIsForceAdd,
+                                                         IntImp_ConstIsoparametric& theIsoChoosen,
+                                                         math_FunctionSetRoot& theRSFunc,
+                                                         Standard_Real theDeltaParam[4])
+{
+  const Standard_Integer RejectIndexMAX = 250000;
+  TColStd_Array1OfReal Param(1,4);
+
+  Standard_Boolean DejaReparti = Standard_False;
+
+  Standard_Boolean hasToArrive = Standard_False;
+
+  while(!hasToArrive)
+  {
+    Standard_Real f = 0.;
+    switch (theIsoChoosen) { 
+      case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
+      case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
+      case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
+      case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
+      default:break;
+    }
+    //
+    if(f<0.1) {
+      f=0.1;
+    }
+    //
+    previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
+    //
+    theDeltaParam[0] = sensCheminement * previousd1.X() /f;
+    theDeltaParam[1] = sensCheminement * previousd1.Y() /f;
+    theDeltaParam[2] = sensCheminement * previousd2.X() /f;
+    theDeltaParam[3] = sensCheminement * previousd2.Y() /f;
+
+    for(Standard_Integer i = 0; i < 4; i++)
+    {
+      Standard_Real &aNewParam = Param(i+1);
+      aNewParam += theDeltaParam[i]*pasuv[i];
+
+      //if(ChoixIso != i)
+      //  continue;
+
+      if(aNewParam - myMaxParam[i] > myReso[i])
+        return IntWalk_IntersectsBoundary;
+
+      if(myMinParam[i] - aNewParam > myReso[i])
+        return IntWalk_IntersectsBoundary;
+    }
+
+    theIsoChoosen= myIntersectionOn2S.Perform(Param, theRSFunc, theIsoChoosen);
+
+    if(!myIntersectionOn2S.IsDone())
+      return IntWalk_IntersectPointNotFound;
+
+    if(myIntersectionOn2S.IsEmpty())
+      return IntWalk_IntersectPointNotFound;
+
+    //== Calculation of exact point from Param(.) is possible
+
+    myIntersectionOn2S.Point().Parameters(Param(1), Param(2), Param(3), Param(4));
+
+    //============================================================
+    //== A point has been found :  T E S T   D E F L E C T I O N 
+    //============================================================
+    const IntWalk_StatusDeflection Status = TestDeflection(theIsoChoosen);
+
+    if((Status != IntWalk_OK) && !(((Status == IntWalk_PasTropGrand) || (Status == IntWalk_StepTooSmall)) && theIsForceAdd))
+      return Status;
+
+    hasToArrive = TestArret(DejaReparti,Param,theIsoChoosen);
+
+    if(hasToArrive)
+    {
+      if(close)
+      {
+        //================= la ligne est fermee ===============
+        AddAPoint(line,line->Value(1)); //ligne fermee
+      }
+      else    //$$$
+      {
+        //====================================================
+        //== Param was not in the limits (was reframed)
+        //====================================================
+        if(myIntersectionOn2S.IsTangent())
+        {
+          return IntWalk_DirectionNotFound;
+        }
+
+        theIsoChoosen = myIntersectionOn2S.Perform(Param,theRSFunc,theIsoChoosen);
+        //
+
+        if(myIntersectionOn2S.IsEmpty())
+        {
+          return IntWalk_IntersectPointNotFound;
+        }
+
+        // mutially outpasses in the square or intersection in corner
+
+        if(TestArret(Standard_True,Param,theIsoChoosen))
+        {
+          theIsoChoosen = myIntersectionOn2S.Perform(Param,theRSFunc,theIsoChoosen);
+
+          if(myIntersectionOn2S.IsEmpty())
+          {
+            return IntWalk_IntersectPointNotFound;
+          }
+
+          previousPoint = myIntersectionOn2S.Point();
+          previoustg = myIntersectionOn2S.IsTangent();
+
+          if (!previoustg)
+          {
+            previousd  = myIntersectionOn2S.Direction();
+            previousd1 = myIntersectionOn2S.DirectionOnS1();
+            previousd2 = myIntersectionOn2S.DirectionOnS2();
+          }
+
+          AddAPoint(line,previousPoint);
+
+          if(line->NbPoints() >= RejectIndexMAX)
+          {
+            return IntWalk_TooManyPoints;
+          }
+
+          //RepartirOuDiviser(DejaReparti,ChoixIso,hasToArrive);
+        }//if(TestArret())
+        else
+          {
+            // save the last point
+            // to revert to it if the current point is out of bounds
+
+            IntSurf_PntOn2S previousPointSave = previousPoint;
+            Standard_Boolean previoustgSave   = previoustg;
+            gp_Dir previousdSave              = previousd;
+            gp_Dir2d previousd1Save           = previousd1;
+            gp_Dir2d previousd2Save           = previousd2;
+
+            previousPoint = myIntersectionOn2S.Point();
+            previoustg = myIntersectionOn2S.IsTangent();
+            hasToArrive = Standard_False;
+
+            if(!previoustg)
+            {
+              previousd  = myIntersectionOn2S.Direction();
+              previousd1 = myIntersectionOn2S.DirectionOnS1();
+              previousd2 = myIntersectionOn2S.DirectionOnS2();
+            }
+
+            //========================================
+            //== Check on PreviousPoint @@
+
+            {
+              Standard_Real u1,v1,u2,v2;
+              previousPoint.Parameters(u1,v1,u2,v2);
+
+              //To save initial 2d points
+              gp_Pnt2d ParamPntOnS1(Param(1), Param(2));
+              gp_Pnt2d ParamPntOnS2(Param(3), Param(4));
+
+              ///////////////////////////
+              Param(1) = u1;
+              Param(2) = v1;
+              Param(3) = u2;
+              Param(4) = v2;
+              //
+
+              //xf
+              Standard_Boolean bFlag1, bFlag2;
+              //
+              bFlag1 = (u1 >= myMinParam[0]-myReso[0]) &&
+                       (v1 >= myMinParam[1]-myReso[1]) &&
+                       (u1 <= myMaxParam[0]+myReso[0]) &&
+                       (v1 <= myMaxParam[1]+myReso[1]);
+              bFlag2 = (u2 >= myMinParam[2]-myReso[2]) &&
+                       (v2 >= myMinParam[3]-myReso[3]) &&
+                       (u2 <= myMaxParam[2]+myReso[2]) &&
+                       (v2 <= myMaxParam[3]+myReso[3]);
+              if (bFlag1 && bFlag2)
+              {
+                if (line->NbPoints() > 1)
+                {
+                  IntSurf_PntOn2S prevprevPoint = line->Value(line->NbPoints()-1);
+                  Standard_Real ppU1, ppV1, ppU2, ppV2;
+                  prevprevPoint.Parameters(ppU1, ppV1, ppU2, ppV2);
+                  Standard_Real pU1, pV1, pU2, pV2;
+                  previousPointSave.Parameters(pU1, pV1, pU2, pV2);
+                  gp_Vec2d V1onS1(gp_Pnt2d(ppU1, ppV1), gp_Pnt2d(pU1, pV1));
+                  gp_Vec2d V2onS1(gp_Pnt2d(pU1, pV1), gp_Pnt2d(u1, v1));
+                  gp_Vec2d V1onS2(gp_Pnt2d(ppU2, ppV2), gp_Pnt2d(pU2, pV2));
+                  gp_Vec2d V2onS2(gp_Pnt2d(pU2, pV2), gp_Pnt2d(u2, v2));
+
+                  const Standard_Real aDot1 = V1onS1 * V2onS1;
+                  const Standard_Real aDot2 = V1onS2 * V2onS2;
+
+                  if ((aDot1 < 0.0) || (aDot2 < 0.0))
+                  {
+                    return IntWalk_AnotherDirection;
+                  }
+                }
+
+                //To avoid walking around the same point
+                //in the tangent zone near a border
+
+                if (previoustg)
+                {
+                  //There are three consecutive points:
+                  //previousPointSave -> ParamPnt -> curPnt.
+
+                  Standard_Real prevU1, prevV1, prevU2, prevV2;
+                  previousPointSave.Parameters(prevU1, prevV1, prevU2, prevV2);
+                  gp_Pnt2d prevPntOnS1(prevU1, prevV1), prevPntOnS2(prevU2, prevV2);
+                  gp_Pnt2d curPntOnS1(u1, v1), curPntOnS2(u2, v2);
+                  gp_Vec2d PrevToParamOnS1(prevPntOnS1, ParamPntOnS1);
+                  gp_Vec2d PrevToCurOnS1(prevPntOnS1, curPntOnS1);
+                  gp_Vec2d PrevToParamOnS2(prevPntOnS2, ParamPntOnS2);
+                  gp_Vec2d PrevToCurOnS2(prevPntOnS2, curPntOnS2);
+                  Standard_Real MaxAngle = 3*M_PI/4;
+                  Standard_Real anAngleS1 = 0.0, anAngleS2 = 0.0;
+                  const Standard_Real aSQMParS1 = PrevToParamOnS1.SquareMagnitude();
+                  const Standard_Real aSQMParS2 = PrevToParamOnS2.SquareMagnitude();
+                  const Standard_Real aSQMCurS1 = PrevToCurOnS1.SquareMagnitude();
+                  const Standard_Real aSQMCurS2 = PrevToCurOnS2.SquareMagnitude();
+
+                  if(aSQMCurS1 < gp::Resolution())
+                  {
+                    //We came back to the one of previos point.
+                    //Therefore, we must break;
+
+                    anAngleS1 = M_PI;
+                  }
+                  else if(aSQMParS1 < gp::Resolution())
+                  {
+                    //We are walking along tangent zone.
+                    //It should be continued.
+                    anAngleS1 = 0.0;
+                  }
+                  else
+                  {
+                    anAngleS1 = Abs(PrevToParamOnS1.Angle(PrevToCurOnS1));
+                  }
+
+                  if(aSQMCurS2 < gp::Resolution())
+                  {
+                    //We came back to the one of previos point.
+                    //Therefore, we must break;
+
+                    anAngleS2 = M_PI;
+                  }
+                  else if(aSQMParS2 < gp::Resolution())
+                  {
+                    //We are walking along tangent zone.
+                    //It should be continued;
+                    anAngleS2 = 0.0;
+                  }
+                  else
+                  {
+                    anAngleS2 = Abs(PrevToParamOnS2.Angle(PrevToCurOnS2));
+                  }
+
+                  if ((anAngleS1 > MaxAngle) && (anAngleS2 > MaxAngle))
+                  {
+                    return IntWalk_DirectionNotFound;
+                  }
+
+                  {
+                    //Check singularity.
+                    //I.e. check if we are walking along direction, which does not
+                    //result in comming to any point (i.e. derivative 
+                    //3D-intersection curve along this direction is equal to 0).
+                    //A sphere with direction {dU=1, dV=0} from point
+                    //(U=0, V=M_PI/2) can be considered as example for
+                    //this case (we cannot find another 3D-point if we go thus).
+
+                    //Direction chosen along 1st and 2nd surface correspondingly
+                    const gp_Vec2d  aDirS1(prevPntOnS1, curPntOnS1),
+                      aDirS2(prevPntOnS2, curPntOnS2);
+
+                    gp_Pnt aPtemp;
+                    gp_Vec aDuS1, aDvS1, aDuS2, aDvS2;
+
+                    myIntersectionOn2S.Function().AuxillarSurface1()->
+                      D1(curPntOnS1.X(), curPntOnS1.Y(), aPtemp, aDuS1, aDvS1);
+                    myIntersectionOn2S.Function().AuxillarSurface2()->
+                      D1(curPntOnS2.X(), curPntOnS2.Y(), aPtemp, aDuS2, aDvS2);
+
+                    //Derivative WLine along (it is vector-function indeed)
+                    //directions chosen
+                    //(https://en.wikipedia.org/wiki/Directional_derivative#Variation_using_only_direction_of_vector).
+                    //F1 - on the 1st surface, F2 - on the 2nd surface.
+                    //x, y, z - coordinates of derivative vector.
+                    const Standard_Real aF1x =  aDuS1.X()*aDirS1.X() + 
+                      aDvS1.X()*aDirS1.Y();
+                    const Standard_Real aF1y =  aDuS1.Y()*aDirS1.X() +
+                      aDvS1.Y()*aDirS1.Y();
+                    const Standard_Real aF1z =  aDuS1.Z()*aDirS1.X() +
+                      aDvS1.Z()*aDirS1.Y();
+                    const Standard_Real aF2x =  aDuS2.X()*aDirS2.X() +
+                      aDvS2.X()*aDirS2.Y();
+                    const Standard_Real aF2y =  aDuS2.Y()*aDirS2.X() +
+                      aDvS2.Y()*aDirS2.Y();
+                    const Standard_Real aF2z =  aDuS2.Z()*aDirS2.X() +
+                      aDvS2.Z()*aDirS2.Y();
+
+                    const Standard_Real aF1 = aF1x*aF1x + aF1y*aF1y + aF1z*aF1z;
+                    const Standard_Real aF2 = aF2x*aF2x + aF2y*aF2y + aF2z*aF2z;
+
+                    if((aF1 < gp::Resolution()) && (aF2 < gp::Resolution()))
+                    {
+                      //All derivative are equal to 0. Therefore, there is
+                      //no point in going along direction chosen.
+                      
+                      return IntWalk_DirectionNotFound;
+                    }
+                  }
+                }//if (previoustg) cond.
+
+                ////////////////////////////////////////
+                AddAPoint(line,previousPoint);
+
+                if(line->NbPoints() >= RejectIndexMAX)
+                {
+                  return IntWalk_TooManyPoints;
+                }
+              }//if (bFlag1 && bFlag2) cond
+              else
+              {
+                // revert to the last correctly calculated point
+                previousPoint = previousPointSave;
+                previoustg    = previoustgSave;
+                previousd     = previousdSave;
+                previousd1    = previousd1Save;
+                previousd2    = previousd2Save;
+              }
+            }
+          }//else !TestArret() $
+      }//$$$ end framing on border (!close)
+
+      return IntWalk_OK;
+    }
+    
+    previousPoint = myIntersectionOn2S.Point();
+    previoustg = myIntersectionOn2S.IsTangent();
+
+    if(!previoustg)
+    {
+      previousd  = myIntersectionOn2S.Direction();
+      previousd1 = myIntersectionOn2S.DirectionOnS1();
+      previousd2 = myIntersectionOn2S.DirectionOnS2();
+    }
+    //=====================================================
+
+    AddAPoint(line,previousPoint);
+    const Standard_Integer aNbPnts = line->NbPoints();
+
+    if(aNbPnts >= RejectIndexMAX)
+    {
+      return IntWalk_TooManyPoints;
+    }
+
+    if(theIsForceAdd)
+    {
+      return IntWalk_ForcefulAdding;
+    }
+
+    if (aNbPnts == 2)
+    {
+      pasSav[0] = pasuv[0];
+      pasSav[1] = pasuv[1];
+      pasSav[2] = pasuv[2];
+      pasSav[3] = pasuv[3];
+    }
+  }//while(!hasToArrive)
+
+
+  return IntWalk_OK;
+}
+
+
 //==================================================================================
 // function : Perform
 // purpose  : 
@@ -617,59 +944,28 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
                                const Standard_Real u2max,
                                const Standard_Real v2max)
 {
-  const Standard_Real aSQDistMax = 1.0e-14;
-  //xf
-
-  Standard_Integer NbPasOKConseq=0;
   TColStd_Array1OfReal Param(1,4);
-  IntImp_ConstIsoparametric ChoixIso;
-  //xt
-  //
+
   done = Standard_False;
   //
   // Caro1 and Caro2
   const Handle(Adaptor3d_HSurface)& Caro1 =myIntersectionOn2S.Function().AuxillarSurface1();
   const Handle(Adaptor3d_HSurface)& Caro2 =myIntersectionOn2S.Function().AuxillarSurface2();
   //
-  const Standard_Real UFirst1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
-  const Standard_Real VFirst1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
-  const Standard_Real ULast1  = Adaptor3d_HSurfaceTool::LastUParameter (Caro1);
-  const Standard_Real VLast1  = Adaptor3d_HSurfaceTool::LastVParameter (Caro1);
-
-  const Standard_Real UFirst2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
-  const Standard_Real VFirst2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
-  const Standard_Real ULast2  = Adaptor3d_HSurfaceTool::LastUParameter (Caro2);
-  const Standard_Real VLast2  = Adaptor3d_HSurfaceTool::LastVParameter (Caro2);
   //
   ComputePasInit(u1max - u1min,v1max - v1min,u2max - u2min,v2max - v2min);
 
-  for (Standard_Integer i=0; i<4; ++i)
-  {
-    if(pasuv[i]>10)
-    {
-      pasuv[i] = 10;
-    }
-
-    pasInit[i] = pasSav[i] = pasuv[i]; 
-  }
-  //
   line = new IntSurf_LineOn2S ();
   //
-  for (Standard_Integer i=1; i<=4; ++i)
-  {
-    Param(i)=ParDep(i);
-  }
-  //-- reproduce steps uv connected to surfaces Caro1 and Caro2
-  //-- pasuv[] and pasSav[] are modified during the marching
-  for(Standard_Integer i = 0; i < 4; ++i)
+  for (Standard_Integer i=Param.Lower(), j = ParDep.Lower(); i<=Param.Upper(); ++i, j++)
   {
-    pasSav[i] = pasuv[i] = pasInit[i];
+    Param(i)=ParDep(j);
   }
 
   //-- calculate the first solution point
   math_FunctionSetRoot  Rsnld(myIntersectionOn2S.Function());
   //
-  ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld);
+  IntImp_ConstIsoparametric ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld);
   if (!myIntersectionOn2S.IsDone())
   {
     return;
@@ -686,12 +982,9 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
     return;
   }
   //
-  Standard_Boolean Arrive, DejaReparti;
-  const Standard_Integer RejectIndexMAX = 250000;
   Standard_Integer IncKey, RejectIndex;
   gp_Pnt pf,pl;
   //
-  DejaReparti = Standard_False;
   IncKey = 0;
   RejectIndex = 0;
   //
@@ -712,8 +1005,6 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
   //-- In this case, DejaReparti is initialized as True
   //-- 
   pf = previousPoint.Value();
-  Standard_Boolean bTestFirstPoint = Standard_True;
-
   previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
 
   if(IsTangentExtCheck(Caro1, Caro2, Param(1), Param(2), Param(3), Param(4), myTolTang, pasuv))
@@ -721,897 +1012,201 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
 
   AddAPoint(line,previousPoint);
   //
-  IntWalk_StatusDeflection Status = IntWalk_OK, aPrevStatus = IntWalk_OK;
-  Standard_Boolean NoTestDeflection = Standard_False;
-  Standard_Real SvParam[4], f;
-  Standard_Integer LevelOfEmptyInmyIntersectionOn2S=0;
-  Standard_Integer LevelOfPointConfondu = 0; 
-  Standard_Integer LevelOfIterWithoutAppend = -1;
-  //
-
-  const Standard_Real aTol[4] = { Epsilon(u1max - u1min),
-                                  Epsilon(v1max - v1min),
-                                  Epsilon(u2max - u2min),
-                                  Epsilon(v2max - v2min)};
-  Arrive = Standard_False;
-  while(!Arrive) //010
-  {
-    aPrevStatus = Status;
-
-    LevelOfIterWithoutAppend++;
-    if(LevelOfIterWithoutAppend>20)
-    {
-      Arrive = Standard_True; 
-      if(DejaReparti) {
-        break;
-      }
-      RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-      LevelOfIterWithoutAppend = 0;
-    }
-    //
-    // compute f
-    f = 0.;
-    switch (ChoixIso) { 
-      case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
-      case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
-      case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
-      case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
-      default:break;
-    }
-    //
-    if(f<0.1) {
-      f=0.1;
-    }
-    //
-    previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
-    //
-    //--ofv.begin
-    Standard_Real aIncKey, aEps, dP1, dP2, dP3, dP4;
-    //
-    dP1 = sensCheminement * pasuv[0] * previousd1.X() /f;
-    dP2 = sensCheminement * pasuv[1] * previousd1.Y() /f;
-    dP3 = sensCheminement * pasuv[2] * previousd2.X() /f; 
-    dP4 = sensCheminement * pasuv[3] * previousd2.Y() /f;
-    //
-    aIncKey=5.*(Standard_Real)IncKey;
-    aEps=1.e-7;
-    if(ChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < aEps)
-    {
-      dP1 *= aIncKey;
-    }
-
-    if(ChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < aEps)
-    {
-      dP2 *= aIncKey;
-    }
-
-    if(ChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < aEps)
-    {
-      dP3 *= aIncKey;
-    }
-
-    if(ChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < aEps)
-    {
-      dP4 *= aIncKey;
-    }
-    //--ofv.end
-    //
-    Param(1) += dP1;
-    Param(2) += dP2;
-    Param(3) += dP3; 
-    Param(4) += dP4;
-    //==========================
-    SvParam[0]=Param(1); 
-    SvParam[1]=Param(2);
-    SvParam[2]=Param(3);
-    SvParam[3]=Param(4);
-    //
-    Standard_Integer aTryNumber = 0;
-    Standard_Real    isBadPoint = Standard_False;
-    IntImp_ConstIsoparametric aBestIso = ChoixIso;
-    do
-    {
-      isBadPoint = Standard_False;
-
-      ChoixIso= myIntersectionOn2S.Perform(Param, Rsnld, aBestIso);
-
-      if (myIntersectionOn2S.IsDone() && !myIntersectionOn2S.IsEmpty())
-      {
-        //If we go along any surface boundary then it is possible 
-        //to find "outboundaried" point.
-        //Nevertheless, if this deflection is quite small, we will be
-        //able to adjust this point to the boundary.
-
-        Standard_Real aNewPnt[4], anAbsParamDist[4];
-        myIntersectionOn2S.Point().Parameters(aNewPnt[0], aNewPnt[1], aNewPnt[2], aNewPnt[3]);
-        const Standard_Real aParMin[4] = {u1min, v1min, u2min, v2min};
-        const Standard_Real aParMax[4] = {u1max, v1max, u2max, v2max};
-
-        for(Standard_Integer i = 0; i < 4; i++)
-        {
-          if(Abs(aNewPnt[i] - aParMin[i]) < aTol[i])
-            aNewPnt[i] = aParMin[i];
-          else if(Abs(aNewPnt[i] - aParMax[i]) < aTol[i])
-            aNewPnt[i] = aParMax[i];
-        }
-
-        if (aNewPnt[0] < u1min || aNewPnt[0] > u1max ||
-            aNewPnt[1] < v1min || aNewPnt[1] > v1max ||
-            aNewPnt[2] < u2min || aNewPnt[2] > u2max ||
-            aNewPnt[3] < v2min || aNewPnt[3] > v2max)
-        {
-          break; // Out of borders, handle this later.
-        }
-
-        myIntersectionOn2S.ChangePoint().SetValue(aNewPnt[0],
-                                                  aNewPnt[1],
-                                                  aNewPnt[2],
-                                                  aNewPnt[3]);
-
-        anAbsParamDist[0] = Abs(Param(1) - dP1 - aNewPnt[0]);
-        anAbsParamDist[1] = Abs(Param(2) - dP2 - aNewPnt[1]);
-        anAbsParamDist[2] = Abs(Param(3) - dP3 - aNewPnt[2]);
-        anAbsParamDist[3] = Abs(Param(4) - dP4 - aNewPnt[3]);
-        if (anAbsParamDist[0] < ResoU1 &&
-            anAbsParamDist[1] < ResoV1 &&
-            anAbsParamDist[2] < ResoU2 &&
-            anAbsParamDist[3] < ResoV2 &&
-            Status != IntWalk_PasTropGrand)
-        {
-          isBadPoint = Standard_True;
-          aBestIso = IntImp_ConstIsoparametric((aBestIso + 1) % 4);
-        }
-      }
-    } while (isBadPoint && ++aTryNumber <= 4);
-    //
-    if (!myIntersectionOn2S.IsDone())
-    {
-      //end of line, division
-      Arrive = Standard_False;
-      Param(1)=SvParam[0]; 
-      Param(2)=SvParam[1]; 
-      Param(3)=SvParam[2];
-      Param(4)=SvParam[3];
-      RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
-    }
-    else  //009 
-    {
-      //== Calculation of exact point from Param(.) is possible
-      if (myIntersectionOn2S.IsEmpty())
-      {
-        Standard_Real u1,v1,u2,v2;
-        previousPoint.Parameters(u1,v1,u2,v2);
-        //
-        Arrive = Standard_False;
-        if(u1<UFirst1 || u1>ULast1)
-        {
-          Arrive=Standard_True;
-        }      
-
-        if(u2<UFirst2 || u2>ULast2)
-        {
-          Arrive=Standard_True;
-        }
-
-        if(v1<VFirst1 || v1>VLast1)
-        {
-          Arrive=Standard_True;
-        }
-
-        if(v2<VFirst2 || v2>VLast2)
-        {
-          Arrive=Standard_True;
-        }
-
-        RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-        LevelOfEmptyInmyIntersectionOn2S++;
-        //
-        if(LevelOfEmptyInmyIntersectionOn2S>10)
-        {
-          pasuv[0]=pasSav[0]; 
-          pasuv[1]=pasSav[1]; 
-          pasuv[2]=pasSav[2]; 
-          pasuv[3]=pasSav[3];
-        }
-      }
-      else //008
-      {
-        //============================================================
-        //== A point has been found :  T E S T   D E F L E C T I O N 
-        //============================================================
-        if(NoTestDeflection)
-        {
-          NoTestDeflection = Standard_False;
-        }                
-        else
-        {
-          if(--LevelOfEmptyInmyIntersectionOn2S<=0)
-          {
-            LevelOfEmptyInmyIntersectionOn2S=0;
-            if(LevelOfIterWithoutAppend < 10)
-            {
-              Status = TestDeflection(ChoixIso);
-            }                  
-            else
-            {
-              pasuv[0]*=0.5; 
-              pasuv[1]*=0.5; 
-              pasuv[2]*=0.5; 
-              pasuv[3]*=0.5;
-            }
-          }
-        }
-
-        //============================================================
-        //==       T r a i t e m e n t   s u r   S t a t u s        ==
-        //============================================================
-        if(LevelOfPointConfondu > 5)
-        { 
-          Status = IntWalk_ArretSurPoint; 
-          LevelOfPointConfondu = 0;  
-        }
-        //
-        if(Status==IntWalk_OK)
-        { 
-          NbPasOKConseq++;
-          if(NbPasOKConseq >= 5)
-          {
-            NbPasOKConseq=0;
-            Standard_Boolean pastroppetit;
-            Standard_Real t;
-            //
-            do
-            {
-              pastroppetit=Standard_True;
-              //
-              if(pasuv[0]<pasInit[0])
-              {
-                t = (pasInit[0]-pasuv[0])*0.25;
-                if(t>0.1*pasInit[0])
-                {
-                  t=0.1*pasuv[0];
-                }
 
-                pasuv[0]+=t; 
-                pastroppetit=Standard_False;
-              }
+  Standard_Boolean hasToArrive = Standard_False;
+  Standard_Real aDeltaParam[] = {1.0, 1.0, 1.0, 1.0};
+  Standard_Boolean isForceAdd = Standard_False;
 
-              if(pasuv[1]<pasInit[1])
-              {
-                t = (pasInit[1]-pasuv[1])*0.25;
-                if(t>0.1*pasInit[1]) {
-                  t=0.1*pasuv[1];
-                }              
-
-                pasuv[1]+=t; 
-                pastroppetit=Standard_False;
-              }
-
-              if(pasuv[2]<pasInit[2])
-              {
-                t = (pasInit[2]-pasuv[2])*0.25;
-                if(t>0.1*pasInit[2])
-                {
-                  t=0.1*pasuv[2];
-                }
+  IntWalk_StatusDeflection aStatusPrev = IntWalk_OK;
 
-                pasuv[2]+=t; 
-                pastroppetit=Standard_False;
-              }
+  while(!hasToArrive) //010
+  {
+    IntWalk_StatusDeflection aStatus = IntersPerform(isForceAdd, ChoixIso, Rsnld, aDeltaParam);
+    previousPoint.Parameters(Param(1), Param(2), Param(3), Param(4));
 
-              if(pasuv[3]<pasInit[3])
-              {
-                t = (pasInit[3]-pasuv[3])*0.25;
-                if(t>0.1*pasInit[3]) {
-                  t=0.1*pasuv[3];
-                }
-                pasuv[3]+=t; 
-                pastroppetit=Standard_False;
-              }
-              if(pastroppetit)
-              {
-                if(pasMax<0.1)
-                {
-                  pasMax*=1.1;
-                  pasInit[0]*=1.1; 
-                  pasInit[1]*=1.1; 
-                  pasInit[2]*=1.1; 
-                  pasInit[3]*=1.1; 
-                }
-                else
-                {
-                  pastroppetit=Standard_False;
-                }
-              }
-            }
-            while(pastroppetit);
-          }
-        }//Status==IntWalk_OK
-        else
-          NbPasOKConseq=0;
+    if((aStatus == IntWalk_OK) || (aStatus == IntWalk_TooManyPoints))
+    {
+      done = Standard_True;
+      return;
+    }
 
-        //
-        switch(Status)//007 
+    switch(aStatus)
+    {
+    case IntWalk_IntersectsBoundary:
+      {
+        if(aStatusPrev == IntWalk_IntersectsBoundary)
         {
-        case IntWalk_ArretSurPointPrecedent:
-          {
-            Arrive = Standard_False;
-            RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
-            break;
+          if(sensCheminement == -1.0)
+          { //Wline has already been reversed earlier.
+            //The line is continued from first to last point
+
+            done = Standard_True;
+            return;
           }
-        case IntWalk_PasTropGrand:
-          {
-            Param(1)=SvParam[0];
-            Param(2)=SvParam[1]; 
-            Param(3)=SvParam[2]; 
-            Param(4)=SvParam[3];
 
-            if(LevelOfIterWithoutAppend > 5)
-            {
-              for (Standard_Integer i = 0; i < 4; i++)
-              {
-                if (pasSav[i] > pasInit[i])
-                  continue;
+          ContinueInAnotherDirection(ChoixIso);
+          isForceAdd = Standard_False;
+        }
 
-                const Standard_Real aDelta = (pasInit[i]-pasSav[i])*0.25;
+        Standard_Real aStepFactor = 1.0;
 
-                if(aDelta > Epsilon(pasInit[i]))
-                {
-                  pasInit[i] -= aDelta;
-                  LevelOfIterWithoutAppend=0;
-                }
-              }
-            }
+        for(Standard_Integer i = 0; i < 4; i++)
+        {
+          const Standard_Real aDP = aDeltaParam[i]*pasuv[i];
+          if(IsEqual(aDP, 0.0))
+            continue;
 
-            break;
-          }
-        case IntWalk_PointConfondu:
-          {
-            LevelOfPointConfondu++;
+          Standard_Real aPrevSF = aStepFactor;
 
-            if(LevelOfPointConfondu>5)
-            {
-              Standard_Boolean pastroppetit;
-              //
-              do
-              {
-                pastroppetit=Standard_True;
+          Standard_Real aDUV = Max(Param(i+1) + aDP - myMaxParam[i], 0.0);
+          aStepFactor = Min(aStepFactor, 1-aDUV/aDP);
 
-                for(Standard_Integer i = 0; i < 4; i++)
-                {
-                  if(pasuv[i]<pasInit[i])
-                  {
-                    pasuv[i]+=(pasInit[i]-pasuv[i])*0.25;
-                    pastroppetit=Standard_False;
-                  }
-                }
+          if(pasuv[i]*aStepFactor < myStepMin[i])
+            aStepFactor = aPrevSF;
 
-                if(pastroppetit)
-                {
-                  if(pasMax<0.1)
-                  {
-                    pasMax*=1.1;
-                    pasInit[0]*=1.1;
-                    pasInit[1]*=1.1;
-                    pasInit[2]*=1.1;
-                    pasInit[3]*=1.1; 
-                  }
-                  else
-                  {
-                    pastroppetit=Standard_False;
-                  }
-                }
-              }
-              while(pastroppetit);
-            }
+          aPrevSF = aStepFactor;
 
-            break;
-          }
-        case IntWalk_StepTooSmall:
-          {
-            Standard_Boolean hasStepBeenIncreased = Standard_False;
+          aDUV = Min(Param(i+1) + aDP - myMinParam[i], 0.0);
+          aStepFactor = Min(aStepFactor, 1-aDUV/aDP);
 
-            for(Standard_Integer i = 0; i < 4; i++)
-            {
-              const Standard_Real aNewStep = Min(1.5*pasuv[i], pasInit[i]);
-              if(aNewStep > pasuv[i])
-              {
-                pasuv[i] = aNewStep;
-                hasStepBeenIncreased = Standard_True;
-              }
-            }
+          if(pasuv[i]*aStepFactor < myStepMin[i])
+            aStepFactor = aPrevSF;
+        }
 
-            if(hasStepBeenIncreased)
-            {
-              Param(1)=SvParam[0];
-              Param(2)=SvParam[1];
-              Param(3)=SvParam[2];
-              Param(4)=SvParam[3];
-
-              // In order to avoid cyclic changes
-              // (PasTropGrand --> Decrease step --> 
-              // StepTooSmall --> Increase step --> PasTropGrand...)
-              // nullify LevelOfIterWithoutAppend only if the condition
-              // is satisfied:
-              if (aPrevStatus != IntWalk_PasTropGrand)
-                LevelOfIterWithoutAppend = 0;
-
-              break;
-            }
-          }
-        case IntWalk_OK:
-        case IntWalk_ArretSurPoint://006
+        if(/*aStepFactor > 0.0 && */(aStepFactor < 1.0))
+        {
+          for(Standard_Integer i = 0; i < 4; i++)
           {
-            //=======================================================
-            //== Stop Test t   :  Frame on Param(.)     ==
-            //=======================================================
-            //xft arrive here
-            Arrive = TestArret(DejaReparti,Param,ChoixIso); 
-            // JMB 30th December 1999. 
-            // Some statement below should not be put in comment because they are useful.
-            // See grid CTO 909 A1 which infinitely loops 
-            if(Arrive==Standard_False && Status==IntWalk_ArretSurPoint)
-            {
-              Arrive=Standard_True;
-#ifdef OCCT_DEBUG
-              cout << "IntWalk_PWalking_1.gxx: Problems with intersection"<<endl;
-#endif
-            }
-
-            if(Arrive)
-            {
-              NbPasOKConseq = -10;
-            }
+            pasuv[i] *= aStepFactor;
+            isForceAdd = Standard_True;
+          }
+        }
+      }
 
-            if(!Arrive)//005
-            {
-              //=====================================================
-              //== Param(.) is in the limits                       ==
-              //==  and does not end a closed  line                ==
-              //=====================================================
-              //== Check on the current point of myInters
-              Standard_Boolean pointisvalid = Standard_False;
-              {
-                Standard_Real u1,v1,u2,v2; 
-                myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
+      break;
+    case IntWalk_StepTooSmall:
+      {
+        if( (aStatusPrev == IntWalk_PasTropGrand) ||
+            (aStatusPrev == IntWalk_IntersectPointNotFound) ||
+            (aStatusPrev == IntWalk_AnotherDirection))
+        {// In order to avoid jumping: StepToSmall status -> Increase step -> PasTropGrand status -> decrease step -> StepToSmall status
+          aStatus = aStatusPrev;
+          isForceAdd = Standard_True;
+          break;
+        }
 
-                //
-                if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
-                  v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                  v1 >= Vm1  && v2 >= Vm2)
-                {
-                  pointisvalid=Standard_True;
-                }
-              }
+        isForceAdd = Standard_False;
+        Standard_Real aStepFactor = 1.0;
 
-              //
-              if(pointisvalid)
-              {
-                previousPoint = myIntersectionOn2S.Point();
-                previoustg = myIntersectionOn2S.IsTangent();
+        for(Standard_Integer i = 0; i < 4; i++)
+        {
+          const Standard_Real aDP = aDeltaParam[i]*pasuv[i];
+          if((ChoixIso != static_cast<IntImp_ConstIsoparametric>(i)) ||
+                                                        IsEqual(aDP, 0.0))
+            continue;
 
-                if(!previoustg)
-                {
-                  previousd  = myIntersectionOn2S.Direction();
-                  previousd1 = myIntersectionOn2S.DirectionOnS1();
-                  previousd2 = myIntersectionOn2S.DirectionOnS2();
-                }
-                //=====================================================
-                //== Check on the previous Point
-                {
-                  Standard_Real u1,v1,u2,v2;
-                  previousPoint.Parameters(u1,v1,u2,v2); 
-                  if( u1 <= UM1  && u2 <= UM2 && v1 <= VM1 &&
-                    v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                    v1 >= Vm1  && v2 >= Vm2)
-                  {
-                    pl = previousPoint.Value();
-                    if(bTestFirstPoint)
-                    {
-                      if(pf.SquareDistance(pl) < aSQDistMax)
-                      {
-                        IncKey++;
-                        if(IncKey == 5000)
-                          return;
-                        else
-                          continue;
-                      }
-                      else
-                      {
-                        bTestFirstPoint = Standard_False;
-                      }
-                    }
-                    //
-                    AddAPoint(line,previousPoint);
-                    RejectIndex++;
+          Standard_Real aDUV = Max(Param(i+1) + aDP - myMaxParam[i], 0.0);
+          aStepFactor = Min(aStepFactor, 1-aDUV/aDP);
 
-                    if(RejectIndex >= RejectIndexMAX)
-                    {
-                      Arrive = Standard_True;
-                      break;
-                    }
+          aDUV = Min(Param(i+1) + aDP - myMinParam[i], 0.0);
+          aStepFactor = Min(aStepFactor, 1-aDUV/aDP);
+        }
 
-                    //
-                    LevelOfIterWithoutAppend = 0;
-                  }
-                }
-              }//pointisvalid
-              //====================================================
+        if(/*aStepFactor > 0.0 && */(aStepFactor < 1.0))
+        {
+          for(Standard_Integer i = 0; i < 4; i++)
+          {
+            pasuv[i] *= aStepFactor;
+          }
+        }
 
-              if(Status == IntWalk_ArretSurPoint)
-              {
-                RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-              }
-              else
-              {
-                if (line->NbPoints() == 2)
-                {
-                  pasSav[0] = pasuv[0];
-                  pasSav[1] = pasuv[1];
-                  pasSav[2] = pasuv[2];
-                  pasSav[3] = pasuv[3];
-                }
-              }
-            }//005 if(!Arrive)
-            else  //004
+        if(aStepFactor == 1.0)
+        {
+          Standard_Boolean hasBeenAdded = Standard_False;
+          for(Standard_Integer i = 0; i < 4; i++)
+          {
+            const Standard_Real aNewStep = Min(myIncMultiplier*pasuv[i], pasInit[i]);
+            if(aNewStep > pasuv[i])
             {
-              if(close)
-              {
-                //================= la ligne est fermee ===============
-                AddAPoint(line,line->Value(1)); //ligne fermee
-                LevelOfIterWithoutAppend=0;
-              }
-              else    //$$$
-              {
-                //====================================================
-                //== Param was not in the limits (was reframed)
-                //====================================================
-                Standard_Boolean bPrevNotTangent = !previoustg || !myIntersectionOn2S.IsTangent();
-
-                IntImp_ConstIsoparametric SauvChoixIso = ChoixIso;
-                ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
-                //
-                if(!myIntersectionOn2S.IsEmpty()) //002
-                {
-                  // mutially outpasses in the square or intersection in corner
+              hasBeenAdded = Standard_True;
+              pasuv[i] = aNewStep;
+            }
+          }
 
-                  if(TestArret(Standard_True,Param,ChoixIso))
-                  {
-                    NbPasOKConseq = -10;
-                    ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
+          if(!hasBeenAdded)
+            isForceAdd = Standard_True;
+        }
+      }
 
-                    if(!myIntersectionOn2S.IsEmpty())
-                    {
-                      previousPoint = myIntersectionOn2S.Point();
-                      previoustg = myIntersectionOn2S.IsTangent();
-
-                      if (!previoustg)
-                      {
-                        previousd  = myIntersectionOn2S.Direction();
-                        previousd1 = myIntersectionOn2S.DirectionOnS1();
-                        previousd2 = myIntersectionOn2S.DirectionOnS2();
-                      }
-
-                      pl = previousPoint.Value();
-
-                      if(bTestFirstPoint)
-                      {
-                        if(pf.SquareDistance(pl) < aSQDistMax)
-                        {
-                          IncKey++;
-                          if(IncKey == 5000)
-                            return;
-                          else
-                            continue;
-                        }
-                        else
-                        {
-                          bTestFirstPoint = Standard_False;
-                        }
-                      }
-                      //
-                      AddAPoint(line,previousPoint);
-                      RejectIndex++;
-
-                      if(RejectIndex >= RejectIndexMAX)
-                      {
-                        Arrive = Standard_True;
-                        break;
-                      }
-
-                      //
-                      LevelOfIterWithoutAppend=0;
-                      RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-                    }
-                    else
-                    {
-                      //fail framing divides the step
-                      Arrive = Standard_False;
-                      RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-                      NoTestDeflection = Standard_True;
-                      ChoixIso = SauvChoixIso;
-                    }
-                  }//if(TestArret())
-                  else
-                  {
-                    // save the last point
-                    // to revert to it if the current point is out of bounds
+      break;
+    case IntWalk_PasTropGrand:
+      {
+        Standard_Boolean hasStepBeenDecreased = Standard_False;
 
-                    IntSurf_PntOn2S previousPointSave = previousPoint;
-                    Standard_Boolean previoustgSave   = previoustg;
-                    gp_Dir previousdSave              = previousd;
-                    gp_Dir2d previousd1Save           = previousd1;
-                    gp_Dir2d previousd2Save           = previousd2;
+        for(Standard_Integer i = 0; i < 4; i++)
+        {
+          const Standard_Real aNewStep = Max(myDecMultiplier*pasuv[i], myStepMin[i]);
+          if(aNewStep < pasuv[i])
+          {
+            pasuv[i] = aNewStep;
+            hasStepBeenDecreased = Standard_True;
+          }
+        }
 
-                    previousPoint = myIntersectionOn2S.Point();
-                    previoustg = myIntersectionOn2S.IsTangent();
-                    Arrive = Standard_False;
+        if(!hasStepBeenDecreased)
+        {
+          done = Standard_True;
+          return;
+        }
+      }
+      break;
 
-                    if(!previoustg)
-                    {
-                      previousd  = myIntersectionOn2S.Direction();
-                      previousd1 = myIntersectionOn2S.DirectionOnS1();
-                      previousd2 = myIntersectionOn2S.DirectionOnS2();
-                    }
+    case IntWalk_IntersectPointNotFound:
+    case IntWalk_AnotherDirection:
+      {
+        isForceAdd = Standard_False;
+        Standard_Boolean hasStepBeenDecreased = Standard_False;
 
-                    //========================================
-                    //== Check on PreviousPoint @@
+        for(Standard_Integer i = 0; i < 4; i++)
+        {
+          const Standard_Real aNewStep = Max(myDecMultiplier*pasuv[i], myStepMin[i]);
+          if(aNewStep < pasuv[i])
+          {
+            pasuv[i] = aNewStep;
+            hasStepBeenDecreased = Standard_True;
+          }
+        }
 
-                    {
-                      Standard_Real u1,v1,u2,v2;
-                      previousPoint.Parameters(u1,v1,u2,v2);
-
-                      //To save initial 2d points
-                      gp_Pnt2d ParamPntOnS1(Param(1), Param(2));
-                      gp_Pnt2d ParamPntOnS2(Param(3), Param(4));
-
-                      ///////////////////////////
-                      Param(1) = u1;
-                      Param(2) = v1;
-                      Param(3) = u2;
-                      Param(4) = v2;
-                      //
-
-                      //xf
-                      Standard_Boolean bFlag1, bFlag2;
-                      Standard_Real aTol2D=1.e-11;
-                      //
-                      bFlag1=u1 >= Um1-aTol2D && v1 >= Vm1-aTol2D && u1 <= UM1+aTol2D && v1 <= VM1+aTol2D;
-                      bFlag2=u2 >= Um2-aTol2D && v2 >= Vm2-aTol2D && u2 <= UM2+aTol2D && v2 <= VM2+aTol2D;
-                      if (bFlag1 && bFlag2)
-                      {
-                        if (line->NbPoints() > 1)
-                        {
-                          IntSurf_PntOn2S prevprevPoint = line->Value(line->NbPoints()-1);
-                          Standard_Real ppU1, ppV1, ppU2, ppV2;
-                          prevprevPoint.Parameters(ppU1, ppV1, ppU2, ppV2);
-                          Standard_Real pU1, pV1, pU2, pV2;
-                          previousPointSave.Parameters(pU1, pV1, pU2, pV2);
-                          gp_Vec2d V1onS1(gp_Pnt2d(ppU1, ppV1), gp_Pnt2d(pU1, pV1));
-                          gp_Vec2d V2onS1(gp_Pnt2d(pU1, pV1), gp_Pnt2d(u1, v1));
-                          gp_Vec2d V1onS2(gp_Pnt2d(ppU2, ppV2), gp_Pnt2d(pU2, pV2));
-                          gp_Vec2d V2onS2(gp_Pnt2d(pU2, pV2), gp_Pnt2d(u2, v2));
-
-                          const Standard_Real aDot1 = V1onS1 * V2onS1;
-                          const Standard_Real aDot2 = V1onS2 * V2onS2;
-
-                          if ((aDot1 < 0.0) || (aDot2 < 0.0))
-                          {
-                            Arrive = Standard_True;
-                            break;
-                          }
-                        }
-                        /*
-                        if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 &&
-                        v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                        v1 >= Vm1  && v2 >= Vm2)  {
-                        */                     
-                        //xt
-                        pl = previousPoint.Value();
-
-                        if(bTestFirstPoint)
-                        {
-                          if(pf.SquareDistance(pl) < aSQDistMax)
-                          {
-                            IncKey++;
-
-                            if(IncKey == 5000)
-                              return;
-                            else
-                              continue;
-                          }
-                          else
-                          {
-                            bTestFirstPoint = Standard_False;
-                          }
-                        }
-
-                        //To avoid walking around the same point
-                        //in the tangent zone near a border
-
-                        if (previoustg)
-                        {
-                          //There are three consecutive points:
-                          //previousPointSave -> ParamPnt -> curPnt.
-
-                          Standard_Real prevU1, prevV1, prevU2, prevV2;
-                          previousPointSave.Parameters(prevU1, prevV1, prevU2, prevV2);
-                          gp_Pnt2d prevPntOnS1(prevU1, prevV1), prevPntOnS2(prevU2, prevV2);
-                          gp_Pnt2d curPntOnS1(u1, v1), curPntOnS2(u2, v2);
-                          gp_Vec2d PrevToParamOnS1(prevPntOnS1, ParamPntOnS1);
-                          gp_Vec2d PrevToCurOnS1(prevPntOnS1, curPntOnS1);
-                          gp_Vec2d PrevToParamOnS2(prevPntOnS2, ParamPntOnS2);
-                          gp_Vec2d PrevToCurOnS2(prevPntOnS2, curPntOnS2);
-                          Standard_Real MaxAngle = 3*M_PI/4;
-                          Standard_Real anAngleS1 = 0.0, anAngleS2 = 0.0;
-                          const Standard_Real aSQMParS1 = PrevToParamOnS1.SquareMagnitude();
-                          const Standard_Real aSQMParS2 = PrevToParamOnS2.SquareMagnitude();
-                          const Standard_Real aSQMCurS1 = PrevToCurOnS1.SquareMagnitude();
-                          const Standard_Real aSQMCurS2 = PrevToCurOnS2.SquareMagnitude();
-
-                          if(aSQMCurS1 < gp::Resolution())
-                          {
-                            //We came back to the one of previos point.
-                            //Therefore, we must break;
-
-                            anAngleS1 = M_PI;
-                          }
-                          else if(aSQMParS1 < gp::Resolution())
-                          {
-                            //We are walking along tangent zone.
-                            //It should be continued.
-                            anAngleS1 = 0.0;
-                          }
-                          else
-                          {
-                            anAngleS1 = Abs(PrevToParamOnS1.Angle(PrevToCurOnS1));
-                          }
-
-                          if(aSQMCurS2 < gp::Resolution())
-                          {
-                            //We came back to the one of previos point.
-                            //Therefore, we must break;
-
-                            anAngleS2 = M_PI;
-                          }
-                          else if(aSQMParS2 < gp::Resolution())
-                          {
-                            //We are walking along tangent zone.
-                            //It should be continued;
-                            anAngleS2 = 0.0;
-                          }
-                          else
-                          {
-                            anAngleS2 = Abs(PrevToParamOnS2.Angle(PrevToCurOnS2));
-                          }
-
-                          if ((anAngleS1 > MaxAngle) && (anAngleS2 > MaxAngle))
-                          {
-                            Arrive = Standard_True;
-                            break;
-                          }
-
-                          {
-                            //Check singularity.
-                            //I.e. check if we are walking along direction, which does not
-                            //result in comming to any point (i.e. derivative 
-                            //3D-intersection curve along this direction is equal to 0).
-                            //A sphere with direction {dU=1, dV=0} from point
-                            //(U=0, V=M_PI/2) can be considered as example for
-                            //this case (we cannot find another 3D-point if we go thus).
-
-                            //Direction chosen along 1st and 2nd surface correspondingly
-                            const gp_Vec2d  aDirS1(prevPntOnS1, curPntOnS1),
-                                            aDirS2(prevPntOnS2, curPntOnS2);
-
-                            gp_Pnt aPtemp;
-                            gp_Vec aDuS1, aDvS1, aDuS2, aDvS2;
-
-                            myIntersectionOn2S.Function().AuxillarSurface1()->
-                                  D1(curPntOnS1.X(), curPntOnS1.Y(), aPtemp, aDuS1, aDvS1);
-                            myIntersectionOn2S.Function().AuxillarSurface2()->
-                                  D1(curPntOnS2.X(), curPntOnS2.Y(), aPtemp, aDuS2, aDvS2);
-
-                            //Derivative WLine along (it is vector-function indeed)
-                            //directions chosen
-                            //(https://en.wikipedia.org/wiki/Directional_derivative#Variation_using_only_direction_of_vector).
-                            //F1 - on the 1st surface, F2 - on the 2nd surface.
-                            //x, y, z - coordinates of derivative vector.
-                            const Standard_Real aF1x =  aDuS1.X()*aDirS1.X() + 
-                                                        aDvS1.X()*aDirS1.Y();
-                            const Standard_Real aF1y =  aDuS1.Y()*aDirS1.X() +
-                                                        aDvS1.Y()*aDirS1.Y();
-                            const Standard_Real aF1z =  aDuS1.Z()*aDirS1.X() +
-                                                        aDvS1.Z()*aDirS1.Y();
-                            const Standard_Real aF2x =  aDuS2.X()*aDirS2.X() +
-                                                        aDvS2.X()*aDirS2.Y();
-                            const Standard_Real aF2y =  aDuS2.Y()*aDirS2.X() +
-                                                        aDvS2.Y()*aDirS2.Y();
-                            const Standard_Real aF2z =  aDuS2.Z()*aDirS2.X() +
-                                                        aDvS2.Z()*aDirS2.Y();
-
-                            const Standard_Real aF1 = aF1x*aF1x + aF1y*aF1y + aF1z*aF1z;
-                            const Standard_Real aF2 = aF2x*aF2x + aF2y*aF2y + aF2z*aF2z;
-
-                            if((aF1 < gp::Resolution()) && (aF2 < gp::Resolution()))
-                            {
-                              //All derivative are equal to 0. Therefore, there is
-                              //no point in going along direction chosen.
-                              Arrive = Standard_True;
-                              break;
-                            }
-                          }
-                        }//if (previoustg) cond.
-
-                        ////////////////////////////////////////
-                        AddAPoint(line,previousPoint);
-                        RejectIndex++;
-
-                        if(RejectIndex >= RejectIndexMAX)
-                        {
-                          Arrive = Standard_True;
-                          break;
-                        }
-
-                        //
-
-                        LevelOfIterWithoutAppend=0;
-                        Arrive = Standard_True;
-                      }
-                      else
-                      {
-                        // revert to the last correctly calculated point
-                        previousPoint = previousPointSave;
-                        previoustg    = previoustgSave;
-                        previousd     = previousdSave;
-                        previousd1    = previousd1Save;
-                        previousd2    = previousd2Save;
-                      }
-                    }
+        if(!hasStepBeenDecreased)
+        {
+          if(sensCheminement == -1.0)
+          { //Wline has already been reversed earlier.
+            //The line is continued from first to last point
 
-                    //
-                    Standard_Boolean wasExtended = Standard_False;
+            done = Standard_True;
+            return;
+          }
 
-                    if(Arrive && myIntersectionOn2S.IsTangent() && bPrevNotTangent)
-                    {
-                      if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
-                      {
-                        wasExtended = Standard_True;
-                        Arrive = Standard_False;
-                        ChoixIso = SauvChoixIso;
-                      }
-                    }
+          ContinueInAnotherDirection(ChoixIso);
+          isForceAdd = Standard_False;
+        }
+      }
+      break;
 
-                    RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+    case IntWalk_ForcefulAdding:
+      {
+        isForceAdd = Standard_False;
+        aStatus = IntWalk_OK;
+      }
+      break;
 
-                    if(Arrive && 
-                      myIntersectionOn2S.IsDone() && !myIntersectionOn2S.IsEmpty() &&
-                      myIntersectionOn2S.IsTangent() && bPrevNotTangent &&
-                      !wasExtended)
-                    {
-                      if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
-                      {
-                        wasExtended = Standard_True;
-                        Arrive = Standard_False;
-                        ChoixIso = SauvChoixIso;
-                      }
-                    }
-                  }//else !TestArret() $
-                }//$$ end successful framing on border (!myIntersectionOn2S.IsEmpty())
-                else
-                {
-                  //echec framing on border; division of step 
-                  Arrive = Standard_False;
-                  NoTestDeflection = Standard_True;
-                  RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-                }
-              }//$$$ end framing on border (!close)
-            }//004 fin TestArret return Arrive = True
-          } // 006case IntWalk_ArretSurPoint:  end Processing Status = OK  or ArretSurPoint 
-        } //007  switch(Status) 
-      } //008 end processing point  (TEST DEFLECTION)
-    } //009 end processing line (else if myIntersectionOn2S.IsDone())
-  }  //010 end if first departure point allows marching  while (!Arrive)
+    default:
+      done = Standard_True;
+      return;
+    }
+
+    aStatusPrev = aStatus;
+  }
 
   done = Standard_True;
 }
@@ -1695,8 +1290,8 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
       if(Status == IntWalk_OK) {
 
         for(uvit = 0; uvit < 4; uvit++) {
-          if(pasuv[uvit] < pasInit[uvit]) {
-            pasuv[uvit] = pasInit[uvit];
+          if(pasuv[uvit] < myRelMaxStep*pasInit[uvit]) {
+            pasuv[uvit] = myRelMaxStep*pasInit[uvit];
           }
         }
       }
@@ -1717,7 +1312,7 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
 
           for(uvit = 0; uvit < 4; uvit++) {
             if(pasSav[uvit] < pasInit[uvit]) { 
-              pasInit[uvit] -= (pasInit[uvit] - pasSav[uvit]) * 0.1;
+              pasInit[uvit] -= (pasInit[uvit] - pasSav[uvit]) * myRelMaxStep;
               bDecrease = Standard_True;
             }
           }
@@ -1729,7 +1324,7 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
         {
           for(uvit = 0; uvit < 4; uvit++) {
             if(pasuv[uvit] < pasInit[uvit]) {
-              pasuv[uvit] += (pasInit[uvit] - pasuv[uvit]) * 0.1;
+              pasuv[uvit] += (pasInit[uvit] - pasuv[uvit]) * myRelMaxStep;
             }
           }
           break;
@@ -1748,8 +1343,8 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
             Standard_Real u21,v21,u22,v22;
             previousPoint.Parameters(u21,v21,u22,v22); 
 
-            if(((fabs(u11-u21) < ResoU1) && (fabs(v11-v21) < ResoV1)) ||
-              ((fabs(u12-u22) < ResoU2) && (fabs(v12-v22) < ResoV2))) {
+            if(((fabs(u11-u21) < myReso[0]) && (fabs(v11-v21) < myReso[1])) ||
+              ((fabs(u12-u22) < myReso[2]) && (fabs(v12-v22) < myReso[3]))) {
                 nbEqualPoints++;
             }
             else {
@@ -1766,9 +1361,9 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
             Standard_Real u1,v1,u2,v2; 
             myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2); 
 
-            if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
-              v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-              v1 >= Vm1  && v2 >= Vm2
+            if(u1 <= myMaxParam[0]  && u2 <= myMaxParam[2] && v1 <= myMaxParam[1] && 
+              v2 <= myMaxParam[3]  && u1 >= myMinParam[0] && u2 >= myMinParam[2] &&
+              v1 >= myMinParam[1]  && v2 >= myMinParam[3]
               pointisvalid = Standard_True;
 
             if(pointisvalid) {
@@ -1809,17 +1404,14 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
               // decrease step if out of bounds
               // otherwise the same calculations will be 
               // repeated several times
-              if ( ( u1 > UM1 ) || ( u1 < Um1 ) )
-                pasuv[0] *= 0.5;
-
-              if ( ( v1 > VM1 ) || ( v1 < Vm1 ) ) 
-                pasuv[1] *= 0.5;
-
-              if ( ( u2 > UM2 ) || ( u2 < Um2 ) )
-                pasuv[2] *= 0.5;
-
-              if ( ( v2 > VM2 ) || ( v2 < Vm2 ) )
-                pasuv[3] *= 0.5;
+              if (( u1 > myMaxParam[0] ) || ( u1 < myMinParam[0] ) ||
+                  ( v1 > myMaxParam[1] ) || ( v1 < myMinParam[1] ) ||
+                  ( u2 > myMaxParam[2] ) || ( u2 < myMinParam[2] ) ||
+                  ( v2 > myMaxParam[3] ) || ( v2 < myMinParam[3] ))
+              {
+                for(Standard_Integer i = 0; i < 4; i++)
+                  pasuv[i] *= myDecMultiplier;
+              }
             }
           } // end if(!bStop)
           else { //if(bStop)
@@ -1845,9 +1437,9 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
                 Standard_Real u1,v1,u2,v2; 
                 previousPoint.Parameters(u1,v1,u2,v2); 
 
-                if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
-                  v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                  v1 >= Vm1  && v2 >= Vm2
+                if(u1 <= myMaxParam[0]  && u2 <= myMaxParam[2] && v1 <= myMaxParam[1] && 
+                  v2 <= myMaxParam[3]  && u1 >= myMinParam[0] && u2 >= myMinParam[2] &&
+                  v1 >= myMinParam[1]  && v2 >= myMinParam[3]
                   pointisvalid = Standard_True;
 
                 if(pointisvalid) {
@@ -1895,14 +1487,14 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
         break;
     }
 
-    if(((u1 - Um1) < ResoU1) ||
-      ((UM1 - u1) < ResoU1) ||
-      ((u2 - Um2) < ResoU2) ||
-      ((UM2 - u2) < ResoU2) ||
-      ((v1 - Vm1) < ResoV1) ||
-      ((VM1 - v1) < ResoV1) ||
-      ((v2 - Vm2) < ResoV2) ||
-      ((VM2 - v2) < ResoV2))
+    if(((u1 - myMinParam[0]) < myReso[0]) ||
+      ((myMaxParam[0] - u1) < myReso[0]) ||
+      ((u2 - myMinParam[2]) < myReso[2]) ||
+      ((myMaxParam[2] - u2) < myReso[2]) ||
+      ((v1 - myMinParam[1]) < myReso[1]) ||
+      ((myMaxParam[1] - v1) < myReso[1]) ||
+      ((v2 - myMinParam[3]) < myReso[3]) ||
+      ((myMaxParam[3] - v2) < myReso[3]))
       bExtendLine = Standard_True;
   }
 
@@ -1912,8 +1504,7 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
       bExtendLine = Standard_True;
 
       if(aSeqOfNewPoint.Length() > 1) {
-        TColStd_Array1OfReal FirstParams(0, 3), LastParams(0, 3), Resolutions(0, 3);
-        Resolutions(0) = ResoU1; Resolutions(1) = ResoV1; Resolutions(2) = ResoU2; Resolutions(3) = ResoV2;
+        TColStd_Array1OfReal FirstParams(0, 3), LastParams(0, 3);
 
         aSeqOfNewPoint(1).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
           FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
@@ -2035,12 +1626,12 @@ DistanceMinimizeByGradient( const Handle(Adaptor3d_HSurface)& theASurf1,
 
   Handle(Geom_Surface) aS1, aS2;
 
-  if (theASurf1->GetType() != GeomAbs_BezierSurface &&
-      theASurf1->GetType() != GeomAbs_BSplineSurface)
-      return Standard_True;
-  if (theASurf2->GetType() != GeomAbs_BezierSurface &&
-      theASurf2->GetType() != GeomAbs_BSplineSurface)
-      return Standard_True;
+  //if (theASurf1->GetType() != GeomAbs_BezierSurface &&
+  //    theASurf1->GetType() != GeomAbs_BSplineSurface)
+  //    return Standard_True;
+  //if (theASurf2->GetType() != GeomAbs_BezierSurface &&
+  //    theASurf2->GetType() != GeomAbs_BSplineSurface)
+  //    return Standard_True;
 
   Standard_Boolean aStatus = Standard_False;
 
@@ -2769,112 +2360,39 @@ SeekAdditionalPoints( const Handle(Adaptor3d_HSurface)& theASurf1,
   return isPrecise;
 }
 
-void IntWalk_PWalking::
-RepartirOuDiviser(Standard_Boolean& DejaReparti,
-                  IntImp_ConstIsoparametric& ChoixIso,
-                  Standard_Boolean& Arrive) 
-
-                  // at the neighborhood of a point, there is a fail of marching 
-                  // it is required to divide the steps to try to continue
-                  // if the step is too small if we are on border
-                  // restart in another direction if it was not done, otherwise stop
-
+//=======================================================================
+//function : ContinueInAnotherDirection
+//purpose  : at the neighborhood of a point, there is a fail of marching 
+// it is required to divide the steps to try to continue
+// if the step is too small if we are on border
+// restart in another direction if it was not done, otherwise stop
+//=======================================================================
+void IntWalk_PWalking::ContinueInAnotherDirection(IntImp_ConstIsoparametric& ChoixIso) 
 {
-  //  Standard_Integer i;
-  if (Arrive) {    //restart in the other direction
-    if (!DejaReparti ) {
-      Arrive        = Standard_False; 
-      DejaReparti   = Standard_True;
-      previousPoint = line->Value(1);
-      previoustg    = Standard_False;
-      previousd1    = firstd1;
-      previousd2    = firstd2;
-      previousd     = tgdir;
-      indextg       = line->NbPoints();
-      tgdir.Reverse();
-      line->Reverse();
-
-      //-- printf("\nIntWalk_PWalking_2.gxx Reverse %3d\n",indextg);
-      sensCheminement = -1;
-      tgfirst      = tglast;
-      tglast       = Standard_False;
-      ChoixIso     = choixIsoSav;
-#if 0
-      pasuv[0]=pasSav[0];
-      pasuv[1]=pasSav[1];
-      pasuv[2]=pasSav[2];
-      pasuv[3]=pasSav[3];
-#else 
-      Standard_Real u1,v1,u2,v2;
-      Standard_Real U1,V1,U2,V2;
-      Standard_Integer nn=line->NbPoints();
-      if(nn>2) { 
-        line->Value(nn).Parameters(u1,v1,u2,v2);
-        line->Value(nn-1).Parameters(U1,V1,U2,V2);
-        pasuv[0]=Abs(u1-U1);
-        pasuv[1]=Abs(v1-V1);
-        pasuv[2]=Abs(u2-U2);
-        pasuv[3]=Abs(v2-V2);
-      }
-#endif
-
-    }
-  }  
-  else  {
-    if (    pasuv[0]*0.5 < ResoU1
-      &&  pasuv[1]*0.5 < ResoV1
-      &&  pasuv[2]*0.5 < ResoU2
-      &&  pasuv[3]*0.5 < ResoV2
-      ) {
-        if (!previoustg) {
-          tglast = Standard_True;      // IS IT ENOUGH ????
-        }
-
-        if (!DejaReparti) {  //restart in the other direction
-          DejaReparti       = Standard_True;
-          previousPoint     = line->Value(1);
-          previoustg        = Standard_False;
-          previousd1        = firstd1;
-          previousd2        = firstd2;
-          previousd         = tgdir;
-          indextg           = line->NbPoints();
-          tgdir.Reverse();
-          line->Reverse();
-
-          //-- printf("\nIntWalk_PWalking_2.gxx Reverse %3d\n",indextg);
-
-          sensCheminement   = -1;
-          tgfirst           = tglast;
-          tglast            = Standard_False;
-          ChoixIso          = choixIsoSav;
-
-#if 0 
-          pasuv[0]=pasSav[0];
-          pasuv[1]=pasSav[1];
-          pasuv[2]=pasSav[2];
-          pasuv[3]=pasSav[3];
-#else 
-          Standard_Real u1,v1,u2,v2;
-          Standard_Real U1,V1,U2,V2;
-          Standard_Integer nn=line->NbPoints();
-          if(nn>2) { 
-            line->Value(nn).Parameters(u1,v1,u2,v2);
-            line->Value(nn-1).Parameters(U1,V1,U2,V2);
-            pasuv[0]=Abs(u1-U1);
-            pasuv[1]=Abs(v1-V1);
-            pasuv[2]=Abs(u2-U2);
-            pasuv[3]=Abs(v2-V2);
-          }
-#endif
-        }
-        else Arrive = Standard_True;
-    }
-    else {
-      pasuv[0]*=0.5;
-      pasuv[1]*=0.5;
-      pasuv[2]*=0.5;
-      pasuv[3]*=0.5; 
-    }
+  previousPoint = line->Value(1);
+  previoustg    = Standard_False;
+  previousd1    = firstd1;
+  previousd2    = firstd2;
+  previousd     = tgdir;
+  indextg       = line->NbPoints();
+  tgdir.Reverse();
+  line->Reverse();
+
+  sensCheminement = -1;
+  tgfirst      = tglast;
+  tglast       = Standard_False;
+  ChoixIso     = choixIsoSav;
+  Standard_Real u1,v1,u2,v2;
+  Standard_Real U1,V1,U2,V2;
+  Standard_Integer nn=line->NbPoints();
+  if(nn>2)
+  { 
+    line->Value(nn).Parameters(u1,v1,u2,v2);
+    line->Value(nn-1).Parameters(U1,V1,U2,V2);
+    pasuv[0]=Abs(u1-U1);
+    pasuv[1]=Abs(v1-V1);
+    pasuv[2]=Abs(u2-U2);
+    pasuv[3]=Abs(v2-V2);
   }
 }
 
@@ -2901,12 +2419,8 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
 // test if there is no change of side
 //  
 {
-  if(line->NbPoints() ==1 ) { 
-    STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=STATIC_PRECEDENT_INFLEXION=0;
-  }
-
   IntWalk_StatusDeflection Status = IntWalk_OK;
-  Standard_Real FlecheCourante , Ratio = 1.0;
+  Standard_Real Ratio = 1.0;
 
   // Caro1 and Caro2
   const Handle(Adaptor3d_HSurface)& Caro1 = myIntersectionOn2S.Function().AuxillarSurface1();
@@ -2927,7 +2441,8 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
   //==================================================================================
   //=========   R i s k   o f    i n f l e x i o n   p o i n t  ============
   //==================================================================================  
-  if (aCosBetweenTangent < 0) {
+  if (aCosBetweenTangent < 0)
+  {
     //------------------------------------------------------------
     //-- Risk of inflexion point : Divide the step by 2
     //-- Initialize STATIC_PRECEDENT_INFLEXION so that 
@@ -2935,21 +2450,16 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
     //-- more risk of the point of inflexion
     //------------------------------------------------------------
 
-    pasuv[0]*=0.5;
-    pasuv[1]*=0.5;
-    pasuv[2]*=0.5;
-    pasuv[3]*=0.5;
-    STATIC_PRECEDENT_INFLEXION+=3; 
-    if (pasuv[0] < ResoU1 && pasuv[1] <ResoV1 && pasuv[2] <ResoU2 && pasuv[3] < ResoV2)
-      return IntWalk_ArretSurPointPrecedent;
-    else 
-      return IntWalk_PasTropGrand;
-  }
-  else {
-    if(STATIC_PRECEDENT_INFLEXION  > 0) { 
-      STATIC_PRECEDENT_INFLEXION -- ;
-      return IntWalk_OK;
+    Status = IntWalk_ArretSurPointPrecedent;
+    for(Standard_Integer i = 0; i < 4; i++)
+    {
+      pasuv[i]*=myDecMultiplier;
+
+      if(pasuv[i] > myReso[i])
+        Status = IntWalk_PasTropGrand;
     }
+
+    return Status;
   }
 
   //==================================================================================
@@ -2961,14 +2471,9 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
 
 
   if (aSqDist < Precision::SquareConfusion()) { 
-    pasInit[0] = Max(pasInit[0], 5.0*ResoU1);
-    pasInit[1] = Max(pasInit[1], 5.0*ResoV1);
-    pasInit[2] = Max(pasInit[2], 5.0*ResoU2);
-    pasInit[3] = Max(pasInit[3], 5.0*ResoV2);
-
     for(Standard_Integer i = 0; i < 4; i++)
     {
-      pasuv[i] = Max(pasuv[i], Min(1.5*pasuv[i], pasInit[i]));
+      pasuv[i] = Max(pasuv[i], Min(myIncMultiplier*pasuv[i], pasInit[i]));
     }
     //Compute local resolution: for OCC26717
     if (Abs(pasuv[choixIso] - pasInit[choixIso]) <= Precision::Confusion())
@@ -3040,19 +2545,24 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
   //=================================================================================
   //====   S t e p   o f   p  r o g r e s s i o n (between previous and Current)   =======
   //=================================================================================
-  if (   AbsDu1 < ResoU1 && AbsDv1 < ResoV1 
-    && AbsDu2 < ResoU2 && AbsDv2 < ResoV2) {
-      pasuv[0] = ResoU1; pasuv[1] = ResoV1; pasuv[2] = ResoU2; pasuv[3] = ResoV2;
+  if (   AbsDu1 < myReso[0] && AbsDv1 < myReso[1] && AbsDu2 < myReso[2] && AbsDv2 < myReso[3])
+  {
+      for(Standard_Integer  i = 0; i < 4; i++)
+        pasuv[i] = myReso[i];
+
       return(IntWalk_ArretSurPointPrecedent);
   }
   //==================================================================================
 
   Standard_Real tolArea = 100.0;
-  if (ResoU1 < Precision::PConfusion() ||
-    ResoV1 < Precision::PConfusion() ||
-    ResoU2 < Precision::PConfusion() ||
-    ResoV2 < Precision::PConfusion() )
-    tolArea =  tolArea*2.0;
+  for(Standard_Integer  i = 0; i < 4; i++)
+  {
+    if (myReso[i] < Precision::PConfusion())
+    {
+      tolArea =  tolArea*2.0;
+      break;
+    }
+  }
 
   Standard_Real Cosi1, CosRef1, Ang1, AngRef1, ResoUV1, Duv1, d1, tolCoeff1;   
   Standard_Real Cosi2, CosRef2, Ang2, AngRef2, ResoUV2, Duv2, d2, tolCoeff2;   
@@ -3060,8 +2570,8 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
   Cosi2 = Du2*previousd2.X() + Dv2*previousd2.Y();
   Duv1 = Du1*Du1 + Dv1*Dv1;
   Duv2 = Du2*Du2 + Dv2*Dv2;
-  ResoUV1 = ResoU1*ResoU1 + ResoV1*ResoV1;
-  ResoUV2 = ResoU2*ResoU2 + ResoV2*ResoV2;
+  ResoUV1 = myReso[0]*myReso[0] + myReso[1]*myReso[1];
+  ResoUV2 = myReso[2]*myReso[2] + myReso[3]*myReso[3];
   //
   //modified by NIZNHY-PKV Wed Nov 13 12:25:44 2002 f
   //
@@ -3098,16 +2608,17 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
   //==                           C h a n g e    o f    s i d e                ==
   //==================================================================================
   if (Status != IntWalk_PointConfondu) { 
-    if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2) {
-      pasuv[0]*=0.5;  pasuv[1]*=0.5;  pasuv[2]*=0.5;  pasuv[3]*=0.5;
-      if (pasuv[0]<ResoU1 && pasuv[1]<ResoV1 && pasuv[2]<ResoU2 && pasuv[3]<ResoV2) { 
-        return(IntWalk_ArretSurPointPrecedent);
-      }
-      else {
-        pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
-        return(IntWalk_PasTropGrand);
+    if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2)
+    {
+      for(Standard_Integer i = 0; i < 4; i++)
+      {
+        if(pasuv[i] > 2.0*myReso[i])
+          return IntWalk_AnotherDirection;
       }
+
+      return IntWalk_ArretSurPointPrecedent;
     }
+
     const gp_Dir2d& Tg2dcourante1 = myIntersectionOn2S.DirectionOnS1();
     const gp_Dir2d& Tg2dcourante2 = myIntersectionOn2S.DirectionOnS2();
     Cosi1 = Du1*Tg2dcourante1.X() + Dv1*Tg2dcourante1.Y();
@@ -3120,12 +2631,15 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
     //-- Test : Angle too great in space UV       -----
     //--        Change of  side                      -----
     //-------------------------------------------------------
-    if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2 || Ang1 > AngRef1 || Ang2 > AngRef2) {
-      pasuv[0]*=0.5;  pasuv[1]*=0.5;  pasuv[2]*=0.5;  pasuv[3]*=0.5;
-      if (pasuv[0]<ResoU1 && pasuv[1]<ResoV1 && pasuv[2]<ResoU2 && pasuv[3]<ResoV2) 
-        return(IntWalk_ArretSurPoint);
-      else 
-        return(IntWalk_PasTropGrand);
+    if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2 || Ang1 > AngRef1 || Ang2 > AngRef2)
+    {
+      for(Standard_Integer i = 0; i < 4; i++)
+      {
+        if(pasuv[i] > 2.0*myReso[i])
+          return IntWalk_AnotherDirection;
+      }
+
+      return IntWalk_ArretSurPoint;
     }
   }
   //<-OCC431(apo)
@@ -3137,74 +2651,6 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
   //---------------------------------------
   //-- Estimate of the vector           --
   //---------------------------------------
-  FlecheCourante =
-    Sqrt(Abs((previousd.XYZ()-TgCourante.XYZ()).SquareModulus()*aSqDist))/8.;
-
-  if ( FlecheCourante<= fleche*0.5) {     //-- Current step too small
-    if(FlecheCourante>1e-16) { 
-      Ratio = 0.5*(fleche/FlecheCourante);
-    }
-    else { 
-      Ratio = 10.0;
-    }
-    Standard_Real pasSu1 = pasuv[0];
-    Standard_Real pasSv1 = pasuv[1];
-    Standard_Real pasSu2 = pasuv[2];
-    Standard_Real pasSv2 = pasuv[3];
-
-    //-- In  case if 
-    //-- a point at U+DeltaU is required, ....
-    //-- return a point at U + Epsilon
-    //-- Epsilon << DeltaU.
-
-    if(pasuv[0]< AbsDu1) pasuv[0] = AbsDu1;
-    if(pasuv[1]< AbsDv1) pasuv[1] = AbsDv1;
-    if(pasuv[2]< AbsDu2) pasuv[2] = AbsDu2;
-    if(pasuv[3]< AbsDv2) pasuv[3] = AbsDv2;
-
-    if(pasuv[0]<ResoU1) pasuv[0]=ResoU1;
-    if(pasuv[1]<ResoV1) pasuv[1]=ResoV1;
-    if(pasuv[2]<ResoU2) pasuv[2]=ResoU2;
-    if(pasuv[3]<ResoV2) pasuv[3]=ResoV2;
-    //-- if(Ratio>10.0 ) { Ratio=10.0; } 
-    Standard_Real R1,R = pasInit[0]/pasuv[0];
-    R1= pasInit[1]/pasuv[1];     if(R1<R) R=R1;
-    R1= pasInit[2]/pasuv[2];     if(R1<R) R=R1;
-    R1= pasInit[3]/pasuv[3];     if(R1<R) R=R1;
-    if(Ratio > R) Ratio=R;
-    pasuv[0] = Min(Ratio*pasuv[0],pasInit[0]);
-    pasuv[1] = Min(Ratio*pasuv[1],pasInit[1]);
-    pasuv[2] = Min(Ratio*pasuv[2],pasInit[2]);
-    pasuv[3] = Min(Ratio*pasuv[3],pasInit[3]);
-    if (pasuv[0] != pasSu1 || pasuv[2] != pasSu2|| 
-      pasuv[1] != pasSv1 || pasuv[3] != pasSv2) {
-        if(++STATIC_BLOCAGE_SUR_PAS_TROP_GRAND > 5) {
-          STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0;
-          return IntWalk_PasTropGrand; 
-        }
-    }
-    if(Status == IntWalk_OK) { 
-      STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=0;
-      //-- Try to increase the step
-    }
-    return Status;
-  }
-  else {                                //-- CurrentVector > vector*0.5 
-    if (FlecheCourante > fleche) {      //-- Current step too Great
-      Ratio = fleche/FlecheCourante; 
-      pasuv[0] = Ratio*pasuv[0];
-      pasuv[1] = Ratio*pasuv[1];
-      pasuv[2] = Ratio*pasuv[2];
-      pasuv[3] = Ratio*pasuv[3];
-      //if(++STATIC_BLOCAGE_SUR_PAS_TROP_GRAND > 5) {
-      //       STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0;
-      return IntWalk_PasTropGrand; 
-      //}
-    }
-    else {                             //-- vector/2  <  CurrentVector <= vector   
-      Ratio = 0.75 * (fleche / FlecheCourante);
-    }
-  }
 
   if(Status != IntWalk_PointConfondu)
   {
@@ -3271,9 +2717,10 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
     const Standard_Real anInvSqAbsArcDeflMax = 0.25*aSqDist/(tolconf*tolconf);
     const Standard_Real aSinB2Max = 1.0 - 2.0/(1.0 + anInvSqAbsArcDeflMax);
 
-    if(aSinB2Max >= 0.0 && (aCosBetweenTangent <= 2.0 * aSinB2Max * aSinB2Max - 1.0))
+    if(aSinB2Max >= 0.0 && (aCosBetweenTangent < 2.0 * aSinB2Max * aSinB2Max - 1.0))
     {//Real deflection is greater or equal than tolconf
-      Status = IntWalk_PasTropGrand;
+      //pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
+      return IntWalk_PasTropGrand;
     }
     else
     {//Real deflection is less than tolconf
@@ -3282,38 +2729,18 @@ IntWalk_StatusDeflection  IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
 
       if((aSinB2Min < 0.0) || (aCosBetweenTangent >= 2.0 * aSinB2Min * aSinB2Min - 1.0))
       {//Real deflection is less than tolconf/2.0
-        Status = IntWalk_StepTooSmall;
+        return IntWalk_StepTooSmall;
       }
     }
-
-    if(Status == IntWalk_PasTropGrand)
-    {
-      pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
-      return Status;
-    }
-
-    if(Status == IntWalk_StepTooSmall)
-    {
-      pasuv[0] = Max(pasuv[0], AbsDu1);
-      pasuv[1] = Max(pasuv[1], AbsDv1);
-      pasuv[2] = Max(pasuv[2], AbsDu2);
-      pasuv[3] = Max(pasuv[3], AbsDv2);
-
-      pasInit[0] = Max(pasInit[0], AbsDu1);
-      pasInit[1] = Max(pasInit[1], AbsDv1);
-      pasInit[2] = Max(pasInit[2], AbsDu2);
-      pasInit[3] = Max(pasInit[3], AbsDv2);
-
-      return Status;
-    }
+  }
+  else
+  {
+    pasuv[0] = Max(myStepMin[0],Min(Min(Ratio*AbsDu1,pasuv[0]),pasInit[0]));
+    pasuv[1] = Max(myStepMin[1],Min(Min(Ratio*AbsDv1,pasuv[1]),pasInit[1]));
+    pasuv[2] = Max(myStepMin[2],Min(Min(Ratio*AbsDu2,pasuv[2]),pasInit[2]));
+    pasuv[3] = Max(myStepMin[3],Min(Min(Ratio*AbsDv2,pasuv[3]),pasInit[3]));
   }
 
-  pasuv[0] = Max(myStepMin[0],Min(Min(Ratio*AbsDu1,pasuv[0]),pasInit[0]));
-  pasuv[1] = Max(myStepMin[1],Min(Min(Ratio*AbsDv1,pasuv[1]),pasInit[1]));
-  pasuv[2] = Max(myStepMin[2],Min(Min(Ratio*AbsDu2,pasuv[2]),pasInit[2]));
-  pasuv[3] = Max(myStepMin[3],Min(Min(Ratio*AbsDv2,pasuv[3]),pasInit[3]));
-
-  if(Status == IntWalk_OK) STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=0;
   return Status;
 }
 
@@ -3330,13 +2757,9 @@ TestArret(const Standard_Boolean DejaReparti,
           // otherwise test if closed line is present  
           // 
 {
-  Standard_Real Uvd[4],Uvf[4],Epsuv[4],Duv[4],Uvp[4],dv,dv2,ParC[4];
+  Standard_Real Uvd[4],Uvf[4],Duv[4],Uvp[4],dv,dv2,ParC[4];
   Standard_Real DPc,DPb;
   Standard_Integer i = 0, k = 0;
-  Epsuv[0] = ResoU1;
-  Epsuv[1] = ResoV1;
-  Epsuv[2] = ResoU2;
-  Epsuv[3] = ResoV2;
   previousPoint.Parameters(Uvp[0],Uvp[1],Uvp[2],Uvp[3]);
 
   Standard_Real SolParam[4];
@@ -3344,8 +2767,8 @@ TestArret(const Standard_Boolean DejaReparti,
 
   Standard_Boolean Trouve = Standard_False;
 
-  Uvd[0]=Um1;   Uvf[0]=UM1;   Uvd[1]=Vm1;   Uvf[1]=VM1;
-  Uvd[2]=Um2;   Uvf[2]=UM2;   Uvd[3]=Vm2;   Uvf[3]=VM2;
+  Uvd[0]=myMinParam[0];   Uvf[0]=myMaxParam[0];   Uvd[1]=myMinParam[1];   Uvf[1]=myMaxParam[1];
+  Uvd[2]=myMinParam[2];   Uvf[2]=myMaxParam[2];   Uvd[3]=myMinParam[3];   Uvf[3]=myMaxParam[3];
 
   Standard_Integer im1;
   for ( i = 1,im1 = 0;i<=4;i++,im1++) {
@@ -3355,8 +2778,8 @@ TestArret(const Standard_Boolean DejaReparti,
     case 3: k=4; break;
     case 4: k=3; break;
     }
-    if (Param(i) < (Uvd[im1]-Epsuv[im1]) ||
-      SolParam[im1] < (Uvd[im1]-Epsuv[im1]))     //--     Current -----  Bound Inf -----  Previous
+    if (Param(i) < (Uvd[im1]-myReso[im1]) ||
+      SolParam[im1] < (Uvd[im1]-myReso[im1]))     //--     Current -----  Bound Inf -----  Previous
     {
       Trouve    = Standard_True;                   //-- 
       DPc       = Uvp[im1]-Param(i);               //--     Previous  - Current
@@ -3372,8 +2795,8 @@ TestArret(const Standard_Boolean DejaReparti,
         Duv[im1]=-1.0;                              //--    If no progress, do not change  
       }                                             //--    the choice of iso 
     }   
-    else if (Param(i) > (Uvf[im1] + Epsuv[im1]) ||
-      SolParam[im1] > (Uvf[im1] + Epsuv[im1]))//--    Previous -----  Bound Sup -----  Current
+    else if (Param(i) > (Uvf[im1] + myReso[im1]) ||
+      SolParam[im1] > (Uvf[im1] + myReso[im1]))//--    Previous -----  Bound Sup -----  Current
     {
       Trouve    = Standard_True;                    //-- 
       DPc       = Param(i)-Uvp[im1];                //--     Current   - Previous
@@ -3415,17 +2838,13 @@ TestArret(const Standard_Boolean DejaReparti,
       ChoixIso   = ChoixRef[k];
     }
     else { 
-      if((ParC[0]<=Uvd[0]+Epsuv[0]) || (ParC[0]>=Uvf[0]-Epsuv[0])) {
-        ChoixIso = IntImp_UIsoparametricOnCaro1;
-      }
-      else if((ParC[1]<=Uvd[1]+Epsuv[1]) || (ParC[1]>=Uvf[1]-Epsuv[1])) {
-        ChoixIso = IntImp_VIsoparametricOnCaro1;
-      }
-      else if((ParC[2]<=Uvd[2]+Epsuv[2]) || (ParC[2]>=Uvf[2]-Epsuv[2])) {
-        ChoixIso = IntImp_UIsoparametricOnCaro2;
-      }
-      else if((ParC[3]<=Uvd[3]+Epsuv[3]) || (ParC[3]>=Uvf[3]-Epsuv[3])) {
-        ChoixIso = IntImp_VIsoparametricOnCaro2;
+      for(Standard_Integer i = 0; i < 4; i++)
+      {
+        if((ParC[i]<=Uvd[i]+myReso[i]) || (ParC[i]>=Uvf[0]-myReso[i]))
+        {
+          ChoixIso = static_cast<IntImp_ConstIsoparametric> (i);
+          break;
+        }
       }
     }
     close = Standard_False;
index 9dd8ecb6adcc8e2ea782dd561fbd657b400c4f59..6eee84ec28f3995a5f34afb55d020edd6445aa8c 100644 (file)
@@ -66,7 +66,7 @@ public:
   //! border of one of the domains. If an open line
   //! stops at the middle of a domain, one stops at the tangent point.
   //! Epsilon is SquareTolerance of points confusion.
-  Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_HSurface)& Caro2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment);
+  Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_HSurface)& Caro2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection);
   
   //! Returns the intersection line containing the exact
   //! point Poin. This line is a polygonal line.
@@ -81,7 +81,7 @@ public:
   //! border of one of the domains. If an open line
   //! stops at the middle of a domain, one stops at the tangent point.
   //! Epsilon is SquareTolerance of points confusion.
-  Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_HSurface)& Caro2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real Increment, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2);
+  Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1, const Handle(Adaptor3d_HSurface)& Caro2, const Standard_Real TolTangency, const Standard_Real Epsilon, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2);
   
   //! calculate the line of intersection
   Standard_EXPORT void Perform (const TColStd_Array1OfReal& ParDep);
@@ -126,32 +126,40 @@ public:
   
     const gp_Dir& TangentAtLine (Standard_Integer& Index) const;
   
-  Standard_EXPORT   IntWalk_StatusDeflection TestDeflection (const IntImp_ConstIsoparametric ChoixIso) ;
-  
-  Standard_EXPORT Standard_Boolean TestArret (const Standard_Boolean DejaReparti, TColStd_Array1OfReal& Param, IntImp_ConstIsoparametric& ChoixIso);
-  
-  Standard_EXPORT void RepartirOuDiviser (Standard_Boolean& DejaReparti, IntImp_ConstIsoparametric& ChoixIso, Standard_Boolean& Arrive);
-  
-    void AddAPoint (Handle(IntSurf_LineOn2S)& line, const IntSurf_PntOn2S& POn2S);
+  void AddAPoint (Handle(IntSurf_LineOn2S)& line, const IntSurf_PntOn2S& POn2S);
   
   Standard_EXPORT Standard_Boolean PutToBoundary (const Handle(Adaptor3d_HSurface)& theASurf1, const Handle(Adaptor3d_HSurface)& theASurf2);
   
   Standard_EXPORT Standard_Boolean SeekAdditionalPoints (const Handle(Adaptor3d_HSurface)& theASurf1, const Handle(Adaptor3d_HSurface)& theASurf2, const Standard_Integer theMinNbPoints);
 
-  Standard_Real MaxStep(Standard_Integer theIndex)
+  Standard_Real Step(Standard_Integer theIndex) const
   {
     Standard_OutOfRange_Raise_if((theIndex < 0) || (theIndex > 3), "");
-    return pasInit[theIndex];
+    return myRelMaxStep*pasInit[theIndex];
   }
 
+  Standard_Real MaxStep(void) const
+  {
+    Standard_Real aRetVal = pasInit[0];
+
+    for(Standard_Integer  i = 1; i < 4; i++)
+      aRetVal = Max(aRetVal, pasInit[i]);
+
+    return myRelMaxStep*aRetVal;
+  }
 
 
 protected:
+  IntWalk_PWalking operator=(const IntWalk_PWalking&);
+
   Standard_EXPORT void ComputePasInit(const Standard_Real theDeltaU1,
                                       const Standard_Real theDeltaV1,
                                       const Standard_Real theDeltaU2,
                                       const Standard_Real theDeltaV2);
 
+  Standard_EXPORT   IntWalk_StatusDeflection TestDeflection (const IntImp_ConstIsoparametric ChoixIso) ;
+
+  Standard_EXPORT Standard_Boolean TestArret (const Standard_Boolean DejaReparti, TColStd_Array1OfReal& Param, IntImp_ConstIsoparametric& ChoixIso);
   //! Uses Gradient method in order to find intersection point between the given surfaces
   //! Arrays theInit (initial point to be precise) and theStep0 (steps-array) must contain
   //! four items and must be filled strictly in following order:
@@ -161,6 +169,7 @@ protected:
                                                               TColStd_Array1OfReal& theInit,
                                                               const Standard_Real* theStep0 = 0);
   
+
   //! Finds the point on theASurf which is the nearest point to theP0.
   //! theU0 and theV0 must be initialized (before calling the method) by initial
   //! parameters on theASurf. Their values are changed while algorithm being launched.
@@ -172,6 +181,7 @@ protected:
                                                               Standard_Real& theV0,
                                                               const Standard_Real* theStep0 = 0);
   
+
   //! Searches an intersection point which lies on the some surface boundary.
   //! Found point (in case of successful result) is added in the line.
   //! theU1, theV1, theU2 and theV2 parameters are initial parameters in
@@ -191,6 +201,8 @@ protected:
                                                         const Standard_Real theV2,
                                                         const Standard_Boolean isTheFirst);
 
+  Standard_EXPORT IntWalk_StatusDeflection IntersPerform(const Standard_Boolean theIsForceAdd, IntImp_ConstIsoparametric& theInitIsoChoosen, math_FunctionSetRoot& theRSFunc, Standard_Real theDeltaParam[4]);
+  Standard_EXPORT void ContinueInAnotherDirection(IntImp_ConstIsoparametric& ChoixIso);
 
   // Method to handle single singular point. Sub-method in SeekPointOnBoundary.
   Standard_EXPORT Standard_Boolean HandleSingleSingularPoint(const Handle(Adaptor3d_HSurface) &theASurf1,
@@ -198,10 +210,12 @@ protected:
                                                              const Standard_Real the3DTol,
                                                              TColStd_Array1OfReal &thePnt);
   
+  
   Standard_EXPORT Standard_Boolean ExtendLineInCommonZone (const IntImp_ConstIsoparametric theChoixIso,
                                                            const Standard_Boolean theDirectionFlag);
 
 private:
+
   Standard_Boolean done;
   Handle(IntSurf_LineOn2S) line;
   Standard_Boolean close;
@@ -210,25 +224,18 @@ private:
   Standard_Integer indextg;
   gp_Dir tgdir;
   Standard_Real fleche;
-  Standard_Real pasMax;
   Standard_Real tolconf;
   Standard_Real myTolTang;
   Standard_Real pasuv[4];
+  const Standard_Real myRelMaxStep;
+  const Standard_Real myIncMultiplier;
+  const Standard_Real myDecMultiplier;
   Standard_Real myStepMin[4];
   Standard_Real pasSav[4];
-  Standard_Real pasInit[4];
-  Standard_Real Um1;
-  Standard_Real UM1;
-  Standard_Real Vm1;
-  Standard_Real VM1;
-  Standard_Real Um2;
-  Standard_Real UM2;
-  Standard_Real Vm2;
-  Standard_Real VM2;
-  Standard_Real ResoU1;
-  Standard_Real ResoU2;
-  Standard_Real ResoV1;
-  Standard_Real ResoV2;
+  Standard_Real pasInit[4]; // Should be constant while algorithm working
+  Standard_Real myMaxParam[4]; //[0] = UM1, [1] = VM1, [2] = UM2, [3] = VM2
+  Standard_Real myMinParam[4]; //[0] = Um1, [1] = Vm1, [2] = Um2, [3] = Vm2
+  Standard_Real myReso[4]; //[0] = ResoU1, [1] = ResoV1, [2] = ResoU2, [3] = ResoV2
   Standard_Integer sensCheminement;
   IntImp_ConstIsoparametric choixIsoSav;
   IntSurf_PntOn2S previousPoint;
@@ -239,10 +246,6 @@ private:
   gp_Dir2d firstd1;
   gp_Dir2d firstd2;
   IntWalk_TheInt2S myIntersectionOn2S;
-  Standard_Integer STATIC_BLOCAGE_SUR_PAS_TROP_GRAND;
-  Standard_Integer STATIC_PRECEDENT_INFLEXION;
-
-
 };
 
 
index 9c18ffbab20b34d9dd5e7b471184a8e31148f5e7..be220e6657a9e7c34ab1e03fabc34afe3e4627fe 100644 (file)
@@ -25,6 +25,12 @@ IntWalk_StepTooSmall,
 IntWalk_PointConfondu,
 IntWalk_ArretSurPointPrecedent,
 IntWalk_ArretSurPoint,
+IntWalk_IntersectsBoundary,
+IntWalk_IntersectPointNotFound,
+IntWalk_TooManyPoints,
+IntWalk_AnotherDirection,
+IntWalk_DirectionNotFound,
+IntWalk_ForcefulAdding,
 IntWalk_OK
 };
 
index 01ed90a28896dd42625c2946c1a996ff2462f483..867638a520ff352365aeed7d35adcfe165d8db1d 100644 (file)
@@ -195,8 +195,9 @@ void TopOpeBRep_FacesIntersector::Perform(const TopoDS_Shape& F1,const TopoDS_Sh
   if (TopOpeBRepTool_GettraceKRO()) KRO_DSFILLER_INTFF.Start();
 #endif
 
-  Standard_Real Deflection=0.01,MaxUV=0.01;
+  Standard_Real Deflection=0.01;
   if (!myForceTolerances) {
+    Standard_Real MaxUV;
     FTOL_FaceTolerances3d(B1,B2,myFace1,myFace2,S1,S2,
                                myTol1,myTol2,Deflection,MaxUV);  
     myTol1 = (myTol1 > 1.e-4)? 1.e-4: myTol1;
@@ -211,11 +212,10 @@ void TopOpeBRep_FacesIntersector::Perform(const TopoDS_Shape& F1,const TopoDS_Sh
   if (TopOpeBRep_GettraceFITOL()) {
     cout<<"FacesIntersector : Perform tol1 = "<<tol1<<endl;
     cout<<"                           tol2 = "<<tol2<<endl;
-    cout<<"                           defl = "<<Deflection<<"  MaxUV = "<<MaxUV<<endl;
   }
 #endif
 
-  myIntersector.SetTolerances(myTol1,myTol2,MaxUV,Deflection); 
+  myIntersector.SetTolerances(myTol1,myTol2,Deflection); 
   myIntersector.Perform(mySurface1,myDomain1,mySurface2,myDomain2,
                         myTol1,myTol2,Standard_True,Standard_True,
                         Standard_False);
index fb3ff15aeab3e48f780be95094267168c064e815..839f30125fbc5115e3458d5799bad72e2dbc85c8 100644 (file)
@@ -1,3 +1,5 @@
+puts "TODO OCCT ALL: Faulty shapes in variables faulty_1 to faulty_4"
+
 # Original bug : fra60810
 # Date : 30mar98
 
@@ -7,3 +9,23 @@ restore [locate_data_file CTO900_fra60810-tool.rle] tool
 bcut result part tool
 checkprops result -s 30948.9
 checkview -display result -2d -s -otherwise { part tool } -path ${imagedir}/${test_image}.png
+
+
+############
+# This fragment should be deleted later.
+# It is used for regression explanation. Intersection result seems to be valid.
+
+restore [locate_data_file CTO900_fra60810-part.rle] part
+restore [locate_data_file CTO900_fra60810-tool.rle] tool
+
+explode part f
+explode tool f
+
+donly part_9 part_10 part_23 part_24 tool_4 tool_13
+bclearobjects
+bcleartools
+baddobjects part_9 part_10 part_23 part_24
+baddtools tool_4 tool_13
+bfillds
+bbop rr 4
+
index 2c8a64a6ec66e5558426564bb6478fc835ba276f..610437c99fe1fe072f0d1ff22025bee7eafd1d75 100644 (file)
@@ -4,5 +4,11 @@ explode m
 compound m_2 m_3 m_4 m_5 c1
 
 bcut result m_1 c1
+
+set log [bopargcheck result #F]
+if { [string compare -nocase $log "Shape(s) seem(s) to be valid for BOP.\n"] } {
+  puts "ERROR. result is not valid for BOP"
+}
+
 checkprops result -s 57618.4
 checkview -display result -2d -s -otherwise { m_1 c1 } -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_6/bug23914 b/tests/bugs/modalg_6/bug23914
new file mode 100644 (file)
index 0000000..65e45f8
--- /dev/null
@@ -0,0 +1,41 @@
+puts "========"
+puts "OCC23914"
+puts "========"
+puts ""
+#################################
+# Intersection algorithm produced too many intersection points
+#################################
+
+set max_time 0.05
+
+bsplinesurf s1 1 2 0 2 1000 2 1 2 200 2 2000 2 100 300 200 1 400 300 200 1 100 300 500 1 400 300 500 1
+bsplinesurf s2 1 2 0 2 100 2 1 2 500 2 1000 2 100 200 400 1 500 200 400 1 100 600 400 1 500 600 400 1
+
+dchrono cr reset
+dchrono cr start
+
+intersect result s1 s2 -npp
+# Only one curve must be found
+
+dchrono cr stop
+
+set chrono_info [dchrono cr show]
+regexp {CPU user time: ([-0-9.+eE]+) seconds} $chrono_info full CPU_time
+if { $CPU_time > ${max_time} } {
+  puts "CPU user time of Boolean operation is more than ${max_time} seconds - Error"
+} else {
+  puts "CPU user time of Boolean operation is less than ${max_time} seconds - OK"
+}
+
+mkedge ee result
+checkprops ee -l 300
+
+bounds result t1 t2
+xdistcs result s1 t1 t2 10 1.0e-7
+xdistcs result s2 t1 t2 10 1.0e-7
+
+smallview 
+donly s1 s2 result
+fit
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file
index d235965ee4cdbbb01e31e7c3cbfe4fe5468a421e..61ad4d4a1e3d360b5c2d01933bf62c3d3f97ca05 100755 (executable)
@@ -12,7 +12,7 @@ set U2 0.01131870392278708
 set V1 226.9760100729095
 set V2 203.7283534809051
 
-intersect result su1 su2 $U1 $V1 $U2 $V2
+intersect result su1 su2 -sp $U1 $V1 $U2 $V2
 
 set che [whatis result]