+//=============================================================================
+/*!
+ * 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;
+}
+