1 // Copyright (C) 2007-2020 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"
29 #include <Utils_ExceptHandlers.hxx>
31 #include <TFunction_DriverTable.hxx>
32 #include <TFunction_Driver.hxx>
33 #include <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_PointDriver.hxx>
39 #include <GEOMImpl_VectorDriver.hxx>
40 #include <GEOMImpl_LineDriver.hxx>
41 #include <GEOMImpl_PlaneDriver.hxx>
42 #include <GEOMImpl_MarkerDriver.hxx>
44 #include <GEOMImpl_IPoint.hxx>
45 #include <GEOMImpl_IVector.hxx>
46 #include <GEOMImpl_ILine.hxx>
47 #include <GEOMImpl_IPlane.hxx>
48 #include <GEOMImpl_IMarker.hxx>
50 #include <GEOMImpl_Types.hxx>
52 #include <Standard_Failure.hxx>
53 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
55 //=============================================================================
59 //=============================================================================
60 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine)
61 : GEOM_IOperations(theEngine)
63 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
66 //=============================================================================
70 //=============================================================================
71 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
73 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
77 //=============================================================================
81 //=============================================================================
82 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
83 (double theX, double theY, double theZ)
87 //Add a new Point object
88 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
90 //Add a new Point function with XYZ parameters
91 Handle(GEOM_Function) aFunction =
92 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
93 if (aFunction.IsNull()) return NULL;
95 //Check if the function is set correctly
96 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
98 GEOMImpl_IPoint aPI(aFunction);
104 //Compute the point value
107 if (!GetSolver()->ComputeFunction(aFunction)) {
108 SetErrorCode("Point driver failed");
112 catch (Standard_Failure& aFail) {
113 SetErrorCode(aFail.GetMessageString());
117 //Make a Python command
118 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
119 << theX << ", " << theY << ", " << theZ << ")";
125 //=============================================================================
127 * MakePointWithReference
129 //=============================================================================
130 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
131 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
135 if (theReference.IsNull()) return NULL;
137 //Add a new Point object
138 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
140 //Add a new Point function for creation a point relativley another point
141 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
143 //Check if the function is set correctly
144 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
146 GEOMImpl_IPoint aPI(aFunction);
148 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
149 if (aRefFunction.IsNull()) return NULL;
151 aPI.SetRef(aRefFunction);
156 //Compute the point value
159 if (!GetSolver()->ComputeFunction(aFunction)) {
160 SetErrorCode("Point driver failed");
164 catch (Standard_Failure& aFail) {
165 SetErrorCode(aFail.GetMessageString());
169 //Make a Python command
170 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
171 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
177 //=============================================================================
181 //=============================================================================
182 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
183 (Handle(GEOM_Object) theGeomObj,
187 const PointLocation theLocation,
188 const bool takeOrientationIntoAccount,
189 Handle(GEOM_Object) theRefPoint)
193 if (theGeomObj.IsNull()) return NULL;
195 //Add a new Point object
196 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
198 //Add a new Point function for creation a point relativley another point
199 int fType = POINT_CURVE_PAR;
200 switch( theLocation )
202 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
203 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
204 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
205 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
206 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
207 case PointOn_Face: fType = POINT_FACE_ANY; break;
210 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
212 //Check if the function is set correctly
213 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
215 GEOMImpl_IPoint aPI (aFunction);
217 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
218 if (aRefFunction.IsNull()) return NULL;
220 switch( theLocation )
222 case PointOn_CurveByParam:
223 aPI.SetCurve(aRefFunction);
224 aPI.SetParameter(theParam1);
225 aPI.SetTakeOrientationIntoAccount(takeOrientationIntoAccount);
227 case PointOn_CurveByLength:
228 aPI.SetCurve(aRefFunction);
229 aPI.SetLength(theParam1);
230 if (!theRefPoint.IsNull()) {
231 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
232 aPI.SetRef(aRefPoint);
235 case PointOn_CurveByCoord:
236 aPI.SetCurve(aRefFunction);
241 case PointOn_SurfaceByParam:
242 aPI.SetSurface(aRefFunction);
243 aPI.SetParameter(theParam1);
244 aPI.SetParameter2(theParam2);
246 case PointOn_SurfaceByCoord:
247 aPI.SetSurface(aRefFunction);
253 aPI.SetSurface(aRefFunction);
258 //Compute the point value
261 if (!GetSolver()->ComputeFunction(aFunction)) {
262 SetErrorCode("Point driver failed");
266 catch (Standard_Failure& aFail) {
267 SetErrorCode(aFail.GetMessageString());
271 //Make a Python command
272 switch( theLocation )
274 case PointOn_CurveByParam:
275 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
276 << theGeomObj << ", " << theParam1 << ", "
277 << takeOrientationIntoAccount << ")";
279 case PointOn_CurveByLength:
280 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
281 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
283 case PointOn_CurveByCoord:
284 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
285 << theGeomObj << ", " << theParam1
286 << ", " << theParam2 << ", " << theParam3 << ")";
288 case PointOn_SurfaceByParam:
289 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
290 << theGeomObj << ", " << theParam1
291 << ", " << theParam2 << ")";
293 case PointOn_SurfaceByCoord:
294 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
295 << theGeomObj << ", " << theParam1
296 << ", " << theParam2 << ", " << theParam3 << ")";
299 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
300 << theGeomObj << ")";
309 //=============================================================================
313 //=============================================================================
314 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
315 (Handle(GEOM_Object) theCurve,
317 bool takeOrientationIntoAccount)
319 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
320 takeOrientationIntoAccount);
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,
348 false, theStartPoint);
351 //=============================================================================
355 //=============================================================================
356 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
357 (Handle(GEOM_Object) theSurface,
358 double theUParameter,
359 double theVParameter)
361 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
364 //=============================================================================
366 * MakePointOnSurfaceByCoord
368 //=============================================================================
369 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
370 (Handle(GEOM_Object) theSurface,
375 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
378 //=============================================================================
382 //=============================================================================
383 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
385 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
388 //=============================================================================
390 * MakePointOnLinesIntersection
392 //=============================================================================
393 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
394 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
398 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
400 //Add a new Point object
401 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
403 //Add a new Point function for creation a point relativley another point
404 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
406 //Check if the function is set correctly
407 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
409 GEOMImpl_IPoint aPI (aFunction);
411 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
412 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
413 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
418 //Compute the point value
421 if (!GetSolver()->ComputeFunction(aFunction)) {
422 SetErrorCode("Point driver failed");
426 catch (Standard_Failure& aFail) {
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(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& aFail) {
477 SetErrorCode(aFail.GetMessageString());
481 //Make a Python command
482 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
483 << theCurve << ", " << theParameter << ")";
489 //=============================================================================
493 //=============================================================================
494 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
495 (double theDX, double theDY, double theDZ)
499 //Add a new Vector object
500 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GEOM_VECTOR);
502 //Add a new Vector function with DXDYDZ parameters
503 Handle(GEOM_Function) aFunction =
504 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
505 if (aFunction.IsNull()) return NULL;
507 //Check if the function is set correctly
508 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
510 GEOMImpl_IVector aPI (aFunction);
516 //Compute the Vector value
519 if (!GetSolver()->ComputeFunction(aFunction)) {
520 SetErrorCode("Vector driver failed");
524 catch (Standard_Failure& aFail) {
525 SetErrorCode(aFail.GetMessageString());
529 //Make a Python command
530 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
531 << theDX << ", " << theDY << ", " << theDZ << ")";
537 //=============================================================================
541 //=============================================================================
542 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
543 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
547 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
549 //Add a new Vector object
550 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GEOM_VECTOR);
552 //Add a new Vector function
553 Handle(GEOM_Function) aFunction =
554 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
556 //Check if the function is set correctly
557 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
559 GEOMImpl_IVector aPI (aFunction);
561 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
562 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
563 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
565 aPI.SetPoint1(aRef1);
566 aPI.SetPoint2(aRef2);
568 //Compute the Vector value
571 if (!GetSolver()->ComputeFunction(aFunction)) {
572 SetErrorCode("Vector driver failed");
576 catch (Standard_Failure& aFail) {
577 SetErrorCode(aFail.GetMessageString());
581 //Make a Python command
582 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
583 << thePnt1 << ", " << thePnt2 << ")";
590 //=============================================================================
594 //=============================================================================
595 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
596 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
600 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
602 //Add a new Line object
603 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
605 //Add a new Line function
606 Handle(GEOM_Function) aFunction =
607 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
609 //Check if the function is set correctly
610 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
612 GEOMImpl_ILine aPI (aFunction);
614 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
615 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
616 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
618 aPI.SetPoint1(aRef1);
619 aPI.SetPoint2(aRef2);
621 //Compute the Line value
624 if (!GetSolver()->ComputeFunction(aFunction)) {
625 SetErrorCode("Line driver failed");
629 catch (Standard_Failure& aFail) {
630 SetErrorCode(aFail.GetMessageString());
634 //Make a Python command
635 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
636 << thePnt << ", " << theDir << ")";
642 //=============================================================================
646 //=============================================================================
647 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
648 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
652 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
654 //Add a new Line object
655 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
657 //Add a new Line function
658 Handle(GEOM_Function) aFunction =
659 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
661 //Check if the function is set correctly
662 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
664 GEOMImpl_ILine aPI (aFunction);
666 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
667 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
668 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
670 aPI.SetPoint1(aRef1);
671 aPI.SetPoint2(aRef2);
673 //Compute the Line value
676 if (!GetSolver()->ComputeFunction(aFunction)) {
677 SetErrorCode("Line driver failed");
681 catch (Standard_Failure& aFail) {
682 SetErrorCode(aFail.GetMessageString());
686 //Make a Python command
687 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
688 << thePnt1 << ", " << thePnt2 << ")";
694 //=============================================================================
698 //=============================================================================
699 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
700 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
704 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
706 //Add a new Line object
707 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
709 //Add a new Line function
710 Handle(GEOM_Function) aFunction =
711 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
713 //Check if the function is set correctly
714 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
716 GEOMImpl_ILine aPI (aFunction);
718 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
719 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
720 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
725 //Compute the Line value
728 if (!GetSolver()->ComputeFunction(aFunction)) {
729 SetErrorCode("Line driver failed");
733 catch (Standard_Failure& aFail) {
734 SetErrorCode(aFail.GetMessageString());
738 //Make a Python command
739 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
740 << theFace1 << ", " << theFace2 << ")";
746 //=============================================================================
750 //=============================================================================
751 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
752 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
753 Handle(GEOM_Object) thePnt3, double theSize)
757 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
759 //Add a new Plane object
760 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
762 //Add a new Plane function
763 Handle(GEOM_Function) aFunction =
764 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
766 //Check if the function is set correctly
767 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
769 GEOMImpl_IPlane aPI (aFunction);
771 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
772 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
773 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
774 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
776 aPI.SetPoint1(aRef1);
777 aPI.SetPoint2(aRef2);
778 aPI.SetPoint3(aRef3);
779 aPI.SetSize(theSize);
781 //Compute the Plane value
784 if (!GetSolver()->ComputeFunction(aFunction)) {
785 SetErrorCode("Plane driver failed");
789 catch (Standard_Failure& aFail) {
790 SetErrorCode(aFail.GetMessageString());
794 //Make a Python command
795 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
796 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
802 //=============================================================================
806 //=============================================================================
807 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
808 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
813 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
815 //Add a new Plane object
816 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
818 //Add a new Plane function
819 Handle(GEOM_Function) aFunction =
820 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
822 //Check if the function is set correctly
823 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
825 GEOMImpl_IPlane aPI (aFunction);
827 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
828 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
829 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
831 aPI.SetPoint(aRefPnt);
832 aPI.SetVector(aRefVec);
833 aPI.SetSize(theSize);
835 //Compute the Plane value
838 if (!GetSolver()->ComputeFunction(aFunction)) {
839 SetErrorCode("Plane driver failed");
843 catch (Standard_Failure& aFail) {
844 SetErrorCode(aFail.GetMessageString());
848 //Make a Python command
849 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
850 << thePnt << ", " << theVec << ", " << theSize << ")";
856 //=============================================================================
860 //=============================================================================
861 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
862 (Handle(GEOM_Object) theFace, double theSize)
866 if (theFace.IsNull()) return NULL;
868 //Add a new Plane object
869 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
871 //Add a new Plane function
872 Handle(GEOM_Function) aFunction =
873 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
875 //Check if the function is set correctly
876 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
878 GEOMImpl_IPlane aPI (aFunction);
880 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
881 if (aRef.IsNull()) return NULL;
884 aPI.SetSize(theSize);
886 //Compute the Plane value
889 if (!GetSolver()->ComputeFunction(aFunction)) {
890 SetErrorCode("Plane driver failed");
894 catch (Standard_Failure& aFail) {
895 SetErrorCode(aFail.GetMessageString());
899 //Make a Python command
900 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
901 << theFace << ", " << theSize << ")";
907 //=============================================================================
911 //=============================================================================
912 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
913 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
918 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
920 //Add a new Plane object
921 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
923 //Add a new Plane function
924 Handle(GEOM_Function) aFunction =
925 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
927 //Check if the function is set correctly
928 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
930 GEOMImpl_IPlane aPI (aFunction);
932 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
933 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
934 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
936 aPI.SetVector1(aRefVec1);
937 aPI.SetVector2(aRefVec2);
938 aPI.SetSize(theSize);
940 //Compute the Plane value
943 if (!GetSolver()->ComputeFunction(aFunction)) {
944 SetErrorCode("Plane driver failed");
948 catch (Standard_Failure& aFail) {
949 SetErrorCode(aFail.GetMessageString());
953 //Make a Python command
954 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
955 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
961 //=============================================================================
965 //=============================================================================
966 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
967 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
971 //Add a new Plane object
972 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
974 //Add a new Plane function
975 Handle(GEOM_Function) aFunction =
976 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
978 //Check if the function is set correctly
979 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
981 GEOMImpl_IPlane aPI (aFunction);
983 if ( !theLCS.IsNull() ) {
984 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
988 aPI.SetSize(theSize);
989 aPI.SetOrientation(theOrientation);
991 //Compute the Plane value
994 if (!GetSolver()->ComputeFunction(aFunction)) {
995 SetErrorCode("Plane driver failed");
999 catch (Standard_Failure& aFail) {
1000 SetErrorCode(aFail.GetMessageString());
1004 //Make a Python command
1005 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1006 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1013 //=============================================================================
1017 //=============================================================================
1018 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1019 (double theOX, double theOY, double theOZ,
1020 double theXDX, double theXDY, double theXDZ,
1021 double theYDX, double theYDY, double theYDZ)
1025 //Add a new Marker object
1026 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1028 //Add a new Marker function
1029 Handle(GEOM_Function) aFunction =
1030 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1031 if (aFunction.IsNull()) return NULL;
1033 //Check if the function is set correctly
1034 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1036 GEOMImpl_IMarker aPI(aFunction);
1038 aPI.SetOrigin(theOX, theOY, theOZ);
1039 aPI.SetXDir(theXDX, theXDY, theXDZ);
1040 aPI.SetYDir(theYDX, theYDY, theYDZ);
1042 //Compute the marker value
1045 if (!GetSolver()->ComputeFunction(aFunction)) {
1046 SetErrorCode("Marker driver failed");
1050 catch (Standard_Failure& aFail) {
1051 SetErrorCode(aFail.GetMessageString());
1055 //Make a Python command
1056 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1057 << theOX << ", " << theOY << ", " << theOZ << ", "
1058 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1059 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1065 //=============================================================================
1067 * MakeMarkerFromShape
1069 //=============================================================================
1070 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1071 (const Handle(GEOM_Object)& theShape)
1075 //Add a new Marker object
1076 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1078 //Add a new Marker function
1079 Handle(GEOM_Function) aFunction =
1080 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1081 if (aFunction.IsNull()) return NULL;
1083 //Check if the function is set correctly
1084 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1086 GEOMImpl_IMarker aPI(aFunction);
1088 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1089 if (aRefShape.IsNull()) return NULL;
1091 aPI.SetShape(aRefShape);
1093 //Compute the marker value
1096 if (!GetSolver()->ComputeFunction(aFunction)) {
1097 SetErrorCode("Marker driver failed");
1101 catch (Standard_Failure& aFail) {
1102 SetErrorCode(aFail.GetMessageString());
1106 //Make a Python command
1107 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1113 //=============================================================================
1115 * MakeMarkerPntTwoVec
1117 //=============================================================================
1118 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1119 (const Handle(GEOM_Object)& theOrigin,
1120 const Handle(GEOM_Object)& theXVec,
1121 const Handle(GEOM_Object)& theYVec)
1125 //Add a new Marker object
1126 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1128 //Add a new Marker function
1129 Handle(GEOM_Function) aFunction =
1130 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1131 if (aFunction.IsNull()) return NULL;
1133 //Check if the function is set correctly
1134 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1136 GEOMImpl_IMarker aPI(aFunction);
1138 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1139 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1140 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1141 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1143 aPI.SetOrigin(aRefOrigin);
1144 aPI.SetXVec(aRefXVec);
1145 aPI.SetYVec(aRefYVec);
1147 //Compute the marker value
1150 if (!GetSolver()->ComputeFunction(aFunction)) {
1151 SetErrorCode("Marker driver failed");
1155 catch (Standard_Failure& aFail) {
1156 SetErrorCode(aFail.GetMessageString());
1160 //Make a Python command
1161 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1162 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1168 //=============================================================================
1170 * MakeTangentPlaneOnFace
1172 //=============================================================================
1174 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1181 if (theFace.IsNull()) return NULL;
1183 //Add a new Plane object
1184 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
1186 //Add a new Plane function
1187 Handle(GEOM_Function) aFunction =
1188 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1190 //Check if the function is set correctly
1191 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1193 GEOMImpl_IPlane aPI (aFunction);
1195 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1196 if (aRef.IsNull()) return NULL;
1199 aPI.SetSize(theSize);
1200 aPI.SetParameterU(theParamU);
1201 aPI.SetParameterV(theParamV);
1203 //Compute the Plane value
1206 if (!GetSolver()->ComputeFunction(aFunction)) {
1207 SetErrorCode("Plane driver failed");
1211 catch (Standard_Failure& aFail) {
1212 SetErrorCode(aFail.GetMessageString());
1216 //Make a Python command
1217 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1218 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";