Salome HOME
Fix compilation error (conflict of OK name between OCCT Plate_Plate.hxx and GEOM...
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ICurvesOperations.cxx
index 60983a177fe7a2daa593178514c8ca8dc856a968..eff9b923327bc8b740add25967556c9831a74bb0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
-#ifdef WNT
+#ifdef WIN32
 // E.A. : On windows with python 2.6, there is a conflict
 // E.A. : between pymath.h and Standard_math.h which define
 // E.A. : some same symbols : acosh, asinh, ...
-#include <Standard_math.hxx>
+#include <Standard_Real.hxx>
+#include <pyport.h>
 #include <pymath.h>
 #endif
 
 #ifdef HAVE_FINITE
 #undef HAVE_FINITE
 #endif
-#include <Standard_Stream.hxx>
-
-#include <GEOMImpl_ICurvesOperations.hxx>
-#include <GEOMImpl_Types.hxx>
-
-#include <GEOM_Function.hxx>
-#include <GEOM_PythonDump.hxx>
 
-#include <GEOMImpl_PolylineDriver.hxx>
-#include <GEOMImpl_CircleDriver.hxx>
-#include <GEOMImpl_SplineDriver.hxx>
-#include <GEOMImpl_EllipseDriver.hxx>
-#include <GEOMImpl_ArcDriver.hxx>
-#include <GEOMImpl_SketcherDriver.hxx>
-#include <GEOMImpl_3DSketcherDriver.hxx>
-
-#include <GEOMImpl_IPolyline.hxx>
-#include <GEOMImpl_ICircle.hxx>
-#include <GEOMImpl_ISpline.hxx>
-#include <GEOMImpl_IEllipse.hxx>
-#include <GEOMImpl_IArc.hxx>
-#include <GEOMImpl_ISketcher.hxx>
-#include <GEOMImpl_I3DSketcher.hxx>
-
-#include <Basics_OCCTVersion.hxx>
+#include "GEOMImpl_ICurvesOperations.hxx"
+#include "GEOMImpl_Types.hxx"
+
+#include "GEOM_Function.hxx"
+#include "GEOM_PythonDump.hxx"
+
+#include "GEOMImpl_PolylineDriver.hxx"
+#include "GEOMImpl_CircleDriver.hxx"
+#include "GEOMImpl_SplineDriver.hxx"
+#include "GEOMImpl_EllipseDriver.hxx"
+#include "GEOMImpl_ArcDriver.hxx"
+#include "GEOMImpl_ShapeDriver.hxx"
+#include "GEOMImpl_SketcherDriver.hxx"
+#include "GEOMImpl_3DSketcherDriver.hxx"
+
+#include "GEOMImpl_IPolyline.hxx"
+#include "GEOMImpl_IPolyline2D.hxx"
+#include "GEOMImpl_ICircle.hxx"
+#include "GEOMImpl_ISpline.hxx"
+#include "GEOMImpl_IEllipse.hxx"
+#include "GEOMImpl_IArc.hxx"
+#include "GEOMImpl_ISketcher.hxx"
+#include "GEOMImpl_I3DSketcher.hxx"
+#include "GEOMImpl_ICurveParametric.hxx"
+#include "GEOMImpl_IIsoline.hxx"
+#include "GEOMImpl_PolylineDumper.hxx"
 
 #include "utilities.h"
 
 #include <TDF_Tool.hxx>
+#include <TColStd_HArray1OfByte.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 
 #include <Standard_Failure.hxx>
  * ===========  PYTHON ==============
  * ==================================*/
 
-typedef struct {
-  PyObject_HEAD
-  int softspace;
-  std::string *out;
-  } PyStdOut;
-
-static void
-PyStdOut_dealloc(PyStdOut *self)
+namespace
 {
-  PyObject_Del(self);
-}
-
-static PyObject *
-PyStdOut_write(PyStdOut *self, PyObject *args)
-{
-  char *c;
-  int l;
-  if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
-    return NULL;
-
-  //std::cerr << c ;
-  *(self->out)=*(self->out)+c;
-
-  Py_INCREF(Py_None);
-  return Py_None;
-}
+  typedef struct {
+    PyObject_HEAD
+    int softspace;
+    std::string *out;
+  } PyStdOut;
+  
+  static void
+  PyStdOut_dealloc(PyStdOut *self)
+  {
+    PyObject_Del(self);
+  }
 
-static PyMethodDef PyStdOut_methods[] = {
-  {"write",  (PyCFunction)PyStdOut_write,  METH_VARARGS,
-    PyDoc_STR("write(string) -> None")},
-  {NULL,    NULL}   /* sentinel */
-};
-
-static PyMemberDef PyStdOut_memberlist[] = {
-  {(char*)"softspace", T_INT,  offsetof(PyStdOut, softspace), 0,
-   (char*)"flag indicating that a space needs to be printed; used by print"},
-  {NULL} /* Sentinel */
-};
-
-static PyTypeObject PyStdOut_Type = {
-  /* The ob_type field must be initialized in the module init function
-   * to be portable to Windows without using C++. */
-  PyObject_HEAD_INIT(NULL)
-  0,                            /*ob_size*/
-  "PyOut",                      /*tp_name*/
-  sizeof(PyStdOut),             /*tp_basicsize*/
-  0,                            /*tp_itemsize*/
-  /* methods */
-  (destructor)PyStdOut_dealloc, /*tp_dealloc*/
-  0,                            /*tp_print*/
-  0,                            /*tp_getattr*/
-  0,                            /*tp_setattr*/
-  0,                            /*tp_compare*/
-  0,                            /*tp_repr*/
-  0,                            /*tp_as_number*/
-  0,                            /*tp_as_sequence*/
-  0,                            /*tp_as_mapping*/
-  0,                            /*tp_hash*/
-  0,                            /*tp_call*/
-  0,                            /*tp_str*/
-  PyObject_GenericGetAttr,      /*tp_getattro*/
-  /* softspace is writable:  we must supply tp_setattro */
-  PyObject_GenericSetAttr,      /* tp_setattro */
-  0,                            /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT,           /*tp_flags*/
-  0,                            /*tp_doc*/
-  0,                            /*tp_traverse*/
-  0,                            /*tp_clear*/
-  0,                            /*tp_richcompare*/
-  0,                            /*tp_weaklistoffset*/
-  0,                            /*tp_iter*/
-  0,                            /*tp_iternext*/
-  PyStdOut_methods,             /*tp_methods*/
-  PyStdOut_memberlist,          /*tp_members*/
-  0,                            /*tp_getset*/
-  0,                            /*tp_base*/
-  0,                            /*tp_dict*/
-  0,                            /*tp_descr_get*/
-  0,                            /*tp_descr_set*/
-  0,                            /*tp_dictoffset*/
-  0,                            /*tp_init*/
-  0,                            /*tp_alloc*/
-  0,                            /*tp_new*/
-  0,                            /*tp_free*/
-  0,                            /*tp_is_gc*/
-};
-
-PyObject * newPyStdOut( std::string& out )
-{
-  PyStdOut *self;
-  self = PyObject_New(PyStdOut, &PyStdOut_Type);
-  if (self == NULL)
-    return NULL;
-  self->softspace = 0;
-  self->out=&out;
-  return (PyObject*)self;
+  static PyObject*
+  PyStdOut_write(PyStdOut* self, PyObject* args)
+  {
+    char *c;
+    if (!PyArg_ParseTuple(args, "s", &c))
+      return NULL;
+    
+    *(self->out) = *(self->out) + c;
+    
+    Py_INCREF(Py_None);
+    return Py_None;
+  }
+  
+  static PyMethodDef PyStdOut_methods[] = {
+    {"write",  (PyCFunction)PyStdOut_write,  METH_VARARGS,
+     PyDoc_STR("write(string) -> None")},
+    {0, 0, 0, 0}   /* sentinel */
+  };
+
+  static PyMemberDef PyStdOut_memberlist[] = {
+    {(char*)"softspace", T_INT,  offsetof(PyStdOut, softspace), 0,
+     (char*)"flag indicating that a space needs to be printed; used by print"},
+    {0, 0, 0, 0, 0}   /* sentinel */
+  };
+  
+  static PyTypeObject PyStdOut_Type = {
+    /* The ob_type field must be initialized in the module init function
+     * to be portable to Windows without using C++. */
+    PyVarObject_HEAD_INIT(NULL, 0)
+    /* 0, */                           /*ob_size*/
+    "PyOut",                      /*tp_name*/
+    sizeof(PyStdOut),             /*tp_basicsize*/
+    0,                            /*tp_itemsize*/
+    /* methods */
+    (destructor)PyStdOut_dealloc, /*tp_dealloc*/
+    0,                            /*tp_print*/
+    0,                            /*tp_getattr*/
+    0,                            /*tp_setattr*/
+    0,                            /*tp_compare*/
+    0,                            /*tp_repr*/
+    0,                            /*tp_as_number*/
+    0,                            /*tp_as_sequence*/
+    0,                            /*tp_as_mapping*/
+    0,                            /*tp_hash*/
+    0,                            /*tp_call*/
+    0,                            /*tp_str*/
+    PyObject_GenericGetAttr,      /*tp_getattro*/
+    /* softspace is writable:  we must supply tp_setattro */
+    PyObject_GenericSetAttr,      /* tp_setattro */
+    0,                            /*tp_as_buffer*/
+    Py_TPFLAGS_DEFAULT,           /*tp_flags*/
+    0,                            /*tp_doc*/
+    0,                            /*tp_traverse*/
+    0,                            /*tp_clear*/
+    0,                            /*tp_richcompare*/
+    0,                            /*tp_weaklistoffset*/
+    0,                            /*tp_iter*/
+    0,                            /*tp_iternext*/
+    PyStdOut_methods,             /*tp_methods*/
+    PyStdOut_memberlist,          /*tp_members*/
+    0,                            /*tp_getset*/
+    0,                            /*tp_base*/
+    0,                            /*tp_dict*/
+    0,                            /*tp_descr_get*/
+    0,                            /*tp_descr_set*/
+    0,                            /*tp_dictoffset*/
+    0,                            /*tp_init*/
+    0,                            /*tp_alloc*/
+    0,                            /*tp_new*/
+    0,                            /*tp_free*/
+    0,                            /*tp_is_gc*/
+    0,                            /*tp_bases*/
+    0,                            /*tp_mro*/
+    0,                            /*tp_cache*/
+    0,                            /*tp_subclasses*/
+    0,                            /*tp_weaklist*/
+    0,                            /*tp_del*/
+    0,                            /*tp_version_tag*/
+    0,                            /*tp_finalize*/
+  };
+  
+  PyObject* newPyStdOut( std::string& out )
+  {
+    PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
+    if (self) {
+      self->softspace = 0;
+      self->out=&out;
+    }
+    return (PyObject*)self;
+  }
 }
 
-
 ////////////////////////END PYTHON///////////////////////////
 //=============================================================================
 /*!
  *   constructor:
  */
 //=============================================================================
-GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
-: GEOM_IOperations(theEngine, theDocID)
+GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
 {
   MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
 }
@@ -208,7 +220,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_
   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
 
   //Add a new Circle object
-  Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
+  Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GEOM_CIRCLE);
 
   //Add a new Circle function for creation a circle relatively to three points
   Handle(GEOM_Function) aFunction =
@@ -232,17 +244,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_
 
   //Compute the Circle value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Circle driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -268,7 +277,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEO
   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
 
   //Add a new Circle object
-  Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
+  Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GEOM_CIRCLE);
 
   //Add a new Circle function for creation a circle relatively to center and 2 points
   Handle(GEOM_Function) aFunction =
@@ -292,17 +301,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEO
 
   //Compute the Circle value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Circle driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -329,7 +335,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
   //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
 
   //Add a new Circle object
-  Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
+  Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GEOM_CIRCLE);
 
   //Add a new Circle function for creation a circle relatively to point and vector
   Handle(GEOM_Function) aFunction =
@@ -357,17 +363,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
 
   //Compute the Circle value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Circle driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -397,7 +400,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
   //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
 
   //Add a new Ellipse object
-  Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
+  Handle(GEOM_Object) anEll = GetEngine()->AddObject(GEOM_ELLIPSE);
 
   //Add a new Ellipse function
   Handle(GEOM_Function) aFunction =
@@ -432,17 +435,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
 
   //Compute the Ellipse value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Ellipse driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -475,7 +475,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the
   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
 
   //Add a new Circle Arc object
-  Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
+  Handle(GEOM_Object) anArc = GetEngine()->AddObject(GEOM_CIRC_ARC);
 
   //Add a new Circle Arc function
   Handle(GEOM_Function) aFunction =
@@ -499,17 +499,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the
 
   //Compute the Arc value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Arc driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -535,7 +532,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Objec
   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
 
   //Add a new Circle Arc object
-  Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
+  Handle(GEOM_Object) anArc = GetEngine()->AddObject(GEOM_CIRC_ARC);
 
   //Add a new Circle Arc function
   Handle(GEOM_Function) aFunction =
@@ -560,17 +557,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Objec
 
   //Compute the Arc value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
-  SetErrorCode("Arc driver failed");
-  return NULL;
+      SetErrorCode("Arc driver failed");
+      return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
   //Make a Python command
@@ -595,7 +589,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Ob
   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
 
   //Add a new Circle Arc object
-  Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
+  Handle(GEOM_Object) anArc = GetEngine()->AddObject(GEOM_ELLIPSE_ARC);
 
   //Add a new Circle Arc function
   Handle(GEOM_Function) aFunction =
@@ -619,17 +613,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Ob
 
   //Compute the Arc value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Arc driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -652,7 +643,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(G
   SetErrorCode(KO);
 
   //Add a new Polyline object
-  Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
+  Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GEOM_POLYLINE);
 
   //Add a new Polyline function for creation a polyline relatively to points set
   Handle(GEOM_Function) aFunction =
@@ -683,17 +674,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(G
 
   //Compute the Polyline value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Polyline driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -724,7 +712,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
   SetErrorCode(KO);
 
   //Add a new Spline object
-  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GEOM_SPLINE);
 
   //Add a new Spline function for creation a bezier curve relatively to points set
   Handle(GEOM_Function) aFunction =
@@ -754,17 +742,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
 
   //Compute the Spline value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Spline driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -796,7 +781,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   SetErrorCode(KO);
 
   //Add a new Spline object
-  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GEOM_SPLINE);
 
   //Add a new Spline function for interpolation type
   Handle(GEOM_Function) aFunction =
@@ -826,17 +811,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
 
   //Compute the Spline value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Spline driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -869,7 +851,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
   SetErrorCode(KO);
 
   //Add a new Spline object
-  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GEOM_SPLINE);
 
   //Add a new Spline function for interpolation type
   Handle(GEOM_Function) aFunction =
@@ -905,17 +887,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
 
   //Compute the Spline value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Spline driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1024,7 +1003,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
 
   PyObject * func = NULL;
   func = PyObject_GetAttrString(main_mod, "coordCalculator");
-
   if (func == NULL){
     SetErrorCode("Can't get function from python module !!!");
     PyGILState_Release(gstate);
@@ -1037,15 +1016,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
   else
     coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
 
-  PyObject* new_stderr = NULL;
-
   if (coords == NULL){
     fflush(stderr);
     std::string err_description="";
-    new_stderr = newPyStdOut(err_description);
+    PyObject* new_stderr = newPyStdOut(err_description);
+    PyObject* old_stderr = PySys_GetObject((char*)"stderr");
+    Py_INCREF(old_stderr);
     PySys_SetObject((char*)"stderr", new_stderr);
     PyErr_Print();
-    PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+    PySys_SetObject((char*)"stderr", old_stderr);
     Py_DECREF(new_stderr);
     MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
     SetErrorCode("Can't evaluate the expressions, please check them !!!");
@@ -1085,7 +1064,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
   switch(theCurveType) {
   case Polyline: {
     //Add a new Polyline object
-    aCurve = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
+    aCurve = GetEngine()->AddObject(GEOM_POLYLINE);
 
     //Add a new Polyline function for creation a polyline relatively to points set
     aFunction = aCurve->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
@@ -1100,12 +1079,12 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
     aCI.SetConstructorType(COORD_CONSTRUCTOR);
     aCI.SetIsClosed(false);
     aCI.SetCoordinates(aCoordsArray);
-    aCurveType = "geompy.GEOM.Polyline";
+    aCurveType = "GEOM.Polyline";
     break;
   }
   case Bezier: {
     //Add a new Spline object
-    aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+    aCurve = GetEngine()->AddObject(GEOM_SPLINE);
     //Add a new Spline function for creation a bezier curve relatively to points set
     aFunction =
       aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
@@ -1119,12 +1098,12 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
     aCI.SetConstructorType(COORD_CONSTRUCTOR);
     aCI.SetIsClosed(false);
     aCI.SetCoordinates(aCoordsArray);
-    aCurveType = "geompy.GEOM.Bezier";
+    aCurveType = "GEOM.Bezier";
     break;
   }
   case Interpolation: {
     //Add a new Spline object
-    aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+    aCurve = GetEngine()->AddObject(GEOM_SPLINE);
 
     //Add a new Spline function for creation a bezier curve relatively to points set
     aFunction = aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
@@ -1138,24 +1117,32 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
     aCI.SetIsClosed(false);
     aCI.SetDoReordering(false);
     aCI.SetCoordinates(aCoordsArray);
-    aCurveType = "geompy.GEOM.Interpolation";
+    aCurveType = "GEOM.Interpolation";
     break;
   }
   }
 
+  GEOMImpl_ICurveParametric aIP(aFunction);
+  aIP.SetExprX      (thexExpr);
+  aIP.SetExprY      (theyExpr);
+  aIP.SetExprZ      (thezExpr);
+  aIP.SetParamMin   (theParamMin);
+  aIP.SetParamMax   (theParamMax);
+  if ( theNewMethod )
+    aIP.SetParamNbStep(theParamNbStep);
+  else
+    aIP.SetParamStep  (theParamStep);
+
   //Compute the Curve value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Curve driver failed !!!");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1192,7 +1179,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
   if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
 
   //Add a new Sketcher object
-  Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
+  Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GEOM_SKETCHER);
 
   //Add a new Sketcher function
   Handle(GEOM_Function) aFunction =
@@ -1214,17 +1201,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
 
   //Compute the Sketcher value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Sketcher driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1257,7 +1241,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
   if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
 
   //Add a new Sketcher object
-  Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
+  Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GEOM_SKETCHER);
 
   //Add a new Sketcher function
   Handle(GEOM_Function) aFunction =
@@ -1278,17 +1262,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
 
   //Compute the Sketcher value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Sketcher driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1312,7 +1293,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const cha
   if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
 
   //Add a new Sketcher object
-  Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
+  Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GEOM_3DSKETCHER);
 
   //Add a new Sketcher function
   Handle(GEOM_Function) aFunction =
@@ -1329,17 +1310,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const cha
 
   //Compute the 3D Sketcher value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("3D Sketcher driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1361,7 +1339,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double
   SetErrorCode(KO);
 
   //Add a new Sketcher object
-  Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
+  Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GEOM_3DSKETCHER);
 
   //Add a new Sketcher function
   Handle(GEOM_Function) aFunction =
@@ -1389,17 +1367,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double
 
   //Compute the Sketcher value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("3D Sketcher driver failed");
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
     return NULL;
   }
 
@@ -1417,3 +1392,214 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double
   SetErrorCode(OK);
   return a3DSketcher;
 }
+
+//=============================================================================
+/*!
+ *  MakeIsoline
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline
+                  (const Handle(GEOM_Object) &theFace,
+                   const bool                 IsUIso,
+                   const double               theParameter)
+{
+  SetErrorCode(KO);
+
+  if (theFace.IsNull()) {
+    return NULL;
+  }
+
+  //Add a new Spline object
+  Handle(GEOM_Object) anIsoline =
+    GetEngine()->AddObject(GEOM_ISOLINE);
+
+  //Add a new Spline function for interpolation type
+  Handle(GEOM_Function) aFunction =
+    anIsoline->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPE_ISOLINE);
+
+  if (aFunction.IsNull()) {
+    return NULL;
+  }
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
+    return NULL;
+  }
+
+  GEOMImpl_IIsoline     aCI (aFunction);
+  Handle(GEOM_Function) aRefFace = theFace->GetLastFunction();
+
+  if (aRefFace.IsNull()) {
+    return NULL;
+  }
+
+  aCI.SetFace(aRefFace);
+  aCI.SetIsUIso(IsUIso);
+  aCI.SetParameter(theParameter);
+
+  //Compute the isoline curve
+  try {
+    OCC_CATCH_SIGNALS;
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Shape driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump (aFunction) << anIsoline << " = geompy.MakeIsoline( "
+    << theFace << ", " << IsUIso << ", " << theParameter << " )";
+
+  SetErrorCode(OK);
+  return anIsoline;
+}
+
+//=============================================================================
+/*!
+ *  MakePolyline2D
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2D
+            (const std::list <std::list <double> >         &theCoords,
+             const Handle(TColStd_HArray1OfExtendedString) &theNames,
+             const Handle(TColStd_HArray1OfByte)           &theTypes,
+             const Handle(TColStd_HArray1OfByte)           &theCloseds,
+             const Handle(TColStd_HArray1OfReal)           &theWorkingPlane)
+{
+  SetErrorCode(KO);
+
+  if (theCoords.empty()   || theNames.IsNull() || theTypes.IsNull() ||
+      theCloseds.IsNull() || theWorkingPlane.IsNull()) {
+    return NULL;
+  }
+
+  // Add a new Polyline object
+  Handle(GEOM_Object)   aResult   =
+    GetEngine()->AddObject(GEOM_POLYLINE2D);
+  Handle(GEOM_Function) aFunction = aResult->AddFunction
+    (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_COORDS);
+
+  if (aFunction.IsNull()) {
+    return NULL;
+  }
+
+  // Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
+    return NULL;
+  }
+
+  GEOMImpl_IPolyline2D aCI(aFunction);
+
+  aCI.SetCoords(theCoords);
+  aCI.SetNames(theNames);
+  aCI.SetTypes(theTypes);
+  aCI.SetClosedFlags(theCloseds);
+  aCI.SetWorkingPlaneDbls(theWorkingPlane);
+
+  // Compute the isoline curve
+  try {
+    OCC_CATCH_SIGNALS;
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Polyline driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
+                                  theCloseds, theWorkingPlane);
+
+  aDumper.Dump(aResult);
+
+  if (aDumper.IsDone() == Standard_False) {
+    SetErrorCode("Python dump failed");
+    return NULL;
+  }
+
+  SetErrorCode(OK);
+  return aResult;
+}
+
+//=============================================================================
+/*!
+ *  MakePolyline2DOnPlane
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2DOnPlane
+            (const std::list <std::list <double> >         &theCoords,
+             const Handle(TColStd_HArray1OfExtendedString) &theNames,
+             const Handle(TColStd_HArray1OfByte)           &theTypes,
+             const Handle(TColStd_HArray1OfByte)           &theCloseds,
+             const Handle(GEOM_Object)                     &theWorkingPlane)
+{
+  SetErrorCode(KO);
+
+  if (theCoords.empty()   || theNames.IsNull() || theTypes.IsNull() ||
+      theCloseds.IsNull() || theWorkingPlane.IsNull()) {
+    return NULL;
+  }
+
+  //Add a new Polyline object
+  Handle(GEOM_Object) aResult =
+    GetEngine()->AddObject(GEOM_POLYLINE2D);
+  Handle(GEOM_Function) aFunction = aResult->AddFunction
+    (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_OBJECT);
+
+  if (aFunction.IsNull()) {
+    return NULL;
+  }
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
+    return NULL;
+  }
+
+  Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
+
+  if (aRefPlane.IsNull()) {
+    return NULL;
+  }
+
+  GEOMImpl_IPolyline2D aCI(aFunction);
+
+  aCI.SetCoords(theCoords);
+  aCI.SetNames(theNames);
+  aCI.SetTypes(theTypes);
+  aCI.SetClosedFlags(theCloseds);
+  aCI.SetWorkingPlane(aRefPlane);
+
+  //Compute the isoline curve
+  try {
+    OCC_CATCH_SIGNALS;
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Polyline driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure& aFail) {
+    SetErrorCode(aFail.GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
+                                  theCloseds, theWorkingPlane);
+
+  aDumper.Dump(aResult);
+
+  if (aDumper.IsDone() == Standard_False) {
+    SetErrorCode("Python dump failed");
+    return NULL;
+  }
+
+  SetErrorCode(OK);
+  return aResult;
+}