0026431: Can't cut a sphere from a cylinder
[occt.git] / src / Approx / Approx_ComputeLine.gxx
old mode 100755 (executable)
new mode 100644 (file)
index 0788363..edc6086
@@ -1,4 +1,16 @@
-// File Approx_ComputeLine.gxx
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <Approx_ParametrizationType.hxx>
 #include Approx_ParLeastSquareOfMyGradient_hxx
@@ -23,7 +35,7 @@
 
 #include <stdio.h>
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
 static Standard_Boolean mydebug = Standard_False;
 
 #include <Geom_BezierCurve.hxx>
@@ -75,7 +87,6 @@ static void DUMP(const AppParCurves_MultiCurve& C) {
   static Standard_Integer nbappel = 0;
   Standard_Integer i;
   Standard_Integer nbpoles = C.NbPoles();
-  Standard_Integer deg = C.Degree();
 
   Handle(Geom_BezierCurve) BSp;
   Handle(Geom2d_BezierCurve) BSp2d;
@@ -503,7 +514,7 @@ Approx_ComputeLine::Approx_ComputeLine
 
 void Approx_ComputeLine::Perform(const MultiLine& Line)
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   if (mydebug) DUMP(Line);
 #endif
   if (!myIsClear)
@@ -549,7 +560,7 @@ void Approx_ComputeLine::Perform(const MultiLine& Line)
     TheMultiCurve = AppParCurves_MultiCurve();
     alldone = Compute(Line, myfirstpt, mylastpt, TheParam, thetol3d, thetol2d);
     if(!alldone && TheMultiCurve.NbCurves() > 0) {
-#ifdef DEB 
+#ifdef OCCT_DEBUG
       if (mydebug) DUMP(TheMultiCurve);
 #endif
       myMultiCurves.Append(TheMultiCurve);
@@ -607,7 +618,6 @@ void Approx_ComputeLine::Perform(const MultiLine& Line)
        // ========================================
        GoUp = Standard_False;
        Ok = Standard_True;
-       Standard_Boolean FailOnPointsAdded = Standard_False;
        if (MyStatus == Approx_PointsAdded) {
          // Appel recursif du decoupage:
          GoUp = Standard_True;
@@ -621,7 +631,6 @@ void Approx_ComputeLine::Perform(const MultiLine& Line)
          //-- Si MakeML a echoue   on retourne une ligne vide
          if ((nbpdsotherligne == 0) || myMultiLineNb >= 3)
          {
-           FailOnPointsAdded = Standard_True; 
            //-- cout<<" ** ApproxComputeLine MakeML Echec ** LBR lbr "<<endl;
            if (myfirstpt == mylastpt) break;  // Pour etre sur de ne pas 
            // planter la station !!
@@ -665,7 +674,7 @@ void Approx_ComputeLine::Perform(const MultiLine& Line)
                myMultiCurves.Clear();
                return;
              }
-#ifdef DEB 
+#ifdef OCCT_DEBUG
       if (mydebug) DUMP(TheMultiCurve);
 #endif
              myMultiCurves.Append(TheMultiCurve);
@@ -701,7 +710,7 @@ void Approx_ComputeLine::Perform(const MultiLine& Line)
            myMultiCurves.Clear();
            return;
          }
-#ifdef DEB 
+#ifdef OCCT_DEBUG
       if (mydebug) DUMP(TheMultiCurve);
 #endif
          myMultiCurves.Append(TheMultiCurve);
@@ -817,11 +826,10 @@ void Approx_ComputeLine::Parameters(const MultiLine& Line,
                               const Standard_Integer lastP,
                               math_Vector& TheParameters) const
 {
-  Standard_Integer i, j, Nbp, nbP2d, nbP3d;
+  Standard_Integer i, j, nbP2d, nbP3d;
   Standard_Real dist;
   gp_Pnt P1, P2;
   gp_Pnt2d P12d, P22d;
-  Nbp = lastP-firstP+1;
 
   if (Par == Approx_ChordLength || Par == Approx_Centripetal) {
     nbP3d = LineTool::NbP3d(Line);
@@ -938,7 +946,7 @@ Standard_Boolean Approx_ComputeLine::Compute(const MultiLine& Line,
       if (TheTol3d <= mytol3d && TheTol2d <= mytol2d) {
        // Stockage de la multicurve approximee.
        tolreached = Standard_True;
-#ifdef DEB 
+#ifdef OCCT_DEBUG
       if (mydebug) DUMP(mySCU);
 #endif
        myMultiCurves.Append(mySCU);
@@ -983,12 +991,12 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
   gp_Vec2d V12d, V22d;
   gp_Pnt P1, P2;
   gp_Pnt2d P12d, P22d;
-  Standard_Boolean Tangent1, Tangent2, Parallel, mydone= Standard_False;
+  Standard_Boolean Tangent1, Tangent2, mydone= Standard_False;
+#ifdef OCCT_DEBUG
+  Standard_Boolean Parallel;
+#endif
   Standard_Integer myfirstpt = firstpt, mylastpt = lastpt;
   Standard_Integer nbp = lastpt-firstpt+1, Kopt = 0;
-  AppParCurves_Constraint FirstC, LastC;
-  FirstC = AppParCurves_PassPoint;
-  LastC = AppParCurves_PassPoint;
   math_Vector Para(firstpt, lastpt);
 
   Parameters(Line, firstpt, lastpt, Para);
@@ -1031,13 +1039,17 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
   if (nbp == 2) {
     // S il n y a que 2 points, on verifie quand meme que les tangentes sont 
     // alignees.
+#ifdef OCCT_DEBUG
     Parallel = Standard_True;
+#endif
     if (Tangent1) {
       for (i = 1; i <= nbP3d; i++) {
        gp_Vec PVec(tabP1(i), tabP2(i));
        V13d = tabV1(i);
        if (!PVec.IsParallel(V13d, Precision::Angular())) {
+#ifdef OCCT_DEBUG
          Parallel = Standard_False;
+#endif
          break;
        }
       }
@@ -1045,7 +1057,9 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
        gp_Vec2d PVec2d(tabP12d(i), tabP22d(i));
        V12d = tabV12d(i);
        if (!PVec2d.IsParallel(V12d, Precision::Angular())) {
+#ifdef OCCT_DEBUG
          Parallel = Standard_False;
+#endif
          break;
        }
       }
@@ -1056,7 +1070,9 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
        gp_Vec PVec(tabP1(i), tabP2(i));
        V23d = tabV2(i);
        if (!PVec.IsParallel(V23d, Precision::Angular())) {
+#ifdef OCCT_DEBUG
          Parallel = Standard_False;
+#endif
          break;
        }
       }
@@ -1064,13 +1080,15 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
        gp_Vec2d PVec2d(tabP12d(i), tabP22d(i));
        V22d = tabV22d(i);
        if (!PVec2d.IsParallel(V22d, Precision::Angular())) {
+#ifdef OCCT_DEBUG
          Parallel = Standard_False;
+#endif
          break;
        }
       }
     }
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (!Parallel) {
       if (mydebug) cout <<"droite mais tangentes pas vraiment paralleles!!"<< endl;
     }
@@ -1130,7 +1148,7 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
     mydone = Standard_True;
     // Stockage de la multicurve approximee.
     tolreached = Standard_True;
-#ifdef DEB 
+#ifdef OCCT_DEBUG
       if (mydebug) DUMP(mySCU);
 #endif
     myMultiCurves.Append(mySCU);
@@ -1173,7 +1191,7 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
 
     // Stockage de la multicurve approximee.
     tolreached = Standard_True;
-#ifdef DEB 
+#ifdef OCCT_DEBUG
       if (mydebug) DUMP(mySCU);
 #endif
     myMultiCurves.Append(mySCU);
@@ -1256,7 +1274,7 @@ void Approx_ComputeLine::Error(const Standard_Integer Index,
   tol2d = Tolers2d.Value(Index);
 }
 
-void Approx_ComputeLine::Parametrization(Approx_ParametrizationType& partype) const
+Approx_ParametrizationType Approx_ComputeLine::Parametrization() const
 {
-  partype = Par;
+  return Par;
 }