1 // Copyright (C) 2007-2010 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
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_ICurvesOperations.hxx>
27 #include <TColStd_HArray1OfReal.hxx>
29 #include <GEOM_Function.hxx>
30 #include <GEOM_PythonDump.hxx>
32 #include <GEOMImpl_Types.hxx>
34 #include <GEOMImpl_PolylineDriver.hxx>
35 #include <GEOMImpl_CircleDriver.hxx>
36 #include <GEOMImpl_SplineDriver.hxx>
37 #include <GEOMImpl_EllipseDriver.hxx>
38 #include <GEOMImpl_ArcDriver.hxx>
39 #include <GEOMImpl_SketcherDriver.hxx>
40 #include <GEOMImpl_3DSketcherDriver.hxx>
42 #include <GEOMImpl_IPolyline.hxx>
43 #include <GEOMImpl_ICircle.hxx>
44 #include <GEOMImpl_ISpline.hxx>
45 #include <GEOMImpl_IEllipse.hxx>
46 #include <GEOMImpl_IArc.hxx>
47 #include <GEOMImpl_ISketcher.hxx>
48 #include <GEOMImpl_I3DSketcher.hxx>
50 #include "utilities.h"
52 #include <TDF_Tool.hxx>
54 #include <Standard_Failure.hxx>
55 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
57 //=============================================================================
61 //=============================================================================
62 GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID)
63 : GEOM_IOperations(theEngine, theDocID)
65 MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations");
68 //=============================================================================
72 //=============================================================================
73 GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations()
75 MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations");
79 //=============================================================================
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints)
88 //Add a new Polyline object
89 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
91 //Add a new Polyline function for creation a polyline relatively to points set
92 Handle(GEOM_Function) aFunction =
93 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
94 if (aFunction.IsNull()) return NULL;
96 //Check if the function is set correctly
97 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
99 GEOMImpl_IPolyline aCI (aFunction);
101 int aLen = thePoints.size();
105 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
106 for (; it != thePoints.end(); it++, ind++) {
107 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
108 if (aRefPnt.IsNull()) {
109 SetErrorCode("NULL point for Polyline");
112 aCI.SetPoint(ind, aRefPnt);
115 //Compute the Polyline value
117 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
120 if (!GetSolver()->ComputeFunction(aFunction)) {
121 SetErrorCode("Polyline driver failed");
125 catch (Standard_Failure) {
126 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
127 SetErrorCode(aFail->GetMessageString());
131 //Make a Python command
132 GEOM::TPythonDump pd (aFunction);
133 pd << aPolyline << " = geompy.MakePolyline([";
135 it = thePoints.begin();
137 while (it != thePoints.end()) {
138 pd << ", " << (*it++);
146 //=============================================================================
150 //=============================================================================
151 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
152 Handle(GEOM_Object) thePnt2,
153 Handle(GEOM_Object) thePnt3)
157 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
159 //Add a new Circle object
160 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
162 //Add a new Circle function for creation a circle relatively to three points
163 Handle(GEOM_Function) aFunction =
164 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
165 if (aFunction.IsNull()) return NULL;
167 //Check if the function is set correctly
168 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
170 GEOMImpl_ICircle aCI (aFunction);
172 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
173 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
174 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
176 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
178 aCI.SetPoint1(aRefPnt1);
179 aCI.SetPoint2(aRefPnt2);
180 aCI.SetPoint3(aRefPnt3);
182 //Compute the Circle value
184 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
187 if (!GetSolver()->ComputeFunction(aFunction)) {
188 SetErrorCode("Circle driver failed");
192 catch (Standard_Failure) {
193 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
194 SetErrorCode(aFail->GetMessageString());
198 //Make a Python command
199 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
200 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
206 //=============================================================================
208 * MakeCircleCenter2Pnt
210 //=============================================================================
211 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
212 Handle(GEOM_Object) thePnt2,
213 Handle(GEOM_Object) thePnt3)
217 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
219 //Add a new Circle object
220 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
222 //Add a new Circle function for creation a circle relatively to center and 2 points
223 Handle(GEOM_Function) aFunction =
224 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
225 if (aFunction.IsNull()) return NULL;
227 //Check if the function is set correctly
228 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
230 GEOMImpl_ICircle aCI (aFunction);
232 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
233 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
234 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
236 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
238 aCI.SetPoint1(aRefPnt1);
239 aCI.SetPoint2(aRefPnt2);
240 aCI.SetPoint3(aRefPnt3);
242 //Compute the Circle value
244 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
247 if (!GetSolver()->ComputeFunction(aFunction)) {
248 SetErrorCode("Circle driver failed");
252 catch (Standard_Failure) {
253 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
254 SetErrorCode(aFail->GetMessageString());
258 //Make a Python command
259 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleCenter2Pnt("
260 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
266 //=============================================================================
270 //=============================================================================
271 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
272 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
276 // Not set thePnt means origin of global CS,
277 // Not set theVec means Z axis of global CS
278 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
280 //Add a new Circle object
281 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
283 //Add a new Circle function for creation a circle relatively to point and vector
284 Handle(GEOM_Function) aFunction =
285 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
286 if (aFunction.IsNull()) return NULL;
288 //Check if the function is set correctly
289 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
291 GEOMImpl_ICircle aCI (aFunction);
293 if (!thePnt.IsNull()) {
294 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
295 if (aRefPnt.IsNull()) return NULL;
296 aCI.SetCenter(aRefPnt);
299 if (!theVec.IsNull()) {
300 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
301 if (aRefVec.IsNull()) return NULL;
302 aCI.SetVector(aRefVec);
307 //Compute the Circle value
309 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
312 if (!GetSolver()->ComputeFunction(aFunction)) {
313 SetErrorCode("Circle driver failed");
317 catch (Standard_Failure) {
318 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
319 SetErrorCode(aFail->GetMessageString());
323 //Make a Python command
324 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
325 << thePnt << ", " << theVec << ", " << theR << ")";
331 //=============================================================================
335 //=============================================================================
336 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
337 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
338 double theRMajor, double theRMinor,
339 Handle(GEOM_Object) theVecMaj)
343 // Not set thePnt means origin of global CS,
344 // Not set theVec means Z axis of global CS
345 // Not set theVecMaj means X axis of global CS
346 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
348 //Add a new Ellipse object
349 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
351 //Add a new Ellipse function
352 Handle(GEOM_Function) aFunction =
353 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
354 if (aFunction.IsNull()) return NULL;
356 //Check if the function is set correctly
357 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
359 GEOMImpl_IEllipse aCI (aFunction);
361 if (!thePnt.IsNull()) {
362 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
363 if (aRefPnt.IsNull()) return NULL;
364 aCI.SetCenter(aRefPnt);
367 if (!theVec.IsNull()) {
368 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
369 if (aRefVec.IsNull()) return NULL;
370 aCI.SetVector(aRefVec);
373 aCI.SetRMajor(theRMajor);
374 aCI.SetRMinor(theRMinor);
376 if (!theVecMaj.IsNull()) {
377 Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
378 if (aRefVecMaj.IsNull()) return NULL;
379 aCI.SetVectorMajor(aRefVecMaj);
382 //Compute the Ellipse value
384 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
387 if (!GetSolver()->ComputeFunction(aFunction)) {
388 SetErrorCode("Ellipse driver failed");
392 catch (Standard_Failure) {
393 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
394 SetErrorCode(aFail->GetMessageString());
398 //Make a Python command
399 if (!theVecMaj.IsNull()) {
400 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
401 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
402 << ", " << theVecMaj << ")";
405 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
406 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
413 //=============================================================================
417 //=============================================================================
418 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
419 Handle(GEOM_Object) thePnt2,
420 Handle(GEOM_Object) thePnt3)
424 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
426 //Add a new Circle Arc object
427 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
429 //Add a new Circle Arc function
430 Handle(GEOM_Function) aFunction =
431 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
433 if (aFunction.IsNull()) return NULL;
435 //Check if the function is set correctly
436 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
437 GEOMImpl_IArc aCI (aFunction);
439 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
440 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
441 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
444 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
446 aCI.SetPoint1(aRefPnt1);
447 aCI.SetPoint2(aRefPnt2);
448 aCI.SetPoint3(aRefPnt3);
450 //Compute the Arc value
452 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
455 if (!GetSolver()->ComputeFunction(aFunction)) {
456 SetErrorCode("Arc driver failed");
460 catch (Standard_Failure) {
461 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
462 SetErrorCode(aFail->GetMessageString());
466 //Make a Python command
467 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
468 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
474 //=============================================================================
478 //=============================================================================
479 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
480 Handle(GEOM_Object) thePnt2,
481 Handle(GEOM_Object) thePnt3,
485 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
487 //Add a new Circle Arc object
488 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
490 //Add a new Circle Arc function
491 Handle(GEOM_Function) aFunction =
492 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
493 if (aFunction.IsNull()) return NULL;
495 //Check if the function is set correctly
496 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
498 GEOMImpl_IArc aCI (aFunction);
500 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
501 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
502 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
504 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
506 aCI.SetPoint1(aRefPnt1);
507 aCI.SetPoint2(aRefPnt2);
508 aCI.SetPoint3(aRefPnt3);
509 aCI.SetSense(theSense);
511 //Compute the Arc value
513 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
516 if (!GetSolver()->ComputeFunction(aFunction)) {
517 SetErrorCode("Arc driver failed");
521 catch (Standard_Failure) {
522 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
523 SetErrorCode(aFail->GetMessageString());
526 //Make a Python command
527 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
528 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
534 //=============================================================================
538 //=============================================================================
539 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
540 Handle(GEOM_Object) thePnt2,
541 Handle(GEOM_Object) thePnt3)
545 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
547 //Add a new Circle Arc object
548 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
550 //Add a new Circle Arc function
551 Handle(GEOM_Function) aFunction =
552 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
554 if (aFunction.IsNull()) return NULL;
556 //Check if the function is set correctly
557 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
558 GEOMImpl_IArc aCI (aFunction);
560 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
561 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
562 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
565 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
567 aCI.SetPoint1(aRefPnt1);
568 aCI.SetPoint2(aRefPnt2);
569 aCI.SetPoint3(aRefPnt3);
571 //Compute the Arc value
573 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
576 if (!GetSolver()->ComputeFunction(aFunction)) {
577 SetErrorCode("Arc driver failed");
581 catch (Standard_Failure) {
582 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
583 SetErrorCode(aFail->GetMessageString());
587 //Make a Python command
588 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
589 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
595 //=============================================================================
599 //=============================================================================
600 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
601 (std::list<Handle(GEOM_Object)> thePoints)
605 //Add a new Spline object
606 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
608 //Add a new Spline function for creation a bezier curve relatively to points set
609 Handle(GEOM_Function) aFunction =
610 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
611 if (aFunction.IsNull()) return NULL;
613 //Check if the function is set correctly
614 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
616 GEOMImpl_ISpline aCI (aFunction);
618 int aLen = thePoints.size();
622 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
623 for (; it != thePoints.end(); it++, ind++) {
624 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
626 if (aRefPnt.IsNull()) return NULL;
628 aCI.SetPoint(ind, aRefPnt);
631 //Compute the Spline value
633 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
636 if (!GetSolver()->ComputeFunction(aFunction)) {
637 SetErrorCode("Spline driver failed");
641 catch (Standard_Failure) {
642 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
643 SetErrorCode(aFail->GetMessageString());
647 //Make a Python command
648 GEOM::TPythonDump pd (aFunction);
649 pd << aSpline << " = geompy.MakeBezier([";
651 it = thePoints.begin();
653 while (it != thePoints.end()) {
654 pd << ", " << (*it++);
662 //=============================================================================
664 * MakeSplineInterpolation
666 //=============================================================================
667 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
668 (std::list<Handle(GEOM_Object)> thePoints,
673 //Add a new Spline object
674 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
676 //Add a new Spline function for creation a bezier curve relatively to points set
677 Handle(GEOM_Function) aFunction =
678 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
679 if (aFunction.IsNull()) return NULL;
681 //Check if the function is set correctly
682 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
684 GEOMImpl_ISpline aCI (aFunction);
686 int aLen = thePoints.size();
690 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
691 for (; it != thePoints.end(); it++, ind++) {
692 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
694 if (aRefPnt.IsNull()) return NULL;
696 aCI.SetPoint(ind, aRefPnt);
699 aCI.SetIsClosed(theIsClosed);
701 //Compute the Spline value
703 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
706 if (!GetSolver()->ComputeFunction(aFunction)) {
707 SetErrorCode("Spline driver failed");
711 catch (Standard_Failure) {
712 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
713 SetErrorCode(aFail->GetMessageString());
717 //Make a Python command
718 GEOM::TPythonDump pd (aFunction);
719 pd << aSpline << " = geompy.MakeInterpol([";
721 it = thePoints.begin();
723 while (it != thePoints.end()) {
724 pd << ", " << (*it++);
732 //=============================================================================
736 //=============================================================================
737 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
738 std::list<double> theWorkingPlane)
742 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
744 //Add a new Sketcher object
745 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
747 //Add a new Sketcher function
748 Handle(GEOM_Function) aFunction =
749 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
750 if (aFunction.IsNull()) return NULL;
752 //Check if the function is set correctly
753 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
755 GEOMImpl_ISketcher aCI (aFunction);
757 TCollection_AsciiString aCommand((char*) theCommand);
758 aCI.SetCommand(aCommand);
761 std::list<double>::iterator it = theWorkingPlane.begin();
762 for (; it != theWorkingPlane.end(); it++, ind++)
763 aCI.SetWorkingPlane(ind, *it);
765 //Compute the Sketcher value
767 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
770 if (!GetSolver()->ComputeFunction(aFunction)) {
771 SetErrorCode("Sketcher driver failed");
775 catch (Standard_Failure) {
776 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
777 SetErrorCode(aFail->GetMessageString());
781 //Make a Python command
782 GEOM::TPythonDump pd (aFunction);
783 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
785 it = theWorkingPlane.begin();
787 while (it != theWorkingPlane.end()) {
788 pd << ", " << (*it++);
796 //=============================================================================
800 //=============================================================================
801 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
805 //Add a new Sketcher object
806 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
808 //Add a new Sketcher function
809 Handle(GEOM_Function) aFunction =
810 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
811 if (aFunction.IsNull()) return NULL;
813 //Check if the function is set correctly
814 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
816 GEOMImpl_I3DSketcher aCI (aFunction);
819 std::list<double>::iterator it = theCoordinates.begin();
820 for (; it != theCoordinates.end(); it++)
823 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
825 it = theCoordinates.begin();
827 for (; it != theCoordinates.end(); it++, ind++)
828 aCoordsArray->SetValue(ind, *it);
830 aCI.SetCoordinates(aCoordsArray);
832 //Compute the Sketcher value
834 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
837 if (!GetSolver()->ComputeFunction(aFunction)) {
838 SetErrorCode("3D Sketcher driver failed");
842 catch (Standard_Failure) {
843 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
844 SetErrorCode(aFail->GetMessageString());
848 //Make a Python command
849 GEOM::TPythonDump pd (aFunction);
850 pd << a3DSketcher << " = geompy.Make3DSketcher([";
852 it = theCoordinates.begin();
854 while (it != theCoordinates.end()) {
855 pd << ", " << (*it++);
863 //=============================================================================
865 * MakeSketcherOnPlane
867 //=============================================================================
868 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
869 (const char* theCommand,
870 Handle(GEOM_Object) theWorkingPlane)
874 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
876 //Add a new Sketcher object
877 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
879 //Add a new Sketcher function
880 Handle(GEOM_Function) aFunction =
881 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
882 if (aFunction.IsNull()) return NULL;
884 //Check if the function is set correctly
885 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
887 GEOMImpl_ISketcher aCI (aFunction);
889 TCollection_AsciiString aCommand((char*) theCommand);
890 aCI.SetCommand(aCommand);
892 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
893 if (aRefPlane.IsNull()) return NULL;
894 aCI.SetWorkingPlane( aRefPlane );
896 //Compute the Sketcher value
898 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
901 if (!GetSolver()->ComputeFunction(aFunction)) {
902 SetErrorCode("Sketcher driver failed");
906 catch (Standard_Failure) {
907 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
908 SetErrorCode(aFail->GetMessageString());
912 //Make a Python command
913 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
914 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";