1 // Copyright (C) 2007-2023 CEA, EDF, 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,
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);
254 aPI.SetNumberOfPoints(theNumberOfPnts);
259 //Compute the point value
262 if (!GetSolver()->ComputeFunction(aFunction)) {
263 SetErrorCode("Point driver failed");
267 catch (Standard_Failure& aFail) {
268 SetErrorCode(aFail.GetMessageString());
272 //Make a Python command
273 switch( theLocation )
275 case PointOn_CurveByParam:
276 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
277 << theGeomObj << ", " << theParam1 << ", "
278 << takeOrientationIntoAccount << ")";
280 case PointOn_CurveByLength:
281 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
282 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
284 case PointOn_CurveByCoord:
285 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
286 << theGeomObj << ", " << theParam1
287 << ", " << theParam2 << ", " << theParam3 << ")";
289 case PointOn_SurfaceByParam:
290 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
291 << theGeomObj << ", " << theParam1
292 << ", " << theParam2 << ")";
294 case PointOn_SurfaceByCoord:
295 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
296 << theGeomObj << ", " << theParam1
297 << ", " << theParam2 << ", " << theParam3 << ")";
300 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
301 << theGeomObj << ", " << theNumberOfPnts << ")";
310 //=============================================================================
314 //=============================================================================
315 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
316 (Handle(GEOM_Object) theCurve,
318 bool takeOrientationIntoAccount)
320 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
321 1, takeOrientationIntoAccount);
324 //=============================================================================
326 * MakePointOnCurveByCoord
328 //=============================================================================
329 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
330 (Handle(GEOM_Object) theCurve,
335 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
338 //=============================================================================
340 * MakePointOnCurveByLength
342 //=============================================================================
343 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
344 (Handle(GEOM_Object) theCurve,
346 Handle(GEOM_Object) theStartPoint)
348 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength,
349 1, false, theStartPoint);
352 //=============================================================================
356 //=============================================================================
357 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
358 (Handle(GEOM_Object) theSurface,
359 double theUParameter,
360 double theVParameter)
362 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
365 //=============================================================================
367 * MakePointOnSurfaceByCoord
369 //=============================================================================
370 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
371 (Handle(GEOM_Object) theSurface,
376 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
379 //=============================================================================
383 //=============================================================================
384 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace,
387 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face, theNumberOfPnts);
390 //=============================================================================
392 * MakePointOnLinesIntersection
394 //=============================================================================
395 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
396 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
400 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
402 //Add a new Point object
403 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GEOM_POINT);
405 //Add a new Point function for creation a point relativley another point
406 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
408 //Check if the function is set correctly
409 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
411 GEOMImpl_IPoint aPI (aFunction);
413 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
414 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
415 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
420 //Compute the point value
423 if (!GetSolver()->ComputeFunction(aFunction)) {
424 SetErrorCode("Point driver failed");
428 catch (Standard_Failure& aFail) {
429 SetErrorCode(aFail.GetMessageString());
433 //Make a Python command
434 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
435 << theLine1 << ", " << theLine2 << ")";
441 //=============================================================================
445 //=============================================================================
446 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
447 (const Handle(GEOM_Object)& theCurve, double theParameter)
451 if (theCurve.IsNull()) return NULL;
453 //Add a new Vector object
454 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GEOM_VECTOR);
456 //Add a new Point function for creation a point relativley another point
457 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
459 //Check if the function is set correctly
460 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
462 GEOMImpl_IVector aVI (aFunction);
464 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
465 if (aRefFunction.IsNull()) return NULL;
467 aVI.SetCurve(aRefFunction);
468 aVI.SetParameter(theParameter);
470 //Compute the vector value
473 if (!GetSolver()->ComputeFunction(aFunction)) {
474 SetErrorCode("Vector driver failed");
478 catch (Standard_Failure& aFail) {
479 SetErrorCode(aFail.GetMessageString());
483 //Make a Python command
484 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
485 << theCurve << ", " << theParameter << ")";
491 //=============================================================================
495 //=============================================================================
496 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
497 (double theDX, double theDY, double theDZ)
501 //Add a new Vector object
502 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GEOM_VECTOR);
504 //Add a new Vector function with DXDYDZ parameters
505 Handle(GEOM_Function) aFunction =
506 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
507 if (aFunction.IsNull()) return NULL;
509 //Check if the function is set correctly
510 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
512 GEOMImpl_IVector aPI (aFunction);
518 //Compute the Vector value
521 if (!GetSolver()->ComputeFunction(aFunction)) {
522 SetErrorCode("Vector driver failed");
526 catch (Standard_Failure& aFail) {
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(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& aFail) {
579 SetErrorCode(aFail.GetMessageString());
583 //Make a Python command
584 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
585 << thePnt1 << ", " << thePnt2 << ")";
592 //=============================================================================
596 //=============================================================================
597 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
598 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
602 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
604 //Add a new Line object
605 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
607 //Add a new Line function
608 Handle(GEOM_Function) aFunction =
609 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
611 //Check if the function is set correctly
612 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
614 GEOMImpl_ILine aPI (aFunction);
616 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
617 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
618 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
620 aPI.SetPoint1(aRef1);
621 aPI.SetPoint2(aRef2);
623 //Compute the Line value
626 if (!GetSolver()->ComputeFunction(aFunction)) {
627 SetErrorCode("Line driver failed");
631 catch (Standard_Failure& aFail) {
632 SetErrorCode(aFail.GetMessageString());
636 //Make a Python command
637 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
638 << thePnt << ", " << theDir << ")";
644 //=============================================================================
648 //=============================================================================
649 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
650 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
654 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
656 //Add a new Line object
657 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
659 //Add a new Line function
660 Handle(GEOM_Function) aFunction =
661 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
663 //Check if the function is set correctly
664 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
666 GEOMImpl_ILine aPI (aFunction);
668 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
669 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
670 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
672 aPI.SetPoint1(aRef1);
673 aPI.SetPoint2(aRef2);
675 //Compute the Line value
678 if (!GetSolver()->ComputeFunction(aFunction)) {
679 SetErrorCode("Line driver failed");
683 catch (Standard_Failure& aFail) {
684 SetErrorCode(aFail.GetMessageString());
688 //Make a Python command
689 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
690 << thePnt1 << ", " << thePnt2 << ")";
696 //=============================================================================
700 //=============================================================================
701 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
702 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
706 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
708 //Add a new Line object
709 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GEOM_LINE);
711 //Add a new Line function
712 Handle(GEOM_Function) aFunction =
713 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
715 //Check if the function is set correctly
716 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
718 GEOMImpl_ILine aPI (aFunction);
720 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
721 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
722 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
727 //Compute the Line value
730 if (!GetSolver()->ComputeFunction(aFunction)) {
731 SetErrorCode("Line driver failed");
735 catch (Standard_Failure& aFail) {
736 SetErrorCode(aFail.GetMessageString());
740 //Make a Python command
741 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
742 << theFace1 << ", " << theFace2 << ")";
748 //=============================================================================
752 //=============================================================================
753 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
754 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
755 Handle(GEOM_Object) thePnt3, double theSize)
759 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
761 //Add a new Plane object
762 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
764 //Add a new Plane function
765 Handle(GEOM_Function) aFunction =
766 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
768 //Check if the function is set correctly
769 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
771 GEOMImpl_IPlane aPI (aFunction);
773 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
774 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
775 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
776 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
778 aPI.SetPoint1(aRef1);
779 aPI.SetPoint2(aRef2);
780 aPI.SetPoint3(aRef3);
781 aPI.SetSize(theSize);
783 //Compute the Plane value
786 if (!GetSolver()->ComputeFunction(aFunction)) {
787 SetErrorCode("Plane driver failed");
791 catch (Standard_Failure& aFail) {
792 SetErrorCode(aFail.GetMessageString());
796 //Make a Python command
797 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
798 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
804 //=============================================================================
808 //=============================================================================
809 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
810 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
815 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
817 //Add a new Plane object
818 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
820 //Add a new Plane function
821 Handle(GEOM_Function) aFunction =
822 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
824 //Check if the function is set correctly
825 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
827 GEOMImpl_IPlane aPI (aFunction);
829 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
830 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
831 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
833 aPI.SetPoint(aRefPnt);
834 aPI.SetVector(aRefVec);
835 aPI.SetSize(theSize);
837 //Compute the Plane value
840 if (!GetSolver()->ComputeFunction(aFunction)) {
841 SetErrorCode("Plane driver failed");
845 catch (Standard_Failure& aFail) {
846 SetErrorCode(aFail.GetMessageString());
850 //Make a Python command
851 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
852 << thePnt << ", " << theVec << ", " << theSize << ")";
858 //=============================================================================
862 //=============================================================================
863 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
864 (Handle(GEOM_Object) theFace, double theSize)
868 if (theFace.IsNull()) return NULL;
870 //Add a new Plane object
871 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
873 //Add a new Plane function
874 Handle(GEOM_Function) aFunction =
875 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
877 //Check if the function is set correctly
878 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
880 GEOMImpl_IPlane aPI (aFunction);
882 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
883 if (aRef.IsNull()) return NULL;
886 aPI.SetSize(theSize);
888 //Compute the Plane value
891 if (!GetSolver()->ComputeFunction(aFunction)) {
892 SetErrorCode("Plane driver failed");
896 catch (Standard_Failure& aFail) {
897 SetErrorCode(aFail.GetMessageString());
901 //Make a Python command
902 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
903 << theFace << ", " << theSize << ")";
909 //=============================================================================
913 //=============================================================================
914 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
915 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
920 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
922 //Add a new Plane object
923 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
925 //Add a new Plane function
926 Handle(GEOM_Function) aFunction =
927 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
929 //Check if the function is set correctly
930 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
932 GEOMImpl_IPlane aPI (aFunction);
934 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
935 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
936 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
938 aPI.SetVector1(aRefVec1);
939 aPI.SetVector2(aRefVec2);
940 aPI.SetSize(theSize);
942 //Compute the Plane value
945 if (!GetSolver()->ComputeFunction(aFunction)) {
946 SetErrorCode("Plane driver failed");
950 catch (Standard_Failure& aFail) {
951 SetErrorCode(aFail.GetMessageString());
955 //Make a Python command
956 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
957 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
963 //=============================================================================
967 //=============================================================================
968 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
969 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
973 //Add a new Plane object
974 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
976 //Add a new Plane function
977 Handle(GEOM_Function) aFunction =
978 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
980 //Check if the function is set correctly
981 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
983 GEOMImpl_IPlane aPI (aFunction);
985 if ( !theLCS.IsNull() ) {
986 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
990 aPI.SetSize(theSize);
991 aPI.SetOrientation(theOrientation);
993 //Compute the Plane value
996 if (!GetSolver()->ComputeFunction(aFunction)) {
997 SetErrorCode("Plane driver failed");
1001 catch (Standard_Failure& aFail) {
1002 SetErrorCode(aFail.GetMessageString());
1006 //Make a Python command
1007 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1008 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1015 //=============================================================================
1019 //=============================================================================
1020 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1021 (double theOX, double theOY, double theOZ,
1022 double theXDX, double theXDY, double theXDZ,
1023 double theYDX, double theYDY, double theYDZ)
1027 //Add a new Marker object
1028 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1030 //Add a new Marker function
1031 Handle(GEOM_Function) aFunction =
1032 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1033 if (aFunction.IsNull()) return NULL;
1035 //Check if the function is set correctly
1036 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1038 GEOMImpl_IMarker aPI(aFunction);
1040 aPI.SetOrigin(theOX, theOY, theOZ);
1041 aPI.SetXDir(theXDX, theXDY, theXDZ);
1042 aPI.SetYDir(theYDX, theYDY, theYDZ);
1044 //Compute the marker value
1047 if (!GetSolver()->ComputeFunction(aFunction)) {
1048 SetErrorCode("Marker driver failed");
1052 catch (Standard_Failure& aFail) {
1053 SetErrorCode(aFail.GetMessageString());
1057 //Make a Python command
1058 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1059 << theOX << ", " << theOY << ", " << theOZ << ", "
1060 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1061 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1067 //=============================================================================
1069 * MakeMarkerFromShape
1071 //=============================================================================
1072 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1073 (const Handle(GEOM_Object)& theShape)
1077 //Add a new Marker object
1078 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1080 //Add a new Marker function
1081 Handle(GEOM_Function) aFunction =
1082 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1083 if (aFunction.IsNull()) return NULL;
1085 //Check if the function is set correctly
1086 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1088 GEOMImpl_IMarker aPI(aFunction);
1090 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1091 if (aRefShape.IsNull()) return NULL;
1093 aPI.SetShape(aRefShape);
1095 //Compute the marker value
1098 if (!GetSolver()->ComputeFunction(aFunction)) {
1099 SetErrorCode("Marker driver failed");
1103 catch (Standard_Failure& aFail) {
1104 SetErrorCode(aFail.GetMessageString());
1108 //Make a Python command
1109 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1115 //=============================================================================
1117 * MakeMarkerPntTwoVec
1119 //=============================================================================
1120 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1121 (const Handle(GEOM_Object)& theOrigin,
1122 const Handle(GEOM_Object)& theXVec,
1123 const Handle(GEOM_Object)& theYVec)
1127 //Add a new Marker object
1128 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GEOM_MARKER);
1130 //Add a new Marker function
1131 Handle(GEOM_Function) aFunction =
1132 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1133 if (aFunction.IsNull()) return NULL;
1135 //Check if the function is set correctly
1136 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1138 GEOMImpl_IMarker aPI(aFunction);
1140 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1141 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1142 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1143 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1145 aPI.SetOrigin(aRefOrigin);
1146 aPI.SetXVec(aRefXVec);
1147 aPI.SetYVec(aRefYVec);
1149 //Compute the marker value
1152 if (!GetSolver()->ComputeFunction(aFunction)) {
1153 SetErrorCode("Marker driver failed");
1157 catch (Standard_Failure& aFail) {
1158 SetErrorCode(aFail.GetMessageString());
1162 //Make a Python command
1163 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1164 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1170 //=============================================================================
1172 * MakeTangentPlaneOnFace
1174 //=============================================================================
1176 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1183 if (theFace.IsNull()) return NULL;
1185 //Add a new Plane object
1186 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GEOM_PLANE);
1188 //Add a new Plane function
1189 Handle(GEOM_Function) aFunction =
1190 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1192 //Check if the function is set correctly
1193 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1195 GEOMImpl_IPlane aPI (aFunction);
1197 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1198 if (aRef.IsNull()) return NULL;
1201 aPI.SetSize(theSize);
1202 aPI.SetParameterU(theParamU);
1203 aPI.SetParameterV(theParamV);
1205 //Compute the Plane value
1208 if (!GetSolver()->ComputeFunction(aFunction)) {
1209 SetErrorCode("Plane driver failed");
1213 catch (Standard_Failure& aFail) {
1214 SetErrorCode(aFail.GetMessageString());
1218 //Make a Python command
1219 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1220 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";