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,
338 Handle(GEOM_Object) theVecMaj)
342 // Not set thePnt means origin of global CS,
343 // Not set theVec means Z axis of global CS
344 // Not set theVecMaj means X axis of global CS
345 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
347 //Add a new Ellipse object
348 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
350 //Add a new Ellipse function
351 Handle(GEOM_Function) aFunction =
352 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
353 if (aFunction.IsNull()) return NULL;
355 //Check if the function is set correctly
356 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
358 GEOMImpl_IEllipse aCI (aFunction);
360 if (!thePnt.IsNull()) {
361 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
362 if (aRefPnt.IsNull()) return NULL;
363 aCI.SetCenter(aRefPnt);
366 if (!theVec.IsNull()) {
367 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
368 if (aRefVec.IsNull()) return NULL;
369 aCI.SetVector(aRefVec);
372 aCI.SetRMajor(theRMajor);
373 aCI.SetRMinor(theRMinor);
375 if (!theVecMaj.IsNull()) {
376 Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
377 if (aRefVecMaj.IsNull()) return NULL;
378 aCI.SetVectorMajor(aRefVecMaj);
381 //Compute the Ellipse value
383 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
386 if (!GetSolver()->ComputeFunction(aFunction)) {
387 SetErrorCode("Ellipse driver failed");
391 catch (Standard_Failure) {
392 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
393 SetErrorCode(aFail->GetMessageString());
397 //Make a Python command
398 if (!theVecMaj.IsNull()) {
399 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
400 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
401 << ", " << theVecMaj << ")";
404 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
405 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
412 //=============================================================================
416 //=============================================================================
417 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
418 Handle(GEOM_Object) thePnt2,
419 Handle(GEOM_Object) thePnt3)
423 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
425 //Add a new Circle Arc object
426 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
428 //Add a new Circle Arc function
429 Handle(GEOM_Function) aFunction =
430 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
432 if (aFunction.IsNull()) return NULL;
434 //Check if the function is set correctly
435 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
436 GEOMImpl_IArc aCI (aFunction);
438 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
439 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
440 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
443 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
445 aCI.SetPoint1(aRefPnt1);
446 aCI.SetPoint2(aRefPnt2);
447 aCI.SetPoint3(aRefPnt3);
449 //Compute the Arc value
451 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
454 if (!GetSolver()->ComputeFunction(aFunction)) {
455 SetErrorCode("Arc driver failed");
459 catch (Standard_Failure) {
460 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
461 SetErrorCode(aFail->GetMessageString());
465 //Make a Python command
466 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
467 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
473 //=============================================================================
477 //=============================================================================
478 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
479 Handle(GEOM_Object) thePnt2,
480 Handle(GEOM_Object) thePnt3,
484 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
486 //Add a new Circle Arc object
487 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
489 //Add a new Circle Arc function
490 Handle(GEOM_Function) aFunction =
491 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
492 if (aFunction.IsNull()) return NULL;
494 //Check if the function is set correctly
495 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
497 GEOMImpl_IArc aCI (aFunction);
499 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
500 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
501 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
503 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
505 aCI.SetPoint1(aRefPnt1);
506 aCI.SetPoint2(aRefPnt2);
507 aCI.SetPoint3(aRefPnt3);
508 aCI.SetSense(theSense);
510 //Compute the Arc value
512 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
515 if (!GetSolver()->ComputeFunction(aFunction)) {
516 SetErrorCode("Arc driver failed");
520 catch (Standard_Failure) {
521 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
522 SetErrorCode(aFail->GetMessageString());
525 //Make a Python command
526 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
527 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
533 //=============================================================================
537 //=============================================================================
538 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
539 Handle(GEOM_Object) thePnt2,
540 Handle(GEOM_Object) thePnt3)
544 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
546 //Add a new Circle Arc object
547 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
549 //Add a new Circle Arc function
550 Handle(GEOM_Function) aFunction =
551 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
553 if (aFunction.IsNull()) return NULL;
555 //Check if the function is set correctly
556 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
557 GEOMImpl_IArc aCI (aFunction);
559 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
560 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
561 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
564 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
566 aCI.SetPoint1(aRefPnt1);
567 aCI.SetPoint2(aRefPnt2);
568 aCI.SetPoint3(aRefPnt3);
570 //Compute the Arc value
572 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
575 if (!GetSolver()->ComputeFunction(aFunction)) {
576 SetErrorCode("Arc driver failed");
580 catch (Standard_Failure) {
581 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
582 SetErrorCode(aFail->GetMessageString());
586 //Make a Python command
587 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
588 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
594 //=============================================================================
598 //=============================================================================
599 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
600 (list<Handle(GEOM_Object)> thePoints)
604 //Add a new Spline object
605 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
607 //Add a new Spline function for creation a bezier curve relatively to points set
608 Handle(GEOM_Function) aFunction =
609 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
610 if (aFunction.IsNull()) return NULL;
612 //Check if the function is set correctly
613 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
615 GEOMImpl_ISpline aCI (aFunction);
617 int aLen = thePoints.size();
621 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
622 for (; it != thePoints.end(); it++, ind++) {
623 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
625 if (aRefPnt.IsNull()) return NULL;
627 aCI.SetPoint(ind, aRefPnt);
630 //Compute the Spline value
632 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
635 if (!GetSolver()->ComputeFunction(aFunction)) {
636 SetErrorCode("Spline driver failed");
640 catch (Standard_Failure) {
641 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
642 SetErrorCode(aFail->GetMessageString());
646 //Make a Python command
647 GEOM::TPythonDump pd (aFunction);
648 pd << aSpline << " = geompy.MakeBezier([";
650 it = thePoints.begin();
652 while (it != thePoints.end()) {
653 pd << ", " << (*it++);
661 //=============================================================================
663 * MakeSplineInterpolation
665 //=============================================================================
666 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
667 (list<Handle(GEOM_Object)> thePoints)
671 //Add a new Spline object
672 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
674 //Add a new Spline function for creation a bezier curve relatively to points set
675 Handle(GEOM_Function) aFunction =
676 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
677 if (aFunction.IsNull()) return NULL;
679 //Check if the function is set correctly
680 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
682 GEOMImpl_ISpline aCI (aFunction);
684 int aLen = thePoints.size();
688 list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
689 for (; it != thePoints.end(); it++, ind++) {
690 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
692 if (aRefPnt.IsNull()) return NULL;
694 aCI.SetPoint(ind, aRefPnt);
697 //Compute the Spline value
699 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
702 if (!GetSolver()->ComputeFunction(aFunction)) {
703 SetErrorCode("Spline driver failed");
707 catch (Standard_Failure) {
708 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
709 SetErrorCode(aFail->GetMessageString());
713 //Make a Python command
714 GEOM::TPythonDump pd (aFunction);
715 pd << aSpline << " = geompy.MakeInterpol([";
717 it = thePoints.begin();
719 while (it != thePoints.end()) {
720 pd << ", " << (*it++);
728 //=============================================================================
732 //=============================================================================
733 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
734 list<double> theWorkingPlane)
738 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
740 //Add a new Sketcher object
741 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
743 //Add a new Sketcher function
744 Handle(GEOM_Function) aFunction =
745 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
746 if (aFunction.IsNull()) return NULL;
748 //Check if the function is set correctly
749 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
751 GEOMImpl_ISketcher aCI (aFunction);
753 TCollection_AsciiString aCommand((char*) theCommand);
754 aCI.SetCommand(aCommand);
757 list<double>::iterator it = theWorkingPlane.begin();
758 for (; it != theWorkingPlane.end(); it++, ind++)
759 aCI.SetWorkingPlane(ind, *it);
761 //Compute the Sketcher value
763 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
766 if (!GetSolver()->ComputeFunction(aFunction)) {
767 SetErrorCode("Sketcher driver failed");
771 catch (Standard_Failure) {
772 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
773 SetErrorCode(aFail->GetMessageString());
777 //Make a Python command
778 GEOM::TPythonDump pd (aFunction);
779 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
781 it = theWorkingPlane.begin();
783 while (it != theWorkingPlane.end()) {
784 pd << ", " << (*it++);
792 //=============================================================================
796 //=============================================================================
797 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list<double> theCoordinates)
801 //Add a new Sketcher object
802 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
804 //Add a new Sketcher function
805 Handle(GEOM_Function) aFunction =
806 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
807 if (aFunction.IsNull()) return NULL;
809 //Check if the function is set correctly
810 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
812 GEOMImpl_I3DSketcher aCI (aFunction);
815 list<double>::iterator it = theCoordinates.begin();
816 for (; it != theCoordinates.end(); it++)
819 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
821 it = theCoordinates.begin();
823 for (; it != theCoordinates.end(); it++, ind++)
824 aCoordsArray->SetValue(ind, *it);
826 aCI.SetCoordinates(aCoordsArray);
828 //Compute the Sketcher value
830 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
833 if (!GetSolver()->ComputeFunction(aFunction)) {
834 SetErrorCode("3D Sketcher driver failed");
838 catch (Standard_Failure) {
839 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
840 SetErrorCode(aFail->GetMessageString());
844 //Make a Python command
845 GEOM::TPythonDump pd (aFunction);
846 pd << a3DSketcher << " = geompy.Make3DSketcher([";
848 it = theCoordinates.begin();
850 while (it != theCoordinates.end()) {
851 pd << ", " << (*it++);
859 //=============================================================================
861 * MakeSketcherOnPlane
863 //=============================================================================
864 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
865 (const char* theCommand,
866 Handle(GEOM_Object) theWorkingPlane)
870 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
872 //Add a new Sketcher object
873 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
875 //Add a new Sketcher function
876 Handle(GEOM_Function) aFunction =
877 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
878 if (aFunction.IsNull()) return NULL;
880 //Check if the function is set correctly
881 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
883 GEOMImpl_ISketcher aCI (aFunction);
885 TCollection_AsciiString aCommand((char*) theCommand);
886 aCI.SetCommand(aCommand);
888 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
889 if (aRefPlane.IsNull()) return NULL;
890 aCI.SetWorkingPlane( aRefPlane );
892 //Compute the Sketcher value
894 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
897 if (!GetSolver()->ComputeFunction(aFunction)) {
898 SetErrorCode("Sketcher driver failed");
902 catch (Standard_Failure) {
903 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
904 SetErrorCode(aFail->GetMessageString());
908 //Make a Python command
909 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
910 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";