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)
100 if (!PyArg_ParseTuple(args, "t#:write", &c, &l))
103 *(self->out) = *(self->out) + c;
109 static PyMethodDef PyStdOut_methods[] = {
110 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
111 PyDoc_STR("write(string) -> None")},
112 {NULL, NULL} /* sentinel */
115 static PyMemberDef PyStdOut_memberlist[] = {
116 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
117 (char*)"flag indicating that a space needs to be printed; used by print"},
118 {NULL} /* Sentinel */
121 static PyTypeObject PyStdOut_Type = {
122 /* The ob_type field must be initialized in the module init function
123 * to be portable to Windows without using C++. */
124 PyObject_HEAD_INIT(NULL)
127 sizeof(PyStdOut), /*tp_basicsize*/
130 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
137 0, /*tp_as_sequence*/
142 PyObject_GenericGetAttr, /*tp_getattro*/
143 /* softspace is writable: we must supply tp_setattro */
144 PyObject_GenericSetAttr, /* tp_setattro */
146 Py_TPFLAGS_DEFAULT, /*tp_flags*/
150 0, /*tp_richcompare*/
151 0, /*tp_weaklistoffset*/
154 PyStdOut_methods, /*tp_methods*/
155 PyStdOut_memberlist, /*tp_members*/
169 PyObject* newPyStdOut( std::string& out )
171 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
176 return (PyObject*)self;
180 ////////////////////////END PYTHON///////////////////////////
181 //=============================================================================
185 //=============================================================================
186 GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
187 : GEOM_IOperations(theEngine, theDocID)
189 MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
192 //=============================================================================
196 //=============================================================================
197 GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
199 MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations");
203 //=============================================================================
207 //=============================================================================
208 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
209 Handle(GEOM_Object) thePnt2,
210 Handle(GEOM_Object) thePnt3)
214 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
216 //Add a new Circle object
217 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
219 //Add a new Circle function for creation a circle relatively to three points
220 Handle(GEOM_Function) aFunction =
221 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
222 if (aFunction.IsNull()) return NULL;
224 //Check if the function is set correctly
225 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
227 GEOMImpl_ICircle aCI (aFunction);
229 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
230 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
231 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
233 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
235 aCI.SetPoint1(aRefPnt1);
236 aCI.SetPoint2(aRefPnt2);
237 aCI.SetPoint3(aRefPnt3);
239 //Compute the Circle value
242 if (!GetSolver()->ComputeFunction(aFunction)) {
243 SetErrorCode("Circle driver failed");
247 catch (Standard_Failure) {
248 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
249 SetErrorCode(aFail->GetMessageString());
253 //Make a Python command
254 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
255 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
261 //=============================================================================
263 * MakeCircleCenter2Pnt
265 //=============================================================================
266 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
267 Handle(GEOM_Object) thePnt2,
268 Handle(GEOM_Object) thePnt3)
272 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
274 //Add a new Circle object
275 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
277 //Add a new Circle function for creation a circle relatively to center and 2 points
278 Handle(GEOM_Function) aFunction =
279 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
280 if (aFunction.IsNull()) return NULL;
282 //Check if the function is set correctly
283 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
285 GEOMImpl_ICircle aCI (aFunction);
287 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
288 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
289 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
291 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
293 aCI.SetPoint1(aRefPnt1);
294 aCI.SetPoint2(aRefPnt2);
295 aCI.SetPoint3(aRefPnt3);
297 //Compute the Circle value
300 if (!GetSolver()->ComputeFunction(aFunction)) {
301 SetErrorCode("Circle driver failed");
305 catch (Standard_Failure) {
306 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
307 SetErrorCode(aFail->GetMessageString());
311 //Make a Python command
312 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleCenter2Pnt("
313 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
319 //=============================================================================
323 //=============================================================================
324 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
325 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
329 // Not set thePnt means origin of global CS,
330 // Not set theVec means Z axis of global CS
331 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
333 //Add a new Circle object
334 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
336 //Add a new Circle function for creation a circle relatively to point and vector
337 Handle(GEOM_Function) aFunction =
338 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
339 if (aFunction.IsNull()) return NULL;
341 //Check if the function is set correctly
342 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
344 GEOMImpl_ICircle aCI (aFunction);
346 if (!thePnt.IsNull()) {
347 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
348 if (aRefPnt.IsNull()) return NULL;
349 aCI.SetCenter(aRefPnt);
352 if (!theVec.IsNull()) {
353 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
354 if (aRefVec.IsNull()) return NULL;
355 aCI.SetVector(aRefVec);
360 //Compute the Circle value
363 if (!GetSolver()->ComputeFunction(aFunction)) {
364 SetErrorCode("Circle driver failed");
368 catch (Standard_Failure) {
369 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
370 SetErrorCode(aFail->GetMessageString());
374 //Make a Python command
375 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
376 << thePnt << ", " << theVec << ", " << theR << ")";
382 //=============================================================================
386 //=============================================================================
387 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
388 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
389 double theRMajor, double theRMinor,
390 Handle(GEOM_Object) theVecMaj)
394 // Not set thePnt means origin of global CS,
395 // Not set theVec means Z axis of global CS
396 // Not set theVecMaj means X axis of global CS
397 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
399 //Add a new Ellipse object
400 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
402 //Add a new Ellipse function
403 Handle(GEOM_Function) aFunction =
404 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
405 if (aFunction.IsNull()) return NULL;
407 //Check if the function is set correctly
408 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
410 GEOMImpl_IEllipse aCI (aFunction);
412 if (!thePnt.IsNull()) {
413 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
414 if (aRefPnt.IsNull()) return NULL;
415 aCI.SetCenter(aRefPnt);
418 if (!theVec.IsNull()) {
419 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
420 if (aRefVec.IsNull()) return NULL;
421 aCI.SetVector(aRefVec);
424 aCI.SetRMajor(theRMajor);
425 aCI.SetRMinor(theRMinor);
427 if (!theVecMaj.IsNull()) {
428 Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
429 if (aRefVecMaj.IsNull()) return NULL;
430 aCI.SetVectorMajor(aRefVecMaj);
433 //Compute the Ellipse value
436 if (!GetSolver()->ComputeFunction(aFunction)) {
437 SetErrorCode("Ellipse driver failed");
441 catch (Standard_Failure) {
442 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
443 SetErrorCode(aFail->GetMessageString());
447 //Make a Python command
448 if (!theVecMaj.IsNull()) {
449 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
450 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
451 << ", " << theVecMaj << ")";
454 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
455 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
462 //=============================================================================
466 //=============================================================================
467 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
468 Handle(GEOM_Object) thePnt2,
469 Handle(GEOM_Object) thePnt3)
473 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
475 //Add a new Circle Arc object
476 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
478 //Add a new Circle Arc function
479 Handle(GEOM_Function) aFunction =
480 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
482 if (aFunction.IsNull()) return NULL;
484 //Check if the function is set correctly
485 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
486 GEOMImpl_IArc aCI (aFunction);
488 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
489 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
490 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
492 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
494 aCI.SetPoint1(aRefPnt1);
495 aCI.SetPoint2(aRefPnt2);
496 aCI.SetPoint3(aRefPnt3);
498 //Compute the Arc value
501 if (!GetSolver()->ComputeFunction(aFunction)) {
502 SetErrorCode("Arc driver failed");
506 catch (Standard_Failure) {
507 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
508 SetErrorCode(aFail->GetMessageString());
512 //Make a Python command
513 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
514 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
520 //=============================================================================
524 //=============================================================================
525 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
526 Handle(GEOM_Object) thePnt2,
527 Handle(GEOM_Object) thePnt3,
531 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
533 //Add a new Circle Arc object
534 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
536 //Add a new Circle Arc function
537 Handle(GEOM_Function) aFunction =
538 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
539 if (aFunction.IsNull()) return NULL;
541 //Check if the function is set correctly
542 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
544 GEOMImpl_IArc aCI (aFunction);
546 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
547 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
548 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
550 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
552 aCI.SetPoint1(aRefPnt1);
553 aCI.SetPoint2(aRefPnt2);
554 aCI.SetPoint3(aRefPnt3);
555 aCI.SetSense(theSense);
557 //Compute the Arc value
560 if (!GetSolver()->ComputeFunction(aFunction)) {
561 SetErrorCode("Arc driver failed");
565 catch (Standard_Failure) {
566 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
567 SetErrorCode(aFail->GetMessageString());
570 //Make a Python command
571 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
572 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
578 //=============================================================================
582 //=============================================================================
583 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
584 Handle(GEOM_Object) thePnt2,
585 Handle(GEOM_Object) thePnt3)
589 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
591 //Add a new Circle Arc object
592 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
594 //Add a new Circle Arc function
595 Handle(GEOM_Function) aFunction =
596 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
598 if (aFunction.IsNull()) return NULL;
600 //Check if the function is set correctly
601 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
602 GEOMImpl_IArc aCI (aFunction);
604 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
605 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
606 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
608 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
610 aCI.SetPoint1(aRefPnt1);
611 aCI.SetPoint2(aRefPnt2);
612 aCI.SetPoint3(aRefPnt3);
614 //Compute the Arc value
617 if (!GetSolver()->ComputeFunction(aFunction)) {
618 SetErrorCode("Arc driver failed");
622 catch (Standard_Failure) {
623 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
624 SetErrorCode(aFail->GetMessageString());
628 //Make a Python command
629 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
630 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
636 //=============================================================================
640 //=============================================================================
641 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints,
646 //Add a new Polyline object
647 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
649 //Add a new Polyline function for creation a polyline relatively to points set
650 Handle(GEOM_Function) aFunction =
651 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
652 if (aFunction.IsNull()) return NULL;
654 //Check if the function is set correctly
655 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
657 GEOMImpl_IPolyline aCI (aFunction);
659 int aLen = thePoints.size();
661 aCI.SetConstructorType(POINT_CONSTRUCTOR);
664 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
665 for (; it != thePoints.end(); it++, ind++) {
666 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
667 if (aRefPnt.IsNull()) {
668 SetErrorCode("NULL point for Polyline");
671 aCI.SetPoint(ind, aRefPnt);
674 aCI.SetIsClosed(theIsClosed);
676 //Compute the Polyline value
679 if (!GetSolver()->ComputeFunction(aFunction)) {
680 SetErrorCode("Polyline driver failed");
684 catch (Standard_Failure) {
685 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
686 SetErrorCode(aFail->GetMessageString());
690 //Make a Python command
691 GEOM::TPythonDump pd (aFunction);
692 pd << aPolyline << " = geompy.MakePolyline([";
694 it = thePoints.begin();
696 while (it != thePoints.end()) {
697 pd << ", " << (*it++);
699 pd << "], " << theIsClosed << ")";
705 //=============================================================================
709 //=============================================================================
710 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
711 (std::list<Handle(GEOM_Object)> thePoints,
716 //Add a new Spline object
717 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
719 //Add a new Spline function for creation a bezier curve relatively to points set
720 Handle(GEOM_Function) aFunction =
721 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
722 if (aFunction.IsNull()) return NULL;
724 //Check if the function is set correctly
725 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
727 GEOMImpl_ISpline aCI (aFunction);
729 aCI.SetConstructorType(POINT_CONSTRUCTOR);
731 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
732 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
733 for (; it != thePoints.end(); it++) {
734 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
735 if (aRefPnt.IsNull()) {
736 SetErrorCode("NULL point for Besier curve");
739 aPoints->Append(aRefPnt);
741 aCI.SetPoints(aPoints);
743 aCI.SetIsClosed(theIsClosed);
745 //Compute the Spline value
748 if (!GetSolver()->ComputeFunction(aFunction)) {
749 SetErrorCode("Spline driver failed");
753 catch (Standard_Failure) {
754 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
755 SetErrorCode(aFail->GetMessageString());
759 //Make a Python command
760 GEOM::TPythonDump pd (aFunction);
761 pd << aSpline << " = geompy.MakeBezier([";
763 it = thePoints.begin();
765 while (it != thePoints.end()) {
766 pd << ", " << (*it++);
768 pd << "], " << theIsClosed << ")";
774 //=============================================================================
776 * MakeSplineInterpolation
778 //=============================================================================
779 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
780 (std::list<Handle(GEOM_Object)> thePoints,
782 bool theDoReordering)
786 //Add a new Spline object
787 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
789 //Add a new Spline function for interpolation type
790 Handle(GEOM_Function) aFunction =
791 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
792 if (aFunction.IsNull()) return NULL;
794 //Check if the function is set correctly
795 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
797 GEOMImpl_ISpline aCI (aFunction);
799 aCI.SetConstructorType(POINT_CONSTRUCTOR);
801 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
802 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
803 for (; it != thePoints.end(); it++) {
804 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
805 if (aRefPnt.IsNull()) {
808 aPoints->Append(aRefPnt);
810 aCI.SetPoints(aPoints);
812 aCI.SetIsClosed(theIsClosed);
813 aCI.SetDoReordering(theDoReordering);
815 //Compute the Spline value
818 if (!GetSolver()->ComputeFunction(aFunction)) {
819 SetErrorCode("Spline driver failed");
823 catch (Standard_Failure) {
824 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
825 SetErrorCode(aFail->GetMessageString());
829 //Make a Python command
830 GEOM::TPythonDump pd (aFunction);
831 pd << aSpline << " = geompy.MakeInterpol([";
833 it = thePoints.begin();
835 while (it != thePoints.end()) {
836 pd << ", " << (*it++);
838 pd << "], " << theIsClosed << ", " << theDoReordering << ")";
845 //=============================================================================
847 * MakeSplineInterpolWithTangents
849 //=============================================================================
850 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents
851 (std::list<Handle(GEOM_Object)> thePoints,
852 Handle(GEOM_Object) theFirstVec,
853 Handle(GEOM_Object) theLastVec)
857 //Add a new Spline object
858 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
860 //Add a new Spline function for interpolation type
861 Handle(GEOM_Function) aFunction =
862 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOL_TANGENTS);
863 if (aFunction.IsNull()) return NULL;
865 //Check if the function is set correctly
866 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
868 GEOMImpl_ISpline aCI (aFunction);
870 aCI.SetConstructorType(POINT_CONSTRUCTOR);
872 Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient;
873 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
874 for (; it != thePoints.end(); it++) {
875 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
876 if (aRefPnt.IsNull()) {
877 SetErrorCode("NULL point for Interpolation");
880 aPoints->Append(aRefPnt);
882 aCI.SetPoints(aPoints);
884 Handle(GEOM_Function) aVec1 = theFirstVec->GetLastFunction();
885 Handle(GEOM_Function) aVec2 = theLastVec->GetLastFunction();
887 if (aVec1.IsNull() || aVec2.IsNull()) return NULL;
889 aCI.SetFirstVector(aVec1);
890 aCI.SetLastVector(aVec2);
892 //Compute the Spline value
895 if (!GetSolver()->ComputeFunction(aFunction)) {
896 SetErrorCode("Spline driver failed");
900 catch (Standard_Failure) {
901 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
902 SetErrorCode(aFail->GetMessageString());
906 //Make a Python command
907 GEOM::TPythonDump pd (aFunction);
908 pd << aSpline << " = geompy.MakeInterpolWithTangents([";
910 it = thePoints.begin();
912 while (it != thePoints.end()) {
913 pd << ", " << (*it++);
915 pd << "], " << theFirstVec << ", " << theLastVec << ")";
921 //=============================================================================
923 * MakeCurveParametric
925 //=============================================================================
926 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
927 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
928 double theParamMin, double theParamMax, double theParamStep,
929 CurveType theCurveType,
930 int theParamNbStep, bool theNewMethod)
932 TCollection_AsciiString aPyScript;
933 aPyScript +="from math import * \n";
934 aPyScript +="def X(t): \n";
935 aPyScript +=" return ";
936 aPyScript += thexExpr;
938 aPyScript +="def Y(t): \n";
939 aPyScript +=" return ";
940 aPyScript += theyExpr;
943 aPyScript +="def Z(t): \n";
944 aPyScript +=" return ";
945 aPyScript += thezExpr;
950 aPyScript +="def coordCalculator(tmin, tmax, nstep): \n";
951 aPyScript +=" coords = [] \n";
952 aPyScript +=" tstep = (tmax - tmin) / nstep \n";
953 aPyScript +=" n = 0 \n";
954 aPyScript +=" while n <= nstep : \n";
955 aPyScript +=" t = tmin + n*tstep \n";
956 aPyScript +=" coords.append([X(t), Y(t), Z(t)]) \n";
957 aPyScript +=" n = n+1 \n";
958 aPyScript +=" return coords \n";
962 aPyScript +="def coordCalculator(tmin, tmax, tstep): \n";
963 aPyScript +=" coords = [] \n";
964 aPyScript +=" while tmin <= tmax : \n";
965 aPyScript +=" coords.append([X(tmin), Y(tmin), Z(tmin)]) \n";
966 aPyScript +=" tmin = tmin + tstep \n";
967 aPyScript +=" return coords \n";
972 if(theParamMin >= theParamMax) {
973 SetErrorCode("The minimum value of the parameter must be less than maximum value !!!");
977 if(!theNewMethod && theParamStep <= 0.0) {
978 SetErrorCode("Value of the step must be positive !!!");
981 else if(theNewMethod && theParamNbStep < 0) {
982 SetErrorCode("The number of steps must be positive !!!");
986 /* Initialize the Python interpreter */
987 if (! Py_IsInitialized()) {
988 SetErrorCode("Python interpreter is not initialized !!! ");
992 PyGILState_STATE gstate;
993 gstate = PyGILState_Ensure();
995 PyObject* main_mod = PyImport_AddModule("__main__");
996 PyObject* main_dict = PyModule_GetDict(main_mod);
998 PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
1001 SetErrorCode("Error during executing of python script !!!");
1003 PyGILState_Release(gstate);
1009 PyObject * func = NULL;
1010 func = PyObject_GetAttrString(main_mod, "coordCalculator");
1013 SetErrorCode("Can't get function from python module !!!");
1014 PyGILState_Release(gstate);
1020 coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep );
1022 coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
1024 if (coords == NULL){
1026 std::string err_description="";
1027 PyObject* new_stderr = newPyStdOut(err_description);
1028 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
1029 Py_INCREF(old_stderr);
1030 PySys_SetObject((char*)"stderr", new_stderr);
1032 PySys_SetObject((char*)"stderr", old_stderr);
1033 Py_DECREF(new_stderr);
1034 MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
1035 SetErrorCode("Can't evaluate the expressions, please check them !!!");
1036 PyGILState_Release(gstate);
1040 int lsize = PyList_Size( coords );
1043 SetErrorCode("Empty list of the points, please check input parameters !!!");
1047 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, lsize * 3);
1050 for ( Py_ssize_t i = 0; i < lsize; ++i ) {
1051 PyObject* coord = PyList_GetItem( coords, i );
1052 if (coord != NULL) {
1053 for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
1054 PyObject* item = PyList_GetItem(coord, j);
1055 aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
1063 PyGILState_Release(gstate);
1065 Handle(GEOM_Object) aCurve;
1066 Handle(GEOM_Function) aFunction;
1067 TCollection_AsciiString aCurveType;
1069 switch(theCurveType) {
1071 //Add a new Polyline object
1072 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
1074 //Add a new Polyline function for creation a polyline relatively to points set
1075 aFunction = aCurve->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
1076 if (aFunction.IsNull()) return NULL;
1078 //Check if the function is set correctly
1079 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
1081 GEOMImpl_IPolyline aCI (aFunction);
1083 aCI.SetLength(lsize);
1084 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1085 aCI.SetIsClosed(false);
1086 aCI.SetCoordinates(aCoordsArray);
1087 aCurveType = "GEOM.Polyline";
1091 //Add a new Spline object
1092 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
1093 //Add a new Spline function for creation a bezier curve relatively to points set
1095 aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
1096 if (aFunction.IsNull()) return NULL;
1098 //Check if the function is set correctly
1099 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
1101 GEOMImpl_ISpline aCI (aFunction);
1103 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1104 aCI.SetIsClosed(false);
1105 aCI.SetCoordinates(aCoordsArray);
1106 aCurveType = "GEOM.Bezier";
1109 case Interpolation: {
1110 //Add a new Spline object
1111 aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
1113 //Add a new Spline function for creation a bezier curve relatively to points set
1114 aFunction = aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
1115 if (aFunction.IsNull()) return NULL;
1117 //Check if the function is set correctly
1118 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
1120 GEOMImpl_ISpline aCI (aFunction);
1121 aCI.SetConstructorType(COORD_CONSTRUCTOR);
1122 aCI.SetIsClosed(false);
1123 aCI.SetDoReordering(false);
1124 aCI.SetCoordinates(aCoordsArray);
1125 aCurveType = "GEOM.Interpolation";
1130 GEOMImpl_ICurveParametric aIP(aFunction);
1131 aIP.SetExprX (thexExpr);
1132 aIP.SetExprY (theyExpr);
1133 aIP.SetExprZ (thezExpr);
1134 aIP.SetParamMin (theParamMin);
1135 aIP.SetParamMax (theParamMax);
1137 aIP.SetParamNbStep(theParamNbStep);
1139 aIP.SetParamStep (theParamStep);
1141 //Compute the Curve value
1144 if (!GetSolver()->ComputeFunction(aFunction)) {
1145 SetErrorCode("Curve driver failed !!!");
1149 catch (Standard_Failure) {
1150 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1151 SetErrorCode(aFail->GetMessageString());
1155 //Make a Python command
1156 GEOM::TPythonDump pd (aFunction);
1157 pd << aCurve << " = geompy.MakeCurveParametric(";
1158 pd << "\"" << thexExpr << "\", ";
1159 pd << "\"" << theyExpr << "\", ";
1160 pd << "\"" << thezExpr << "\", ";
1162 pd << theParamMin <<", ";
1163 pd << theParamMax <<", ";
1165 pd << theParamNbStep <<", ";
1167 pd << theParamStep <<", ";
1168 pd << aCurveType.ToCString() <<", ";
1169 pd << theNewMethod <<")";
1175 //=============================================================================
1179 //=============================================================================
1180 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
1181 std::list<double> theWorkingPlane)
1185 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1187 //Add a new Sketcher object
1188 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
1190 //Add a new Sketcher function
1191 Handle(GEOM_Function) aFunction =
1192 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
1193 if (aFunction.IsNull()) return NULL;
1195 //Check if the function is set correctly
1196 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
1198 GEOMImpl_ISketcher aCI (aFunction);
1200 TCollection_AsciiString aCommand((char*) theCommand);
1201 aCI.SetCommand(aCommand);
1204 std::list<double>::iterator it = theWorkingPlane.begin();
1205 for (; it != theWorkingPlane.end(); it++, ind++)
1206 aCI.SetWorkingPlane(ind, *it);
1208 //Compute the Sketcher value
1211 if (!GetSolver()->ComputeFunction(aFunction)) {
1212 SetErrorCode("Sketcher driver failed");
1216 catch (Standard_Failure) {
1217 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1218 SetErrorCode(aFail->GetMessageString());
1222 //Make a Python command
1223 GEOM::TPythonDump pd (aFunction);
1224 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
1226 it = theWorkingPlane.begin();
1228 while (it != theWorkingPlane.end()) {
1229 pd << ", " << (*it++);
1237 //=============================================================================
1239 * MakeSketcherOnPlane
1241 //=============================================================================
1242 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
1243 (const char* theCommand,
1244 Handle(GEOM_Object) theWorkingPlane)
1248 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1250 //Add a new Sketcher object
1251 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
1253 //Add a new Sketcher function
1254 Handle(GEOM_Function) aFunction =
1255 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
1256 if (aFunction.IsNull()) return NULL;
1258 //Check if the function is set correctly
1259 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
1261 GEOMImpl_ISketcher aCI (aFunction);
1263 TCollection_AsciiString aCommand((char*) theCommand);
1264 aCI.SetCommand(aCommand);
1266 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
1267 if (aRefPlane.IsNull()) return NULL;
1268 aCI.SetWorkingPlane( aRefPlane );
1270 //Compute the Sketcher value
1273 if (!GetSolver()->ComputeFunction(aFunction)) {
1274 SetErrorCode("Sketcher driver failed");
1278 catch (Standard_Failure) {
1279 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1280 SetErrorCode(aFail->GetMessageString());
1284 //Make a Python command
1285 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
1286 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";
1292 //=============================================================================
1294 * Make3DSketcherCommand
1296 //=============================================================================
1297 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const char* theCommand)
1301 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
1303 //Add a new Sketcher object
1304 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
1306 //Add a new Sketcher function
1307 Handle(GEOM_Function) aFunction =
1308 aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND);
1309 if (aFunction.IsNull()) return NULL;
1311 //Check if the function is set correctly
1312 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
1314 GEOMImpl_I3DSketcher aCI (aFunction);
1316 TCollection_AsciiString aCommand ((char*) theCommand);
1317 aCI.SetCommand(aCommand);
1319 //Compute the 3D Sketcher value
1322 if (!GetSolver()->ComputeFunction(aFunction)) {
1323 SetErrorCode("3D Sketcher driver failed");
1327 catch (Standard_Failure) {
1328 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1329 SetErrorCode(aFail->GetMessageString());
1333 //Make a Python command
1334 GEOM::TPythonDump pd (aFunction);
1335 pd << aSketcher << " = geompy.Make3DSketcherCommand(\"" << aCommand.ToCString() << "\")";
1341 //=============================================================================
1345 //=============================================================================
1346 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
1350 //Add a new Sketcher object
1351 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
1353 //Add a new Sketcher function
1354 Handle(GEOM_Function) aFunction =
1355 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COORDS);
1356 if (aFunction.IsNull()) return NULL;
1358 //Check if the function is set correctly
1359 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
1361 GEOMImpl_I3DSketcher aCI (aFunction);
1364 std::list<double>::iterator it = theCoordinates.begin();
1365 for (; it != theCoordinates.end(); it++)
1368 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
1370 it = theCoordinates.begin();
1372 for (; it != theCoordinates.end(); it++, ind++)
1373 aCoordsArray->SetValue(ind, *it);
1375 aCI.SetCoordinates(aCoordsArray);
1377 //Compute the Sketcher value
1380 if (!GetSolver()->ComputeFunction(aFunction)) {
1381 SetErrorCode("3D Sketcher driver failed");
1385 catch (Standard_Failure) {
1386 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1387 SetErrorCode(aFail->GetMessageString());
1391 //Make a Python command
1392 GEOM::TPythonDump pd (aFunction);
1393 pd << a3DSketcher << " = geompy.Make3DSketcher([";
1395 it = theCoordinates.begin();
1397 while (it != theCoordinates.end()) {
1398 pd << ", " << (*it++);
1406 //=============================================================================
1410 //=============================================================================
1411 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeIsoline
1412 (const Handle(GEOM_Object) &theFace,
1414 const double theParameter)
1418 if (theFace.IsNull()) {
1422 //Add a new Spline object
1423 Handle(GEOM_Object) anIsoline =
1424 GetEngine()->AddObject(GetDocID(), GEOM_ISOLINE);
1426 //Add a new Spline function for interpolation type
1427 Handle(GEOM_Function) aFunction =
1428 anIsoline->AddFunction(GEOMImpl_ShapeDriver::GetID(), SHAPE_ISOLINE);
1430 if (aFunction.IsNull()) {
1434 //Check if the function is set correctly
1435 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
1439 GEOMImpl_IIsoline aCI (aFunction);
1440 Handle(GEOM_Function) aRefFace = theFace->GetLastFunction();
1442 if (aRefFace.IsNull()) {
1446 aCI.SetFace(aRefFace);
1447 aCI.SetIsUIso(IsUIso);
1448 aCI.SetParameter(theParameter);
1450 //Compute the isoline curve
1453 if (!GetSolver()->ComputeFunction(aFunction)) {
1454 SetErrorCode("Shape driver failed");
1458 catch (Standard_Failure) {
1459 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1460 SetErrorCode(aFail->GetMessageString());
1464 //Make a Python command
1465 GEOM::TPythonDump (aFunction) << anIsoline << " = geompy.MakeIsoline( "
1466 << theFace << ", " << IsUIso << ", " << theParameter << " )";
1472 //=============================================================================
1476 //=============================================================================
1477 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2D
1478 (const std::list <std::list <double> > &theCoords,
1479 const Handle(TColStd_HArray1OfExtendedString) &theNames,
1480 const Handle(TColStd_HArray1OfByte) &theTypes,
1481 const Handle(TColStd_HArray1OfByte) &theCloseds,
1482 const Handle(TColStd_HArray1OfReal) &theWorkingPlane)
1486 if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
1487 theCloseds.IsNull() || theWorkingPlane.IsNull()) {
1491 // Add a new Polyline object
1492 Handle(GEOM_Object) aResult =
1493 GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
1494 Handle(GEOM_Function) aFunction = aResult->AddFunction
1495 (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_COORDS);
1497 if (aFunction.IsNull()) {
1501 // Check if the function is set correctly
1502 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
1506 GEOMImpl_IPolyline2D aCI(aFunction);
1508 aCI.SetCoords(theCoords);
1509 aCI.SetNames(theNames);
1510 aCI.SetTypes(theTypes);
1511 aCI.SetClosedFlags(theCloseds);
1512 aCI.SetWorkingPlaneDbls(theWorkingPlane);
1514 // Compute the isoline curve
1516 #if OCC_VERSION_LARGE > 0x06010000
1519 if (!GetSolver()->ComputeFunction(aFunction)) {
1520 SetErrorCode("Polyline driver failed");
1524 catch (Standard_Failure) {
1525 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1526 SetErrorCode(aFail->GetMessageString());
1530 //Make a Python command
1531 GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
1532 theCloseds, theWorkingPlane);
1534 aDumper.Dump(aResult);
1536 if (aDumper.IsDone() == Standard_False) {
1537 SetErrorCode("Python dump failed");
1545 //=============================================================================
1547 * MakePolyline2DOnPlane
1549 //=============================================================================
1550 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline2DOnPlane
1551 (const std::list <std::list <double> > &theCoords,
1552 const Handle(TColStd_HArray1OfExtendedString) &theNames,
1553 const Handle(TColStd_HArray1OfByte) &theTypes,
1554 const Handle(TColStd_HArray1OfByte) &theCloseds,
1555 const Handle(GEOM_Object) &theWorkingPlane)
1559 if (theCoords.empty() || theNames.IsNull() || theTypes.IsNull() ||
1560 theCloseds.IsNull() || theWorkingPlane.IsNull()) {
1564 //Add a new Polyline object
1565 Handle(GEOM_Object) aResult =
1566 GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE2D);
1567 Handle(GEOM_Function) aFunction = aResult->AddFunction
1568 (GEOMImpl_PolylineDriver::GetID(), POLYLINE2D_PLN_OBJECT);
1570 if (aFunction.IsNull()) {
1574 //Check if the function is set correctly
1575 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) {
1579 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
1581 if (aRefPlane.IsNull()) {
1585 GEOMImpl_IPolyline2D aCI(aFunction);
1587 aCI.SetCoords(theCoords);
1588 aCI.SetNames(theNames);
1589 aCI.SetTypes(theTypes);
1590 aCI.SetClosedFlags(theCloseds);
1591 aCI.SetWorkingPlane(aRefPlane);
1593 //Compute the isoline curve
1595 #if OCC_VERSION_LARGE > 0x06010000
1598 if (!GetSolver()->ComputeFunction(aFunction)) {
1599 SetErrorCode("Polyline driver failed");
1603 catch (Standard_Failure) {
1604 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1605 SetErrorCode(aFail->GetMessageString());
1609 //Make a Python command
1610 GEOMImpl_PolylineDumper aDumper(theCoords, theNames, theTypes,
1611 theCloseds, theWorkingPlane);
1613 aDumper.Dump(aResult);
1615 if (aDumper.IsDone() == Standard_False) {
1616 SetErrorCode("Python dump failed");