0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / GeometryTest / GeometryTest_CurveCommands.cxx
index 2ff026b..3aa06fb 100644 (file)
 #include <GCPnts_QuasiUniformDeflection.hxx>
 #include <GCPnts_UniformDeflection.hxx>
 #include <GCPnts_TangentialDeflection.hxx>
+#include <GCPnts_DistFunction.hxx>
 #include <GeomAPI_ExtremaCurveCurve.hxx>
 #include <gce_MakeLin.hxx>
 #include <TColStd_Array1OfBoolean.hxx>
 //epa test
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <AIS_Shape.hxx>
+#include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRepAdaptor_HCompCurve.hxx>
 #include <GeomLProp_CLProps.hxx>
 #include <GCPnts_AbscissaPoint.hxx>
 #include <GCPnts_UniformAbscissa.hxx>
@@ -272,7 +276,7 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
     ONE = 2;
   }
   else {
-   di << "gproject wait 2 or 3 arguments" << "\n";
+   di << "gproject wait 2 or 3 arguments\n";
    return 1;
   } 
 
@@ -295,7 +299,7 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
 
   Standard_Integer k;
   Standard_Real Udeb, Ufin, UIso, VIso;
-  Standard_Integer Only2d, Only3d;
+  Standard_Boolean Only2d, Only3d;
   gp_Pnt2d P2d, Pdeb, Pfin;
   gp_Pnt P;
   Handle(Adaptor2d_HCurve2d) HPCur;
@@ -305,12 +309,12 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
     Sprintf(newname,"%s_%d",name,k);
     Sprintf(newname1,"%s2d_%d",name,k);
     if(Projector.IsSinglePnt(k, P2d)){
-//      cout<<"Part "<<k<<" of the projection is punctual"<<endl;
+//      std::cout<<"Part "<<k<<" of the projection is punctual"<<std::endl;
       Projector.GetSurface()->D0(P2d.X(), P2d.Y(), P);
       DrawTrSurf::Set(temp, P);
       DrawTrSurf::Set(temp1, P2d);
-      di<<temp<<" is 3d projected curve"<<"\n";
-      di<<temp1<<" is pcurve"<<"\n";
+      di<<temp<<" is 3d projected curve\n";
+      di<<temp1<<" is pcurve\n";
     }
     else {
       Only2d = Only3d = Standard_False;
@@ -318,7 +322,7 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
       gp_Dir2d Dir; // Only for isoparametric projection
       
       if (Projector.IsUIso(k, UIso)) {
-//      cout<<"Part "<<k<<" of the projection is U-isoparametric curve"<<endl;
+//      std::cout<<"Part "<<k<<" of the projection is U-isoparametric curve"<<std::endl;
         Projector.D0(Udeb, Pdeb);
         Projector.D0(Ufin, Pfin);
         Udeb = Pdeb.Y();
@@ -334,7 +338,7 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
         Only3d = Standard_True;
       }
       else if(Projector.IsVIso(k, VIso)) {
-//      cout<<"Part "<<k<<" of the projection is V-isoparametric curve"<<endl;
+//      std::cout<<"Part "<<k<<" of the projection is V-isoparametric curve"<<std::endl;
         Projector.D0(Udeb, Pdeb);
         Projector.D0(Ufin, Pfin);
         Udeb = Pdeb.X();
@@ -358,14 +362,13 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
         Handle(Geom_Curve) OutCur = new Geom_TrimmedCurve(GeomAdaptor::MakeCurve(hcur->Curve()), Ufin, Udeb);
         DrawTrSurf::Set(temp, OutCur);
         DrawTrSurf::Set(temp1, PCur2d);
-        di<<temp<<" is 3d projected curve"<<"\n";
-        di<<temp1<<" is pcurve"<<"\n";
+        di<<temp<<" is 3d projected curve\n";
+        di<<temp1<<" is pcurve\n";
         return 0;
         }
       else {
-        Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d, 
-                                  myContinuity, myMaxDegree, myMaxSeg, 
-                                  Only3d, Only2d);
+        Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d);
+        appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d);
         if(!Only3d) {
          PCur2d = appr.Curve2d();
          di << " Error in 2d is " << appr.MaxError2dU()
@@ -382,8 +385,8 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
          DrawTrSurf::Set(temp, appr.Curve3d());
        }
         DrawTrSurf::Set(temp1, PCur2d);
-        di<<temp<<" is 3d projected curve"<<"\n";
-        di<<temp1<<" is pcurve"<<"\n";
+        di<<temp<<" is 3d projected curve\n";
+        di<<temp1<<" is pcurve\n";
       }
     }
   }
@@ -399,10 +402,10 @@ static Standard_Integer project (Draw_Interpretor& di,
 {
   if ( n == 1) {
     
-    di << "project result2d c3d surf [-e p] [-v n] [-t tol]" << "\n";
-    di << "   -e p   : extent the surface of <p>%" << "\n";
-    di << "   -v n   : verify the projection at <n> points." << "\n";
-    di << "   -t tol : set the tolerance for approximation" << "\n";
+    di << "project result2d c3d surf [-e p] [-v n] [-t tol]\n";
+    di << "   -e p   : extent the surface of <p>%\n";
+    di << "   -v n   : verify the projection at <n> points.\n";
+    di << "   -t tol : set the tolerance for approximation\n";
     return 0;
   }
 
@@ -445,7 +448,7 @@ static Standard_Integer project (Draw_Interpretor& di,
     GeomProjLib::Curve2d(GC, GS, U1, U2, V1, V2, tolerance);
 
   if ( G2d.IsNull() ) {
-    di << "\n" << "Projection Failed" << "\n";
+    di << "\nProjection Failed\n";
     return 1;
   }
   else {
@@ -453,7 +456,7 @@ static Standard_Integer project (Draw_Interpretor& di,
   }
   if ( Verif) {  // verify the projection on n points
     if ( NbPoints <= 0) { 
-      di << " n must be positive" << "\n";
+      di << " n must be positive\n";
       return 0;
     }
     gp_Pnt P1,P2;
@@ -494,7 +497,7 @@ Standard_Integer projonplane(Draw_Interpretor& di,
 
   Handle(Geom_Plane)   Pl = Handle(Geom_Plane)::DownCast(S);
   if ( Pl.IsNull()) {
-    di << " The surface must be a plane" << "\n";
+    di << " The surface must be a plane\n";
     return 1;
   }
 
@@ -592,7 +595,7 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          }
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
@@ -610,7 +613,7 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          }
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
@@ -629,7 +632,7 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          }
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
@@ -648,12 +651,12 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          }
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
       else {
-       di << " args must be line/circle/point line/circle/point" << "\n";
+       di << " args must be line/circle/point line/circle/point\n";
        return 1;
       }
     }
@@ -670,7 +673,7 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          }
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
@@ -682,13 +685,13 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          solution(Bis.ThisSolution(),a[1],0);
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
     }
     else {
-      di << " the second arg must be line/circle/point " << "\n";
+      di << " the second arg must be line/circle/point \n";
     }
   }
   else if ( ip1) {
@@ -706,7 +709,7 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          }
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
@@ -718,7 +721,7 @@ static Standard_Integer bisec (Draw_Interpretor& di,
          solution(Bis.ThisSolution(),a[1],0);
        }
        else {
-         di << " Bisec has failed !!" << "\n";
+         di << " Bisec has failed !!\n";
          return 1;
        }
       }
@@ -730,25 +733,25 @@ static Standard_Integer bisec (Draw_Interpretor& di,
        DrawTrSurf::Set(a[1],new Geom2d_Line(Bis.ThisSolution()));
       }
       else {
-       di << " Bisec has failed !!" << "\n";
+       di << " Bisec has failed !!\n";
        return 1;
       }
     }
     else {
-      di << " the second arg must be line/circle/point " << "\n";
+      di << " the second arg must be line/circle/point \n";
       return 1;
     }
   }
   else {
-    di << " args must be line/circle/point line/circle/point" << "\n";
+    di << " args must be line/circle/point line/circle/point\n";
     return 1;
   }
 
   if ( NbSol >= 2) {
-    di << "There are " << NbSol << " Solutions." << "\n";
+    di << "There are " << NbSol << " Solutions.\n";
   }
   else {
-    di << "There is " << NbSol << " Solution." << "\n";
+    di << "There is " << NbSol << " Solution.\n";
   }
 
   return 0;
@@ -819,7 +822,7 @@ static Standard_Integer movelaw (Draw_Interpretor& di, Standard_Integer n, const
       Draw::Repaint();
     }
     else {
-      di << "Not enought degree of freedom increase degree please" << "\n";
+      di << "Not enought degree of freedom increase degree please\n";
     }
 
 
@@ -831,99 +834,13 @@ static Standard_Integer movelaw (Draw_Interpretor& di, Standard_Integer n, const
 //Static method computing deviation of curve and polyline
 #include <math_PSO.hxx>
 #include <math_PSOParticlesPool.hxx>
-#include <math_MultipleVarFunctionWithHessian.hxx>
-#include <math_NewtonMinimum.hxx>
+#include <math_MultipleVarFunction.hxx>
+#include <math_BrentMinimum.hxx>
 
-class aMaxCCDist : public math_MultipleVarFunctionWithHessian
-{
-public:
-  aMaxCCDist(const Handle(Geom_Curve)& theCurve,
-             const Handle(Geom_BSplineCurve)& thePnts)
-: myCurve(theCurve),
-  myPnts(thePnts)
-  {
-  }
-
-  virtual Standard_Boolean Value (const math_Vector& X,
-                                  Standard_Real& F)
-  {
-    if (!CheckInputData(X(1)))
-    {
-      return Standard_False;
-    }
-    F = -myCurve->Value(X(1)).SquareDistance(myPnts->Value(X(1)));
-    return Standard_True;
-  }
-
-  
-  virtual Standard_Boolean Gradient (const math_Vector& X, math_Vector& G)
-  {
-    if (!CheckInputData(X(1)))
-    {
-      return Standard_False;
-    }
-    gp_Pnt aPnt1, aPnt2;
-    gp_Vec aVec1, aVec2;
-    myCurve->D1(X(1), aPnt1, aVec1);
-    myPnts->D1 (X(1), aPnt2, aVec2);
-
-    G(1) = 2 * (aPnt1.X() - aPnt2.X()) * (aVec1.X() - aVec2.X())
-         + 2 * (aPnt1.Y() - aPnt2.Y()) * (aVec1.Y() - aVec2.Y())
-         + 2 * (aPnt1.Z() - aPnt2.Z()) * (aVec1.Z() - aVec2.Z());
-    G(1) *= -1.0; // Maximum search.
+static Standard_Real CompLocalDev(const Adaptor3d_Curve& theCurve,
+                                  const Standard_Real u1, const Standard_Real u2);
 
-    return Standard_True;
-  }
-
-  virtual Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G, math_Matrix& H)
-  {
-    if (Value(X, F) && Gradient(X, G))
-    {
-      gp_Pnt aPnt1, aPnt2;
-      gp_Vec aVec11, aVec12, aVec21, aVec22;
-      myCurve->D2(X(1), aPnt1, aVec11, aVec12);
-      myPnts->D2 (X(1), aPnt2, aVec21, aVec22);
-
-      H(1,1) = 2 * (aVec11.X() - aVec21.X()) * (aVec11.X() - aVec21.X())
-             + 2 * (aVec11.Y() - aVec21.Y()) * (aVec11.Y() - aVec21.Y())
-             + 2 * (aVec11.Z() - aVec21.Z()) * (aVec11.Z() - aVec21.Z())
-             + 2 * (aPnt1.X() - aPnt2.X()) * (aVec12.X() - aVec22.X())
-             + 2 * (aPnt1.Y() - aPnt2.Y()) * (aVec12.Y() - aVec22.Y())
-             + 2 * (aPnt1.Z() - aPnt2.Z()) * (aVec12.Z() - aVec22.Z());
-      H(1,1) *= -1.0; // Maximum search.
-
-      return Standard_True;
-    }
-    return Standard_False;
-  }
-
-  virtual Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G)
-  {
-    return (Value(X, F) && Gradient(X, G));
-  }
-
-  virtual Standard_Integer NbVariables() const
-  {
-    return 1;
-  }
-
-private:
-  aMaxCCDist & operator = (const aMaxCCDist & theOther);
-
-  Standard_Boolean CheckInputData(Standard_Real theParam)
-  {
-    if (theParam < myCurve->FirstParameter() || 
-        theParam > myCurve->LastParameter())
-      return Standard_False;
-    return Standard_True;
-  }
-
-  const Handle(Geom_Curve)& myCurve;
-  const Handle(Geom_BSplineCurve)& myPnts;
-};
-
-
-static void ComputeDeviation(const Handle(Geom_Curve)& theCurve,
+static void ComputeDeviation(const Adaptor3d_Curve& theCurve,
                              const Handle(Geom_BSplineCurve)& thePnts,
                              Standard_Real& theDmax,
                              Standard_Real& theUfMax,
@@ -939,42 +856,75 @@ static void ComputeDeviation(const Handle(Geom_Curve)& theCurve,
   Standard_Integer nbp = thePnts->NbKnots();
   TColStd_Array1OfReal aKnots(1, nbp);
   thePnts->Knots(aKnots);
-  math_Vector aLowBorder(1,1);
-  math_Vector aUppBorder(1,1);
-  math_Vector aSteps(1,1);
 
   Standard_Integer i;
   for(i = 1; i < nbp; ++i)
   {
-    aLowBorder(1) = aKnots(i);
-    aUppBorder(1) = aKnots(i+1);
-    aSteps(1) =(aUppBorder(1) - aLowBorder(1)) * 0.01; // Run PSO on even distribution with 100 points.
-
-    Standard_Real aValue;
-    math_Vector aT(1,1);
-    aMaxCCDist aFunc(theCurve, thePnts);
-    math_PSO aFinder(&aFunc, aLowBorder, aUppBorder, aSteps); // Choose 32 best points from 100 above.
-    aFinder.Perform(aSteps, aValue, aT);
-    Standard_Real d = 0.;
-
-    math_NewtonMinimum anOptLoc(aFunc);
-    anOptLoc.Perform(aFunc, aT);
-
-    if (anOptLoc.IsDone())
+    Standard_Real u1 = aKnots(i), u2 = aKnots(i+1);
+    Standard_Real d = CompLocalDev(theCurve, u1, u2);
+    if(d > theDmax)
     {
-      d = -anOptLoc.Minimum();
-      if(d > theDmax)
-      {
-        theDmax = d;
-        theUfMax = aLowBorder(1);
-        theUlMax = aUppBorder(1);
-        theImax = i;
-      }
+      theDmax = d;
+      theImax = i;
+      theUfMax = u1;
+      theUlMax = u2;
     }
   }
-  theDmax = Sqrt(theDmax); // Convert to Euclidean distance.
 }
 
+Standard_Real CompLocalDev(const Adaptor3d_Curve& theCurve,
+                           const Standard_Real u1, const Standard_Real u2)
+{
+  math_Vector aLowBorder(1,1);
+  math_Vector aUppBorder(1,1);
+  math_Vector aSteps(1,1);
+  //
+  aLowBorder(1) = u1;
+  aUppBorder(1) = u2;
+  aSteps(1) =(aUppBorder(1) - aLowBorder(1)) * 0.01; // Run PSO on even distribution with 100 points.
+  //
+  GCPnts_DistFunction aFunc1(theCurve,  u1, u2);
+  //
+  Standard_Real aValue;
+  math_Vector aT(1,1);
+  GCPnts_DistFunctionMV aFunc(aFunc1);
+
+  math_PSO aFinder(&aFunc, aLowBorder, aUppBorder, aSteps); // Choose 32 best points from 100 above.
+  aFinder.Perform(aSteps, aValue, aT);
+  Standard_Real d = 0.;
+
+  Standard_Real d1, d2;
+  Standard_Real x1 = Max(u1, aT(1) - aSteps(1));
+  Standard_Boolean Ok = aFunc1.Value(x1, d1);
+  if(!Ok)
+  {
+    return Sqrt(-aValue);
+  }
+  Standard_Real x2 = Min(u2, aT(1) + aSteps(1));
+  Ok = aFunc1.Value(x2, d2);
+  if(!Ok)
+  {
+    return Sqrt(-aValue);
+  }
+  if(!(d1 > aValue && d2 > aValue))
+  {
+    Standard_Real dmin = Min(d1, Min(aValue, d2));
+    return Sqrt(-dmin);
+  }
+
+  math_BrentMinimum anOptLoc(Precision::PConfusion());
+  anOptLoc.Perform(aFunc1, x1, aT(1), x2);
+
+  if (anOptLoc.IsDone())
+  {
+    d = -anOptLoc.Minimum();
+  }
+  else
+  {
+    d = -aValue;
+  }
+  return Sqrt(d);
+}
 
 //=======================================================================
 //function : crvpoints
@@ -986,14 +936,31 @@ static Standard_Integer crvpoints (Draw_Interpretor& di, Standard_Integer /*n*/,
   Standard_Integer i, nbp;
   Standard_Real defl;
 
+  Handle(Adaptor3d_HCurve) aHCurve;
   Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
+  if (C.IsNull())
+  {
+    // try getting a wire
+    TopoDS_Wire aWire = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
+    if (aWire.IsNull())
+    {
+      std::cout << "cannot evaluate the argument " << a[2] << " as a curve" << std::endl;
+      return 1;
+    }
+    BRepAdaptor_CompCurve aCompCurve(aWire);
+    aHCurve = new BRepAdaptor_HCompCurve(aCompCurve);
+  }
+  else
+  {
+    aHCurve = new GeomAdaptor_HCurve(C);
+  }
+
   defl = Draw::Atof(a[3]);
 
-  GeomAdaptor_Curve GAC(C);
-  GCPnts_QuasiUniformDeflection PntGen(GAC, defl);
+  GCPnts_QuasiUniformDeflection PntGen(aHCurve->Curve(), defl);
     
   if(!PntGen.IsDone()) {
-    di << "Points generation failed" << "\n";
+    di << "Points generation failed\n";
     return 1;
   }
 
@@ -1027,7 +994,7 @@ static Standard_Integer crvpoints (Draw_Interpretor& di, Standard_Integer /*n*/,
   Standard_Integer imax = 0;
 
   //check deviation
-  ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
+  ComputeDeviation(aHCurve->Curve(), aPnts, dmax, ufmax, ulmax, imax);
   di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n"; 
 
   return 0;
@@ -1040,17 +1007,36 @@ static Standard_Integer crvpoints (Draw_Interpretor& di, Standard_Integer /*n*/,
 
 static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, const char** a)
 {
-  Standard_Integer i, nbp;
+  Standard_Integer i, nbp, aMinPntsNb = 2;
   Standard_Real defl, angle = Precision::Angular();
 
+  Handle(Adaptor3d_HCurve) aHCurve;
   Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
+  if (C.IsNull())
+  {
+    // try getting a wire
+    TopoDS_Wire aWire = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
+    if (aWire.IsNull())
+    {
+      std::cout << "cannot evaluate the argument " << a[2] << " as a curve" << std::endl;
+      return 1;
+    }
+    BRepAdaptor_CompCurve aCompCurve(aWire);
+    aHCurve = new BRepAdaptor_HCompCurve(aCompCurve);
+  }
+  else
+  {
+    aHCurve = new GeomAdaptor_HCurve(C);
+  }
   defl = Draw::Atof(a[3]);
 
-  if(n > 3)
+  if(n > 4)
     angle = Draw::Atof(a[4]);
 
-  GeomAdaptor_Curve GAC(C);
-  GCPnts_TangentialDeflection PntGen(GAC, angle, defl, 2);
+  if(n > 5)
+    aMinPntsNb = Draw::Atoi (a[5]);
+
+  GCPnts_TangentialDeflection PntGen(aHCurve->Curve(), angle, defl, aMinPntsNb);
   
   nbp = PntGen.NbPoints();
   di << "Nb points : " << nbp << "\n";
@@ -1082,7 +1068,8 @@ static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, co
   Standard_Integer imax = 0;
 
   //check deviation
-  ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
+  ComputeDeviation(aHCurve->Curve(), aPnts, dmax, ufmax, ulmax, imax);
+  //
   di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n"; 
 
   return 0;
@@ -1100,7 +1087,7 @@ static Standard_Integer uniformAbscissa (Draw_Interpretor& di, Standard_Integer
   ellip = DrawTrSurf::GetBSplineCurve(a[1]);
   if (ellip.IsNull())
   {
-    di << " BSpline is NULL  "<<"\n";     
+    di << " BSpline is NULL  \n";     
     return 1;
   }*/
 
@@ -1108,7 +1095,7 @@ static Standard_Integer uniformAbscissa (Draw_Interpretor& di, Standard_Integer
   ellip = DrawTrSurf::GetCurve(a[1]);
   if (ellip.IsNull())
   {
-    di << " Curve is NULL  "<<"\n";     
+    di << " Curve is NULL  \n";     
     return 1;
   }
 
@@ -1144,9 +1131,9 @@ static Standard_Integer uniformAbscissa (Draw_Interpretor& di, Standard_Integer
     }
   }
 
-  catch (Standard_Failure )
+  catch (Standard_Failure const&)
   {
-    di << " Standard Failure  " <<"\n";
+    di << " Standard Failure  \n";
   }
   return 0;
 }
@@ -1192,9 +1179,9 @@ static Standard_Integer EllipsUniformAbscissa (Draw_Interpretor& di, Standard_In
     DBRep::Set("Ellipse",edge_curve);
   }
   
-  catch(Standard_Failure)
+  catch(Standard_Failure const&)
   {
-    di << " Standard Failure  "<<"\n";     
+    di << " Standard Failure  \n";     
   }
 
   try
@@ -1221,9 +1208,9 @@ static Standard_Integer EllipsUniformAbscissa (Draw_Interpretor& di, Standard_In
     }
   }
 
-  catch (Standard_Failure )
+  catch (Standard_Failure const&)
   {
-    di << " Standard Failure  " <<"\n";
+    di << " Standard Failure  \n";
   }
   return 0;
 }
@@ -1449,7 +1436,7 @@ static Standard_Integer mypoints (Draw_Interpretor& di, Standard_Integer /*n*/,
   Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
   Standard_Integer imax = 0;
 
-  ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
+  ComputeDeviation(GeomAdaptor_Curve(C),aPnts,dmax,ufmax,ulmax,imax);
   di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n"; 
 
   return 0;
@@ -1625,14 +1612,14 @@ static Standard_Integer intersection (Draw_Interpretor& di,
     }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
     else
     {
-      di<<"incorrect number of arguments"<<"\n";
+      di<<"incorrect number of arguments\n";
       return 1;
     }
 
     //
     if (!Inters.IsDone())
     {
-      di<<"No intersections found!"<<"\n";
+      di<<"No intersections found!\n";
 
       return 1;
     }
@@ -1681,7 +1668,7 @@ static Standard_Integer intersection (Draw_Interpretor& di,
     //
     if (!Inters.IsDone())
     {
-      di<<"No intersections found!"<<"\n";
+      di<<"No intersections found!\n";
       return 1;
     }
 
@@ -1696,7 +1683,7 @@ static Standard_Integer intersection (Draw_Interpretor& di,
       Standard_Integer Compt = 1;
 
       if(nblines >= 1)
-        cout << "   Lines: " << endl;
+        std::cout << "   Lines: " << std::endl;
 
       for (i = 1; i <= nblines; i++, Compt++)
       {
@@ -1708,7 +1695,7 @@ static Standard_Integer intersection (Draw_Interpretor& di,
       }
 
       if(nbpoints >= 1)
-        cout << "   Points: " << endl;
+        std::cout << "   Points: " << std::endl;
 
       const Standard_Integer imax = nblines+nbpoints;
 
@@ -1854,12 +1841,12 @@ void  GeometryTest::CurveCommands(Draw_Interpretor& theCommands)
                  intersection,g);
 
   theCommands.Add("crvpoints",
-                 "crvpoints result curv deflection",
+                 "crvpoints result <curve or wire> deflection",
                  __FILE__,
                  crvpoints,g);
 
   theCommands.Add("crvtpoints",
-                 "crvtpoints result curv deflection angular deflection - tangential deflection points",
+                 "crvtpoints result <curve or wire> deflection angular deflection - tangential deflection points",
                  __FILE__,
                  crvtpoints,g);