Salome HOME
Remove warnings
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ICurvesOperations.cxx
index 6a6b8f9ef257d21b2d4ee2100df8f92446718695..3d53948c382bdace1eaa0ba7e56eb43e4810d7af 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_ICurvesOperations.hxx>
@@ -75,73 +75,6 @@ GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
 }
 
 
-//=============================================================================
-/*!
- *  MakePolyline
- */
-//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list<Handle(GEOM_Object)> thePoints)
-{
-  SetErrorCode(KO);
-
-  //Add a new Polyline object
-  Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
-
-  //Add a new Polyline function for creation a polyline relatively to points set
-  Handle(GEOM_Function) aFunction =
-    aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
-  if (aFunction.IsNull()) return NULL;
-
-  //Check if the function is set correctly
-  if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
-
-  GEOMImpl_IPolyline aCI (aFunction);
-
-  int aLen = thePoints.size();
-  aCI.SetLength(aLen);
-
-  int ind = 1;
-  list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
-  for (; it != thePoints.end(); it++, ind++) {
-    Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
-    if (aRefPnt.IsNull()) {
-      SetErrorCode("NULL point for Polyline");
-      return NULL;
-    }
-    aCI.SetPoint(ind, aRefPnt);
-  }
-
-  //Compute the Polyline value
-  try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
-    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
-  GEOM::TPythonDump pd (aFunction);
-  pd << aPolyline << " = geompy.MakePolyline([";
-
-  it = thePoints.begin();
-  pd << (*it++);
-  while (it != thePoints.end()) {
-    pd << ", " << (*it++);
-  }
-  pd << "])";
-
-  SetErrorCode(OK);
-  return aPolyline;
-}
-
 //=============================================================================
 /*!
  *  MakeCircleThreePnt
@@ -334,12 +267,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
                        (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
-                        double theRMajor, double theRMinor)
+                        double theRMajor, double theRMinor,
+                        Handle(GEOM_Object) theVecMaj)
 {
   SetErrorCode(KO);
 
   // Not set thePnt means origin of global CS,
   // Not set theVec means Z axis of global CS
+  // Not set theVecMaj means X axis of global CS
   //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
 
   //Add a new Ellipse object
@@ -370,6 +305,12 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
   aCI.SetRMajor(theRMajor);
   aCI.SetRMinor(theRMinor);
 
+  if (!theVecMaj.IsNull()) {
+    Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
+    if (aRefVecMaj.IsNull()) return NULL;
+    aCI.SetVectorMajor(aRefVecMaj);
+  }
+
   //Compute the Ellipse value
   try {
 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
@@ -387,8 +328,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
   }
 
   //Make a Python command
-  GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
-    << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+  if (!theVecMaj.IsNull()) {
+    GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+                                 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
+                                 << ", " << theVecMaj << ")";
+  }
+  else {
+    GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+                                 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+  }
 
   SetErrorCode(OK);
   return anEll;
@@ -521,8 +469,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Objec
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
-                                                                 Handle(GEOM_Object) thePnt2,
-                                                                 Handle(GEOM_Object) thePnt3)
+                                                                  Handle(GEOM_Object) thePnt2,
+                                                                  Handle(GEOM_Object) thePnt3)
 {
   SetErrorCode(KO);
 
@@ -576,13 +524,84 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Ob
   return anArc;
 }
 
+//=============================================================================
+/*!
+ *  MakePolyline
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints,
+                                                              bool theIsClosed)
+{
+  SetErrorCode(KO);
+
+  //Add a new Polyline object
+  Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
+
+  //Add a new Polyline function for creation a polyline relatively to points set
+  Handle(GEOM_Function) aFunction =
+    aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
+  if (aFunction.IsNull()) return NULL;
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
+
+  GEOMImpl_IPolyline aCI (aFunction);
+
+  int aLen = thePoints.size();
+  aCI.SetLength(aLen);
+
+  int ind = 1;
+  std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+  for (; it != thePoints.end(); it++, ind++) {
+    Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
+    if (aRefPnt.IsNull()) {
+      SetErrorCode("NULL point for Polyline");
+      return NULL;
+    }
+    aCI.SetPoint(ind, aRefPnt);
+  }
+
+  aCI.SetIsClosed(theIsClosed);
+
+  //Compute the Polyline value
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    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
+  GEOM::TPythonDump pd (aFunction);
+  pd << aPolyline << " = geompy.MakePolyline([";
+
+  it = thePoints.begin();
+  pd << (*it++);
+  while (it != thePoints.end()) {
+    pd << ", " << (*it++);
+  }
+  pd << "], " << theIsClosed << ")";
+
+  SetErrorCode(OK);
+  return aPolyline;
+}
+
 //=============================================================================
 /*!
  *  MakeSplineBezier
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
-                                          (list<Handle(GEOM_Object)> thePoints)
+                                          (std::list<Handle(GEOM_Object)> thePoints,
+                                           bool theIsClosed)
 {
   SetErrorCode(KO);
 
@@ -603,7 +622,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
   aCI.SetLength(aLen);
 
   int ind = 1;
-  list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+  std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
   for (; it != thePoints.end(); it++, ind++) {
     Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
 
@@ -612,6 +631,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
     aCI.SetPoint(ind, aRefPnt);
   }
 
+  aCI.SetIsClosed(theIsClosed);
+
   //Compute the Spline value
   try {
 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
@@ -637,7 +658,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
   while (it != thePoints.end()) {
     pd << ", " << (*it++);
   }
-  pd << "])";
+  pd << "], " << theIsClosed << ")";
 
   SetErrorCode(OK);
   return aSpline;
@@ -649,7 +670,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
-                                          (list<Handle(GEOM_Object)> thePoints)
+                                          (std::list<Handle(GEOM_Object)> thePoints,
+                                           bool theIsClosed,
+                                           bool theDoReordering)
 {
   SetErrorCode(KO);
 
@@ -670,7 +693,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   aCI.SetLength(aLen);
 
   int ind = 1;
-  list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
+  std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
   for (; it != thePoints.end(); it++, ind++) {
     Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
 
@@ -679,6 +702,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
     aCI.SetPoint(ind, aRefPnt);
   }
 
+  aCI.SetIsClosed(theIsClosed);
+  aCI.SetDoReordering(theDoReordering);
+
   //Compute the Spline value
   try {
 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
@@ -704,7 +730,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   while (it != thePoints.end()) {
     pd << ", " << (*it++);
   }
-  pd << "])";
+  pd << "], " << theIsClosed << ", " << theDoReordering << ")";
 
   SetErrorCode(OK);
   return aSpline;
@@ -716,7 +742,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
-                                                             list<double> theWorkingPlane)
+                                                              std::list<double> theWorkingPlane)
 {
   SetErrorCode(KO);
 
@@ -739,7 +765,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
   aCI.SetCommand(aCommand);
 
   int ind = 1;
-  list<double>::iterator it = theWorkingPlane.begin();
+  std::list<double>::iterator it = theWorkingPlane.begin();
   for (; it != theWorkingPlane.end(); it++, ind++)
     aCI.SetWorkingPlane(ind, *it);
 
@@ -779,7 +805,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
  *  Make3DSketcher
  */
 //=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list<double> theCoordinates)
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
 {
   SetErrorCode(KO);
 
@@ -797,7 +823,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list<double> the
   GEOMImpl_I3DSketcher aCI (aFunction);
 
   int nbOfCoords = 0;
-  list<double>::iterator it = theCoordinates.begin();
+  std::list<double>::iterator it = theCoordinates.begin();
   for (; it != theCoordinates.end(); it++)
     nbOfCoords++;