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
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::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1,
84 Handle(GEOM_Object) thePnt2,
85 Handle(GEOM_Object) thePnt3)
89 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
91 //Add a new Circle object
92 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
94 //Add a new Circle function for creation a circle relatively to three points
95 Handle(GEOM_Function) aFunction =
96 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT);
97 if (aFunction.IsNull()) return NULL;
99 //Check if the function is set correctly
100 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
102 GEOMImpl_ICircle aCI (aFunction);
104 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
105 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
106 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
108 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
110 aCI.SetPoint1(aRefPnt1);
111 aCI.SetPoint2(aRefPnt2);
112 aCI.SetPoint3(aRefPnt3);
114 //Compute the Circle value
116 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
119 if (!GetSolver()->ComputeFunction(aFunction)) {
120 SetErrorCode("Circle 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(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
132 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
138 //=============================================================================
140 * MakeCircleCenter2Pnt
142 //=============================================================================
143 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1,
144 Handle(GEOM_Object) thePnt2,
145 Handle(GEOM_Object) thePnt3)
149 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
151 //Add a new Circle object
152 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
154 //Add a new Circle function for creation a circle relatively to center and 2 points
155 Handle(GEOM_Function) aFunction =
156 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT);
157 if (aFunction.IsNull()) return NULL;
159 //Check if the function is set correctly
160 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
162 GEOMImpl_ICircle aCI (aFunction);
164 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
165 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
166 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
168 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
170 aCI.SetPoint1(aRefPnt1);
171 aCI.SetPoint2(aRefPnt2);
172 aCI.SetPoint3(aRefPnt3);
174 //Compute the Circle value
176 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
179 if (!GetSolver()->ComputeFunction(aFunction)) {
180 SetErrorCode("Circle driver failed");
184 catch (Standard_Failure) {
185 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
186 SetErrorCode(aFail->GetMessageString());
190 //Make a Python command
191 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleCenter2Pnt("
192 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
198 //=============================================================================
202 //=============================================================================
203 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
204 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
208 // Not set thePnt means origin of global CS,
209 // Not set theVec means Z axis of global CS
210 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
212 //Add a new Circle object
213 Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE);
215 //Add a new Circle function for creation a circle relatively to point and vector
216 Handle(GEOM_Function) aFunction =
217 aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R);
218 if (aFunction.IsNull()) return NULL;
220 //Check if the function is set correctly
221 if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL;
223 GEOMImpl_ICircle aCI (aFunction);
225 if (!thePnt.IsNull()) {
226 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
227 if (aRefPnt.IsNull()) return NULL;
228 aCI.SetCenter(aRefPnt);
231 if (!theVec.IsNull()) {
232 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
233 if (aRefVec.IsNull()) return NULL;
234 aCI.SetVector(aRefVec);
239 //Compute the Circle value
241 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
244 if (!GetSolver()->ComputeFunction(aFunction)) {
245 SetErrorCode("Circle driver failed");
249 catch (Standard_Failure) {
250 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
251 SetErrorCode(aFail->GetMessageString());
255 //Make a Python command
256 GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
257 << thePnt << ", " << theVec << ", " << theR << ")";
263 //=============================================================================
267 //=============================================================================
268 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
269 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
270 double theRMajor, double theRMinor,
271 Handle(GEOM_Object) theVecMaj)
275 // Not set thePnt means origin of global CS,
276 // Not set theVec means Z axis of global CS
277 // Not set theVecMaj means X axis of global CS
278 //if (thePnt.IsNull() || theVec.IsNull()) return NULL;
280 //Add a new Ellipse object
281 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE);
283 //Add a new Ellipse function
284 Handle(GEOM_Function) aFunction =
285 anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR);
286 if (aFunction.IsNull()) return NULL;
288 //Check if the function is set correctly
289 if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL;
291 GEOMImpl_IEllipse 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);
305 aCI.SetRMajor(theRMajor);
306 aCI.SetRMinor(theRMinor);
308 if (!theVecMaj.IsNull()) {
309 Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
310 if (aRefVecMaj.IsNull()) return NULL;
311 aCI.SetVectorMajor(aRefVecMaj);
314 //Compute the Ellipse value
316 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
319 if (!GetSolver()->ComputeFunction(aFunction)) {
320 SetErrorCode("Ellipse driver failed");
324 catch (Standard_Failure) {
325 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
326 SetErrorCode(aFail->GetMessageString());
330 //Make a Python command
331 if (!theVecMaj.IsNull()) {
332 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
333 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
334 << ", " << theVecMaj << ")";
337 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
338 << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
345 //=============================================================================
349 //=============================================================================
350 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1,
351 Handle(GEOM_Object) thePnt2,
352 Handle(GEOM_Object) thePnt3)
356 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
358 //Add a new Circle Arc object
359 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
361 //Add a new Circle Arc function
362 Handle(GEOM_Function) aFunction =
363 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT);
365 if (aFunction.IsNull()) return NULL;
367 //Check if the function is set correctly
368 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
369 GEOMImpl_IArc aCI (aFunction);
371 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
372 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
373 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
376 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
378 aCI.SetPoint1(aRefPnt1);
379 aCI.SetPoint2(aRefPnt2);
380 aCI.SetPoint3(aRefPnt3);
382 //Compute the Arc value
384 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
387 if (!GetSolver()->ComputeFunction(aFunction)) {
388 SetErrorCode("Arc driver failed");
392 catch (Standard_Failure) {
393 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
394 SetErrorCode(aFail->GetMessageString());
398 //Make a Python command
399 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
400 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
406 //=============================================================================
410 //=============================================================================
411 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1,
412 Handle(GEOM_Object) thePnt2,
413 Handle(GEOM_Object) thePnt3,
417 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
419 //Add a new Circle Arc object
420 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC);
422 //Add a new Circle Arc function
423 Handle(GEOM_Function) aFunction =
424 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER);
425 if (aFunction.IsNull()) return NULL;
427 //Check if the function is set correctly
428 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
430 GEOMImpl_IArc aCI (aFunction);
432 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
433 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
434 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
436 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
438 aCI.SetPoint1(aRefPnt1);
439 aCI.SetPoint2(aRefPnt2);
440 aCI.SetPoint3(aRefPnt3);
441 aCI.SetSense(theSense);
443 //Compute the Arc value
445 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
448 if (!GetSolver()->ComputeFunction(aFunction)) {
449 SetErrorCode("Arc driver failed");
453 catch (Standard_Failure) {
454 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
455 SetErrorCode(aFail->GetMessageString());
458 //Make a Python command
459 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcCenter("
460 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")";
466 //=============================================================================
470 //=============================================================================
471 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1,
472 Handle(GEOM_Object) thePnt2,
473 Handle(GEOM_Object) thePnt3)
477 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
479 //Add a new Circle Arc object
480 Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC);
482 //Add a new Circle Arc function
483 Handle(GEOM_Function) aFunction =
484 anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT);
486 if (aFunction.IsNull()) return NULL;
488 //Check if the function is set correctly
489 if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL;
490 GEOMImpl_IArc aCI (aFunction);
492 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
493 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
494 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
497 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
499 aCI.SetPoint1(aRefPnt1);
500 aCI.SetPoint2(aRefPnt2);
501 aCI.SetPoint3(aRefPnt3);
503 //Compute the Arc value
505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
508 if (!GetSolver()->ComputeFunction(aFunction)) {
509 SetErrorCode("Arc driver failed");
513 catch (Standard_Failure) {
514 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
515 SetErrorCode(aFail->GetMessageString());
519 //Make a Python command
520 GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse("
521 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
527 //=============================================================================
531 //=============================================================================
532 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(GEOM_Object)> thePoints,
537 //Add a new Polyline object
538 Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
540 //Add a new Polyline function for creation a polyline relatively to points set
541 Handle(GEOM_Function) aFunction =
542 aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
543 if (aFunction.IsNull()) return NULL;
545 //Check if the function is set correctly
546 if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
548 GEOMImpl_IPolyline aCI (aFunction);
550 int aLen = thePoints.size();
554 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
555 for (; it != thePoints.end(); it++, ind++) {
556 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
557 if (aRefPnt.IsNull()) {
558 SetErrorCode("NULL point for Polyline");
561 aCI.SetPoint(ind, aRefPnt);
564 aCI.SetIsClosed(theIsClosed);
566 //Compute the Polyline value
568 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
571 if (!GetSolver()->ComputeFunction(aFunction)) {
572 SetErrorCode("Polyline driver failed");
576 catch (Standard_Failure) {
577 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
578 SetErrorCode(aFail->GetMessageString());
582 //Make a Python command
583 GEOM::TPythonDump pd (aFunction);
584 pd << aPolyline << " = geompy.MakePolyline([";
586 it = thePoints.begin();
588 while (it != thePoints.end()) {
589 pd << ", " << (*it++);
591 pd << "], " << theIsClosed << ")";
597 //=============================================================================
601 //=============================================================================
602 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
603 (std::list<Handle(GEOM_Object)> thePoints,
608 //Add a new Spline object
609 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
611 //Add a new Spline function for creation a bezier curve relatively to points set
612 Handle(GEOM_Function) aFunction =
613 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
614 if (aFunction.IsNull()) return NULL;
616 //Check if the function is set correctly
617 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
619 GEOMImpl_ISpline aCI (aFunction);
621 int aLen = thePoints.size();
625 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
626 for (; it != thePoints.end(); it++, ind++) {
627 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
629 if (aRefPnt.IsNull()) return NULL;
631 aCI.SetPoint(ind, aRefPnt);
634 aCI.SetIsClosed(theIsClosed);
636 //Compute the Spline value
638 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
641 if (!GetSolver()->ComputeFunction(aFunction)) {
642 SetErrorCode("Spline driver failed");
646 catch (Standard_Failure) {
647 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
648 SetErrorCode(aFail->GetMessageString());
652 //Make a Python command
653 GEOM::TPythonDump pd (aFunction);
654 pd << aSpline << " = geompy.MakeBezier([";
656 it = thePoints.begin();
658 while (it != thePoints.end()) {
659 pd << ", " << (*it++);
661 pd << "], " << theIsClosed << ")";
667 //=============================================================================
669 * MakeSplineInterpolation
671 //=============================================================================
672 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
673 (std::list<Handle(GEOM_Object)> thePoints,
675 bool theDoReordering)
679 //Add a new Spline object
680 Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
682 //Add a new Spline function for creation a bezier curve relatively to points set
683 Handle(GEOM_Function) aFunction =
684 aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
685 if (aFunction.IsNull()) return NULL;
687 //Check if the function is set correctly
688 if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
690 GEOMImpl_ISpline aCI (aFunction);
692 int aLen = thePoints.size();
696 std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
697 for (; it != thePoints.end(); it++, ind++) {
698 Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction();
700 if (aRefPnt.IsNull()) return NULL;
702 aCI.SetPoint(ind, aRefPnt);
705 aCI.SetIsClosed(theIsClosed);
706 aCI.SetDoReordering(theDoReordering);
708 //Compute the Spline value
710 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
713 if (!GetSolver()->ComputeFunction(aFunction)) {
714 SetErrorCode("Spline driver failed");
718 catch (Standard_Failure) {
719 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
720 SetErrorCode(aFail->GetMessageString());
724 //Make a Python command
725 GEOM::TPythonDump pd (aFunction);
726 pd << aSpline << " = geompy.MakeInterpol([";
728 it = thePoints.begin();
730 while (it != thePoints.end()) {
731 pd << ", " << (*it++);
733 pd << "], " << theIsClosed << ", " << theDoReordering << ")";
739 //=============================================================================
743 //=============================================================================
744 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand,
745 std::list<double> theWorkingPlane)
749 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
751 //Add a new Sketcher object
752 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
754 //Add a new Sketcher function
755 Handle(GEOM_Function) aFunction =
756 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_NINE_DOUBLS);
757 if (aFunction.IsNull()) return NULL;
759 //Check if the function is set correctly
760 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
762 GEOMImpl_ISketcher aCI (aFunction);
764 TCollection_AsciiString aCommand((char*) theCommand);
765 aCI.SetCommand(aCommand);
768 std::list<double>::iterator it = theWorkingPlane.begin();
769 for (; it != theWorkingPlane.end(); it++, ind++)
770 aCI.SetWorkingPlane(ind, *it);
772 //Compute the Sketcher value
774 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
777 if (!GetSolver()->ComputeFunction(aFunction)) {
778 SetErrorCode("Sketcher driver failed");
782 catch (Standard_Failure) {
783 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
784 SetErrorCode(aFail->GetMessageString());
788 //Make a Python command
789 GEOM::TPythonDump pd (aFunction);
790 pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", [";
792 it = theWorkingPlane.begin();
794 while (it != theWorkingPlane.end()) {
795 pd << ", " << (*it++);
803 //=============================================================================
807 //=============================================================================
808 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
812 //Add a new Sketcher object
813 Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
815 //Add a new Sketcher function
816 Handle(GEOM_Function) aFunction =
817 a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
818 if (aFunction.IsNull()) return NULL;
820 //Check if the function is set correctly
821 if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
823 GEOMImpl_I3DSketcher aCI (aFunction);
826 std::list<double>::iterator it = theCoordinates.begin();
827 for (; it != theCoordinates.end(); it++)
830 Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
832 it = theCoordinates.begin();
834 for (; it != theCoordinates.end(); it++, ind++)
835 aCoordsArray->SetValue(ind, *it);
837 aCI.SetCoordinates(aCoordsArray);
839 //Compute the Sketcher value
841 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
844 if (!GetSolver()->ComputeFunction(aFunction)) {
845 SetErrorCode("3D Sketcher driver failed");
849 catch (Standard_Failure) {
850 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
851 SetErrorCode(aFail->GetMessageString());
855 //Make a Python command
856 GEOM::TPythonDump pd (aFunction);
857 pd << a3DSketcher << " = geompy.Make3DSketcher([";
859 it = theCoordinates.begin();
861 while (it != theCoordinates.end()) {
862 pd << ", " << (*it++);
870 //=============================================================================
872 * MakeSketcherOnPlane
874 //=============================================================================
875 Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
876 (const char* theCommand,
877 Handle(GEOM_Object) theWorkingPlane)
881 if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
883 //Add a new Sketcher object
884 Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
886 //Add a new Sketcher function
887 Handle(GEOM_Function) aFunction =
888 aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
889 if (aFunction.IsNull()) return NULL;
891 //Check if the function is set correctly
892 if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
894 GEOMImpl_ISketcher aCI (aFunction);
896 TCollection_AsciiString aCommand((char*) theCommand);
897 aCI.SetCommand(aCommand);
899 Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
900 if (aRefPlane.IsNull()) return NULL;
901 aCI.SetWorkingPlane( aRefPlane );
903 //Compute the Sketcher value
905 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
908 if (!GetSolver()->ComputeFunction(aFunction)) {
909 SetErrorCode("Sketcher driver failed");
913 catch (Standard_Failure) {
914 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
915 SetErrorCode(aFail->GetMessageString());
919 //Make a Python command
920 GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
921 << aCommand.ToCString() << "\", " << theWorkingPlane << " )";