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 <Basics_OCCTVersion.hxx>
67 #include "utilities.h"
69 #include <TDF_Tool.hxx>
70 #include <TColStd_HArray1OfByte.hxx>
71 #include <TColStd_HArray1OfReal.hxx>
73 #include <Standard_Failure.hxx>
74 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
77 /* ==================================
78 * =========== PYTHON ==============
79 * ==================================*/
90 PyStdOut_dealloc(PyStdOut *self)
96 PyStdOut_write(PyStdOut* self, PyObject* args)
99 if (!PyArg_ParseTuple(args, "s", &c))
102 *(self->out) = *(self->out) + c;
108 static PyMethodDef PyStdOut_methods[] = {
109 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
110 PyDoc_STR("write(string) -> None")},
111 {NULL, NULL} /* sentinel */
114 static PyMemberDef PyStdOut_memberlist[] = {
115 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
116 (char*)"flag indicating that a space needs to be printed; used by print"},
117 {NULL} /* Sentinel */
120 static PyTypeObject PyStdOut_Type = {
121 /* The ob_type field must be initialized in the module init function
122 * to be portable to Windows without using C++. */
123 PyVarObject_HEAD_INIT(NULL, 0)
126 sizeof(PyStdOut), /*tp_basicsize*/
129 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
136 0, /*tp_as_sequence*/
141 PyObject_GenericGetAttr, /*tp_getattro*/
142 /* softspace is writable: we must supply tp_setattro */
143 PyObject_GenericSetAttr, /* tp_setattro */
145 Py_TPFLAGS_DEFAULT, /*tp_flags*/
149 0, /*tp_richcompare*/
150 0, /*tp_weaklistoffset*/
153 PyStdOut_methods, /*tp_methods*/
154 PyStdOut_memberlist, /*tp_members*/
172 0, /*tp_version_tag*/
176 PyObject* newPyStdOut( std::string& out )
178 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
183 return (PyObject*)self;
187 ////////////////////////END PYTHON///////////////////////////
188 //=============================================================================
192 //=============================================================================
193 GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
194 : GEOM_IOperations(theEngine, theDocID)
196 MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
199 //=============================================================================
203 //=============================================================================
204 GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
206 MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations");
210 //=============================================================================
214 //=============================================================================
215 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
216 Handle(GEOM_Object) thePnt2,
217 Handle(GEOM_Object) thePnt3)
221 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
223 //Add a new Circle object
224 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
226 //Add a new Circle function for creation a circle relatively to three points
227 Handle(GEOM_Function) aFunction =
228 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
229 if (aFunction.IsNull()) return NULL;
231 //Check if the function is set correctly
232 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
234 GEOMImpl_ICircle aCI (aFunction);
236 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
237 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
238 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
240 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
242 aCI.SetPoint1(aRefPnt1);
243 aCI.SetPoint2(aRefPnt2);
244 aCI.SetPoint3(aRefPnt3);
246 //Compute the Circle value
249 if (!GetSolver()->ComputeFunction(aFunction)) {
250 SetErrorCode("Circle driver failed");
254 catch (Standard_Failure) {
255 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
256 SetErrorCode(aFail->GetMessageString());
260 //Make a Python command
261 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
262 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
268 //=============================================================================
270 * MakeCircleCenter2Pnt
272 //=============================================================================
273 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
274 Handle(GEOM_Object) thePnt2,
275 Handle(GEOM_Object) thePnt3)
279 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
281 //Add a new Circle object
282 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
284 //Add a new Circle function for creation a circle relatively to center and 2 points
285 Handle(GEOM_Function) aFunction =
286 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
287 if (aFunction.IsNull()) return NULL;
289 //Check if the function is set correctly
290 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
292 GEOMImpl_ICircle aCI (aFunction);
294 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
295 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
296 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
298 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
300 aCI.SetPoint1(aRefPnt1);
301 aCI.SetPoint2(aRefPnt2);
302 aCI.SetPoint3(aRefPnt3);
304 //Compute the Circle value
307 if (!GetSolver()->ComputeFunction(aFunction)) {
308 SetErrorCode("Circle driver failed");
312 catch (Standard_Failure) {
313 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
314 SetErrorCode(aFail->GetMessageString());
318 //Make a Python command
319 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleCenter2Pnt("
320 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
326 //=============================================================================
330 //=============================================================================
331 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
332 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
336 // Not set thePnt means origin of global CS,
337 // Not set theVec means Z axis of global CS
338 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
340 //Add a new Circle object
341 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
343 //Add a new Circle function for creation a circle relatively to point and vector
344 Handle(GEOM_Function) aFunction =
345 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
346 if (aFunction.IsNull()) return NULL;
348 //Check if the function is set correctly
349 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
351 GEOMImpl_ICircle aCI (aFunction);
353 if (!thePnt.IsNull()) {
354 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
355 if (aRefPnt.IsNull()) return NULL;
356 aCI.SetCenter(aRefPnt);
359 if (!theVec.IsNull()) {
360 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
361 if (aRefVec.IsNull()) return NULL;
362 aCI.SetVector(aRefVec);
367 //Compute the Circle value
370 if (!GetSolver()->ComputeFunction(aFunction)) {
371 SetErrorCode("Circle driver failed");
375 catch (Standard_Failure) {
376 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
377 SetErrorCode(aFail->GetMessageString());
381 //Make a Python command
382 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
383 << thePnt << ", " << theVec << ", " << theR << ")";
389 //=============================================================================
393 //=============================================================================
394 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
395 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
396 double theRMajor, double theRMinor,
397 Handle(GEOM_Object) theVecMaj)
401 // Not set thePnt means origin of global CS,
402 // Not set theVec means Z axis of global CS
403 // Not set theVecMaj means X axis of global CS
404 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
406 //Add a new Ellipse object
407 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
409 //Add a new Ellipse function
410 Handle(GEOM_Function) aFunction =
411 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
412 if (aFunction.IsNull()) return NULL;
414 //Check if the function is set correctly
415 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
417 GEOMImpl_IEllipse aCI (aFunction);
419 if (!thePnt.IsNull()) {
420 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
421 if (aRefPnt.IsNull()) return NULL;
422 aCI.SetCenter(aRefPnt);
425 if (!theVec.IsNull()) {
426 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
427 if (aRefVec.IsNull()) return NULL;
428 aCI.SetVector(aRefVec);
431 aCI.SetRMajor(theRMajor);
432 aCI.SetRMinor(theRMinor);
434 if (!theVecMaj.IsNull()) {
435 Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
436 if (aRefVecMaj.IsNull()) return NULL;
437 aCI.SetVectorMajor(aRefVecMaj);
440 //Compute the Ellipse value
443 if (!GetSolver()->ComputeFunction(aFunction)) {
444 SetErrorCode("Ellipse driver failed");
448 catch (Standard_Failure) {
449 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
450 SetErrorCode(aFail->GetMessageString());
454 //Make a Python command
455 if (!theVecMaj.IsNull()) {
456 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
457 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
458 << ", " << theVecMaj << ")";
461 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
462 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
469 //=============================================================================
473 //=============================================================================
474 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
475 Handle(GEOM_Object) thePnt2,
476 Handle(GEOM_Object) thePnt3)
480 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
482 //Add a new Circle Arc object
483 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
485 //Add a new Circle Arc function
486 Handle(GEOM_Function) aFunction =
487 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
489 if (aFunction.IsNull()) return NULL;
491 //Check if the function is set correctly
492 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
493 GEOMImpl_IArc aCI (aFunction);
495 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
496 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
497 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
499 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
501 aCI.SetPoint1(aRefPnt1);
502 aCI.SetPoint2(aRefPnt2);
503 aCI.SetPoint3(aRefPnt3);
505 //Compute the Arc value
508 if (!GetSolver()->ComputeFunction(aFunction)) {
509 SetErrorCode("Arc driver failed");
513 catch (Standard_Failure) {
514 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
515 SetErrorCode(aFail->GetMessageString());
519 //Make a Python command
520 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
521 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
527 //=============================================================================
531 //=============================================================================
532 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
533 Handle(GEOM_Object) thePnt2,
534 Handle(GEOM_Object) thePnt3,
538 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
540 //Add a new Circle Arc object
541 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
543 //Add a new Circle Arc function
544 Handle(GEOM_Function) aFunction =
545 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
546 if (aFunction.IsNull()) return NULL;
548 //Check if the function is set correctly
549 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
551 GEOMImpl_IArc aCI (aFunction);
553 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
554 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
555 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
557 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
559 aCI.SetPoint1(aRefPnt1);
560 aCI.SetPoint2(aRefPnt2);
561 aCI.SetPoint3(aRefPnt3);
562 aCI.SetSense(theSense);
564 //Compute the Arc value
567 if (!GetSolver()->ComputeFunction(aFunction)) {
568 SetErrorCode("Arc driver failed");
572 catch (Standard_Failure) {
573 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
574 SetErrorCode(aFail->GetMessageString());
577 //Make a Python command
578 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
579 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
585 //=============================================================================
589 //=============================================================================
590 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
591 Handle(GEOM_Object) thePnt2,
592 Handle(GEOM_Object) thePnt3)
596 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
598 //Add a new Circle Arc object
599 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
601 //Add a new Circle Arc function
602 Handle(GEOM_Function) aFunction =
603 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
605 if (aFunction.IsNull()) return NULL;
607 //Check if the function is set correctly
608 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
609 GEOMImpl_IArc aCI (aFunction);
611 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
612 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
613 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
615 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
617 aCI.SetPoint1(aRefPnt1);
618 aCI.SetPoint2(aRefPnt2);
619 aCI.SetPoint3(aRefPnt3);
621 //Compute the Arc value
624 if (!GetSolver()->ComputeFunction(aFunction)) {
625 SetErrorCode("Arc driver failed");
629 catch (Standard_Failure) {
630 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
631 SetErrorCode(aFail->GetMessageString());
635 //Make a Python command
636 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
637 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
643 //=============================================================================
647 //=============================================================================
648 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints,
653 //Add a new Polyline object
654 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
656 //Add a new Polyline function for creation a polyline relatively to points set
657 Handle(GEOM_Function) aFunction =
658 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
659 if (aFunction.IsNull()) return NULL;
661 //Check if the function is set correctly
662 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
664 GEOMImpl_IPolyline aCI (aFunction);
666 int aLen = thePoints.size();
668 aCI.SetConstructorType(POINT_CONSTRUCTOR);
671 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
672 for (; it != thePoints.end(); it++, ind++) {
673 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
674 if (aRefPnt.IsNull()) {
675 SetErrorCode("NULL point for Polyline");
678 aCI.SetPoint(ind, aRefPnt);
681 aCI.SetIsClosed(theIsClosed);
683 //Compute the Polyline value
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Polyline driver failed");
691 catch (Standard_Failure) {
692 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
693 SetErrorCode(aFail->GetMessageString());
697 //Make a Python command
698 GEOM::TPythonDump pd (aFunction);
699 pd << aPolyline << " = geompy.MakePolyline([";
701 it = thePoints.begin();
703 while (it != thePoints.end()) {
704 pd << ", " << (*it++);
706 pd << "], " << theIsClosed << ")";
712 //=============================================================================
716 //=============================================================================
717 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
718 (std::list<Handle(GEOM_Object)> thePoints,
723 //Add a new Spline object
724 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
726 //Add a new Spline function for creation a bezier curve relatively to points set
727 Handle(GEOM_Function) aFunction =
728 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
729 if (aFunction.IsNull()) return NULL;
731 //Check if the function is set correctly
732 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
734 GEOMImpl_ISpline aCI (aFunction);
736 aCI.SetConstructorType(POINT_CONSTRUCTOR);
738 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
739 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
740 for (; it != thePoints.end(); it++) {
741 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
742 if (aRefPnt.IsNull()) {
743 SetErrorCode("NULL point for Besier curve");
746 aPoints->Append(aRefPnt);
748 aCI.SetPoints(aPoints);
750 aCI.SetIsClosed(theIsClosed);
752 //Compute the Spline value
755 if (!GetSolver()->ComputeFunction(aFunction)) {
756 SetErrorCode("Spline driver failed");
760 catch (Standard_Failure) {
761 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
762 SetErrorCode(aFail->GetMessageString());
766 //Make a Python command
767 GEOM::TPythonDump pd (aFunction);
768 pd << aSpline << " = geompy.MakeBezier([";
770 it = thePoints.begin();
772 while (it != thePoints.end()) {
773 pd << ", " << (*it++);
775 pd << "], " << theIsClosed << ")";
781 //=============================================================================
783 * MakeSplineInterpolation
785 //=============================================================================
786 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
787 (std::list<Handle(GEOM_Object)> thePoints,
789 bool theDoReordering)
793 //Add a new Spline object
794 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
796 //Add a new Spline function for interpolation type
797 Handle(GEOM_Function) aFunction =
798 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
799 if (aFunction.IsNull()) return NULL;
801 //Check if the function is set correctly
802 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
804 GEOMImpl_ISpline aCI (aFunction);
806 aCI.SetConstructorType(POINT_CONSTRUCTOR);
808 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
809 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
810 for (; it != thePoints.end(); it++) {
811 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
812 if (aRefPnt.IsNull()) {
815 aPoints->Append(aRefPnt);
817 aCI.SetPoints(aPoints);
819 aCI.SetIsClosed(theIsClosed);
820 aCI.SetDoReordering(theDoReordering);
822 //Compute the Spline value
825 if (!GetSolver()->ComputeFunction(aFunction)) {
826 SetErrorCode("Spline driver failed");
830 catch (Standard_Failure) {
831 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
832 SetErrorCode(aFail->GetMessageString());
836 //Make a Python command
837 GEOM::TPythonDump pd (aFunction);
838 pd << aSpline << " = geompy.MakeInterpol([";
840 it = thePoints.begin();
842 while (it != thePoints.end()) {
843 pd << ", " << (*it++);
845 pd << "], " << theIsClosed << ", " << theDoReordering << ")";
852 //=============================================================================
854 * MakeSplineInterpolWithTangents
856 //=============================================================================
857 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
858 (std::list<Handle(GEOM_Object)> thePoints,
859 Handle(GEOM_Object) theFirstVec,
860 Handle(GEOM_Object) theLastVec)
864 //Add a new Spline object
865 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
867 //Add a new Spline function for interpolation type
868 Handle(GEOM_Function) aFunction =
869 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOL_TANGENTS);
870 if (aFunction.IsNull()) return NULL;
872 //Check if the function is set correctly
873 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
875 GEOMImpl_ISpline aCI (aFunction);
877 aCI.SetConstructorType(POINT_CONSTRUCTOR);
879 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
880 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
881 for (; it != thePoints.end(); it++) {
882 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
883 if (aRefPnt.IsNull()) {
884 SetErrorCode("NULL point for Interpolation");
887 aPoints->Append(aRefPnt);
889 aCI.SetPoints(aPoints);
891 Handle(GEOM_Function) aVec1 = theFirstVec->GetLastFunction();
892 Handle(GEOM_Function) aVec2 = theLastVec->GetLastFunction();
894 if (aVec1.IsNull() || aVec2.IsNull()) return NULL;
896 aCI.SetFirstVector(aVec1);
897 aCI.SetLastVector(aVec2);
899 //Compute the Spline value
902 if (!GetSolver()->ComputeFunction(aFunction)) {
903 SetErrorCode("Spline driver failed");
907 catch (Standard_Failure) {
908 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
909 SetErrorCode(aFail->GetMessageString());
913 //Make a Python command
914 GEOM::TPythonDump pd (aFunction);
915 pd << aSpline << " = geompy.MakeInterpolWithTangents([";
917 it = thePoints.begin();
919 while (it != thePoints.end()) {
920 pd << ", " << (*it++);
922 pd << "], " << theFirstVec << ", " << theLastVec << ")";
928 //=============================================================================
930 * MakeCurveParametric
932 //=============================================================================
933 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
934 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
935 double theParamMin, double theParamMax, double theParamStep,
936 CurveType theCurveType,
937 int theParamNbStep, bool theNewMethod)
939 TCollection_AsciiString aPyScript;
940 aPyScript +="from math import * \n";
941 aPyScript +="def X(t): \n";
942 aPyScript +=" return ";
943 aPyScript += thexExpr;
945 aPyScript +="def Y(t): \n";
946 aPyScript +=" return ";
947 aPyScript += theyExpr;
950 aPyScript +="def Z(t): \n";
951 aPyScript +=" return ";
952 aPyScript += thezExpr;
957 aPyScript +="def coordCalculator(tmin, tmax, nstep): \n";
958 aPyScript +=" coords = [] \n";
959 aPyScript +=" tstep = (tmax - tmin) / nstep \n";
960 aPyScript +=" n = 0 \n";
961 aPyScript +=" while n <= nstep : \n";
962 aPyScript +=" t = tmin + n*tstep \n";
963 aPyScript +=" coords.append([X(t), Y(t), Z(t)]) \n";
964 aPyScript +=" n = n+1 \n";
965 aPyScript +=" return coords \n";
969 aPyScript +="def coordCalculator(tmin, tmax, tstep): \n";
970 aPyScript +=" coords = [] \n";
971 aPyScript +=" while tmin <= tmax : \n";
972 aPyScript +=" coords.append([X(tmin), Y(tmin), Z(tmin)]) \n";
973 aPyScript +=" tmin = tmin + tstep \n";
974 aPyScript +=" return coords \n";
979 if(theParamMin >= theParamMax) {
980 SetErrorCode("The minimum value of the parameter must be less than maximum value !!!");
984 if(!theNewMethod && theParamStep <= 0.0) {
985 SetErrorCode("Value of the step must be positive !!!");
988 else if(theNewMethod && theParamNbStep < 0) {
989 SetErrorCode("The number of steps must be positive !!!");
993 /* Initialize the Python interpreter */
994 if (! Py_IsInitialized()) {
995 SetErrorCode("Python interpreter is not initialized !!! ");
999 PyGILState_STATE gstate;
1000 gstate = PyGILState_Ensure();
1002 PyObject* main_mod = PyImport_AddModule("__main__");
1003 PyObject* main_dict = PyModule_GetDict(main_mod);
1005 PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
1008 SetErrorCode("Error during executing of python script !!!");
1010 PyGILState_Release(gstate);
1016 PyObject * func = NULL;
1017 func = PyObject_GetAttrString(main_mod, "coordCalculator");
1020 SetErrorCode("Can't get function from python module !!!");
1021 PyGILState_Release(gstate);
1027 coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
1029 coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
1031 if (coords == NULL){
1033 std::string err_description="";
1034 PyObject* new_stderr = newPyStdOut(err_description);
1035 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
1036 Py_INCREF(old_stderr);
1037 PySys_SetObject((char*)"stderr", new_stderr);
1039 PySys_SetObject((char*)"stderr", old_stderr);
1040 Py_DECREF(new_stderr);
1041 MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
1042 SetErrorCode("Can't evaluate the expressions, please check them !!!");
1043 PyGILState_Release(gstate);
1047 int lsize = PyList_Size( coords );
1050 SetErrorCode("Empty list of the points, please check input parameters !!!");
1054 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, lsize * 3);
1057 for ( Py_ssize_t i = 0; i < lsize; ++i ) {
1058 PyObject* coord = PyList_GetItem( coords, i );
1059 if (coord != NULL) {
1060 for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
1061 PyObject* item = PyList_GetItem(coord, j);
1062 aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
1070 PyGILState_Release(gstate);
1072 Handle(GEOM_Object) aCurve;
1073 Handle(GEOM_Function) aFunction;
1074 TCollection_AsciiString aCurveType;
1076 switch(theCurveType) {
1078 //Add a new Polyline object
1079 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
1081 //Add a new Polyline function for creation a polyline relatively to points set
1082 aFunction = aCurve->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
1083 if (aFunction.IsNull()) return NULL;
1085 //Check if the function is set correctly
1086 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
1088 GEOMImpl_IPolyline aCI (aFunction);
1090 aCI.SetLength(lsize);
1091 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1092 aCI.SetIsClosed(false);
1093 aCI.SetCoordinates(aCoordsArray);
1094 aCurveType = "GEOM.Polyline";
1098 //Add a new Spline object
1099 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
1100 //Add a new Spline function for creation a bezier curve relatively to points set
1102 aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
1103 if (aFunction.IsNull()) return NULL;
1105 //Check if the function is set correctly
1106 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
1108 GEOMImpl_ISpline aCI (aFunction);
1110 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1111 aCI.SetIsClosed(false);
1112 aCI.SetCoordinates(aCoordsArray);
1113 aCurveType = "GEOM.Bezier";
1116 case Interpolation: {
1117 //Add a new Spline object
1118 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
1120 //Add a new Spline function for creation a bezier curve relatively to points set
1121 aFunction = aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
1122 if (aFunction.IsNull()) return NULL;
1124 //Check if the function is set correctly
1125 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
1127 GEOMImpl_ISpline aCI (aFunction);
1128 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1129 aCI.SetIsClosed(false);
1130 aCI.SetDoReordering(false);
1131 aCI.SetCoordinates(aCoordsArray);
1132 aCurveType = "GEOM.Interpolation";
1137 GEOMImpl_ICurveParametric aIP(aFunction);
1138 aIP.SetExprX (thexExpr);
1139 aIP.SetExprY (theyExpr);
1140 aIP.SetExprZ (thezExpr);
1141 aIP.SetParamMin (theParamMin);
1142 aIP.SetParamMax (theParamMax);
1144 aIP.SetParamNbStep(theParamNbStep);
1146 aIP.SetParamStep (theParamStep);
1148 //Compute the Curve value
1151 if (!GetSolver()->ComputeFunction(aFunction)) {
1152 SetErrorCode("Curve driver failed !!!");
1156 catch (Standard_Failure) {
1157 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1158 SetErrorCode(aFail->GetMessageString());
1162 //Make a Python command
1163 GEOM::TPythonDump pd (aFunction);
1164 pd << aCurve << " = geompy.MakeCurveParametric(";
1165 pd << "\"" << thexExpr << "\", ";
1166 pd << "\"" << theyExpr << "\", ";
1167 pd << "\"" << thezExpr << "\", ";
1169 pd << theParamMin <<", ";
1170 pd << theParamMax <<", ";
1172 pd << theParamNbStep <<", ";
1174 pd << theParamStep <<", ";
1175 pd << aCurveType.ToCString() <<", ";
1176 pd << theNewMethod <<")";
1182 //=============================================================================
1186 //=============================================================================
1187 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
1188 std::list<double> theWorkingPlane)
1192 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1194 //Add a new Sketcher object
1195 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
1197 //Add a new Sketcher function
1198 Handle(GEOM_Function) aFunction =
1199 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
1200 if (aFunction.IsNull()) return NULL;
1202 //Check if the function is set correctly
1203 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
1205 GEOMImpl_ISketcher aCI (aFunction);
1207 TCollection_AsciiString aCommand((char*) theCommand);
1208 aCI.SetCommand(aCommand);
1211 std::list<double>::iterator it = theWorkingPlane.begin();
1212 for (; it != theWorkingPlane.end(); it++, ind++)
1213 aCI.SetWorkingPlane(ind, *it);
1215 //Compute the Sketcher value
1218 if (!GetSolver()->ComputeFunction(aFunction)) {
1219 SetErrorCode("Sketcher driver failed");
1223 catch (Standard_Failure) {
1224 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1225 SetErrorCode(aFail->GetMessageString());
1229 //Make a Python command
1230 GEOM::TPythonDump pd (aFunction);
1231 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
1233 it = theWorkingPlane.begin();
1235 while (it != theWorkingPlane.end()) {
1236 pd << ", " << (*it++);
1244 //=============================================================================
1246 * MakeSketcherOnPlane
1248 //=============================================================================
1249 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
1250 (const char* theCommand,
1251 Handle(GEOM_Object) theWorkingPlane)
1255 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1257 //Add a new Sketcher object
1258 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
1260 //Add a new Sketcher function
1261 Handle(GEOM_Function) aFunction =
1262 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
1263 if (aFunction.IsNull()) return NULL;
1265 //Check if the function is set correctly
1266 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
1268 GEOMImpl_ISketcher aCI (aFunction);
1270 TCollection_AsciiString aCommand((char*) theCommand);
1271 aCI.SetCommand(aCommand);
1273 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
1274 if (aRefPlane.IsNull()) return NULL;
1275 aCI.SetWorkingPlane( aRefPlane );
1277 //Compute the Sketcher value
1280 if (!GetSolver()->ComputeFunction(aFunction)) {
1281 SetErrorCode("Sketcher driver failed");
1285 catch (Standard_Failure) {
1286 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1287 SetErrorCode(aFail->GetMessageString());
1291 //Make a Python command
1292 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
1293 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";
1299 //=============================================================================
1301 * Make3DSketcherCommand
1303 //=============================================================================
1304 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const char* theCommand)
1308 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1310 //Add a new Sketcher object
1311 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
1313 //Add a new Sketcher function
1314 Handle(GEOM_Function) aFunction =
1315 aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND);
1316 if (aFunction.IsNull()) return NULL;
1318 //Check if the function is set correctly
1319 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
1321 GEOMImpl_I3DSketcher aCI (aFunction);
1323 TCollection_AsciiString aCommand ((char*) theCommand);
1324 aCI.SetCommand(aCommand);
1326 //Compute the 3D Sketcher value
1329 if (!GetSolver()->ComputeFunction(aFunction)) {
1330 SetErrorCode("3D Sketcher driver failed");
1334 catch (Standard_Failure) {
1335 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1336 SetErrorCode(aFail->GetMessageString());
1340 //Make a Python command
1341 GEOM::TPythonDump pd (aFunction);
1342 pd << aSketcher << " = geompy.Make3DSketcherCommand(\"" << aCommand.ToCString() << "\")";
1348 //=============================================================================
1352 //=============================================================================
1353 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
1357 //Add a new Sketcher object
1358 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
1360 //Add a new Sketcher function
1361 Handle(GEOM_Function) aFunction =
1362 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COORDS);
1363 if (aFunction.IsNull()) return NULL;
1365 //Check if the function is set correctly
1366 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
1368 GEOMImpl_I3DSketcher aCI (aFunction);
1371 std::list<double>::iterator it = theCoordinates.begin();
1372 for (; it != theCoordinates.end(); it++)
1375 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
1377 it = theCoordinates.begin();
1379 for (; it != theCoordinates.end(); it++, ind++)
1380 aCoordsArray->SetValue(ind, *it);
1382 aCI.SetCoordinates(aCoordsArray);
1384 //Compute the Sketcher value
1387 if (!GetSolver()->ComputeFunction(aFunction)) {
1388 SetErrorCode("3D Sketcher driver failed");
1392 catch (Standard_Failure) {
1393 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1394 SetErrorCode(aFail->GetMessageString());
1398 //Make a Python command
1399 GEOM::TPythonDump pd (aFunction);
1400 pd << a3DSketcher << " = geompy.Make3DSketcher([";
1402 it = theCoordinates.begin();
1404 while (it != theCoordinates.end()) {
1405 pd << ", " << (*it++);
1413 //=============================================================================
1417 //=============================================================================
1418 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline
1419 (const Handle(GEOM_Object) &theFace,
1421 const double theParameter)
1425 if (theFace.IsNull()) {
1429 //Add a new Spline object
1430 Handle(GEOM_Object) anIsoline =
1431 GetEngine()->AddObject(GetDocID(), GEOM_ISOLINE);
1433 //Add a new Spline function for interpolation type
1434 Handle(GEOM_Function) aFunction =
1435 anIsoline->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPE_ISOLINE);
1437 if (aFunction.IsNull()) {
1441 //Check if the function is set correctly
1442 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
1446 GEOMImpl_IIsoline aCI (aFunction);
1447 Handle(GEOM_Function) aRefFace = theFace->GetLastFunction();
1449 if (aRefFace.IsNull()) {
1453 aCI.SetFace(aRefFace);
1454 aCI.SetIsUIso(IsUIso);
1455 aCI.SetParameter(theParameter);
1457 //Compute the isoline curve
1460 if (!GetSolver()->ComputeFunction(aFunction)) {
1461 SetErrorCode("Shape driver failed");
1465 catch (Standard_Failure) {
1466 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1467 SetErrorCode(aFail->GetMessageString());
1471 //Make a Python command
1472 GEOM::TPythonDump (aFunction) << anIsoline << " = geompy.MakeIsoline( "
1473 << theFace << ", " << IsUIso << ", " << theParameter << " )";
1479 //=============================================================================
1483 //=============================================================================
1484 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2D
1485 (const std::list <std::list <double> > &theCoords,
1486 const Handle(TColStd_HArray1OfExtendedString) &theNames,
1487 const Handle(TColStd_HArray1OfByte) &theTypes,
1488 const Handle(TColStd_HArray1OfByte) &theCloseds,
1489 const Handle(TColStd_HArray1OfReal) &theWorkingPlane)
1493 if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
1494 theCloseds.IsNull() || theWorkingPlane.IsNull()) {
1498 // Add a new Polyline object
1499 Handle(GEOM_Object) aResult =
1500 GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
1501 Handle(GEOM_Function) aFunction = aResult->AddFunction
1502 (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_COORDS);
1504 if (aFunction.IsNull()) {
1508 // Check if the function is set correctly
1509 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
1513 GEOMImpl_IPolyline2D aCI(aFunction);
1515 aCI.SetCoords(theCoords);
1516 aCI.SetNames(theNames);
1517 aCI.SetTypes(theTypes);
1518 aCI.SetClosedFlags(theCloseds);
1519 aCI.SetWorkingPlaneDbls(theWorkingPlane);
1521 // Compute the isoline curve
1523 #if OCC_VERSION_LARGE > 0x06010000
1526 if (!GetSolver()->ComputeFunction(aFunction)) {
1527 SetErrorCode("Polyline driver failed");
1531 catch (Standard_Failure) {
1532 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1533 SetErrorCode(aFail->GetMessageString());
1537 //Make a Python command
1538 GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
1539 theCloseds, theWorkingPlane);
1541 aDumper.Dump(aResult);
1543 if (aDumper.IsDone() == Standard_False) {
1544 SetErrorCode("Python dump failed");
1552 //=============================================================================
1554 * MakePolyline2DOnPlane
1556 //=============================================================================
1557 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2DOnPlane
1558 (const std::list <std::list <double> > &theCoords,
1559 const Handle(TColStd_HArray1OfExtendedString) &theNames,
1560 const Handle(TColStd_HArray1OfByte) &theTypes,
1561 const Handle(TColStd_HArray1OfByte) &theCloseds,
1562 const Handle(GEOM_Object) &theWorkingPlane)
1566 if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
1567 theCloseds.IsNull() || theWorkingPlane.IsNull()) {
1571 //Add a new Polyline object
1572 Handle(GEOM_Object) aResult =
1573 GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
1574 Handle(GEOM_Function) aFunction = aResult->AddFunction
1575 (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_OBJECT);
1577 if (aFunction.IsNull()) {
1581 //Check if the function is set correctly
1582 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
1586 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
1588 if (aRefPlane.IsNull()) {
1592 GEOMImpl_IPolyline2D aCI(aFunction);
1594 aCI.SetCoords(theCoords);
1595 aCI.SetNames(theNames);
1596 aCI.SetTypes(theTypes);
1597 aCI.SetClosedFlags(theCloseds);
1598 aCI.SetWorkingPlane(aRefPlane);
1600 //Compute the isoline curve
1602 #if OCC_VERSION_LARGE > 0x06010000
1605 if (!GetSolver()->ComputeFunction(aFunction)) {
1606 SetErrorCode("Polyline driver failed");
1610 catch (Standard_Failure) {
1611 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1612 SetErrorCode(aFail->GetMessageString());
1616 //Make a Python command
1617 GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
1618 theCloseds, theWorkingPlane);
1620 aDumper.Dump(aResult);
1622 if (aDumper.IsDone() == Standard_False) {
1623 SetErrorCode("Python dump failed");