0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / IntStart / IntStart_SearchOnBoundaries.gxx
old mode 100755 (executable)
new mode 100644 (file)
index 164e2be..2aa7330
@@ -1,22 +1,18 @@
 // Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
+#include <algorithm>
 #include <TopoDS_Edge.hxx>
 #include <Geom_Curve.hxx>
 #include <BRepAdaptor_Curve.hxx>
 
 #include <Precision.hxx>
 #include <IntSurf_Quadric.hxx>
+#include <math_Function.hxx>
+#include <math_BrentMinimum.hxx>
+#include <math_Matrix.hxx>
+#include <math_Vector.hxx>
+#include <NCollection_Array1.hxx>
 
 static void FindVertex (const TheArc&,
                         const Handle(TheTopolTool)&,
@@ -64,17 +65,6 @@ static void BoundedArc (const TheArc& A,
                         Standard_Boolean& Arcsol,
                         const Standard_Boolean RecheckOnRegularity);
                  
-static void InfiniteArc (const TheArc&,
-                         const Handle(TheTopolTool)&,
-                         const Standard_Real,
-                         const Standard_Real,
-                         TheFunction&,
-                         IntStart_SequenceOfPathPoint&,
-                         IntStart_SequenceOfSegment&,
-                         const Standard_Real,
-                         const Standard_Real,
-                         Standard_Boolean&);
-
 static void PointProcess (const gp_Pnt&,
                           const Standard_Real,
                           const TheArc&,
@@ -92,6 +82,33 @@ static Standard_Integer TreatLC (const TheArc& A,
 static Standard_Boolean IsRegularity(const TheArc& A,
                                      const Handle(TheTopolTool)& aDomain);
 
+class MinFunction : public math_Function
+{
+public:
+  MinFunction(TheFunction &theFunc) : myFunc(&theFunc) {};
+
+  //returns value of the one-dimension-function when parameter
+  //is equal to theX
+  virtual Standard_Boolean Value(const Standard_Real theX,
+                                 Standard_Real& theFVal)
+  {
+    if(!myFunc->Value(theX, theFVal))
+      return Standard_False;
+
+    theFVal *= theFVal;
+    return Standard_True;
+  }
+
+  //see analogical method for abstract owner class math_Function
+  virtual Standard_Integer GetStateNumber()
+  {
+    return 0;
+  }
+
+private:
+  TheFunction *myFunc;
+};
+
 
 //=======================================================================
 //function : FindVertex
@@ -132,6 +149,54 @@ void FindVertex (const TheArc& A,
   }
 }
 
+class SolInfo
+{
+public:
+  SolInfo() : myMathIndex(-1), myValue(RealLast())
+  {
+  }
+
+  void Init(const math_FunctionAllRoots& theSolution, const Standard_Integer theIndex)
+  {
+    myMathIndex = theIndex;
+    myValue = theSolution.GetPoint(theIndex);
+  }
+
+  Standard_Real Value() const
+  {
+    return myValue;
+  }
+
+  Standard_Integer Index() const
+  {
+    return myMathIndex;
+  }
+
+  bool operator>(const SolInfo& theOther) const
+  {
+    return myValue > theOther.myValue;
+  }
+
+  bool operator<(const SolInfo& theOther) const
+  {
+    return myValue < theOther.myValue;
+  }
+
+  bool operator==(const SolInfo& theOther) const
+  {
+    return myValue == theOther.myValue;
+  }
+
+  Standard_Real& ChangeValue()
+  {
+    return myValue;
+  }
+
+private:
+  Standard_Integer myMathIndex;
+  Standard_Real myValue;
+};
+
 static
 void BoundedArc (const TheArc& A,
                  const Handle(TheTopolTool)& Domain,
@@ -145,18 +210,17 @@ void BoundedArc (const TheArc& A,
                  Standard_Boolean& Arcsol,
                  const Standard_Boolean RecheckOnRegularity)
 {
-  
-// Recherche des points solutions et des bouts d arc solution sur un arc donne.
-// On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour
-// des arcs ayant un point debut et un point de fin (intervalle ferme de
-// parametrage).
+  // Recherche des points solutions et des bouts d arc solution sur un arc donne.
+  // On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour
+  // des arcs ayant un point debut et un point de fin (intervalle ferme de
+  // parametrage).
 
   Standard_Integer i,Nbi,Nbp;
 
   gp_Pnt ptdeb,ptfin;
   Standard_Real pardeb = 0., parfin = 0.;
   Standard_Integer ideb,ifin,range,ranged,rangef;
-  
+
 
   // Creer l echantillonage (math_FunctionSample ou classe heritant)
   // Appel a math_FunctionAllRoots
@@ -172,10 +236,10 @@ void BoundedArc (const TheArc& A,
   //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-  
-//  Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A); 
+
+  //  Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A); 
   Standard_Integer NbEchant = Func.NbSamples(); 
-  
+
   //-- Modif 24  Aout 93 -----------------------------
   Standard_Real nTolTangency = TolTangency;
   if((Pfin - Pdeb) < (TolTangency*10.0)) { 
@@ -192,13 +256,12 @@ void BoundedArc (const TheArc& A,
   //-- if(NbEchant<3) NbEchant = 3; //-- lbr le 19 Avril 95
   //--------------------------------------------------
   Standard_Real para=0,dist,maxdist;
-/*  if(NbEchant<20) NbEchant = 20; //-- lbr le 22 Avril 96 
-                                 //-- Toujours des pbs 
-*/
-   if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96 
-                                  //-- Toujours des pbs 
-
-
+  /*  if(NbEchant<20) NbEchant = 20; //-- lbr le 22 Avril 96 
+  //-- Toujours des pbs 
+  */
+  if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96 
+  //-- Toujours des pbs 
+  
   //-------------------------------------------------------------- REJECTIONS le 15 oct 98 
   Standard_Boolean Rejection=Standard_True;  
   Standard_Real maxdr,maxr,minr,ur,dur;
@@ -219,23 +282,26 @@ void BoundedArc (const TheArc& A,
       if(lmaxr>maxr) maxr=lmaxr;
       if(minr<0.0 && maxr>0.0)  {
         Rejection=Standard_False;
-        continue;
+        break;
       }
     }
     ur+=dur;
   }
-  dur=0.001+maxdr+(maxr-minr)*0.1;
-  minr-=dur;
-  maxr+=dur;
-  if(minr<0.0 && maxr>0.0)  {  
-    Rejection=Standard_False;
+  if(Rejection)
+  {
+    dur=0.001+maxdr+(maxr-minr)*0.1;
+    minr-=dur;
+    maxr+=dur;
+    if(minr<0.0 && maxr>0.0)  {        
+      Rejection=Standard_False;
+    }
   }
 
   Arcsol=Standard_False;
 
   if(Rejection==Standard_False) { 
     math_FunctionSample Echant(Pdeb,Pfin,NbEchant);
-    
+
     Standard_Boolean aelargir=Standard_True;
     //modified by NIZNHY-PKV Thu Apr 12 09:25:19 2001 f
     //
@@ -254,13 +320,13 @@ void BoundedArc (const TheArc& A,
     if(!(aelargir && maxdist<0.01)) { 
       maxdist = TolBoundary;
     }
-    
+
     math_FunctionAllRoots Sol(Func,Echant,EpsX,maxdist,maxdist); //-- TolBoundary,nTolTangency);
-    
-    if (!Sol.IsDone()) {Standard_Failure::Raise();}
-    
-    Nbp=Sol.NbPoints();
 
+    if (!Sol.IsDone()) {throw Standard_Failure();}
+
+    Nbp=Sol.NbPoints();
+    //
     //jgv: build solution on the whole boundary
     if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain))
     {
@@ -268,11 +334,11 @@ void BoundedArc (const TheArc& A,
       //theTol += theTol;
       Standard_Real theTol = 5.e-4;
       math_FunctionAllRoots SolAgain(Func,Echant,EpsX,theTol,theTol); //-- TolBoundary,nTolTangency);
-      
-      if (!SolAgain.IsDone()) {Standard_Failure::Raise();}
-      
+
+      if (!SolAgain.IsDone()) {throw Standard_Failure();}
+
       Standard_Integer Nbi_again = SolAgain.NbIntervals();
-      
+
       if (Nbi_again > 0)
       {
         Standard_Integer NbSamples = 10;
@@ -299,19 +365,19 @@ void BoundedArc (const TheArc& A,
             newseg.SetValue(A);
             // Recuperer point debut et fin, et leur parametre.
             SolAgain.GetInterval(i,pardeb,parfin);
-            
+
             if (Abs(pardeb - Pdeb) <= Precision::PConfusion())
               pardeb = Pdeb;
             if (Abs(parfin - Pfin) <= Precision::PConfusion())
               parfin = Pfin;
-            
+
             SolAgain.GetIntervalState(i,ideb,ifin);
-            
+
             //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<"  ParFin:"<<parfin<<endl;
-            
+
             ptdeb=Func.Valpoint(ideb);
             ptfin=Func.Valpoint(ifin);
-          
+
             PointProcess(ptdeb,pardeb,A,Domain,pnt,theTol,ranged);
             newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
             PointProcess(ptfin,parfin,A,Domain,pnt,theTol,rangef);
@@ -324,30 +390,22 @@ void BoundedArc (const TheArc& A,
       }
     }
     ////////////////////////////////////////////
-    
+
     //-- detection du cas ou la fonction est quasi tangente et que les 
     //-- zeros sont quasi confondus. 
     //-- Dans ce cas on prend le point "milieu"
     //-- On suppose que les solutions sont triees. 
 
-    Standard_Real *TabSol=NULL;
     if(Nbp) { 
-      TabSol = new Standard_Real [Nbp+2];
-      for(i=1;i<=Nbp;i++) { 
-        TabSol[i]=Sol.GetPoint(i);
-      }
-      Standard_Boolean ok;
-      do { 
-        ok=Standard_True;
-        for(i=1;i<Nbp;i++) { 
-          if(TabSol[i]>TabSol[i+1]) { 
-            ok=Standard_False;
-            para=TabSol[i]; TabSol[i]=TabSol[i+1]; TabSol[i+1]=para;
-          }
-        }
+      NCollection_Array1<SolInfo> aSI(1, Nbp);
+
+      for(i=1;i<=Nbp;i++)
+      {
+        aSI(i).Init(Sol, i);
       }
-      
-      while(ok==Standard_False);
+
+      std::sort(aSI.begin(), aSI.end());
+
       //modified by NIZNHY-PKV Wed Mar 21 18:34:18 2001 f
       //////////////////////////////////////////////////////////
       // The treatment of the situation when line(arc) that is 
@@ -358,105 +416,126 @@ void BoundedArc (const TheArc& A,
       //                           PKV Fri Mar 23 12:17:29 2001
       Standard_Integer ip;
       const IntSurf_Quadric& aQuadric=Func.Quadric();
-      
+
       ip=TreatLC (A, Domain, aQuadric, TolBoundary, pnt);
       if (ip) {
-      //////////////////////////////////////////////////////////
-      //modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t
-      // 
-      // Using of old usual way proposed by Laurent 
-      //
-      for(i=1;i<Nbp;i++) { 
-        Standard_Real parap1=TabSol[i+1];
-        para=TabSol[i];
-        Standard_Real param=(para+parap1)*0.5;
-        Standard_Real ym;
-        if(Func.Value(param,ym)) {
-          if(Abs(ym)<maxdist) { 
-            //  Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 Begin
-            // Consider this interval as tangent one. Treat it to find
-            // parameter with the lowest function value.
-
-            // Compute the number of nodes.
-            Standard_Real    aTol = TolBoundary*1000.0;
-            if(aTol > 0.001)
-        aTol = 0.001;
-
-            // fix floating point exception 569, chl-922-e9
-            parap1 = (Abs(parap1) < 1.e9) ? parap1 : ((parap1 >= 0.) ? 1.e9 : -1.e9);
-            para   = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9);
-            
-            Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol));
-
-            Standard_Real    aVal     = RealLast();
-            //Standard_Integer aNbNodes = 23;
-            Standard_Real    aDelta   = (parap1 - para)/(aNbNodes + 1.);
-            Standard_Integer ii;
-            Standard_Real    aCurPar;
-            Standard_Real    aCurVal;
-
-            for (ii = 0; ii <= aNbNodes + 1; ii++) {
-        aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1;
-
-        if (Func.Value(aCurPar, aCurVal)) {
-          //if (aCurVal < aVal) {
-          if (Abs(aCurVal) < aVal) {
-            //aVal  = aCurVal;
-            aVal  = Abs(aCurVal);
-            param = aCurPar;
-          }
-        }
+        //////////////////////////////////////////////////////////
+        //modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t
+        // 
+        // Using of old usual way proposed by Laurent 
+        //
+        for(i=1;i<Nbp;i++) { 
+          Standard_Real parap1 = aSI(i + 1).Value();
+          para = aSI(i).Value();
+
+          Standard_Real param=(para+parap1)*0.5;
+          Standard_Real ym;
+          if(Func.Value(param,ym)) {
+            if(Abs(ym)<maxdist) { 
+              //  Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 Begin
+              // Consider this interval as tangent one. Treat it to find
+              // parameter with the lowest function value.
+
+              // Compute the number of nodes.
+              Standard_Real    aTol = TolBoundary*1000.0;
+              if(aTol > 0.001)
+                aTol = 0.001;
+
+              // fix floating point exception 569, chl-922-e9
+              parap1 = (Abs(parap1) < 1.e9) ? parap1 : ((parap1 >= 0.) ? 1.e9 : -1.e9);
+              para   = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9);
+
+              Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol));
+
+              Standard_Real    aVal     = RealLast();
+              //Standard_Integer aNbNodes = 23;
+              Standard_Real    aDelta   = (parap1 - para)/(aNbNodes + 1.);
+              Standard_Integer ii;
+              Standard_Real    aCurPar;
+              Standard_Real    aCurVal;
+
+              for (ii = 0; ii <= aNbNodes + 1; ii++) {
+                aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1;
+
+                if (Func.Value(aCurPar, aCurVal)) {
+                  //if (aCurVal < aVal) {
+                  if (Abs(aCurVal) < aVal) {
+                    //aVal  = aCurVal;
+                    aVal  = Abs(aCurVal);
+                    param = aCurPar;
+                  }
+                }
+              }
+              //  Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End
+              aSI(i).ChangeValue() = Pdeb - 1;
+              aSI(i + 1).ChangeValue() = param;
             }
-            //  Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End
-            TabSol[i]=Pdeb-1;
-            TabSol[i+1]=param;
           }
         }
-      }
-          
-      for (i=1; i<=Nbp; i++) {
-        para=TabSol[i];
-        if((para-Pdeb)<EpsX || (Pfin-para)<EpsX) { 
-        }
-        else { 
-          if(Func.Value(para,dist)) {
-            //modified by jgv 5.07.01 for the bug buc60927
-            Standard_Integer anIndx;
-            Standard_Real aParam;
-            if (Abs(dist) < maxdist)
-        {
-          aParam = Sol.GetPoint(i);
-          if (Abs(aParam-Pdeb)<=Precision::PConfusion() || Abs(aParam-Pfin)<=Precision::PConfusion())
-            anIndx = Sol.GetPointState(i);
-          else
+
+        for (i=1; i<=Nbp; i++) {
+          para = aSI(i).Value();
+          if((para-Pdeb)<EpsX || (Pfin-para)<EpsX)
+            continue;
+
+          if(!Func.Value(para,dist))
+            continue;
+
+          dist = Abs(dist);
+
+          Standard_Integer anIndx = -1;
+          const Standard_Real aParam = Sol.GetPoint(aSI(i).Index());
+          if (dist < maxdist)
+          {
+            if (Abs(aParam - Pdeb) <= Precision::PConfusion() || Abs(aParam - Pfin) <= Precision::PConfusion())
             {
-              anIndx = Func.GetStateNumber(); //take the middle point
-              aParam = para;
+              Standard_Real aDistTemp = RealLast();
+              if (Func.Value(aParam, aDistTemp))
+              {
+                if (Abs(aDistTemp) < maxdist)
+                {
+                  anIndx = Sol.GetPointState(aSI(i).Index());
+                }
+              }
             }
-        }
-            else
-        {
-          anIndx = Sol.GetPointState(i);
-          aParam = Sol.GetPoint(i);
-        }
-            const gp_Pnt& aPnt = Func.Valpoint(anIndx);
-            //////////////////////////////////////////////
+          }
 
-            PointProcess(aPnt, aParam, A, Domain, pnt, TolBoundary, range);
+          gp_Pnt aPnt(anIndx < 0 ? Func.LastComputedPoint() : Func.Valpoint(anIndx));
+
+          if (dist > 0.1*Precision::Confusion())
+          {
+            //Precise found points. It results in following:
+            //  1. Make the vertex nearer to the intersection line
+            //    (see description to issue #27252 in order to 
+            //    understand necessity).
+            //  2. Merge two near vertices to single point.
+
+            //All members in TabSol array has already been sorted in increase order.
+            //Now, we limit precise boundaries in order to avoid changing this order.
+            const Standard_Real aFPar = (i == 1) ? Pdeb : (para + aSI(i - 1).Value()) / 2.0;
+            const Standard_Real aLPar = (i == Nbp) ? Pfin : (para + aSI(i + 1).Value()) / 2.0;
+
+            MinFunction aNewFunc(Func);
+            math_BrentMinimum aMin(Precision::Confusion());
+
+            aMin.Perform(aNewFunc, aFPar, para, aLPar);
+            if(aMin.IsDone())
+            {
+              para = aMin.Location();
+              const gp_Pnt2d aP2d(A->Value(para));
+              aPnt = Func.Surface()->Value(aP2d.X(), aP2d.Y());
+            }
           }
+
+          PointProcess(aPnt, para, A, Domain, pnt, TolBoundary, range);
         }
-      }
-      
-      if(TabSol) { 
-        delete [] TabSol;
-      }
-      }// end ofif (ip)
+      }// end of if(ip)
     } // end of if(Nbp)  
 
     // Pour chaque intervalle trouve faire
     //   Traiter les extremites comme des points
     //   Ajouter intervalle dans la liste des segments
-    
+
     Nbi=Sol.NbIntervals();
 
 
@@ -466,7 +545,7 @@ void BoundedArc (const TheArc& A,
     }
 
     //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : Nbi : "<<Nbi<<endl;
-    
+
     for (i=1; i<=Nbi; i++) {
       IntStart_TheSegment newseg;
       newseg.SetValue(A);
@@ -479,7 +558,7 @@ void BoundedArc (const TheArc& A,
 
       ptdeb=Func.Valpoint(ideb);
       ptfin=Func.Valpoint(ifin);
-      
+
       PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged);
       newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
       PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef);
@@ -488,7 +567,9 @@ void BoundedArc (const TheArc& A,
     }
 
     if (Nbi==1) {
-      if (pardeb == Pdeb && parfin == Pfin) {
+      if((Abs(pardeb - Pdeb) < Precision::PConfusion()) &&
+         (Abs(parfin - Pfin) < Precision::PConfusion()))
+      {
         Arcsol=Standard_True;
       }
     }
@@ -513,7 +594,7 @@ void ComputeBoundsfromInfinite(TheFunction& Func,
   //
   // - The quadric is a plane, a cylinder, a cone and a sphere.
   // - Idea: We take any point on the arc and the fact grow
-  // - Terminals to the signed distance function values ​​or is likely
+  // - Terminals to the signed distance function values or is likely
   // - S cancel.
   //
   // - WARNING: The following calculations provide a very estimated coarse parameters.
@@ -521,7 +602,7 @@ void ComputeBoundsfromInfinite(TheFunction& Func,
   // - Inifinies walk. It will take this code
   // - With curve surface intersections.
 
-  NbEchant = 10;
+  NbEchant = 100;
 
   Standard_Real U0    = 0.0;
   Standard_Real dU    = 0.001;
@@ -556,8 +637,8 @@ void ComputeBoundsfromInfinite(TheFunction& Func,
     if(Umin>U0) { Umin=U0-10.0; } 
     if(Umax<U0) { Umax=U0+10.0; } 
     
-    PFin = Umax;
-    PDeb = Umin;
+    PFin = Umax + 10. * (Umax - Umin);
+    PDeb = Umin - 10. * (Umax - Umin);
   }
   else { 
     //-- Possibilite de Arc totalement inclu ds Quad
@@ -566,115 +647,6 @@ void ComputeBoundsfromInfinite(TheFunction& Func,
   }
 } 
 
-//=======================================================================
-//function : InfiniteArc
-//purpose  : 
-//=======================================================================
-void InfiniteArc (const TheArc& A,
-                  const Handle(TheTopolTool)& Domain,
-                  const Standard_Real Pdeb,
-                  const Standard_Real Pfin,
-                  TheFunction& Func,
-                  IntStart_SequenceOfPathPoint& pnt,
-                  IntStart_SequenceOfSegment& seg,
-                  const Standard_Real TolBoundary,
-                   const Standard_Real TolTangency,
-                  Standard_Boolean& Arcsol)
-{
-  
-  // Find points of solutions and tips bow bow gives a solution.
-  // The math_FunctionAllRoots function is used. Therefore suitable for
-  // Beginning of arcs having a point and a closed end point (range
-  // Parametrage).
-
-  Standard_Integer i,Nbi,Nbp;
-
-  gp_Pnt ptdeb,ptfin;
-  Standard_Real pardeb = 0.,parfin = 0.;
-  Standard_Integer ideb,ifin,range,ranged,rangef;
-  
-  // Create the Sample Rate (math_FunctionSample or inheriting class)
-  // Call a math_FunctionAllRoots
-
-  Standard_Real EpsX = TheArcTool::Resolution(A,Precision::Confusion());
-  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-  //@@@ Tolerance is the asociee al arc (Inconsistency with tracking)
-  //@@@ (EPSX ~ 1e-5 and ResolutionU and V ~ 1e-9)
-  //@@@ Vertex is here is not found as a point to stop
-  //@@@ Wayline
-  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-  EpsX = 0.0000000001;
-  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-  //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-
-  Standard_Integer NbEchant = Func.NbSamples(); 
-  
-  //-- Modif 24  Aout 93 -----------------------------
-  Standard_Real nTolTangency = TolTangency;
-  if((Pfin - Pdeb) < (TolTangency*10.0)) { 
-    nTolTangency=(Pfin-Pdeb)*0.1;
-  }   
-  if(EpsX>(nTolTangency+nTolTangency)) { 
-    EpsX = nTolTangency * 0.1; 
-  }
-  //--------------------------------------------------
-  // - Plant with a edge with 2 Samples
-  // - Whose ends are solutions (f = 0)
-  // - And the derivative is zero or
-  // - Example: a diameter of a sphere segment
-  if(NbEchant<3) NbEchant = 3; //-- lbr 19.04.95
-  //--------------------------------------------------
-  
-  Standard_Real PDeb = Pdeb;
-  Standard_Real PFin = Pfin;
-  
-  ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant);
-
-  math_FunctionSample Echant(PDeb,PFin,NbEchant);
-  math_FunctionAllRoots Sol(Func,Echant,EpsX,TolBoundary,nTolTangency);
-
-  if (!Sol.IsDone()) {Standard_Failure::Raise();}
-
-  Nbp=Sol.NbPoints();
-  for (i=1; i<=Nbp; i++) {
-    Standard_Real para = Sol.GetPoint(i);
-    Standard_Real dist;
-    if(Func.Value(para,dist)) { 
-      PointProcess(Func.Valpoint(Sol.GetPointState(i)),Sol.GetPoint(i),
-                   A,Domain,pnt,TolBoundary,range);
-    }
-  }
-  
-  // For each interval:
-  // Process the ends as points
-  // Add range in the list of segments
-
-  Nbi=Sol.NbIntervals();
-
-  for (i=1; i<=Nbi; i++) {
-    IntStart_TheSegment newseg;
-    newseg.SetValue(A);
-    // Recover start and end points, and parameter.
-    Sol.GetInterval(i,pardeb,parfin);
-    Sol.GetIntervalState(i,ideb,ifin);
-    ptdeb=Func.Valpoint(ideb);
-    ptfin=Func.Valpoint(ifin);
-
-    PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged);
-    newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
-    PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef);
-    newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
-    seg.Append(newseg);
-  }
-
-  Arcsol=Standard_False;
-  if (Nbi==1) {
-    if (pardeb == Pdeb && parfin == Pfin) {
-      Arcsol=Standard_True;
-    }
-  }
-}
 //=======================================================================
 //function : PointProcess
 //purpose  : 
@@ -709,7 +681,7 @@ void PointProcess (const gp_Pnt& Pt,
     vtx = Domain->Vertex();
     dist= Abs(Para-TheSOBTool::Parameter(vtx,A));
     toler = TheSOBTool::Tolerance(vtx,A);
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if(toler>0.1) { 
       cout<<"IntStart_SearchOnBoundaries_1.gxx  : ** WARNING ** Tol Vertex="<<toler<<endl;
       cout<<"                                     Ou Edge degenere Ou Kro pointu"<<endl;
@@ -778,7 +750,8 @@ void PointProcess (const gp_Pnt& Pt,
     {
       Standard_Real TOL=Tol;
       TOL*=1000.0; 
-      if(TOL>0.001) TOL=0.001;
+      //if(TOL>0.001) TOL=0.001;
+      if(TOL>0.005) TOL=0.005; //#24643
       
       ptsol.SetValue(Pt,TOL,A,Para);
       pnt.Append(ptsol);
@@ -842,7 +815,7 @@ Standard_Integer TreatLC (const TheArc& A,
     return anExitCode;
   }
   
-  Standard_Real f, l, U1f, U1l, U2f, U2l, U1, UEgde, TOL, aDist, aR, aRRel, Tol;
+  Standard_Real f, l, U1f, U1l, U2f, U2l, UEgde, TOL, aDist, aR, aRRel, Tol;
   Handle(Geom_Curve) aCEdge=BRep_Tool::Curve(*anE, f, l);
   
   gp_Cylinder aCyl=aQuadric.Cylinder();
@@ -880,7 +853,6 @@ Standard_Integer TreatLC (const TheArc& A,
   P1   =PC1.Value();
   PEdge=PC2.Value();
   
-  U1=PC1.Parameter();
   UEgde=PC2.Parameter();
   
   aDist=PEdge.Distance(P1);
@@ -955,11 +927,10 @@ IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries ()
       TheSOBTool::Bounds(A,PDeb,PFin);
       if(Precision::IsNegativeInfinite(PDeb) || 
          Precision::IsPositiveInfinite(PFin)) { 
-        InfiniteArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol);
-      }
-      else { 
-        BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol,RecheckOnRegularity);
+        Standard_Integer NbEchant;
+        ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant);
       }
+      BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol,RecheckOnRegularity);
       all = (all && Arcsol);
     }