1 // Copyright (C) 2007-2022 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 "utilities.h"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TDF_Tool.hxx>
34 #include <GEOM_Function.hxx>
35 #include <GEOM_PythonDump.hxx>
37 #include <GEOMImpl_PointDriver.hxx>
38 #include <GEOMImpl_VectorDriver.hxx>
39 #include <GEOMImpl_LineDriver.hxx>
40 #include <GEOMImpl_PlaneDriver.hxx>
41 #include <GEOMImpl_MarkerDriver.hxx>
43 #include <GEOMImpl_IPoint.hxx>
44 #include <GEOMImpl_IVector.hxx>
45 #include <GEOMImpl_ILine.hxx>
46 #include <GEOMImpl_IPlane.hxx>
47 #include <GEOMImpl_IMarker.hxx>
49 #include <GEOMImpl_Types.hxx>
51 #include <Standard_Failure.hxx>
52 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
54 //=============================================================================
58 //=============================================================================
59 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine)
60 : GEOM_IOperations(theEngine)
62 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
65 //=============================================================================
69 //=============================================================================
70 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
72 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
76 //=============================================================================
80 //=============================================================================
81 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
82 (double theX, double theY, double theZ)
86 //Add a new Point object
87 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
89 //Add a new Point function with XYZ parameters
90 Handle(GEOM_Function) aFunction =
91 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
92 if (aFunction.IsNull()) return NULL;
94 //Check if the function is set correctly
95 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
97 GEOMImpl_IPoint aPI(aFunction);
103 //Compute the point value
106 if (!GetSolver()->ComputeFunction(aFunction)) {
107 SetErrorCode("Point driver failed");
111 catch (Standard_Failure& aFail) {
112 SetErrorCode(aFail.GetMessageString());
116 //Make a Python command
117 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
118 << theX << ", " << theY << ", " << theZ << ")";
124 //=============================================================================
126 * MakePointWithReference
128 //=============================================================================
129 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
130 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
134 if (theReference.IsNull()) return NULL;
136 //Add a new Point object
137 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
139 //Add a new Point function for creation a point relativley another point
140 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
142 //Check if the function is set correctly
143 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
145 GEOMImpl_IPoint aPI(aFunction);
147 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
148 if (aRefFunction.IsNull()) return NULL;
150 aPI.SetRef(aRefFunction);
155 //Compute the point value
158 if (!GetSolver()->ComputeFunction(aFunction)) {
159 SetErrorCode("Point driver failed");
163 catch (Standard_Failure& aFail) {
164 SetErrorCode(aFail.GetMessageString());
168 //Make a Python command
169 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
170 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
176 //=============================================================================
180 //=============================================================================
181 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
182 (Handle(GEOM_Object) theGeomObj,
186 const PointLocation theLocation,
187 const bool takeOrientationIntoAccount,
188 Handle(GEOM_Object) theRefPoint)
192 if (theGeomObj.IsNull()) return NULL;
194 //Add a new Point object
195 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
197 //Add a new Point function for creation a point relativley another point
198 int fType = POINT_CURVE_PAR;
199 switch( theLocation )
201 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
202 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
203 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
204 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
205 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
206 case PointOn_Face: fType = POINT_FACE_ANY; break;
209 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
211 //Check if the function is set correctly
212 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
214 GEOMImpl_IPoint aPI (aFunction);
216 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
217 if (aRefFunction.IsNull()) return NULL;
219 switch( theLocation )
221 case PointOn_CurveByParam:
222 aPI.SetCurve(aRefFunction);
223 aPI.SetParameter(theParam1);
224 aPI.SetTakeOrientationIntoAccount(takeOrientationIntoAccount);
226 case PointOn_CurveByLength:
227 aPI.SetCurve(aRefFunction);
228 aPI.SetLength(theParam1);
229 if (!theRefPoint.IsNull()) {
230 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
231 aPI.SetRef(aRefPoint);
234 case PointOn_CurveByCoord:
235 aPI.SetCurve(aRefFunction);
240 case PointOn_SurfaceByParam:
241 aPI.SetSurface(aRefFunction);
242 aPI.SetParameter(theParam1);
243 aPI.SetParameter2(theParam2);
245 case PointOn_SurfaceByCoord:
246 aPI.SetSurface(aRefFunction);
252 aPI.SetSurface(aRefFunction);
257 //Compute the point value
260 if (!GetSolver()->ComputeFunction(aFunction)) {
261 SetErrorCode("Point driver failed");
265 catch (Standard_Failure& aFail) {
266 SetErrorCode(aFail.GetMessageString());
270 //Make a Python command
271 switch( theLocation )
273 case PointOn_CurveByParam:
274 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
275 << theGeomObj << ", " << theParam1 << ", "
276 << takeOrientationIntoAccount << ")";
278 case PointOn_CurveByLength:
279 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
280 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
282 case PointOn_CurveByCoord:
283 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
284 << theGeomObj << ", " << theParam1
285 << ", " << theParam2 << ", " << theParam3 << ")";
287 case PointOn_SurfaceByParam:
288 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
289 << theGeomObj << ", " << theParam1
290 << ", " << theParam2 << ")";
292 case PointOn_SurfaceByCoord:
293 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
294 << theGeomObj << ", " << theParam1
295 << ", " << theParam2 << ", " << theParam3 << ")";
298 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
299 << theGeomObj << ")";
308 //=============================================================================
312 //=============================================================================
313 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
314 (Handle(GEOM_Object) theCurve,
316 bool takeOrientationIntoAccount)
318 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
319 takeOrientationIntoAccount);
322 //=============================================================================
324 * MakePointOnCurveByCoord
326 //=============================================================================
327 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
328 (Handle(GEOM_Object) theCurve,
333 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
336 //=============================================================================
338 * MakePointOnCurveByLength
340 //=============================================================================
341 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
342 (Handle(GEOM_Object) theCurve,
344 Handle(GEOM_Object) theStartPoint)
346 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength,
347 false, 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(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& aFail) {
426 SetErrorCode(aFail.GetMessageString());
430 //Make a Python command
431 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
432 << theLine1 << ", " << theLine2 << ")";
438 //=============================================================================
442 //=============================================================================
443 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
444 (const Handle(GEOM_Object)& theCurve, double theParameter)
448 if (theCurve.IsNull()) return NULL;
450 //Add a new Vector object
451 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GEOM_VECTOR);
453 //Add a new Point function for creation a point relativley another point
454 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
456 //Check if the function is set correctly
457 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
459 GEOMImpl_IVector aVI (aFunction);
461 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
462 if (aRefFunction.IsNull()) return NULL;
464 aVI.SetCurve(aRefFunction);
465 aVI.SetParameter(theParameter);
467 //Compute the vector value
470 if (!GetSolver()->ComputeFunction(aFunction)) {
471 SetErrorCode("Vector driver failed");
475 catch (Standard_Failure& aFail) {
476 SetErrorCode(aFail.GetMessageString());
480 //Make a Python command
481 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
482 << theCurve << ", " << theParameter << ")";
488 //=============================================================================
492 //=============================================================================
493 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
494 (double theDX, double theDY, double theDZ)
498 //Add a new Vector object
499 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GEOM_VECTOR);
501 //Add a new Vector function with DXDYDZ parameters
502 Handle(GEOM_Function) aFunction =
503 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
504 if (aFunction.IsNull()) return NULL;
506 //Check if the function is set correctly
507 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
509 GEOMImpl_IVector aPI (aFunction);
515 //Compute the Vector value
518 if (!GetSolver()->ComputeFunction(aFunction)) {
519 SetErrorCode("Vector driver failed");
523 catch (Standard_Failure& aFail) {
524 SetErrorCode(aFail.GetMessageString());
528 //Make a Python command
529 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
530 << theDX << ", " << theDY << ", " << theDZ << ")";
536 //=============================================================================
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
542 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
546 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
548 //Add a new Vector object
549 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GEOM_VECTOR);
551 //Add a new Vector function
552 Handle(GEOM_Function) aFunction =
553 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
555 //Check if the function is set correctly
556 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
558 GEOMImpl_IVector aPI (aFunction);
560 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
561 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
562 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
564 aPI.SetPoint1(aRef1);
565 aPI.SetPoint2(aRef2);
567 //Compute the Vector value
570 if (!GetSolver()->ComputeFunction(aFunction)) {
571 SetErrorCode("Vector driver failed");
575 catch (Standard_Failure& aFail) {
576 SetErrorCode(aFail.GetMessageString());
580 //Make a Python command
581 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
582 << thePnt1 << ", " << thePnt2 << ")";
589 //=============================================================================
593 //=============================================================================
594 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
595 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
599 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
601 //Add a new Line object
602 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
604 //Add a new Line function
605 Handle(GEOM_Function) aFunction =
606 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
608 //Check if the function is set correctly
609 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
611 GEOMImpl_ILine aPI (aFunction);
613 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
614 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
615 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
617 aPI.SetPoint1(aRef1);
618 aPI.SetPoint2(aRef2);
620 //Compute the Line value
623 if (!GetSolver()->ComputeFunction(aFunction)) {
624 SetErrorCode("Line driver failed");
628 catch (Standard_Failure& aFail) {
629 SetErrorCode(aFail.GetMessageString());
633 //Make a Python command
634 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
635 << thePnt << ", " << theDir << ")";
641 //=============================================================================
645 //=============================================================================
646 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
647 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
651 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
653 //Add a new Line object
654 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
656 //Add a new Line function
657 Handle(GEOM_Function) aFunction =
658 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
660 //Check if the function is set correctly
661 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
663 GEOMImpl_ILine aPI (aFunction);
665 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
666 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
667 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
669 aPI.SetPoint1(aRef1);
670 aPI.SetPoint2(aRef2);
672 //Compute the Line value
675 if (!GetSolver()->ComputeFunction(aFunction)) {
676 SetErrorCode("Line driver failed");
680 catch (Standard_Failure& aFail) {
681 SetErrorCode(aFail.GetMessageString());
685 //Make a Python command
686 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
687 << thePnt1 << ", " << thePnt2 << ")";
693 //=============================================================================
697 //=============================================================================
698 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
699 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
703 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
705 //Add a new Line object
706 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
708 //Add a new Line function
709 Handle(GEOM_Function) aFunction =
710 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
712 //Check if the function is set correctly
713 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
715 GEOMImpl_ILine aPI (aFunction);
717 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
718 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
719 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
724 //Compute the Line value
727 if (!GetSolver()->ComputeFunction(aFunction)) {
728 SetErrorCode("Line driver failed");
732 catch (Standard_Failure& aFail) {
733 SetErrorCode(aFail.GetMessageString());
737 //Make a Python command
738 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
739 << theFace1 << ", " << theFace2 << ")";
745 //=============================================================================
749 //=============================================================================
750 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
751 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
752 Handle(GEOM_Object) thePnt3, double theSize)
756 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
758 //Add a new Plane object
759 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
761 //Add a new Plane function
762 Handle(GEOM_Function) aFunction =
763 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
765 //Check if the function is set correctly
766 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
768 GEOMImpl_IPlane aPI (aFunction);
770 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
771 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
772 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
773 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
775 aPI.SetPoint1(aRef1);
776 aPI.SetPoint2(aRef2);
777 aPI.SetPoint3(aRef3);
778 aPI.SetSize(theSize);
780 //Compute the Plane value
783 if (!GetSolver()->ComputeFunction(aFunction)) {
784 SetErrorCode("Plane driver failed");
788 catch (Standard_Failure& aFail) {
789 SetErrorCode(aFail.GetMessageString());
793 //Make a Python command
794 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
795 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
801 //=============================================================================
805 //=============================================================================
806 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
807 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
812 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
814 //Add a new Plane object
815 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
817 //Add a new Plane function
818 Handle(GEOM_Function) aFunction =
819 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
821 //Check if the function is set correctly
822 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
824 GEOMImpl_IPlane aPI (aFunction);
826 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
827 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
828 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
830 aPI.SetPoint(aRefPnt);
831 aPI.SetVector(aRefVec);
832 aPI.SetSize(theSize);
834 //Compute the Plane value
837 if (!GetSolver()->ComputeFunction(aFunction)) {
838 SetErrorCode("Plane driver failed");
842 catch (Standard_Failure& aFail) {
843 SetErrorCode(aFail.GetMessageString());
847 //Make a Python command
848 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
849 << thePnt << ", " << theVec << ", " << theSize << ")";
855 //=============================================================================
859 //=============================================================================
860 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
861 (Handle(GEOM_Object) theFace, double theSize)
865 if (theFace.IsNull()) return NULL;
867 //Add a new Plane object
868 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
870 //Add a new Plane function
871 Handle(GEOM_Function) aFunction =
872 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
874 //Check if the function is set correctly
875 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
877 GEOMImpl_IPlane aPI (aFunction);
879 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
880 if (aRef.IsNull()) return NULL;
883 aPI.SetSize(theSize);
885 //Compute the Plane value
888 if (!GetSolver()->ComputeFunction(aFunction)) {
889 SetErrorCode("Plane driver failed");
893 catch (Standard_Failure& aFail) {
894 SetErrorCode(aFail.GetMessageString());
898 //Make a Python command
899 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
900 << theFace << ", " << theSize << ")";
906 //=============================================================================
910 //=============================================================================
911 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
912 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
917 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
919 //Add a new Plane object
920 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
922 //Add a new Plane function
923 Handle(GEOM_Function) aFunction =
924 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
926 //Check if the function is set correctly
927 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
929 GEOMImpl_IPlane aPI (aFunction);
931 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
932 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
933 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
935 aPI.SetVector1(aRefVec1);
936 aPI.SetVector2(aRefVec2);
937 aPI.SetSize(theSize);
939 //Compute the Plane value
942 if (!GetSolver()->ComputeFunction(aFunction)) {
943 SetErrorCode("Plane driver failed");
947 catch (Standard_Failure& aFail) {
948 SetErrorCode(aFail.GetMessageString());
952 //Make a Python command
953 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
954 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
960 //=============================================================================
964 //=============================================================================
965 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
966 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
970 //Add a new Plane object
971 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
973 //Add a new Plane function
974 Handle(GEOM_Function) aFunction =
975 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
977 //Check if the function is set correctly
978 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
980 GEOMImpl_IPlane aPI (aFunction);
982 if ( !theLCS.IsNull() ) {
983 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
987 aPI.SetSize(theSize);
988 aPI.SetOrientation(theOrientation);
990 //Compute the Plane value
993 if (!GetSolver()->ComputeFunction(aFunction)) {
994 SetErrorCode("Plane driver failed");
998 catch (Standard_Failure& aFail) {
999 SetErrorCode(aFail.GetMessageString());
1003 //Make a Python command
1004 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1005 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1012 //=============================================================================
1016 //=============================================================================
1017 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1018 (double theOX, double theOY, double theOZ,
1019 double theXDX, double theXDY, double theXDZ,
1020 double theYDX, double theYDY, double theYDZ)
1024 //Add a new Marker object
1025 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1027 //Add a new Marker function
1028 Handle(GEOM_Function) aFunction =
1029 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1030 if (aFunction.IsNull()) return NULL;
1032 //Check if the function is set correctly
1033 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1035 GEOMImpl_IMarker aPI(aFunction);
1037 aPI.SetOrigin(theOX, theOY, theOZ);
1038 aPI.SetXDir(theXDX, theXDY, theXDZ);
1039 aPI.SetYDir(theYDX, theYDY, theYDZ);
1041 //Compute the marker value
1044 if (!GetSolver()->ComputeFunction(aFunction)) {
1045 SetErrorCode("Marker driver failed");
1049 catch (Standard_Failure& aFail) {
1050 SetErrorCode(aFail.GetMessageString());
1054 //Make a Python command
1055 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1056 << theOX << ", " << theOY << ", " << theOZ << ", "
1057 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1058 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1064 //=============================================================================
1066 * MakeMarkerFromShape
1068 //=============================================================================
1069 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1070 (const Handle(GEOM_Object)& theShape)
1074 //Add a new Marker object
1075 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1077 //Add a new Marker function
1078 Handle(GEOM_Function) aFunction =
1079 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1080 if (aFunction.IsNull()) return NULL;
1082 //Check if the function is set correctly
1083 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1085 GEOMImpl_IMarker aPI(aFunction);
1087 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1088 if (aRefShape.IsNull()) return NULL;
1090 aPI.SetShape(aRefShape);
1092 //Compute the marker value
1095 if (!GetSolver()->ComputeFunction(aFunction)) {
1096 SetErrorCode("Marker driver failed");
1100 catch (Standard_Failure& aFail) {
1101 SetErrorCode(aFail.GetMessageString());
1105 //Make a Python command
1106 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1112 //=============================================================================
1114 * MakeMarkerPntTwoVec
1116 //=============================================================================
1117 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1118 (const Handle(GEOM_Object)& theOrigin,
1119 const Handle(GEOM_Object)& theXVec,
1120 const Handle(GEOM_Object)& theYVec)
1124 //Add a new Marker object
1125 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1127 //Add a new Marker function
1128 Handle(GEOM_Function) aFunction =
1129 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1130 if (aFunction.IsNull()) return NULL;
1132 //Check if the function is set correctly
1133 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1135 GEOMImpl_IMarker aPI(aFunction);
1137 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1138 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1139 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1140 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1142 aPI.SetOrigin(aRefOrigin);
1143 aPI.SetXVec(aRefXVec);
1144 aPI.SetYVec(aRefYVec);
1146 //Compute the marker value
1149 if (!GetSolver()->ComputeFunction(aFunction)) {
1150 SetErrorCode("Marker driver failed");
1154 catch (Standard_Failure& aFail) {
1155 SetErrorCode(aFail.GetMessageString());
1159 //Make a Python command
1160 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1161 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1167 //=============================================================================
1169 * MakeTangentPlaneOnFace
1171 //=============================================================================
1173 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1180 if (theFace.IsNull()) return NULL;
1182 //Add a new Plane object
1183 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
1185 //Add a new Plane function
1186 Handle(GEOM_Function) aFunction =
1187 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1189 //Check if the function is set correctly
1190 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1192 GEOMImpl_IPlane aPI (aFunction);
1194 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1195 if (aRef.IsNull()) return NULL;
1198 aPI.SetSize(theSize);
1199 aPI.SetParameterU(theParamU);
1200 aPI.SetParameterV(theParamV);
1202 //Compute the Plane value
1205 if (!GetSolver()->ComputeFunction(aFunction)) {
1206 SetErrorCode("Plane driver failed");
1210 catch (Standard_Failure& aFail) {
1211 SetErrorCode(aFail.GetMessageString());
1215 //Make a Python command
1216 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1217 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";