1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // E.A. : On windows with python 2.6, there is a conflict
25 // E.A. : between pymath.h and Standard_math.h which define
26 // E.A. : some same symbols : acosh, asinh, ...
27 #include <Standard_math.hxx>
32 #include <structmember.h>
38 #include "GEOMImpl_ICurvesOperations.hxx"
39 #include "GEOMImpl_Types.hxx"
41 #include "GEOM_Function.hxx"
42 #include "GEOM_PythonDump.hxx"
44 #include "GEOMImpl_PolylineDriver.hxx"
45 #include "GEOMImpl_CircleDriver.hxx"
46 #include "GEOMImpl_SplineDriver.hxx"
47 #include "GEOMImpl_EllipseDriver.hxx"
48 #include "GEOMImpl_ArcDriver.hxx"
49 #include "GEOMImpl_ShapeDriver.hxx"
50 #include "GEOMImpl_SketcherDriver.hxx"
51 #include "GEOMImpl_3DSketcherDriver.hxx"
53 #include "GEOMImpl_IPolyline.hxx"
54 #include "GEOMImpl_IPolyline2D.hxx"
55 #include "GEOMImpl_ICircle.hxx"
56 #include "GEOMImpl_ISpline.hxx"
57 #include "GEOMImpl_IEllipse.hxx"
58 #include "GEOMImpl_IArc.hxx"
59 #include "GEOMImpl_ISketcher.hxx"
60 #include "GEOMImpl_I3DSketcher.hxx"
61 #include "GEOMImpl_ICurveParametric.hxx"
62 #include "GEOMImpl_IIsoline.hxx"
63 #include "GEOMImpl_PolylineDumper.hxx"
65 #include "utilities.h"
67 #include <TDF_Tool.hxx>
68 #include <TColStd_HArray1OfByte.hxx>
69 #include <TColStd_HArray1OfReal.hxx>
71 #include <Standard_Failure.hxx>
72 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
75 /* ==================================
76 * =========== PYTHON ==============
77 * ==================================*/
88 PyStdOut_dealloc(PyStdOut *self)
94 PyStdOut_write(PyStdOut* self, PyObject* args)
98 if (!PyArg_ParseTuple(args, "t#:write", &c, &l))
101 *(self->out) = *(self->out) + c;
107 static PyMethodDef PyStdOut_methods[] = {
108 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
109 PyDoc_STR("write(string) -> None")},
110 {NULL, NULL} /* sentinel */
113 static PyMemberDef PyStdOut_memberlist[] = {
114 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
115 (char*)"flag indicating that a space needs to be printed; used by print"},
116 {NULL} /* Sentinel */
119 static PyTypeObject PyStdOut_Type = {
120 /* The ob_type field must be initialized in the module init function
121 * to be portable to Windows without using C++. */
122 PyObject_HEAD_INIT(NULL)
125 sizeof(PyStdOut), /*tp_basicsize*/
128 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
135 0, /*tp_as_sequence*/
140 PyObject_GenericGetAttr, /*tp_getattro*/
141 /* softspace is writable: we must supply tp_setattro */
142 PyObject_GenericSetAttr, /* tp_setattro */
144 Py_TPFLAGS_DEFAULT, /*tp_flags*/
148 0, /*tp_richcompare*/
149 0, /*tp_weaklistoffset*/
152 PyStdOut_methods, /*tp_methods*/
153 PyStdOut_memberlist, /*tp_members*/
167 PyObject* newPyStdOut( std::string& out )
169 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
174 return (PyObject*)self;
178 ////////////////////////END PYTHON///////////////////////////
179 //=============================================================================
183 //=============================================================================
184 GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
185 : GEOM_IOperations(theEngine, theDocID)
187 MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
190 //=============================================================================
194 //=============================================================================
195 GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
197 MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations");
201 //=============================================================================
205 //=============================================================================
206 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
207 Handle(GEOM_Object) thePnt2,
208 Handle(GEOM_Object) thePnt3)
212 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
214 //Add a new Circle object
215 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
217 //Add a new Circle function for creation a circle relatively to three points
218 Handle(GEOM_Function) aFunction =
219 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
220 if (aFunction.IsNull()) return NULL;
222 //Check if the function is set correctly
223 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
225 GEOMImpl_ICircle aCI (aFunction);
227 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
228 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
229 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
231 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
233 aCI.SetPoint1(aRefPnt1);
234 aCI.SetPoint2(aRefPnt2);
235 aCI.SetPoint3(aRefPnt3);
237 //Compute the Circle value
240 if (!GetSolver()->ComputeFunction(aFunction)) {
241 SetErrorCode("Circle driver failed");
245 catch (Standard_Failure& aFail) {
246 SetErrorCode(aFail.GetMessageString());
250 //Make a Python command
251 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
252 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
258 //=============================================================================
260 * MakeCircleCenter2Pnt
262 //=============================================================================
263 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
264 Handle(GEOM_Object) thePnt2,
265 Handle(GEOM_Object) thePnt3)
269 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
271 //Add a new Circle object
272 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
274 //Add a new Circle function for creation a circle relatively to center and 2 points
275 Handle(GEOM_Function) aFunction =
276 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
277 if (aFunction.IsNull()) return NULL;
279 //Check if the function is set correctly
280 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
282 GEOMImpl_ICircle aCI (aFunction);
284 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
285 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
286 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
288 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
290 aCI.SetPoint1(aRefPnt1);
291 aCI.SetPoint2(aRefPnt2);
292 aCI.SetPoint3(aRefPnt3);
294 //Compute the Circle value
297 if (!GetSolver()->ComputeFunction(aFunction)) {
298 SetErrorCode("Circle driver failed");
302 catch (Standard_Failure& aFail) {
303 SetErrorCode(aFail.GetMessageString());
307 //Make a Python command
308 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleCenter2Pnt("
309 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
315 //=============================================================================
319 //=============================================================================
320 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
321 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
325 // Not set thePnt means origin of global CS,
326 // Not set theVec means Z axis of global CS
327 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
329 //Add a new Circle object
330 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
332 //Add a new Circle function for creation a circle relatively to point and vector
333 Handle(GEOM_Function) aFunction =
334 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
335 if (aFunction.IsNull()) return NULL;
337 //Check if the function is set correctly
338 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
340 GEOMImpl_ICircle aCI (aFunction);
342 if (!thePnt.IsNull()) {
343 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
344 if (aRefPnt.IsNull()) return NULL;
345 aCI.SetCenter(aRefPnt);
348 if (!theVec.IsNull()) {
349 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
350 if (aRefVec.IsNull()) return NULL;
351 aCI.SetVector(aRefVec);
356 //Compute the Circle value
359 if (!GetSolver()->ComputeFunction(aFunction)) {
360 SetErrorCode("Circle driver failed");
364 catch (Standard_Failure& aFail) {
365 SetErrorCode(aFail.GetMessageString());
369 //Make a Python command
370 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
371 << thePnt << ", " << theVec << ", " << theR << ")";
377 //=============================================================================
381 //=============================================================================
382 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
383 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
384 double theRMajor, double theRMinor,
385 Handle(GEOM_Object) theVecMaj)
389 // Not set thePnt means origin of global CS,
390 // Not set theVec means Z axis of global CS
391 // Not set theVecMaj means X axis of global CS
392 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
394 //Add a new Ellipse object
395 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
397 //Add a new Ellipse function
398 Handle(GEOM_Function) aFunction =
399 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
400 if (aFunction.IsNull()) return NULL;
402 //Check if the function is set correctly
403 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
405 GEOMImpl_IEllipse aCI (aFunction);
407 if (!thePnt.IsNull()) {
408 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
409 if (aRefPnt.IsNull()) return NULL;
410 aCI.SetCenter(aRefPnt);
413 if (!theVec.IsNull()) {
414 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
415 if (aRefVec.IsNull()) return NULL;
416 aCI.SetVector(aRefVec);
419 aCI.SetRMajor(theRMajor);
420 aCI.SetRMinor(theRMinor);
422 if (!theVecMaj.IsNull()) {
423 Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
424 if (aRefVecMaj.IsNull()) return NULL;
425 aCI.SetVectorMajor(aRefVecMaj);
428 //Compute the Ellipse value
431 if (!GetSolver()->ComputeFunction(aFunction)) {
432 SetErrorCode("Ellipse driver failed");
436 catch (Standard_Failure& aFail) {
437 SetErrorCode(aFail.GetMessageString());
441 //Make a Python command
442 if (!theVecMaj.IsNull()) {
443 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
444 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
445 << ", " << theVecMaj << ")";
448 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
449 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
456 //=============================================================================
460 //=============================================================================
461 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
462 Handle(GEOM_Object) thePnt2,
463 Handle(GEOM_Object) thePnt3)
467 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
469 //Add a new Circle Arc object
470 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
472 //Add a new Circle Arc function
473 Handle(GEOM_Function) aFunction =
474 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
476 if (aFunction.IsNull()) return NULL;
478 //Check if the function is set correctly
479 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
480 GEOMImpl_IArc aCI (aFunction);
482 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
483 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
484 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
486 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
488 aCI.SetPoint1(aRefPnt1);
489 aCI.SetPoint2(aRefPnt2);
490 aCI.SetPoint3(aRefPnt3);
492 //Compute the Arc value
495 if (!GetSolver()->ComputeFunction(aFunction)) {
496 SetErrorCode("Arc driver failed");
500 catch (Standard_Failure& aFail) {
501 SetErrorCode(aFail.GetMessageString());
505 //Make a Python command
506 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
507 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
513 //=============================================================================
517 //=============================================================================
518 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
519 Handle(GEOM_Object) thePnt2,
520 Handle(GEOM_Object) thePnt3,
524 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
526 //Add a new Circle Arc object
527 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
529 //Add a new Circle Arc function
530 Handle(GEOM_Function) aFunction =
531 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
532 if (aFunction.IsNull()) return NULL;
534 //Check if the function is set correctly
535 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
537 GEOMImpl_IArc aCI (aFunction);
539 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
540 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
541 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
543 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
545 aCI.SetPoint1(aRefPnt1);
546 aCI.SetPoint2(aRefPnt2);
547 aCI.SetPoint3(aRefPnt3);
548 aCI.SetSense(theSense);
550 //Compute the Arc value
553 if (!GetSolver()->ComputeFunction(aFunction)) {
554 SetErrorCode("Arc driver failed");
558 catch (Standard_Failure& aFail) {
559 SetErrorCode(aFail.GetMessageString());
562 //Make a Python command
563 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
564 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
570 //=============================================================================
574 //=============================================================================
575 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
576 Handle(GEOM_Object) thePnt2,
577 Handle(GEOM_Object) thePnt3)
581 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
583 //Add a new Circle Arc object
584 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
586 //Add a new Circle Arc function
587 Handle(GEOM_Function) aFunction =
588 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
590 if (aFunction.IsNull()) return NULL;
592 //Check if the function is set correctly
593 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
594 GEOMImpl_IArc aCI (aFunction);
596 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
597 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
598 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
600 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
602 aCI.SetPoint1(aRefPnt1);
603 aCI.SetPoint2(aRefPnt2);
604 aCI.SetPoint3(aRefPnt3);
606 //Compute the Arc value
609 if (!GetSolver()->ComputeFunction(aFunction)) {
610 SetErrorCode("Arc driver failed");
614 catch (Standard_Failure& aFail) {
615 SetErrorCode(aFail.GetMessageString());
619 //Make a Python command
620 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
621 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
627 //=============================================================================
631 //=============================================================================
632 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints,
637 //Add a new Polyline object
638 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
640 //Add a new Polyline function for creation a polyline relatively to points set
641 Handle(GEOM_Function) aFunction =
642 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
643 if (aFunction.IsNull()) return NULL;
645 //Check if the function is set correctly
646 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
648 GEOMImpl_IPolyline aCI (aFunction);
650 int aLen = thePoints.size();
652 aCI.SetConstructorType(POINT_CONSTRUCTOR);
655 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
656 for (; it != thePoints.end(); it++, ind++) {
657 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
658 if (aRefPnt.IsNull()) {
659 SetErrorCode("NULL point for Polyline");
662 aCI.SetPoint(ind, aRefPnt);
665 aCI.SetIsClosed(theIsClosed);
667 //Compute the Polyline value
670 if (!GetSolver()->ComputeFunction(aFunction)) {
671 SetErrorCode("Polyline driver failed");
675 catch (Standard_Failure& aFail) {
676 SetErrorCode(aFail.GetMessageString());
680 //Make a Python command
681 GEOM::TPythonDump pd (aFunction);
682 pd << aPolyline << " = geompy.MakePolyline([";
684 it = thePoints.begin();
686 while (it != thePoints.end()) {
687 pd << ", " << (*it++);
689 pd << "], " << theIsClosed << ")";
695 //=============================================================================
699 //=============================================================================
700 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
701 (std::list<Handle(GEOM_Object)> thePoints,
706 //Add a new Spline object
707 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
709 //Add a new Spline function for creation a bezier curve relatively to points set
710 Handle(GEOM_Function) aFunction =
711 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
712 if (aFunction.IsNull()) return NULL;
714 //Check if the function is set correctly
715 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
717 GEOMImpl_ISpline aCI (aFunction);
719 aCI.SetConstructorType(POINT_CONSTRUCTOR);
721 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
722 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
723 for (; it != thePoints.end(); it++) {
724 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
725 if (aRefPnt.IsNull()) {
726 SetErrorCode("NULL point for Besier curve");
729 aPoints->Append(aRefPnt);
731 aCI.SetPoints(aPoints);
733 aCI.SetIsClosed(theIsClosed);
735 //Compute the Spline value
738 if (!GetSolver()->ComputeFunction(aFunction)) {
739 SetErrorCode("Spline driver failed");
743 catch (Standard_Failure& aFail) {
744 SetErrorCode(aFail.GetMessageString());
748 //Make a Python command
749 GEOM::TPythonDump pd (aFunction);
750 pd << aSpline << " = geompy.MakeBezier([";
752 it = thePoints.begin();
754 while (it != thePoints.end()) {
755 pd << ", " << (*it++);
757 pd << "], " << theIsClosed << ")";
763 //=============================================================================
765 * MakeSplineInterpolation
767 //=============================================================================
768 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
769 (std::list<Handle(GEOM_Object)> thePoints,
771 bool theDoReordering)
775 //Add a new Spline object
776 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
778 //Add a new Spline function for interpolation type
779 Handle(GEOM_Function) aFunction =
780 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
781 if (aFunction.IsNull()) return NULL;
783 //Check if the function is set correctly
784 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
786 GEOMImpl_ISpline aCI (aFunction);
788 aCI.SetConstructorType(POINT_CONSTRUCTOR);
790 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
791 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
792 for (; it != thePoints.end(); it++) {
793 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
794 if (aRefPnt.IsNull()) {
797 aPoints->Append(aRefPnt);
799 aCI.SetPoints(aPoints);
801 aCI.SetIsClosed(theIsClosed);
802 aCI.SetDoReordering(theDoReordering);
804 //Compute the Spline value
807 if (!GetSolver()->ComputeFunction(aFunction)) {
808 SetErrorCode("Spline driver failed");
812 catch (Standard_Failure& aFail) {
813 SetErrorCode(aFail.GetMessageString());
817 //Make a Python command
818 GEOM::TPythonDump pd (aFunction);
819 pd << aSpline << " = geompy.MakeInterpol([";
821 it = thePoints.begin();
823 while (it != thePoints.end()) {
824 pd << ", " << (*it++);
826 pd << "], " << theIsClosed << ", " << theDoReordering << ")";
833 //=============================================================================
835 * MakeSplineInterpolWithTangents
837 //=============================================================================
838 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
839 (std::list<Handle(GEOM_Object)> thePoints,
840 Handle(GEOM_Object) theFirstVec,
841 Handle(GEOM_Object) theLastVec)
845 //Add a new Spline object
846 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
848 //Add a new Spline function for interpolation type
849 Handle(GEOM_Function) aFunction =
850 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOL_TANGENTS);
851 if (aFunction.IsNull()) return NULL;
853 //Check if the function is set correctly
854 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
856 GEOMImpl_ISpline aCI (aFunction);
858 aCI.SetConstructorType(POINT_CONSTRUCTOR);
860 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
861 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
862 for (; it != thePoints.end(); it++) {
863 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
864 if (aRefPnt.IsNull()) {
865 SetErrorCode("NULL point for Interpolation");
868 aPoints->Append(aRefPnt);
870 aCI.SetPoints(aPoints);
872 Handle(GEOM_Function) aVec1 = theFirstVec->GetLastFunction();
873 Handle(GEOM_Function) aVec2 = theLastVec->GetLastFunction();
875 if (aVec1.IsNull() || aVec2.IsNull()) return NULL;
877 aCI.SetFirstVector(aVec1);
878 aCI.SetLastVector(aVec2);
880 //Compute the Spline value
883 if (!GetSolver()->ComputeFunction(aFunction)) {
884 SetErrorCode("Spline driver failed");
888 catch (Standard_Failure& aFail) {
889 SetErrorCode(aFail.GetMessageString());
893 //Make a Python command
894 GEOM::TPythonDump pd (aFunction);
895 pd << aSpline << " = geompy.MakeInterpolWithTangents([";
897 it = thePoints.begin();
899 while (it != thePoints.end()) {
900 pd << ", " << (*it++);
902 pd << "], " << theFirstVec << ", " << theLastVec << ")";
908 //=============================================================================
910 * MakeCurveParametric
912 //=============================================================================
913 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
914 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
915 double theParamMin, double theParamMax, double theParamStep,
916 CurveType theCurveType,
917 int theParamNbStep, bool theNewMethod)
919 TCollection_AsciiString aPyScript;
920 aPyScript +="from math import * \n";
921 aPyScript +="def X(t): \n";
922 aPyScript +=" return ";
923 aPyScript += thexExpr;
925 aPyScript +="def Y(t): \n";
926 aPyScript +=" return ";
927 aPyScript += theyExpr;
930 aPyScript +="def Z(t): \n";
931 aPyScript +=" return ";
932 aPyScript += thezExpr;
937 aPyScript +="def coordCalculator(tmin, tmax, nstep): \n";
938 aPyScript +=" coords = [] \n";
939 aPyScript +=" tstep = (tmax - tmin) / nstep \n";
940 aPyScript +=" n = 0 \n";
941 aPyScript +=" while n <= nstep : \n";
942 aPyScript +=" t = tmin + n*tstep \n";
943 aPyScript +=" coords.append([X(t), Y(t), Z(t)]) \n";
944 aPyScript +=" n = n+1 \n";
945 aPyScript +=" return coords \n";
949 aPyScript +="def coordCalculator(tmin, tmax, tstep): \n";
950 aPyScript +=" coords = [] \n";
951 aPyScript +=" while tmin <= tmax : \n";
952 aPyScript +=" coords.append([X(tmin), Y(tmin), Z(tmin)]) \n";
953 aPyScript +=" tmin = tmin + tstep \n";
954 aPyScript +=" return coords \n";
959 if(theParamMin >= theParamMax) {
960 SetErrorCode("The minimum value of the parameter must be less than maximum value !!!");
964 if(!theNewMethod && theParamStep <= 0.0) {
965 SetErrorCode("Value of the step must be positive !!!");
968 else if(theNewMethod && theParamNbStep < 0) {
969 SetErrorCode("The number of steps must be positive !!!");
973 /* Initialize the Python interpreter */
974 if (! Py_IsInitialized()) {
975 SetErrorCode("Python interpreter is not initialized !!! ");
979 PyGILState_STATE gstate;
980 gstate = PyGILState_Ensure();
982 PyObject* main_mod = PyImport_AddModule("__main__");
983 PyObject* main_dict = PyModule_GetDict(main_mod);
985 PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
988 SetErrorCode("Error during executing of python script !!!");
990 PyGILState_Release(gstate);
996 PyObject * func = NULL;
997 func = PyObject_GetAttrString(main_mod, "coordCalculator");
1000 SetErrorCode("Can't get function from python module !!!");
1001 PyGILState_Release(gstate);
1007 coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
1009 coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
1011 if (coords == NULL){
1013 std::string err_description="";
1014 PyObject* new_stderr = newPyStdOut(err_description);
1015 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
1016 Py_INCREF(old_stderr);
1017 PySys_SetObject((char*)"stderr", new_stderr);
1019 PySys_SetObject((char*)"stderr", old_stderr);
1020 Py_DECREF(new_stderr);
1021 MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
1022 SetErrorCode("Can't evaluate the expressions, please check them !!!");
1023 PyGILState_Release(gstate);
1027 int lsize = PyList_Size( coords );
1030 SetErrorCode("Empty list of the points, please check input parameters !!!");
1034 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, lsize * 3);
1037 for ( Py_ssize_t i = 0; i < lsize; ++i ) {
1038 PyObject* coord = PyList_GetItem( coords, i );
1039 if (coord != NULL) {
1040 for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
1041 PyObject* item = PyList_GetItem(coord, j);
1042 aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
1050 PyGILState_Release(gstate);
1052 Handle(GEOM_Object) aCurve;
1053 Handle(GEOM_Function) aFunction;
1054 TCollection_AsciiString aCurveType;
1056 switch(theCurveType) {
1058 //Add a new Polyline object
1059 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
1061 //Add a new Polyline function for creation a polyline relatively to points set
1062 aFunction = aCurve->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
1063 if (aFunction.IsNull()) return NULL;
1065 //Check if the function is set correctly
1066 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
1068 GEOMImpl_IPolyline aCI (aFunction);
1070 aCI.SetLength(lsize);
1071 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1072 aCI.SetIsClosed(false);
1073 aCI.SetCoordinates(aCoordsArray);
1074 aCurveType = "GEOM.Polyline";
1078 //Add a new Spline object
1079 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
1080 //Add a new Spline function for creation a bezier curve relatively to points set
1082 aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
1083 if (aFunction.IsNull()) return NULL;
1085 //Check if the function is set correctly
1086 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
1088 GEOMImpl_ISpline aCI (aFunction);
1090 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1091 aCI.SetIsClosed(false);
1092 aCI.SetCoordinates(aCoordsArray);
1093 aCurveType = "GEOM.Bezier";
1096 case Interpolation: {
1097 //Add a new Spline object
1098 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
1100 //Add a new Spline function for creation a bezier curve relatively to points set
1101 aFunction = aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
1102 if (aFunction.IsNull()) return NULL;
1104 //Check if the function is set correctly
1105 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
1107 GEOMImpl_ISpline aCI (aFunction);
1108 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1109 aCI.SetIsClosed(false);
1110 aCI.SetDoReordering(false);
1111 aCI.SetCoordinates(aCoordsArray);
1112 aCurveType = "GEOM.Interpolation";
1117 GEOMImpl_ICurveParametric aIP(aFunction);
1118 aIP.SetExprX (thexExpr);
1119 aIP.SetExprY (theyExpr);
1120 aIP.SetExprZ (thezExpr);
1121 aIP.SetParamMin (theParamMin);
1122 aIP.SetParamMax (theParamMax);
1124 aIP.SetParamNbStep(theParamNbStep);
1126 aIP.SetParamStep (theParamStep);
1128 //Compute the Curve value
1131 if (!GetSolver()->ComputeFunction(aFunction)) {
1132 SetErrorCode("Curve driver failed !!!");
1136 catch (Standard_Failure& aFail) {
1137 SetErrorCode(aFail.GetMessageString());
1141 //Make a Python command
1142 GEOM::TPythonDump pd (aFunction);
1143 pd << aCurve << " = geompy.MakeCurveParametric(";
1144 pd << "\"" << thexExpr << "\", ";
1145 pd << "\"" << theyExpr << "\", ";
1146 pd << "\"" << thezExpr << "\", ";
1148 pd << theParamMin <<", ";
1149 pd << theParamMax <<", ";
1151 pd << theParamNbStep <<", ";
1153 pd << theParamStep <<", ";
1154 pd << aCurveType.ToCString() <<", ";
1155 pd << theNewMethod <<")";
1161 //=============================================================================
1165 //=============================================================================
1166 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
1167 std::list<double> theWorkingPlane)
1171 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1173 //Add a new Sketcher object
1174 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
1176 //Add a new Sketcher function
1177 Handle(GEOM_Function) aFunction =
1178 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
1179 if (aFunction.IsNull()) return NULL;
1181 //Check if the function is set correctly
1182 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
1184 GEOMImpl_ISketcher aCI (aFunction);
1186 TCollection_AsciiString aCommand((char*) theCommand);
1187 aCI.SetCommand(aCommand);
1190 std::list<double>::iterator it = theWorkingPlane.begin();
1191 for (; it != theWorkingPlane.end(); it++, ind++)
1192 aCI.SetWorkingPlane(ind, *it);
1194 //Compute the Sketcher value
1197 if (!GetSolver()->ComputeFunction(aFunction)) {
1198 SetErrorCode("Sketcher driver failed");
1202 catch (Standard_Failure& aFail) {
1203 SetErrorCode(aFail.GetMessageString());
1207 //Make a Python command
1208 GEOM::TPythonDump pd (aFunction);
1209 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
1211 it = theWorkingPlane.begin();
1213 while (it != theWorkingPlane.end()) {
1214 pd << ", " << (*it++);
1222 //=============================================================================
1224 * MakeSketcherOnPlane
1226 //=============================================================================
1227 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
1228 (const char* theCommand,
1229 Handle(GEOM_Object) theWorkingPlane)
1233 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1235 //Add a new Sketcher object
1236 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
1238 //Add a new Sketcher function
1239 Handle(GEOM_Function) aFunction =
1240 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
1241 if (aFunction.IsNull()) return NULL;
1243 //Check if the function is set correctly
1244 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
1246 GEOMImpl_ISketcher aCI (aFunction);
1248 TCollection_AsciiString aCommand((char*) theCommand);
1249 aCI.SetCommand(aCommand);
1251 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
1252 if (aRefPlane.IsNull()) return NULL;
1253 aCI.SetWorkingPlane( aRefPlane );
1255 //Compute the Sketcher value
1258 if (!GetSolver()->ComputeFunction(aFunction)) {
1259 SetErrorCode("Sketcher driver failed");
1263 catch (Standard_Failure& aFail) {
1264 SetErrorCode(aFail.GetMessageString());
1268 //Make a Python command
1269 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
1270 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";
1276 //=============================================================================
1278 * Make3DSketcherCommand
1280 //=============================================================================
1281 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const char* theCommand)
1285 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1287 //Add a new Sketcher object
1288 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
1290 //Add a new Sketcher function
1291 Handle(GEOM_Function) aFunction =
1292 aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND);
1293 if (aFunction.IsNull()) return NULL;
1295 //Check if the function is set correctly
1296 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
1298 GEOMImpl_I3DSketcher aCI (aFunction);
1300 TCollection_AsciiString aCommand ((char*) theCommand);
1301 aCI.SetCommand(aCommand);
1303 //Compute the 3D Sketcher value
1306 if (!GetSolver()->ComputeFunction(aFunction)) {
1307 SetErrorCode("3D Sketcher driver failed");
1311 catch (Standard_Failure& aFail) {
1312 SetErrorCode(aFail.GetMessageString());
1316 //Make a Python command
1317 GEOM::TPythonDump pd (aFunction);
1318 pd << aSketcher << " = geompy.Make3DSketcherCommand(\"" << aCommand.ToCString() << "\")";
1324 //=============================================================================
1328 //=============================================================================
1329 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
1333 //Add a new Sketcher object
1334 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
1336 //Add a new Sketcher function
1337 Handle(GEOM_Function) aFunction =
1338 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COORDS);
1339 if (aFunction.IsNull()) return NULL;
1341 //Check if the function is set correctly
1342 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
1344 GEOMImpl_I3DSketcher aCI (aFunction);
1347 std::list<double>::iterator it = theCoordinates.begin();
1348 for (; it != theCoordinates.end(); it++)
1351 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
1353 it = theCoordinates.begin();
1355 for (; it != theCoordinates.end(); it++, ind++)
1356 aCoordsArray->SetValue(ind, *it);
1358 aCI.SetCoordinates(aCoordsArray);
1360 //Compute the Sketcher value
1363 if (!GetSolver()->ComputeFunction(aFunction)) {
1364 SetErrorCode("3D Sketcher driver failed");
1368 catch (Standard_Failure& aFail) {
1369 SetErrorCode(aFail.GetMessageString());
1373 //Make a Python command
1374 GEOM::TPythonDump pd (aFunction);
1375 pd << a3DSketcher << " = geompy.Make3DSketcher([";
1377 it = theCoordinates.begin();
1379 while (it != theCoordinates.end()) {
1380 pd << ", " << (*it++);
1388 //=============================================================================
1392 //=============================================================================
1393 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline
1394 (const Handle(GEOM_Object) &theFace,
1396 const double theParameter)
1400 if (theFace.IsNull()) {
1404 //Add a new Spline object
1405 Handle(GEOM_Object) anIsoline =
1406 GetEngine()->AddObject(GetDocID(), GEOM_ISOLINE);
1408 //Add a new Spline function for interpolation type
1409 Handle(GEOM_Function) aFunction =
1410 anIsoline->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPE_ISOLINE);
1412 if (aFunction.IsNull()) {
1416 //Check if the function is set correctly
1417 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
1421 GEOMImpl_IIsoline aCI (aFunction);
1422 Handle(GEOM_Function) aRefFace = theFace->GetLastFunction();
1424 if (aRefFace.IsNull()) {
1428 aCI.SetFace(aRefFace);
1429 aCI.SetIsUIso(IsUIso);
1430 aCI.SetParameter(theParameter);
1432 //Compute the isoline curve
1435 if (!GetSolver()->ComputeFunction(aFunction)) {
1436 SetErrorCode("Shape driver failed");
1440 catch (Standard_Failure& aFail) {
1441 SetErrorCode(aFail.GetMessageString());
1445 //Make a Python command
1446 GEOM::TPythonDump (aFunction) << anIsoline << " = geompy.MakeIsoline( "
1447 << theFace << ", " << IsUIso << ", " << theParameter << " )";
1453 //=============================================================================
1457 //=============================================================================
1458 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2D
1459 (const std::list <std::list <double> > &theCoords,
1460 const Handle(TColStd_HArray1OfExtendedString) &theNames,
1461 const Handle(TColStd_HArray1OfByte) &theTypes,
1462 const Handle(TColStd_HArray1OfByte) &theCloseds,
1463 const Handle(TColStd_HArray1OfReal) &theWorkingPlane)
1467 if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
1468 theCloseds.IsNull() || theWorkingPlane.IsNull()) {
1472 // Add a new Polyline object
1473 Handle(GEOM_Object) aResult =
1474 GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
1475 Handle(GEOM_Function) aFunction = aResult->AddFunction
1476 (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_COORDS);
1478 if (aFunction.IsNull()) {
1482 // Check if the function is set correctly
1483 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
1487 GEOMImpl_IPolyline2D aCI(aFunction);
1489 aCI.SetCoords(theCoords);
1490 aCI.SetNames(theNames);
1491 aCI.SetTypes(theTypes);
1492 aCI.SetClosedFlags(theCloseds);
1493 aCI.SetWorkingPlaneDbls(theWorkingPlane);
1495 // Compute the isoline curve
1498 if (!GetSolver()->ComputeFunction(aFunction)) {
1499 SetErrorCode("Polyline driver failed");
1503 catch (Standard_Failure& aFail) {
1504 SetErrorCode(aFail.GetMessageString());
1508 //Make a Python command
1509 GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
1510 theCloseds, theWorkingPlane);
1512 aDumper.Dump(aResult);
1514 if (aDumper.IsDone() == Standard_False) {
1515 SetErrorCode("Python dump failed");
1523 //=============================================================================
1525 * MakePolyline2DOnPlane
1527 //=============================================================================
1528 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2DOnPlane
1529 (const std::list <std::list <double> > &theCoords,
1530 const Handle(TColStd_HArray1OfExtendedString) &theNames,
1531 const Handle(TColStd_HArray1OfByte) &theTypes,
1532 const Handle(TColStd_HArray1OfByte) &theCloseds,
1533 const Handle(GEOM_Object) &theWorkingPlane)
1537 if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
1538 theCloseds.IsNull() || theWorkingPlane.IsNull()) {
1542 //Add a new Polyline object
1543 Handle(GEOM_Object) aResult =
1544 GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
1545 Handle(GEOM_Function) aFunction = aResult->AddFunction
1546 (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_OBJECT);
1548 if (aFunction.IsNull()) {
1552 //Check if the function is set correctly
1553 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
1557 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
1559 if (aRefPlane.IsNull()) {
1563 GEOMImpl_IPolyline2D aCI(aFunction);
1565 aCI.SetCoords(theCoords);
1566 aCI.SetNames(theNames);
1567 aCI.SetTypes(theTypes);
1568 aCI.SetClosedFlags(theCloseds);
1569 aCI.SetWorkingPlane(aRefPlane);
1571 //Compute the isoline curve
1574 if (!GetSolver()->ComputeFunction(aFunction)) {
1575 SetErrorCode("Polyline driver failed");
1579 catch (Standard_Failure& aFail) {
1580 SetErrorCode(aFail.GetMessageString());
1584 //Make a Python command
1585 GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
1586 theCloseds, theWorkingPlane);
1588 aDumper.Dump(aResult);
1590 if (aDumper.IsDone() == Standard_False) {
1591 SetErrorCode("Python dump failed");