1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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_IBasicOperations.hxx>
27 #include <Basics_OCCTVersion.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_PointDriver.hxx>
42 #include <GEOMImpl_VectorDriver.hxx>
43 #include <GEOMImpl_LineDriver.hxx>
44 #include <GEOMImpl_PlaneDriver.hxx>
45 #include <GEOMImpl_MarkerDriver.hxx>
47 #include <GEOMImpl_IPoint.hxx>
48 #include <GEOMImpl_IVector.hxx>
49 #include <GEOMImpl_ILine.hxx>
50 #include <GEOMImpl_IPlane.hxx>
51 #include <GEOMImpl_IMarker.hxx>
53 #include <GEOMImpl_Types.hxx>
55 #include <Standard_Failure.hxx>
56 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
58 //=============================================================================
62 //=============================================================================
63 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
64 : GEOM_IOperations(theEngine, theDocID)
66 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
69 //=============================================================================
73 //=============================================================================
74 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
76 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
80 //=============================================================================
84 //=============================================================================
85 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
86 (double theX, double theY, double theZ)
90 //Add a new Point object
91 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
93 //Add a new Point function with XYZ parameters
94 Handle(GEOM_Function) aFunction =
95 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
96 if (aFunction.IsNull()) return NULL;
98 //Check if the function is set correctly
99 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
101 GEOMImpl_IPoint aPI(aFunction);
107 //Compute the point value
110 if (!GetSolver()->ComputeFunction(aFunction)) {
111 SetErrorCode("Point driver failed");
115 catch (Standard_Failure) {
116 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
117 SetErrorCode(aFail->GetMessageString());
121 //Make a Python command
122 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
123 << theX << ", " << theY << ", " << theZ << ")";
129 //=============================================================================
131 * MakePointWithReference
133 //=============================================================================
134 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
135 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
139 if (theReference.IsNull()) return NULL;
141 //Add a new Point object
142 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
144 //Add a new Point function for creation a point relativley another point
145 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
147 //Check if the function is set correctly
148 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
150 GEOMImpl_IPoint aPI(aFunction);
152 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
153 if (aRefFunction.IsNull()) return NULL;
155 aPI.SetRef(aRefFunction);
160 //Compute the point value
163 if (!GetSolver()->ComputeFunction(aFunction)) {
164 SetErrorCode("Point driver failed");
168 catch (Standard_Failure) {
169 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
170 SetErrorCode(aFail->GetMessageString());
174 //Make a Python command
175 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
176 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
182 //=============================================================================
186 //=============================================================================
187 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
188 (Handle(GEOM_Object) theGeomObj,
192 const PointLocation theLocation,
193 Handle(GEOM_Object) theRefPoint)
197 if (theGeomObj.IsNull()) return NULL;
199 //Add a new Point object
200 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
202 //Add a new Point function for creation a point relativley another point
203 int fType = POINT_CURVE_PAR;
204 switch( theLocation )
206 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
207 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
208 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
209 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
210 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
211 case PointOn_Face: fType = POINT_FACE_ANY; break;
214 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
216 //Check if the function is set correctly
217 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
219 GEOMImpl_IPoint aPI (aFunction);
221 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
222 if (aRefFunction.IsNull()) return NULL;
224 switch( theLocation )
226 case PointOn_CurveByParam:
227 aPI.SetCurve(aRefFunction);
228 aPI.SetParameter(theParam1);
230 case PointOn_CurveByLength:
231 aPI.SetCurve(aRefFunction);
232 aPI.SetLength(theParam1);
233 if (!theRefPoint.IsNull()) {
234 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
235 aPI.SetRef(aRefPoint);
238 case PointOn_CurveByCoord:
239 aPI.SetCurve(aRefFunction);
244 case PointOn_SurfaceByParam:
245 aPI.SetSurface(aRefFunction);
246 aPI.SetParameter(theParam1);
247 aPI.SetParameter2(theParam2);
249 case PointOn_SurfaceByCoord:
250 aPI.SetSurface(aRefFunction);
256 aPI.SetSurface(aRefFunction);
261 //Compute the point value
264 if (!GetSolver()->ComputeFunction(aFunction)) {
265 SetErrorCode("Point driver failed");
269 catch (Standard_Failure) {
270 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
271 SetErrorCode(aFail->GetMessageString());
275 //Make a Python command
276 switch( theLocation )
278 case PointOn_CurveByParam:
279 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
280 << theGeomObj << ", " << theParam1 << ")";
282 case PointOn_CurveByLength:
283 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
284 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
286 case PointOn_CurveByCoord:
287 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
288 << theGeomObj << ", " << theParam1
289 << ", " << theParam2 << ", " << theParam3 << ")";
291 case PointOn_SurfaceByParam:
292 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
293 << theGeomObj << ", " << theParam1
294 << ", " << theParam2 << ")";
296 case PointOn_SurfaceByCoord:
297 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
298 << theGeomObj << ", " << theParam1
299 << ", " << theParam2 << ", " << theParam3 << ")";
302 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
303 << theGeomObj << ")";
312 //=============================================================================
316 //=============================================================================
317 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
318 (Handle(GEOM_Object) theCurve, double theParameter)
320 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
323 //=============================================================================
325 * MakePointOnCurveByCoord
327 //=============================================================================
328 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
329 (Handle(GEOM_Object) theCurve,
334 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
337 //=============================================================================
339 * MakePointOnCurveByLength
341 //=============================================================================
342 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
343 (Handle(GEOM_Object) theCurve,
345 Handle(GEOM_Object) theStartPoint)
347 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
350 //=============================================================================
354 //=============================================================================
355 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
356 (Handle(GEOM_Object) theSurface,
357 double theUParameter,
358 double theVParameter)
360 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
363 //=============================================================================
365 * MakePointOnSurfaceByCoord
367 //=============================================================================
368 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
369 (Handle(GEOM_Object) theSurface,
374 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
377 //=============================================================================
381 //=============================================================================
382 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
384 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
387 //=============================================================================
389 * MakePointOnLinesIntersection
391 //=============================================================================
392 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
393 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
397 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
399 //Add a new Point object
400 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
402 //Add a new Point function for creation a point relativley another point
403 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
405 //Check if the function is set correctly
406 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
408 GEOMImpl_IPoint aPI (aFunction);
410 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
411 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
412 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
417 //Compute the point value
420 if (!GetSolver()->ComputeFunction(aFunction)) {
421 SetErrorCode("Point driver failed");
425 catch (Standard_Failure) {
426 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
427 SetErrorCode(aFail->GetMessageString());
431 //Make a Python command
432 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
433 << theLine1 << ", " << theLine2 << ")";
439 //=============================================================================
443 //=============================================================================
444 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
445 (const Handle(GEOM_Object)& theCurve, double theParameter)
449 if (theCurve.IsNull()) return NULL;
451 //Add a new Vector object
452 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
454 //Add a new Point function for creation a point relativley another point
455 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
457 //Check if the function is set correctly
458 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
460 GEOMImpl_IVector aVI (aFunction);
462 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
463 if (aRefFunction.IsNull()) return NULL;
465 aVI.SetCurve(aRefFunction);
466 aVI.SetParameter(theParameter);
468 //Compute the vector value
471 if (!GetSolver()->ComputeFunction(aFunction)) {
472 SetErrorCode("Vector driver failed");
476 catch (Standard_Failure) {
477 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
478 SetErrorCode(aFail->GetMessageString());
482 //Make a Python command
483 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
484 << theCurve << ", " << theParameter << ")";
490 //=============================================================================
494 //=============================================================================
495 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
496 (double theDX, double theDY, double theDZ)
500 //Add a new Vector object
501 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
503 //Add a new Vector function with DXDYDZ parameters
504 Handle(GEOM_Function) aFunction =
505 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
506 if (aFunction.IsNull()) return NULL;
508 //Check if the function is set correctly
509 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
511 GEOMImpl_IVector aPI (aFunction);
517 //Compute the Vector value
520 if (!GetSolver()->ComputeFunction(aFunction)) {
521 SetErrorCode("Vector driver failed");
525 catch (Standard_Failure) {
526 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
527 SetErrorCode(aFail->GetMessageString());
531 //Make a Python command
532 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
533 << theDX << ", " << theDY << ", " << theDZ << ")";
539 //=============================================================================
543 //=============================================================================
544 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
545 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
549 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
551 //Add a new Vector object
552 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
554 //Add a new Vector function
555 Handle(GEOM_Function) aFunction =
556 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
558 //Check if the function is set correctly
559 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
561 GEOMImpl_IVector aPI (aFunction);
563 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
564 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
565 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
567 aPI.SetPoint1(aRef1);
568 aPI.SetPoint2(aRef2);
570 //Compute the Vector value
573 if (!GetSolver()->ComputeFunction(aFunction)) {
574 SetErrorCode("Vector driver failed");
578 catch (Standard_Failure) {
579 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
580 SetErrorCode(aFail->GetMessageString());
584 //Make a Python command
585 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
586 << thePnt1 << ", " << thePnt2 << ")";
593 //=============================================================================
597 //=============================================================================
598 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
599 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
603 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
605 //Add a new Line object
606 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
608 //Add a new Line function
609 Handle(GEOM_Function) aFunction =
610 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
612 //Check if the function is set correctly
613 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
615 GEOMImpl_ILine aPI (aFunction);
617 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
618 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
619 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
621 aPI.SetPoint1(aRef1);
622 aPI.SetPoint2(aRef2);
624 //Compute the Line value
627 if (!GetSolver()->ComputeFunction(aFunction)) {
628 SetErrorCode("Line driver failed");
632 catch (Standard_Failure) {
633 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
634 SetErrorCode(aFail->GetMessageString());
638 //Make a Python command
639 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
640 << thePnt << ", " << theDir << ")";
646 //=============================================================================
650 //=============================================================================
651 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
652 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
656 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
658 //Add a new Line object
659 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
661 //Add a new Line function
662 Handle(GEOM_Function) aFunction =
663 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
665 //Check if the function is set correctly
666 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
668 GEOMImpl_ILine aPI (aFunction);
670 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
671 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
672 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
674 aPI.SetPoint1(aRef1);
675 aPI.SetPoint2(aRef2);
677 //Compute the Line value
680 if (!GetSolver()->ComputeFunction(aFunction)) {
681 SetErrorCode("Line driver failed");
685 catch (Standard_Failure) {
686 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
687 SetErrorCode(aFail->GetMessageString());
691 //Make a Python command
692 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
693 << thePnt1 << ", " << thePnt2 << ")";
699 //=============================================================================
703 //=============================================================================
704 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
705 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
709 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
711 //Add a new Line object
712 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
714 //Add a new Line function
715 Handle(GEOM_Function) aFunction =
716 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
718 //Check if the function is set correctly
719 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
721 GEOMImpl_ILine aPI (aFunction);
723 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
724 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
725 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
730 //Compute the Line value
733 if (!GetSolver()->ComputeFunction(aFunction)) {
734 SetErrorCode("Line driver failed");
738 catch (Standard_Failure) {
739 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
740 SetErrorCode(aFail->GetMessageString());
744 //Make a Python command
745 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
746 << theFace1 << ", " << theFace2 << ")";
752 //=============================================================================
756 //=============================================================================
757 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
758 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
759 Handle(GEOM_Object) thePnt3, double theSize)
763 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
765 //Add a new Plane object
766 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
768 //Add a new Plane function
769 Handle(GEOM_Function) aFunction =
770 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
772 //Check if the function is set correctly
773 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
775 GEOMImpl_IPlane aPI (aFunction);
777 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
778 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
779 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
780 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
782 aPI.SetPoint1(aRef1);
783 aPI.SetPoint2(aRef2);
784 aPI.SetPoint3(aRef3);
785 aPI.SetSize(theSize);
787 //Compute the Plane value
790 if (!GetSolver()->ComputeFunction(aFunction)) {
791 SetErrorCode("Plane driver failed");
795 catch (Standard_Failure) {
796 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
797 SetErrorCode(aFail->GetMessageString());
801 //Make a Python command
802 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
803 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
809 //=============================================================================
813 //=============================================================================
814 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
815 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
820 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
822 //Add a new Plane object
823 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
825 //Add a new Plane function
826 Handle(GEOM_Function) aFunction =
827 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
829 //Check if the function is set correctly
830 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
832 GEOMImpl_IPlane aPI (aFunction);
834 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
835 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
836 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
838 aPI.SetPoint(aRefPnt);
839 aPI.SetVector(aRefVec);
840 aPI.SetSize(theSize);
842 //Compute the Plane value
845 if (!GetSolver()->ComputeFunction(aFunction)) {
846 SetErrorCode("Plane driver failed");
850 catch (Standard_Failure) {
851 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
852 SetErrorCode(aFail->GetMessageString());
856 //Make a Python command
857 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
858 << thePnt << ", " << theVec << ", " << theSize << ")";
864 //=============================================================================
868 //=============================================================================
869 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
870 (Handle(GEOM_Object) theFace, double theSize)
874 if (theFace.IsNull()) return NULL;
876 //Add a new Plane object
877 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
879 //Add a new Plane function
880 Handle(GEOM_Function) aFunction =
881 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
883 //Check if the function is set correctly
884 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
886 GEOMImpl_IPlane aPI (aFunction);
888 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
889 if (aRef.IsNull()) return NULL;
892 aPI.SetSize(theSize);
894 //Compute the Plane value
897 if (!GetSolver()->ComputeFunction(aFunction)) {
898 SetErrorCode("Plane 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) << aPlane << " = geompy.MakePlaneFace("
910 << theFace << ", " << theSize << ")";
916 //=============================================================================
920 //=============================================================================
921 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
922 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
927 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
929 //Add a new Plane object
930 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
932 //Add a new Plane function
933 Handle(GEOM_Function) aFunction =
934 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
936 //Check if the function is set correctly
937 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
939 GEOMImpl_IPlane aPI (aFunction);
941 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
942 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
943 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
945 aPI.SetVector1(aRefVec1);
946 aPI.SetVector2(aRefVec2);
947 aPI.SetSize(theSize);
949 //Compute the Plane value
952 if (!GetSolver()->ComputeFunction(aFunction)) {
953 SetErrorCode("Plane driver failed");
957 catch (Standard_Failure) {
958 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
959 SetErrorCode(aFail->GetMessageString());
963 //Make a Python command
964 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
965 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
971 //=============================================================================
975 //=============================================================================
976 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
977 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
981 //Add a new Plane object
982 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
984 //Add a new Plane function
985 Handle(GEOM_Function) aFunction =
986 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
988 //Check if the function is set correctly
989 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
991 GEOMImpl_IPlane aPI (aFunction);
993 if ( !theLCS.IsNull() ) {
994 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
998 aPI.SetSize(theSize);
999 aPI.SetOrientation(theOrientation);
1001 //Compute the Plane value
1004 if (!GetSolver()->ComputeFunction(aFunction)) {
1005 SetErrorCode("Plane driver failed");
1009 catch (Standard_Failure) {
1010 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1011 SetErrorCode(aFail->GetMessageString());
1015 //Make a Python command
1016 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1017 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1024 //=============================================================================
1028 //=============================================================================
1029 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1030 (double theOX, double theOY, double theOZ,
1031 double theXDX, double theXDY, double theXDZ,
1032 double theYDX, double theYDY, double theYDZ)
1036 //Add a new Marker object
1037 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1039 //Add a new Marker function
1040 Handle(GEOM_Function) aFunction =
1041 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1042 if (aFunction.IsNull()) return NULL;
1044 //Check if the function is set correctly
1045 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1047 GEOMImpl_IMarker aPI(aFunction);
1049 aPI.SetOrigin(theOX, theOY, theOZ);
1050 aPI.SetXDir(theXDX, theXDY, theXDZ);
1051 aPI.SetYDir(theYDX, theYDY, theYDZ);
1053 //Compute the marker value
1056 if (!GetSolver()->ComputeFunction(aFunction)) {
1057 SetErrorCode("Marker driver failed");
1061 catch (Standard_Failure) {
1062 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1063 SetErrorCode(aFail->GetMessageString());
1067 //Make a Python command
1068 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1069 << theOX << ", " << theOY << ", " << theOZ << ", "
1070 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1071 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1077 //=============================================================================
1079 * MakeMarkerFromShape
1081 //=============================================================================
1082 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1083 (const Handle(GEOM_Object)& theShape)
1087 //Add a new Marker object
1088 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1090 //Add a new Marker function
1091 Handle(GEOM_Function) aFunction =
1092 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1093 if (aFunction.IsNull()) return NULL;
1095 //Check if the function is set correctly
1096 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1098 GEOMImpl_IMarker aPI(aFunction);
1100 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1101 if (aRefShape.IsNull()) return NULL;
1103 aPI.SetShape(aRefShape);
1105 //Compute the marker value
1108 if (!GetSolver()->ComputeFunction(aFunction)) {
1109 SetErrorCode("Marker driver failed");
1113 catch (Standard_Failure) {
1114 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1115 SetErrorCode(aFail->GetMessageString());
1119 //Make a Python command
1120 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1126 //=============================================================================
1128 * MakeMarkerPntTwoVec
1130 //=============================================================================
1131 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1132 (const Handle(GEOM_Object)& theOrigin,
1133 const Handle(GEOM_Object)& theXVec,
1134 const Handle(GEOM_Object)& theYVec)
1138 //Add a new Marker object
1139 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1141 //Add a new Marker function
1142 Handle(GEOM_Function) aFunction =
1143 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1144 if (aFunction.IsNull()) return NULL;
1146 //Check if the function is set correctly
1147 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1149 GEOMImpl_IMarker aPI(aFunction);
1151 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1152 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1153 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1154 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1156 aPI.SetOrigin(aRefOrigin);
1157 aPI.SetXVec(aRefXVec);
1158 aPI.SetYVec(aRefYVec);
1160 //Compute the marker value
1163 if (!GetSolver()->ComputeFunction(aFunction)) {
1164 SetErrorCode("Marker driver failed");
1168 catch (Standard_Failure) {
1169 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1170 SetErrorCode(aFail->GetMessageString());
1174 //Make a Python command
1175 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1176 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1182 //=============================================================================
1184 * MakeTangentPlaneOnFace
1186 //=============================================================================
1188 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1195 if (theFace.IsNull()) return NULL;
1197 //Add a new Plane object
1198 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1200 //Add a new Plane function
1201 Handle(GEOM_Function) aFunction =
1202 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1204 //Check if the function is set correctly
1205 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1207 GEOMImpl_IPlane aPI (aFunction);
1209 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1210 if (aRef.IsNull()) return NULL;
1213 aPI.SetSize(theSize);
1214 aPI.SetParameterU(theParamU);
1215 aPI.SetParameterV(theParamV);
1217 //Compute the Plane value
1220 if (!GetSolver()->ComputeFunction(aFunction)) {
1221 SetErrorCode("Plane driver failed");
1225 catch (Standard_Failure) {
1226 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1227 SetErrorCode(aFail->GetMessageString());
1231 //Make a Python command
1232 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1233 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";