1 // Copyright (C) 2007-2008 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.
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
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_ICurvesOperations.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
28 #include <GEOM_Function.hxx>
29 #include <GEOM_PythonDump.hxx>
31 #include <GEOMImpl_Types.hxx>
33 #include <GEOMImpl_PolylineDriver.hxx>
34 #include <GEOMImpl_CircleDriver.hxx>
35 #include <GEOMImpl_SplineDriver.hxx>
36 #include <GEOMImpl_EllipseDriver.hxx>
37 #include <GEOMImpl_ArcDriver.hxx>
38 #include <GEOMImpl_SketcherDriver.hxx>
39 #include <GEOMImpl_3DSketcherDriver.hxx>
41 #include <GEOMImpl_IPolyline.hxx>
42 #include <GEOMImpl_ICircle.hxx>
43 #include <GEOMImpl_ISpline.hxx>
44 #include <GEOMImpl_IEllipse.hxx>
45 #include <GEOMImpl_IArc.hxx>
46 #include <GEOMImpl_ISketcher.hxx>
47 #include <GEOMImpl_I3DSketcher.hxx>
49 #include "utilities.h"
51 #include <TDF_Tool.hxx>
53 #include <Standard_Failure.hxx>
54 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
56 //=============================================================================
60 //=============================================================================
61 GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
62 : GEOM_IOperations(theEngine, theDocID)
64 MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
67 //=============================================================================
71 //=============================================================================
72 GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
74 MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations");
78 //=============================================================================
82 //=============================================================================
83 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list<Handle(GEOM_Object)> thePoints)
87 //Add a new Polyline object
88 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
90 //Add a new Polyline function for creation a polyline relatively to points set
91 Handle(GEOM_Function) aFunction =
92 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
93 if (aFunction.IsNull()) return NULL;
95 //Check if the function is set correctly
96 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
98 GEOMImpl_IPolyline aCI (aFunction);
100 int aLen = thePoints.size();
104 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
105 for (; it != thePoints.end(); it++, ind++) {
106 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
107 if (aRefPnt.IsNull()) {
108 SetErrorCode("NULL point for Polyline");
111 aCI.SetPoint(ind, aRefPnt);
114 //Compute the Polyline value
116 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
119 if (!GetSolver()->ComputeFunction(aFunction)) {
120 SetErrorCode("Polyline driver failed");
124 catch (Standard_Failure) {
125 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
126 SetErrorCode(aFail->GetMessageString());
130 //Make a Python command
131 GEOM::TPythonDump pd (aFunction);
132 pd << aPolyline << " = geompy.MakePolyline([";
134 it = thePoints.begin();
136 while (it != thePoints.end()) {
137 pd << ", " << (*it++);
145 //=============================================================================
149 //=============================================================================
150 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
151 Handle(GEOM_Object) thePnt2,
152 Handle(GEOM_Object) thePnt3)
156 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
158 //Add a new Circle object
159 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
161 //Add a new Circle function for creation a circle relatively to three points
162 Handle(GEOM_Function) aFunction =
163 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
164 if (aFunction.IsNull()) return NULL;
166 //Check if the function is set correctly
167 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
169 GEOMImpl_ICircle aCI (aFunction);
171 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
172 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
173 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
175 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
177 aCI.SetPoint1(aRefPnt1);
178 aCI.SetPoint2(aRefPnt2);
179 aCI.SetPoint3(aRefPnt3);
181 //Compute the Circle value
183 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
186 if (!GetSolver()->ComputeFunction(aFunction)) {
187 SetErrorCode("Circle driver failed");
191 catch (Standard_Failure) {
192 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
193 SetErrorCode(aFail->GetMessageString());
197 //Make a Python command
198 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
199 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
205 //=============================================================================
207 * MakeCircleCenter2Pnt
209 //=============================================================================
210 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
211 Handle(GEOM_Object) thePnt2,
212 Handle(GEOM_Object) thePnt3)
216 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
218 //Add a new Circle object
219 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
221 //Add a new Circle function for creation a circle relatively to center and 2 points
222 Handle(GEOM_Function) aFunction =
223 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
224 if (aFunction.IsNull()) return NULL;
226 //Check if the function is set correctly
227 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
229 GEOMImpl_ICircle aCI (aFunction);
231 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
232 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
233 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
235 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
237 aCI.SetPoint1(aRefPnt1);
238 aCI.SetPoint2(aRefPnt2);
239 aCI.SetPoint3(aRefPnt3);
241 //Compute the Circle value
243 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
246 if (!GetSolver()->ComputeFunction(aFunction)) {
247 SetErrorCode("Circle driver failed");
251 catch (Standard_Failure) {
252 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
253 SetErrorCode(aFail->GetMessageString());
257 //Make a Python command
258 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleCenter2Pnt("
259 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
265 //=============================================================================
269 //=============================================================================
270 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
271 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
275 // Not set thePnt means origin of global CS,
276 // Not set theVec means Z axis of global CS
277 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
279 //Add a new Circle object
280 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
282 //Add a new Circle function for creation a circle relatively to point and vector
283 Handle(GEOM_Function) aFunction =
284 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
285 if (aFunction.IsNull()) return NULL;
287 //Check if the function is set correctly
288 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
290 GEOMImpl_ICircle aCI (aFunction);
292 if (!thePnt.IsNull()) {
293 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
294 if (aRefPnt.IsNull()) return NULL;
295 aCI.SetCenter(aRefPnt);
298 if (!theVec.IsNull()) {
299 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
300 if (aRefVec.IsNull()) return NULL;
301 aCI.SetVector(aRefVec);
306 //Compute the Circle value
308 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
311 if (!GetSolver()->ComputeFunction(aFunction)) {
312 SetErrorCode("Circle driver failed");
316 catch (Standard_Failure) {
317 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
318 SetErrorCode(aFail->GetMessageString());
322 //Make a Python command
323 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
324 << thePnt << ", " << theVec << ", " << theR << ")";
330 //=============================================================================
334 //=============================================================================
335 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
336 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
337 double theRMajor, double theRMinor)
341 // Not set thePnt means origin of global CS,
342 // Not set theVec means Z axis of global CS
343 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
345 //Add a new Ellipse object
346 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
348 //Add a new Ellipse function
349 Handle(GEOM_Function) aFunction =
350 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
351 if (aFunction.IsNull()) return NULL;
353 //Check if the function is set correctly
354 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
356 GEOMImpl_IEllipse aCI (aFunction);
358 if (!thePnt.IsNull()) {
359 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
360 if (aRefPnt.IsNull()) return NULL;
361 aCI.SetCenter(aRefPnt);
364 if (!theVec.IsNull()) {
365 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
366 if (aRefVec.IsNull()) return NULL;
367 aCI.SetVector(aRefVec);
370 aCI.SetRMajor(theRMajor);
371 aCI.SetRMinor(theRMinor);
373 //Compute the Ellipse value
375 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
378 if (!GetSolver()->ComputeFunction(aFunction)) {
379 SetErrorCode("Ellipse driver failed");
383 catch (Standard_Failure) {
384 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
385 SetErrorCode(aFail->GetMessageString());
389 //Make a Python command
390 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
391 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
397 //=============================================================================
401 //=============================================================================
402 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
403 Handle(GEOM_Object) thePnt2,
404 Handle(GEOM_Object) thePnt3)
408 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
410 //Add a new Circle Arc object
411 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
413 //Add a new Circle Arc function
414 Handle(GEOM_Function) aFunction =
415 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
417 if (aFunction.IsNull()) return NULL;
419 //Check if the function is set correctly
420 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
421 GEOMImpl_IArc aCI (aFunction);
423 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
424 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
425 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
428 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
430 aCI.SetPoint1(aRefPnt1);
431 aCI.SetPoint2(aRefPnt2);
432 aCI.SetPoint3(aRefPnt3);
434 //Compute the Arc value
436 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
439 if (!GetSolver()->ComputeFunction(aFunction)) {
440 SetErrorCode("Arc driver failed");
444 catch (Standard_Failure) {
445 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
446 SetErrorCode(aFail->GetMessageString());
450 //Make a Python command
451 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
452 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
458 //=============================================================================
462 //=============================================================================
463 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
464 Handle(GEOM_Object) thePnt2,
465 Handle(GEOM_Object) thePnt3,
469 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
471 //Add a new Circle Arc object
472 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
474 //Add a new Circle Arc function
475 Handle(GEOM_Function) aFunction =
476 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
477 if (aFunction.IsNull()) return NULL;
479 //Check if the function is set correctly
480 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
482 GEOMImpl_IArc aCI (aFunction);
484 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
485 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
486 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
488 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
490 aCI.SetPoint1(aRefPnt1);
491 aCI.SetPoint2(aRefPnt2);
492 aCI.SetPoint3(aRefPnt3);
493 aCI.SetSense(theSense);
495 //Compute the Arc value
497 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
500 if (!GetSolver()->ComputeFunction(aFunction)) {
501 SetErrorCode("Arc driver failed");
505 catch (Standard_Failure) {
506 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
507 SetErrorCode(aFail->GetMessageString());
510 //Make a Python command
511 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
512 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
518 //=============================================================================
522 //=============================================================================
523 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
524 Handle(GEOM_Object) thePnt2,
525 Handle(GEOM_Object) thePnt3)
529 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
531 //Add a new Circle Arc object
532 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
534 //Add a new Circle Arc function
535 Handle(GEOM_Function) aFunction =
536 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
538 if (aFunction.IsNull()) return NULL;
540 //Check if the function is set correctly
541 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
542 GEOMImpl_IArc aCI (aFunction);
544 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
545 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
546 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
549 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
551 aCI.SetPoint1(aRefPnt1);
552 aCI.SetPoint2(aRefPnt2);
553 aCI.SetPoint3(aRefPnt3);
555 //Compute the Arc value
557 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
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());
571 //Make a Python command
572 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
573 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
579 //=============================================================================
583 //=============================================================================
584 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
585 (list<Handle(GEOM_Object)> thePoints)
589 //Add a new Spline object
590 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
592 //Add a new Spline function for creation a bezier curve relatively to points set
593 Handle(GEOM_Function) aFunction =
594 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
595 if (aFunction.IsNull()) return NULL;
597 //Check if the function is set correctly
598 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
600 GEOMImpl_ISpline aCI (aFunction);
602 int aLen = thePoints.size();
606 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
607 for (; it != thePoints.end(); it++, ind++) {
608 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
610 if (aRefPnt.IsNull()) return NULL;
612 aCI.SetPoint(ind, aRefPnt);
615 //Compute the Spline value
617 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
620 if (!GetSolver()->ComputeFunction(aFunction)) {
621 SetErrorCode("Spline driver failed");
625 catch (Standard_Failure) {
626 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
627 SetErrorCode(aFail->GetMessageString());
631 //Make a Python command
632 GEOM::TPythonDump pd (aFunction);
633 pd << aSpline << " = geompy.MakeBezier([";
635 it = thePoints.begin();
637 while (it != thePoints.end()) {
638 pd << ", " << (*it++);
646 //=============================================================================
648 * MakeSplineInterpolation
650 //=============================================================================
651 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
652 (list<Handle(GEOM_Object)> thePoints)
656 //Add a new Spline object
657 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
659 //Add a new Spline function for creation a bezier curve relatively to points set
660 Handle(GEOM_Function) aFunction =
661 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
662 if (aFunction.IsNull()) return NULL;
664 //Check if the function is set correctly
665 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
667 GEOMImpl_ISpline aCI (aFunction);
669 int aLen = thePoints.size();
673 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
674 for (; it != thePoints.end(); it++, ind++) {
675 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
677 if (aRefPnt.IsNull()) return NULL;
679 aCI.SetPoint(ind, aRefPnt);
682 //Compute the Spline value
684 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
687 if (!GetSolver()->ComputeFunction(aFunction)) {
688 SetErrorCode("Spline driver failed");
692 catch (Standard_Failure) {
693 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
694 SetErrorCode(aFail->GetMessageString());
698 //Make a Python command
699 GEOM::TPythonDump pd (aFunction);
700 pd << aSpline << " = geompy.MakeInterpol([";
702 it = thePoints.begin();
704 while (it != thePoints.end()) {
705 pd << ", " << (*it++);
713 //=============================================================================
717 //=============================================================================
718 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
719 list<double> theWorkingPlane)
723 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
725 //Add a new Sketcher object
726 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
728 //Add a new Sketcher function
729 Handle(GEOM_Function) aFunction =
730 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
731 if (aFunction.IsNull()) return NULL;
733 //Check if the function is set correctly
734 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
736 GEOMImpl_ISketcher aCI (aFunction);
738 TCollection_AsciiString aCommand((char*) theCommand);
739 aCI.SetCommand(aCommand);
742 list<double>::iterator it = theWorkingPlane.begin();
743 for (; it != theWorkingPlane.end(); it++, ind++)
744 aCI.SetWorkingPlane(ind, *it);
746 //Compute the Sketcher value
748 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
751 if (!GetSolver()->ComputeFunction(aFunction)) {
752 SetErrorCode("Sketcher driver failed");
756 catch (Standard_Failure) {
757 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
758 SetErrorCode(aFail->GetMessageString());
762 //Make a Python command
763 GEOM::TPythonDump pd (aFunction);
764 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
766 it = theWorkingPlane.begin();
768 while (it != theWorkingPlane.end()) {
769 pd << ", " << (*it++);
777 //=============================================================================
781 //=============================================================================
782 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list<double> theCoordinates)
786 //Add a new Sketcher object
787 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
789 //Add a new Sketcher function
790 Handle(GEOM_Function) aFunction =
791 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
792 if (aFunction.IsNull()) return NULL;
794 //Check if the function is set correctly
795 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
797 GEOMImpl_I3DSketcher aCI (aFunction);
800 list<double>::iterator it = theCoordinates.begin();
801 for (; it != theCoordinates.end(); it++)
804 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
806 it = theCoordinates.begin();
808 for (; it != theCoordinates.end(); it++, ind++)
809 aCoordsArray->SetValue(ind, *it);
811 aCI.SetCoordinates(aCoordsArray);
813 //Compute the Sketcher value
815 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
818 if (!GetSolver()->ComputeFunction(aFunction)) {
819 SetErrorCode("3D Sketcher 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 << a3DSketcher << " = geompy.Make3DSketcher([";
833 it = theCoordinates.begin();
835 while (it != theCoordinates.end()) {
836 pd << ", " << (*it++);
844 //=============================================================================
846 * MakeSketcherOnPlane
848 //=============================================================================
849 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
850 (const char* theCommand,
851 Handle(GEOM_Object) theWorkingPlane)
855 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
857 //Add a new Sketcher object
858 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
860 //Add a new Sketcher function
861 Handle(GEOM_Function) aFunction =
862 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
863 if (aFunction.IsNull()) return NULL;
865 //Check if the function is set correctly
866 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
868 GEOMImpl_ISketcher aCI (aFunction);
870 TCollection_AsciiString aCommand((char*) theCommand);
871 aCI.SetCommand(aCommand);
873 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
874 if (aRefPlane.IsNull()) return NULL;
875 aCI.SetWorkingPlane( aRefPlane );
877 //Compute the Sketcher value
879 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
882 if (!GetSolver()->ComputeFunction(aFunction)) {
883 SetErrorCode("Sketcher driver failed");
887 catch (Standard_Failure) {
888 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
889 SetErrorCode(aFail->GetMessageString());
893 //Make a Python command
894 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
895 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";