Salome HOME
0022749: [EDF] Improvement of Remove Internal Faces operation
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ICurvesOperations.cxx
index f4508d35b089d5c9028a7db2c698e1747438dc29..f6c452b951ebbb6dc730764b009df7bba96e10fc 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, 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
@@ -18,8 +18,9 @@
 // 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, ...
 #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 "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 <Basics_OCCTVersion.hxx>
 
 #include "utilities.h"
 
 #include <TDF_Tool.hxx>
+#include <TColStd_HArray1OfByte.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 
 #include <Standard_Failure.hxx>
@@ -232,9 +238,7 @@ 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;
@@ -292,9 +296,7 @@ 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;
@@ -357,9 +359,7 @@ 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;
@@ -432,9 +432,7 @@ 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;
@@ -499,9 +497,7 @@ 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;
@@ -560,12 +556,10 @@ 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) {
@@ -619,9 +613,7 @@ 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;
@@ -683,9 +675,7 @@ 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;
@@ -736,27 +726,25 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
 
   GEOMImpl_ISpline aCI (aFunction);
 
-  int aLen = thePoints.size();
-  aCI.SetLength(aLen);
   aCI.SetConstructorType(POINT_CONSTRUCTOR);
 
-  int ind = 1;
+  Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
   std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
-  for (; it != thePoints.end(); it++, ind++) {
+  for (; it != thePoints.end(); it++) {
     Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
-
-    if (aRefPnt.IsNull()) return NULL;
-
-    aCI.SetPoint(ind, aRefPnt);
+    if (aRefPnt.IsNull()) {
+      SetErrorCode("NULL point for Besier curve");
+      return NULL;
+    }
+    aPoints->Append(aRefPnt);
   }
+  aCI.SetPoints(aPoints);
 
   aCI.SetIsClosed(theIsClosed);
 
   //Compute the Spline value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Spline driver failed");
       return NULL;
@@ -798,7 +786,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   //Add a new Spline object
   Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
 
-  //Add a new Spline function for creation a bezier curve relatively to points set
+  //Add a new Spline function for interpolation type
   Handle(GEOM_Function) aFunction =
     aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
   if (aFunction.IsNull()) return NULL;
@@ -808,28 +796,25 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
 
   GEOMImpl_ISpline aCI (aFunction);
 
-  int aLen = thePoints.size();
   aCI.SetConstructorType(POINT_CONSTRUCTOR);
-  aCI.SetLength(aLen);
 
-  int ind = 1;
+  Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
   std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
-  for (; it != thePoints.end(); it++, ind++) {
+  for (; it != thePoints.end(); it++) {
     Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
-
-    if (aRefPnt.IsNull()) return NULL;
-
-    aCI.SetPoint(ind, aRefPnt);
+    if (aRefPnt.IsNull()) {
+      return NULL;
+    }
+    aPoints->Append(aRefPnt);
   }
+  aCI.SetPoints(aPoints);
 
   aCI.SetIsClosed(theIsClosed);
   aCI.SetDoReordering(theDoReordering);
 
   //Compute the Spline value
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if (!GetSolver()->ComputeFunction(aFunction)) {
       SetErrorCode("Spline driver failed");
       return NULL;
@@ -856,6 +841,83 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   return aSpline;
 }
 
+
+//=============================================================================
+/*!
+ *  MakeSplineInterpolWithTangents
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
+                                          (std::list<Handle(GEOM_Object)> thePoints,
+                                           Handle(GEOM_Object) theFirstVec,
+                                           Handle(GEOM_Object) theLastVec)
+{
+  SetErrorCode(KO);
+
+  //Add a new Spline object
+  Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+
+  //Add a new Spline function for interpolation type
+  Handle(GEOM_Function) aFunction =
+    aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOL_TANGENTS);
+  if (aFunction.IsNull()) return NULL;
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
+
+  GEOMImpl_ISpline aCI (aFunction);
+
+  aCI.SetConstructorType(POINT_CONSTRUCTOR);
+
+  Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
+  std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+  for (; it != thePoints.end(); it++) {
+    Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
+    if (aRefPnt.IsNull()) {
+      SetErrorCode("NULL point for Interpolation");
+      return NULL;
+    }
+    aPoints->Append(aRefPnt);
+  }
+  aCI.SetPoints(aPoints);
+
+  Handle(GEOM_Function) aVec1 = theFirstVec->GetLastFunction();
+  Handle(GEOM_Function) aVec2 = theLastVec->GetLastFunction();
+
+  if (aVec1.IsNull() || aVec2.IsNull()) return NULL;
+
+  aCI.SetFirstVector(aVec1);
+  aCI.SetLastVector(aVec2);
+
+  //Compute the Spline value
+  try {
+    OCC_CATCH_SIGNALS;
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Spline driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump pd (aFunction);
+  pd << aSpline << " = geompy.MakeInterpolWithTangents([";
+
+  it = thePoints.begin();
+  pd << (*it++);
+  while (it != thePoints.end()) {
+    pd << ", " << (*it++);
+  }
+  pd << "], " << theFirstVec << ", " << theLastVec << ")";
+
+  SetErrorCode(OK);
+  return aSpline;
+}
+
 //=============================================================================
 /*!
  *  MakeCurveParametric
@@ -864,7 +926,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
              (const char* thexExpr, const char* theyExpr, const char* thezExpr,
               double theParamMin, double theParamMax, double theParamStep,
-              CurveType theCurveType, 
+              CurveType theCurveType,
               int theParamNbStep, bool theNewMethod)
 {
   TCollection_AsciiString aPyScript;
@@ -958,7 +1020,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
     coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
   else
     coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
-  
+
   PyObject* new_stderr = NULL;
 
   if (coords == NULL){
@@ -975,15 +1037,17 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
     return NULL;
   }
 
-  Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, PyList_Size( coords ) * 3);
+  int lsize = PyList_Size( coords );
 
-  if(PyList_Size( coords ) <= 0) {
+  if(lsize <= 0) {
     SetErrorCode("Empty list of the points, please check input parameters !!!");
     return NULL;
   }
 
+  Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, lsize * 3);
+
   int k=1;
-  for ( Py_ssize_t i = 0; i< PyList_Size( coords ); ++i ) {
+  for ( Py_ssize_t i = 0; i < lsize; ++i ) {
     PyObject* coord = PyList_GetItem( coords, i );
     if (coord != NULL) {
       for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
@@ -1016,11 +1080,11 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
 
     GEOMImpl_IPolyline aCI (aFunction);
 
-    aCI.SetLength(PyList_Size( coords ));
+    aCI.SetLength(lsize);
     aCI.SetConstructorType(COORD_CONSTRUCTOR);
     aCI.SetIsClosed(false);
     aCI.SetCoordinates(aCoordsArray);
-    aCurveType = "geompy.GEOM.Polyline";
+    aCurveType = "GEOM.Polyline";
     break;
   }
   case Bezier: {
@@ -1036,11 +1100,10 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
 
     GEOMImpl_ISpline aCI (aFunction);
 
-    aCI.SetLength(PyList_Size( coords ));
     aCI.SetConstructorType(COORD_CONSTRUCTOR);
     aCI.SetIsClosed(false);
     aCI.SetCoordinates(aCoordsArray);
-    aCurveType = "geompy.GEOM.Bezier";
+    aCurveType = "GEOM.Bezier";
     break;
   }
   case Interpolation: {
@@ -1056,20 +1119,28 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
 
     GEOMImpl_ISpline aCI (aFunction);
     aCI.SetConstructorType(COORD_CONSTRUCTOR);
-    aCI.SetLength(PyList_Size( coords ));
     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;
@@ -1136,9 +1207,7 @@ 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;
@@ -1200,9 +1269,7 @@ 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;
@@ -1251,9 +1318,7 @@ 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;
@@ -1311,9 +1376,7 @@ 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;
@@ -1339,3 +1402,221 @@ 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(GetDocID(), 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) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    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(GetDocID(), 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 {
+#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());
+    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(GetDocID(), 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 {
+#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());
+    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;
+}