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 <GEOM_Function.hxx>
27 #include <GEOM_PythonDump.hxx>
29 #include <GEOMImpl_Types.hxx>
31 #include <GEOMImpl_PolylineDriver.hxx>
32 #include <GEOMImpl_CircleDriver.hxx>
33 #include <GEOMImpl_SplineDriver.hxx>
34 #include <GEOMImpl_EllipseDriver.hxx>
35 #include <GEOMImpl_ArcDriver.hxx>
36 #include <GEOMImpl_SketcherDriver.hxx>
38 #include <GEOMImpl_IPolyline.hxx>
39 #include <GEOMImpl_ICircle.hxx>
40 #include <GEOMImpl_ISpline.hxx>
41 #include <GEOMImpl_IEllipse.hxx>
42 #include <GEOMImpl_IArc.hxx>
43 #include <GEOMImpl_ISketcher.hxx>
45 #include "utilities.h"
47 #include <TDF_Tool.hxx>
49 #include <Standard_Failure.hxx>
50 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
52 //=============================================================================
56 //=============================================================================
57 GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
58 : GEOM_IOperations(theEngine, theDocID)
60 MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
63 //=============================================================================
67 //=============================================================================
68 GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
70 MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations");
74 //=============================================================================
78 //=============================================================================
79 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list<Handle(GEOM_Object)> thePoints)
83 //Add a new Polyline object
84 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
86 //Add a new Polyline function for creation a polyline relatively to points set
87 Handle(GEOM_Function) aFunction =
88 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
89 if (aFunction.IsNull()) return NULL;
91 //Check if the function is set correctly
92 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
94 GEOMImpl_IPolyline aCI (aFunction);
96 int aLen = thePoints.size();
100 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
101 for (; it != thePoints.end(); it++, ind++) {
102 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
103 if (aRefPnt.IsNull()) {
104 SetErrorCode("NULL point for Polyline");
107 aCI.SetPoint(ind, aRefPnt);
110 //Compute the Polyline value
112 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
115 if (!GetSolver()->ComputeFunction(aFunction)) {
116 SetErrorCode("Polyline driver failed");
120 catch (Standard_Failure) {
121 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
122 SetErrorCode(aFail->GetMessageString());
126 //Make a Python command
127 GEOM::TPythonDump pd (aFunction);
128 pd << aPolyline << " = geompy.MakePolyline([";
130 it = thePoints.begin();
132 while (it != thePoints.end()) {
133 pd << ", " << (*it++);
141 //=============================================================================
145 //=============================================================================
146 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
147 Handle(GEOM_Object) thePnt2,
148 Handle(GEOM_Object) thePnt3)
152 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
154 //Add a new Circle object
155 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
157 //Add a new Circle function for creation a circle relatively to three points
158 Handle(GEOM_Function) aFunction =
159 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
160 if (aFunction.IsNull()) return NULL;
162 //Check if the function is set correctly
163 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
165 GEOMImpl_ICircle aCI (aFunction);
167 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
168 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
169 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
171 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
173 aCI.SetPoint1(aRefPnt1);
174 aCI.SetPoint2(aRefPnt2);
175 aCI.SetPoint3(aRefPnt3);
177 //Compute the Circle value
179 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
182 if (!GetSolver()->ComputeFunction(aFunction)) {
183 SetErrorCode("Circle driver failed");
187 catch (Standard_Failure) {
188 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
189 SetErrorCode(aFail->GetMessageString());
193 //Make a Python command
194 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
195 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
201 //=============================================================================
203 * MakeCircleCenter2Pnt
205 //=============================================================================
206 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
207 Handle(GEOM_Object) thePnt2,
208 Handle(GEOM_Object) thePnt3)
212 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
214 //Add a new Circle object
215 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
217 //Add a new Circle function for creation a circle relatively to center and 2 points
218 Handle(GEOM_Function) aFunction =
219 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
220 if (aFunction.IsNull()) return NULL;
222 //Check if the function is set correctly
223 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
225 GEOMImpl_ICircle aCI (aFunction);
227 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
228 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
229 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
231 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
233 aCI.SetPoint1(aRefPnt1);
234 aCI.SetPoint2(aRefPnt2);
235 aCI.SetPoint3(aRefPnt3);
237 //Compute the Circle value
239 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
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.MakeCircleCenter2Pnt("
255 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
261 //=============================================================================
265 //=============================================================================
266 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
267 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
271 // Not set thePnt means origin of global CS,
272 // Not set theVec means Z axis of global CS
273 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
275 //Add a new Circle object
276 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
278 //Add a new Circle function for creation a circle relatively to point and vector
279 Handle(GEOM_Function) aFunction =
280 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
281 if (aFunction.IsNull()) return NULL;
283 //Check if the function is set correctly
284 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
286 GEOMImpl_ICircle aCI (aFunction);
288 if (!thePnt.IsNull()) {
289 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
290 if (aRefPnt.IsNull()) return NULL;
291 aCI.SetCenter(aRefPnt);
294 if (!theVec.IsNull()) {
295 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
296 if (aRefVec.IsNull()) return NULL;
297 aCI.SetVector(aRefVec);
302 //Compute the Circle value
304 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
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.MakeCircle("
320 << thePnt << ", " << theVec << ", " << theR << ")";
326 //=============================================================================
330 //=============================================================================
331 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
332 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
333 double theRMajor, double theRMinor)
337 // Not set thePnt means origin of global CS,
338 // Not set theVec means Z axis of global CS
339 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
341 //Add a new Ellipse object
342 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
344 //Add a new Ellipse function
345 Handle(GEOM_Function) aFunction =
346 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
347 if (aFunction.IsNull()) return NULL;
349 //Check if the function is set correctly
350 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
352 GEOMImpl_IEllipse aCI (aFunction);
354 if (!thePnt.IsNull()) {
355 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
356 if (aRefPnt.IsNull()) return NULL;
357 aCI.SetCenter(aRefPnt);
360 if (!theVec.IsNull()) {
361 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
362 if (aRefVec.IsNull()) return NULL;
363 aCI.SetVector(aRefVec);
366 aCI.SetRMajor(theRMajor);
367 aCI.SetRMinor(theRMinor);
369 //Compute the Ellipse value
371 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
374 if (!GetSolver()->ComputeFunction(aFunction)) {
375 SetErrorCode("Ellipse driver failed");
379 catch (Standard_Failure) {
380 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
381 SetErrorCode(aFail->GetMessageString());
385 //Make a Python command
386 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
387 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
393 //=============================================================================
397 //=============================================================================
398 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
399 Handle(GEOM_Object) thePnt2,
400 Handle(GEOM_Object) thePnt3)
404 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
406 //Add a new Circle Arc object
407 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
409 //Add a new Circle Arc function
410 Handle(GEOM_Function) aFunction =
411 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
413 if (aFunction.IsNull()) return NULL;
415 //Check if the function is set correctly
416 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
417 GEOMImpl_IArc aCI (aFunction);
419 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
420 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
421 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
424 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
426 aCI.SetPoint1(aRefPnt1);
427 aCI.SetPoint2(aRefPnt2);
428 aCI.SetPoint3(aRefPnt3);
430 //Compute the Arc value
432 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
435 if (!GetSolver()->ComputeFunction(aFunction)) {
436 SetErrorCode("Arc driver failed");
440 catch (Standard_Failure) {
441 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
442 SetErrorCode(aFail->GetMessageString());
446 //Make a Python command
447 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
448 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
454 //=============================================================================
458 //=============================================================================
459 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
460 Handle(GEOM_Object) thePnt2,
461 Handle(GEOM_Object) thePnt3,
465 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
467 //Add a new Circle Arc object
468 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
470 //Add a new Circle Arc function
471 Handle(GEOM_Function) aFunction =
472 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
473 if (aFunction.IsNull()) return NULL;
475 //Check if the function is set correctly
476 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
478 GEOMImpl_IArc aCI (aFunction);
480 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
481 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
482 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
484 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
486 aCI.SetPoint1(aRefPnt1);
487 aCI.SetPoint2(aRefPnt2);
488 aCI.SetPoint3(aRefPnt3);
489 aCI.SetSense(theSense);
491 //Compute the Arc value
493 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
496 if (!GetSolver()->ComputeFunction(aFunction)) {
497 SetErrorCode("Arc driver failed");
501 catch (Standard_Failure) {
502 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
503 SetErrorCode(aFail->GetMessageString());
506 //Make a Python command
507 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
508 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
514 //=============================================================================
518 //=============================================================================
519 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
520 (list<Handle(GEOM_Object)> thePoints)
524 //Add a new Spline object
525 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
527 //Add a new Spline function for creation a bezier curve relatively to points set
528 Handle(GEOM_Function) aFunction =
529 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
530 if (aFunction.IsNull()) return NULL;
532 //Check if the function is set correctly
533 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
535 GEOMImpl_ISpline aCI (aFunction);
537 int aLen = thePoints.size();
541 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
542 for (; it != thePoints.end(); it++, ind++) {
543 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
545 if (aRefPnt.IsNull()) return NULL;
547 aCI.SetPoint(ind, aRefPnt);
550 //Compute the Spline value
552 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
555 if (!GetSolver()->ComputeFunction(aFunction)) {
556 SetErrorCode("Spline driver failed");
560 catch (Standard_Failure) {
561 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
562 SetErrorCode(aFail->GetMessageString());
566 //Make a Python command
567 GEOM::TPythonDump pd (aFunction);
568 pd << aSpline << " = geompy.MakeBezier([";
570 it = thePoints.begin();
572 while (it != thePoints.end()) {
573 pd << ", " << (*it++);
581 //=============================================================================
583 * MakeSplineInterpolation
585 //=============================================================================
586 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
587 (list<Handle(GEOM_Object)> thePoints)
591 //Add a new Spline object
592 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
594 //Add a new Spline function for creation a bezier curve relatively to points set
595 Handle(GEOM_Function) aFunction =
596 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
597 if (aFunction.IsNull()) return NULL;
599 //Check if the function is set correctly
600 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
602 GEOMImpl_ISpline aCI (aFunction);
604 int aLen = thePoints.size();
608 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
609 for (; it != thePoints.end(); it++, ind++) {
610 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
612 if (aRefPnt.IsNull()) return NULL;
614 aCI.SetPoint(ind, aRefPnt);
617 //Compute the Spline value
619 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
622 if (!GetSolver()->ComputeFunction(aFunction)) {
623 SetErrorCode("Spline driver failed");
627 catch (Standard_Failure) {
628 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
629 SetErrorCode(aFail->GetMessageString());
633 //Make a Python command
634 GEOM::TPythonDump pd (aFunction);
635 pd << aSpline << " = geompy.MakeInterpol([";
637 it = thePoints.begin();
639 while (it != thePoints.end()) {
640 pd << ", " << (*it++);
648 //=============================================================================
652 //=============================================================================
653 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
654 list<double> theWorkingPlane)
658 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
660 //Add a new Sketcher object
661 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
663 //Add a new Sketcher function
664 Handle(GEOM_Function) aFunction =
665 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
666 if (aFunction.IsNull()) return NULL;
668 //Check if the function is set correctly
669 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
671 GEOMImpl_ISketcher aCI (aFunction);
673 TCollection_AsciiString aCommand((char*) theCommand);
674 aCI.SetCommand(aCommand);
677 list<double>::iterator it = theWorkingPlane.begin();
678 for (; it != theWorkingPlane.end(); it++, ind++)
679 aCI.SetWorkingPlane(ind, *it);
681 //Compute the Sketcher value
683 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Sketcher 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 << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
701 it = theWorkingPlane.begin();
703 while (it != theWorkingPlane.end()) {
704 pd << ", " << (*it++);
712 //=============================================================================
714 * MakeSketcherOnPlane
716 //=============================================================================
717 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
718 (const char* theCommand,
719 Handle(GEOM_Object) 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_PLANE);
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);
741 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
742 if (aRefPlane.IsNull()) return NULL;
743 aCI.SetWorkingPlane( aRefPlane );
745 //Compute the Sketcher value
747 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
750 if (!GetSolver()->ComputeFunction(aFunction)) {
751 SetErrorCode("Sketcher driver failed");
755 catch (Standard_Failure) {
756 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
757 SetErrorCode(aFail->GetMessageString());
761 //Make a Python command
762 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
763 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";