1 // Copyright (C) 2007-2016 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, int theDocID)
61 : GEOM_IOperations(theEngine, theDocID)
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(GetDocID(), 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) {
113 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
114 SetErrorCode(aFail->GetMessageString());
118 //Make a Python command
119 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
120 << theX << ", " << theY << ", " << theZ << ")";
126 //=============================================================================
128 * MakePointWithReference
130 //=============================================================================
131 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
132 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
136 if (theReference.IsNull()) return NULL;
138 //Add a new Point object
139 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
141 //Add a new Point function for creation a point relativley another point
142 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
144 //Check if the function is set correctly
145 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
147 GEOMImpl_IPoint aPI(aFunction);
149 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
150 if (aRefFunction.IsNull()) return NULL;
152 aPI.SetRef(aRefFunction);
157 //Compute the point value
160 if (!GetSolver()->ComputeFunction(aFunction)) {
161 SetErrorCode("Point driver failed");
165 catch (Standard_Failure) {
166 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
167 SetErrorCode(aFail->GetMessageString());
171 //Make a Python command
172 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
173 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
179 //=============================================================================
183 //=============================================================================
184 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
185 (Handle(GEOM_Object) theGeomObj,
189 const PointLocation theLocation,
190 const bool takeOrientationIntoAccount,
191 Handle(GEOM_Object) theRefPoint)
195 if (theGeomObj.IsNull()) return NULL;
197 //Add a new Point object
198 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
200 //Add a new Point function for creation a point relativley another point
201 int fType = POINT_CURVE_PAR;
202 switch( theLocation )
204 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
205 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
206 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
207 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
208 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
209 case PointOn_Face: fType = POINT_FACE_ANY; break;
212 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
214 //Check if the function is set correctly
215 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
217 GEOMImpl_IPoint aPI (aFunction);
219 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
220 if (aRefFunction.IsNull()) return NULL;
222 switch( theLocation )
224 case PointOn_CurveByParam:
225 aPI.SetCurve(aRefFunction);
226 aPI.SetParameter(theParam1);
227 aPI.SetTakeOrientationIntoAccount(takeOrientationIntoAccount);
229 case PointOn_CurveByLength:
230 aPI.SetCurve(aRefFunction);
231 aPI.SetLength(theParam1);
232 if (!theRefPoint.IsNull()) {
233 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
234 aPI.SetRef(aRefPoint);
237 case PointOn_CurveByCoord:
238 aPI.SetCurve(aRefFunction);
243 case PointOn_SurfaceByParam:
244 aPI.SetSurface(aRefFunction);
245 aPI.SetParameter(theParam1);
246 aPI.SetParameter2(theParam2);
248 case PointOn_SurfaceByCoord:
249 aPI.SetSurface(aRefFunction);
255 aPI.SetSurface(aRefFunction);
260 //Compute the point value
263 if (!GetSolver()->ComputeFunction(aFunction)) {
264 SetErrorCode("Point driver failed");
268 catch (Standard_Failure) {
269 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
270 SetErrorCode(aFail->GetMessageString());
274 //Make a Python command
275 switch( theLocation )
277 case PointOn_CurveByParam:
278 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
279 << theGeomObj << ", " << theParam1 << ", "
280 << takeOrientationIntoAccount << ")";
282 case PointOn_CurveByLength:
283 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
284 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
286 case PointOn_CurveByCoord:
287 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
288 << theGeomObj << ", " << theParam1
289 << ", " << theParam2 << ", " << theParam3 << ")";
291 case PointOn_SurfaceByParam:
292 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
293 << theGeomObj << ", " << theParam1
294 << ", " << theParam2 << ")";
296 case PointOn_SurfaceByCoord:
297 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
298 << theGeomObj << ", " << theParam1
299 << ", " << theParam2 << ", " << theParam3 << ")";
302 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
303 << theGeomObj << ")";
312 //=============================================================================
316 //=============================================================================
317 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
318 (Handle(GEOM_Object) theCurve,
320 bool takeOrientationIntoAccount)
322 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
323 takeOrientationIntoAccount);
326 //=============================================================================
328 * MakePointOnCurveByCoord
330 //=============================================================================
331 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
332 (Handle(GEOM_Object) theCurve,
337 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
340 //=============================================================================
342 * MakePointOnCurveByLength
344 //=============================================================================
345 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
346 (Handle(GEOM_Object) theCurve,
348 Handle(GEOM_Object) theStartPoint)
350 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength,
351 false, theStartPoint);
354 //=============================================================================
358 //=============================================================================
359 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
360 (Handle(GEOM_Object) theSurface,
361 double theUParameter,
362 double theVParameter)
364 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
367 //=============================================================================
369 * MakePointOnSurfaceByCoord
371 //=============================================================================
372 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
373 (Handle(GEOM_Object) theSurface,
378 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
381 //=============================================================================
385 //=============================================================================
386 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
388 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
391 //=============================================================================
393 * MakePointOnLinesIntersection
395 //=============================================================================
396 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
397 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
401 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
403 //Add a new Point object
404 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
406 //Add a new Point function for creation a point relativley another point
407 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
409 //Check if the function is set correctly
410 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
412 GEOMImpl_IPoint aPI (aFunction);
414 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
415 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
416 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
421 //Compute the point value
424 if (!GetSolver()->ComputeFunction(aFunction)) {
425 SetErrorCode("Point driver failed");
429 catch (Standard_Failure) {
430 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
431 SetErrorCode(aFail->GetMessageString());
435 //Make a Python command
436 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
437 << theLine1 << ", " << theLine2 << ")";
443 //=============================================================================
447 //=============================================================================
448 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
449 (const Handle(GEOM_Object)& theCurve, double theParameter)
453 if (theCurve.IsNull()) return NULL;
455 //Add a new Vector object
456 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
458 //Add a new Point function for creation a point relativley another point
459 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
461 //Check if the function is set correctly
462 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
464 GEOMImpl_IVector aVI (aFunction);
466 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
467 if (aRefFunction.IsNull()) return NULL;
469 aVI.SetCurve(aRefFunction);
470 aVI.SetParameter(theParameter);
472 //Compute the vector value
475 if (!GetSolver()->ComputeFunction(aFunction)) {
476 SetErrorCode("Vector driver failed");
480 catch (Standard_Failure) {
481 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
482 SetErrorCode(aFail->GetMessageString());
486 //Make a Python command
487 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
488 << theCurve << ", " << theParameter << ")";
494 //=============================================================================
498 //=============================================================================
499 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
500 (double theDX, double theDY, double theDZ)
504 //Add a new Vector object
505 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
507 //Add a new Vector function with DXDYDZ parameters
508 Handle(GEOM_Function) aFunction =
509 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
510 if (aFunction.IsNull()) return NULL;
512 //Check if the function is set correctly
513 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
515 GEOMImpl_IVector aPI (aFunction);
521 //Compute the Vector value
524 if (!GetSolver()->ComputeFunction(aFunction)) {
525 SetErrorCode("Vector driver failed");
529 catch (Standard_Failure) {
530 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
531 SetErrorCode(aFail->GetMessageString());
535 //Make a Python command
536 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
537 << theDX << ", " << theDY << ", " << theDZ << ")";
543 //=============================================================================
547 //=============================================================================
548 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
549 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
553 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
555 //Add a new Vector object
556 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
558 //Add a new Vector function
559 Handle(GEOM_Function) aFunction =
560 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
562 //Check if the function is set correctly
563 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
565 GEOMImpl_IVector aPI (aFunction);
567 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
568 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
569 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
571 aPI.SetPoint1(aRef1);
572 aPI.SetPoint2(aRef2);
574 //Compute the Vector value
577 if (!GetSolver()->ComputeFunction(aFunction)) {
578 SetErrorCode("Vector driver failed");
582 catch (Standard_Failure) {
583 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
584 SetErrorCode(aFail->GetMessageString());
588 //Make a Python command
589 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
590 << thePnt1 << ", " << thePnt2 << ")";
597 //=============================================================================
601 //=============================================================================
602 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
603 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
607 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
609 //Add a new Line object
610 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
612 //Add a new Line function
613 Handle(GEOM_Function) aFunction =
614 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
616 //Check if the function is set correctly
617 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
619 GEOMImpl_ILine aPI (aFunction);
621 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
622 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
623 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
625 aPI.SetPoint1(aRef1);
626 aPI.SetPoint2(aRef2);
628 //Compute the Line value
631 if (!GetSolver()->ComputeFunction(aFunction)) {
632 SetErrorCode("Line driver failed");
636 catch (Standard_Failure) {
637 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
638 SetErrorCode(aFail->GetMessageString());
642 //Make a Python command
643 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
644 << thePnt << ", " << theDir << ")";
650 //=============================================================================
654 //=============================================================================
655 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
656 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
660 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
662 //Add a new Line object
663 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
665 //Add a new Line function
666 Handle(GEOM_Function) aFunction =
667 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
669 //Check if the function is set correctly
670 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
672 GEOMImpl_ILine aPI (aFunction);
674 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
675 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
676 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
678 aPI.SetPoint1(aRef1);
679 aPI.SetPoint2(aRef2);
681 //Compute the Line value
684 if (!GetSolver()->ComputeFunction(aFunction)) {
685 SetErrorCode("Line driver failed");
689 catch (Standard_Failure) {
690 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
691 SetErrorCode(aFail->GetMessageString());
695 //Make a Python command
696 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
697 << thePnt1 << ", " << thePnt2 << ")";
703 //=============================================================================
707 //=============================================================================
708 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
709 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
713 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
715 //Add a new Line object
716 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
718 //Add a new Line function
719 Handle(GEOM_Function) aFunction =
720 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
722 //Check if the function is set correctly
723 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
725 GEOMImpl_ILine aPI (aFunction);
727 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
728 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
729 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
734 //Compute the Line value
737 if (!GetSolver()->ComputeFunction(aFunction)) {
738 SetErrorCode("Line driver failed");
742 catch (Standard_Failure) {
743 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
744 SetErrorCode(aFail->GetMessageString());
748 //Make a Python command
749 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
750 << theFace1 << ", " << theFace2 << ")";
756 //=============================================================================
760 //=============================================================================
761 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
762 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
763 Handle(GEOM_Object) thePnt3, double theSize)
767 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
769 //Add a new Plane object
770 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
772 //Add a new Plane function
773 Handle(GEOM_Function) aFunction =
774 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
776 //Check if the function is set correctly
777 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
779 GEOMImpl_IPlane aPI (aFunction);
781 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
782 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
783 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
784 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
786 aPI.SetPoint1(aRef1);
787 aPI.SetPoint2(aRef2);
788 aPI.SetPoint3(aRef3);
789 aPI.SetSize(theSize);
791 //Compute the Plane value
794 if (!GetSolver()->ComputeFunction(aFunction)) {
795 SetErrorCode("Plane driver failed");
799 catch (Standard_Failure) {
800 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
801 SetErrorCode(aFail->GetMessageString());
805 //Make a Python command
806 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
807 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
813 //=============================================================================
817 //=============================================================================
818 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
819 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
824 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
826 //Add a new Plane object
827 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
829 //Add a new Plane function
830 Handle(GEOM_Function) aFunction =
831 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
833 //Check if the function is set correctly
834 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
836 GEOMImpl_IPlane aPI (aFunction);
838 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
839 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
840 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
842 aPI.SetPoint(aRefPnt);
843 aPI.SetVector(aRefVec);
844 aPI.SetSize(theSize);
846 //Compute the Plane value
849 if (!GetSolver()->ComputeFunction(aFunction)) {
850 SetErrorCode("Plane driver failed");
854 catch (Standard_Failure) {
855 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
856 SetErrorCode(aFail->GetMessageString());
860 //Make a Python command
861 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
862 << thePnt << ", " << theVec << ", " << theSize << ")";
868 //=============================================================================
872 //=============================================================================
873 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
874 (Handle(GEOM_Object) theFace, double theSize)
878 if (theFace.IsNull()) return NULL;
880 //Add a new Plane object
881 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
883 //Add a new Plane function
884 Handle(GEOM_Function) aFunction =
885 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
887 //Check if the function is set correctly
888 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
890 GEOMImpl_IPlane aPI (aFunction);
892 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
893 if (aRef.IsNull()) return NULL;
896 aPI.SetSize(theSize);
898 //Compute the Plane value
901 if (!GetSolver()->ComputeFunction(aFunction)) {
902 SetErrorCode("Plane driver failed");
906 catch (Standard_Failure) {
907 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
908 SetErrorCode(aFail->GetMessageString());
912 //Make a Python command
913 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
914 << theFace << ", " << theSize << ")";
920 //=============================================================================
924 //=============================================================================
925 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
926 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
931 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
933 //Add a new Plane object
934 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
936 //Add a new Plane function
937 Handle(GEOM_Function) aFunction =
938 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
940 //Check if the function is set correctly
941 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
943 GEOMImpl_IPlane aPI (aFunction);
945 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
946 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
947 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
949 aPI.SetVector1(aRefVec1);
950 aPI.SetVector2(aRefVec2);
951 aPI.SetSize(theSize);
953 //Compute the Plane value
956 if (!GetSolver()->ComputeFunction(aFunction)) {
957 SetErrorCode("Plane driver failed");
961 catch (Standard_Failure) {
962 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
963 SetErrorCode(aFail->GetMessageString());
967 //Make a Python command
968 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
969 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
975 //=============================================================================
979 //=============================================================================
980 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
981 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
985 //Add a new Plane object
986 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
988 //Add a new Plane function
989 Handle(GEOM_Function) aFunction =
990 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
992 //Check if the function is set correctly
993 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
995 GEOMImpl_IPlane aPI (aFunction);
997 if ( !theLCS.IsNull() ) {
998 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1002 aPI.SetSize(theSize);
1003 aPI.SetOrientation(theOrientation);
1005 //Compute the Plane value
1008 if (!GetSolver()->ComputeFunction(aFunction)) {
1009 SetErrorCode("Plane driver failed");
1013 catch (Standard_Failure) {
1014 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1015 SetErrorCode(aFail->GetMessageString());
1019 //Make a Python command
1020 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1021 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1028 //=============================================================================
1032 //=============================================================================
1033 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1034 (double theOX, double theOY, double theOZ,
1035 double theXDX, double theXDY, double theXDZ,
1036 double theYDX, double theYDY, double theYDZ)
1040 //Add a new Marker object
1041 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1043 //Add a new Marker function
1044 Handle(GEOM_Function) aFunction =
1045 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1046 if (aFunction.IsNull()) return NULL;
1048 //Check if the function is set correctly
1049 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1051 GEOMImpl_IMarker aPI(aFunction);
1053 aPI.SetOrigin(theOX, theOY, theOZ);
1054 aPI.SetXDir(theXDX, theXDY, theXDZ);
1055 aPI.SetYDir(theYDX, theYDY, theYDZ);
1057 //Compute the marker value
1060 if (!GetSolver()->ComputeFunction(aFunction)) {
1061 SetErrorCode("Marker driver failed");
1065 catch (Standard_Failure) {
1066 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1067 SetErrorCode(aFail->GetMessageString());
1071 //Make a Python command
1072 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1073 << theOX << ", " << theOY << ", " << theOZ << ", "
1074 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1075 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1081 //=============================================================================
1083 * MakeMarkerFromShape
1085 //=============================================================================
1086 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1087 (const Handle(GEOM_Object)& theShape)
1091 //Add a new Marker object
1092 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1094 //Add a new Marker function
1095 Handle(GEOM_Function) aFunction =
1096 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1097 if (aFunction.IsNull()) return NULL;
1099 //Check if the function is set correctly
1100 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1102 GEOMImpl_IMarker aPI(aFunction);
1104 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1105 if (aRefShape.IsNull()) return NULL;
1107 aPI.SetShape(aRefShape);
1109 //Compute the marker value
1112 if (!GetSolver()->ComputeFunction(aFunction)) {
1113 SetErrorCode("Marker driver failed");
1117 catch (Standard_Failure) {
1118 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1119 SetErrorCode(aFail->GetMessageString());
1123 //Make a Python command
1124 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1130 //=============================================================================
1132 * MakeMarkerPntTwoVec
1134 //=============================================================================
1135 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1136 (const Handle(GEOM_Object)& theOrigin,
1137 const Handle(GEOM_Object)& theXVec,
1138 const Handle(GEOM_Object)& theYVec)
1142 //Add a new Marker object
1143 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1145 //Add a new Marker function
1146 Handle(GEOM_Function) aFunction =
1147 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1148 if (aFunction.IsNull()) return NULL;
1150 //Check if the function is set correctly
1151 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1153 GEOMImpl_IMarker aPI(aFunction);
1155 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1156 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1157 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1158 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1160 aPI.SetOrigin(aRefOrigin);
1161 aPI.SetXVec(aRefXVec);
1162 aPI.SetYVec(aRefYVec);
1164 //Compute the marker value
1167 if (!GetSolver()->ComputeFunction(aFunction)) {
1168 SetErrorCode("Marker driver failed");
1172 catch (Standard_Failure) {
1173 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1174 SetErrorCode(aFail->GetMessageString());
1178 //Make a Python command
1179 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1180 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1186 //=============================================================================
1188 * MakeTangentPlaneOnFace
1190 //=============================================================================
1192 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1199 if (theFace.IsNull()) return NULL;
1201 //Add a new Plane object
1202 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1204 //Add a new Plane function
1205 Handle(GEOM_Function) aFunction =
1206 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1208 //Check if the function is set correctly
1209 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1211 GEOMImpl_IPlane aPI (aFunction);
1213 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1214 if (aRef.IsNull()) return NULL;
1217 aPI.SetSize(theSize);
1218 aPI.SetParameterU(theParamU);
1219 aPI.SetParameterV(theParamV);
1221 //Compute the Plane value
1224 if (!GetSolver()->ComputeFunction(aFunction)) {
1225 SetErrorCode("Plane driver failed");
1229 catch (Standard_Failure) {
1230 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1231 SetErrorCode(aFail->GetMessageString());
1235 //Make a Python command
1236 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1237 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";