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 <Basics_OCCTVersion.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_PointDriver.hxx>
42 #include <GEOMImpl_VectorDriver.hxx>
43 #include <GEOMImpl_LineDriver.hxx>
44 #include <GEOMImpl_PlaneDriver.hxx>
45 #include <GEOMImpl_MarkerDriver.hxx>
47 #include <GEOMImpl_IPoint.hxx>
48 #include <GEOMImpl_IVector.hxx>
49 #include <GEOMImpl_ILine.hxx>
50 #include <GEOMImpl_IPlane.hxx>
51 #include <GEOMImpl_IMarker.hxx>
53 #include <GEOMImpl_Types.hxx>
55 #include <Standard_Failure.hxx>
56 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
58 //=============================================================================
62 //=============================================================================
63 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
64 : GEOM_IOperations(theEngine, theDocID)
66 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
69 //=============================================================================
73 //=============================================================================
74 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
76 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
80 //=============================================================================
84 //=============================================================================
85 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
86 (double theX, double theY, double theZ)
90 //Add a new Point object
91 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
93 //Add a new Point function with XYZ parameters
94 Handle(GEOM_Function) aFunction =
95 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
96 if (aFunction.IsNull()) return NULL;
98 //Check if the function is set correctly
99 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
101 GEOMImpl_IPoint aPI(aFunction);
107 //Compute the point value
110 if (!GetSolver()->ComputeFunction(aFunction)) {
111 SetErrorCode("Point driver failed");
115 catch (Standard_Failure) {
116 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
117 SetErrorCode(aFail->GetMessageString());
121 //Make a Python command
122 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
123 << theX << ", " << theY << ", " << theZ << ")";
129 //=============================================================================
131 * MakePointWithReference
133 //=============================================================================
134 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
135 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
139 if (theReference.IsNull()) return NULL;
141 //Add a new Point object
142 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
144 //Add a new Point function for creation a point relativley another point
145 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
147 //Check if the function is set correctly
148 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
150 GEOMImpl_IPoint aPI(aFunction);
152 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
153 if (aRefFunction.IsNull()) return NULL;
155 aPI.SetRef(aRefFunction);
160 //Compute the point value
163 if (!GetSolver()->ComputeFunction(aFunction)) {
164 SetErrorCode("Point driver failed");
168 catch (Standard_Failure) {
169 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
170 SetErrorCode(aFail->GetMessageString());
174 //Make a Python command
175 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
176 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
182 //=============================================================================
186 //=============================================================================
187 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
188 (Handle(GEOM_Object) theGeomObj,
192 const PointLocation theLocation,
193 const bool takeOrientationIntoAccount,
194 Handle(GEOM_Object) theRefPoint)
198 if (theGeomObj.IsNull()) return NULL;
200 //Add a new Point object
201 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
203 //Add a new Point function for creation a point relativley another point
204 int fType = POINT_CURVE_PAR;
205 switch( theLocation )
207 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
208 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
209 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
210 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
211 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
212 case PointOn_Face: fType = POINT_FACE_ANY; break;
215 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
217 //Check if the function is set correctly
218 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
220 GEOMImpl_IPoint aPI (aFunction);
222 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
223 if (aRefFunction.IsNull()) return NULL;
225 switch( theLocation )
227 case PointOn_CurveByParam:
228 aPI.SetCurve(aRefFunction);
229 aPI.SetParameter(theParam1);
230 aPI.SetTakeOrientationIntoAccount(takeOrientationIntoAccount);
232 case PointOn_CurveByLength:
233 aPI.SetCurve(aRefFunction);
234 aPI.SetLength(theParam1);
235 if (!theRefPoint.IsNull()) {
236 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
237 aPI.SetRef(aRefPoint);
240 case PointOn_CurveByCoord:
241 aPI.SetCurve(aRefFunction);
246 case PointOn_SurfaceByParam:
247 aPI.SetSurface(aRefFunction);
248 aPI.SetParameter(theParam1);
249 aPI.SetParameter2(theParam2);
251 case PointOn_SurfaceByCoord:
252 aPI.SetSurface(aRefFunction);
258 aPI.SetSurface(aRefFunction);
263 //Compute the point value
266 if (!GetSolver()->ComputeFunction(aFunction)) {
267 SetErrorCode("Point driver failed");
271 catch (Standard_Failure) {
272 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
273 SetErrorCode(aFail->GetMessageString());
277 //Make a Python command
278 switch( theLocation )
280 case PointOn_CurveByParam:
281 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
282 << theGeomObj << ", " << theParam1 << ", "
283 << takeOrientationIntoAccount << ")";
285 case PointOn_CurveByLength:
286 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
287 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
289 case PointOn_CurveByCoord:
290 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
291 << theGeomObj << ", " << theParam1
292 << ", " << theParam2 << ", " << theParam3 << ")";
294 case PointOn_SurfaceByParam:
295 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
296 << theGeomObj << ", " << theParam1
297 << ", " << theParam2 << ")";
299 case PointOn_SurfaceByCoord:
300 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
301 << theGeomObj << ", " << theParam1
302 << ", " << theParam2 << ", " << theParam3 << ")";
305 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
306 << theGeomObj << ")";
315 //=============================================================================
319 //=============================================================================
320 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
321 (Handle(GEOM_Object) theCurve,
323 bool takeOrientationIntoAccount)
325 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
326 takeOrientationIntoAccount);
329 //=============================================================================
331 * MakePointOnCurveByCoord
333 //=============================================================================
334 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
335 (Handle(GEOM_Object) theCurve,
340 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
343 //=============================================================================
345 * MakePointOnCurveByLength
347 //=============================================================================
348 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
349 (Handle(GEOM_Object) theCurve,
351 Handle(GEOM_Object) theStartPoint)
353 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength,
354 false, theStartPoint);
357 //=============================================================================
361 //=============================================================================
362 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
363 (Handle(GEOM_Object) theSurface,
364 double theUParameter,
365 double theVParameter)
367 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
370 //=============================================================================
372 * MakePointOnSurfaceByCoord
374 //=============================================================================
375 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
376 (Handle(GEOM_Object) theSurface,
381 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
384 //=============================================================================
388 //=============================================================================
389 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
391 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
394 //=============================================================================
396 * MakePointOnLinesIntersection
398 //=============================================================================
399 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
400 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
404 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
406 //Add a new Point object
407 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
409 //Add a new Point function for creation a point relativley another point
410 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
412 //Check if the function is set correctly
413 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
415 GEOMImpl_IPoint aPI (aFunction);
417 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
418 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
419 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
424 //Compute the point value
427 if (!GetSolver()->ComputeFunction(aFunction)) {
428 SetErrorCode("Point driver failed");
432 catch (Standard_Failure) {
433 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
434 SetErrorCode(aFail->GetMessageString());
438 //Make a Python command
439 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
440 << theLine1 << ", " << theLine2 << ")";
446 //=============================================================================
450 //=============================================================================
451 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
452 (const Handle(GEOM_Object)& theCurve, double theParameter)
456 if (theCurve.IsNull()) return NULL;
458 //Add a new Vector object
459 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
461 //Add a new Point function for creation a point relativley another point
462 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
464 //Check if the function is set correctly
465 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
467 GEOMImpl_IVector aVI (aFunction);
469 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
470 if (aRefFunction.IsNull()) return NULL;
472 aVI.SetCurve(aRefFunction);
473 aVI.SetParameter(theParameter);
475 //Compute the vector value
478 if (!GetSolver()->ComputeFunction(aFunction)) {
479 SetErrorCode("Vector driver failed");
483 catch (Standard_Failure) {
484 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
485 SetErrorCode(aFail->GetMessageString());
489 //Make a Python command
490 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
491 << theCurve << ", " << theParameter << ")";
497 //=============================================================================
501 //=============================================================================
502 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
503 (double theDX, double theDY, double theDZ)
507 //Add a new Vector object
508 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
510 //Add a new Vector function with DXDYDZ parameters
511 Handle(GEOM_Function) aFunction =
512 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
513 if (aFunction.IsNull()) return NULL;
515 //Check if the function is set correctly
516 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
518 GEOMImpl_IVector aPI (aFunction);
524 //Compute the Vector value
527 if (!GetSolver()->ComputeFunction(aFunction)) {
528 SetErrorCode("Vector driver failed");
532 catch (Standard_Failure) {
533 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
534 SetErrorCode(aFail->GetMessageString());
538 //Make a Python command
539 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
540 << theDX << ", " << theDY << ", " << theDZ << ")";
546 //=============================================================================
550 //=============================================================================
551 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
552 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
556 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
558 //Add a new Vector object
559 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
561 //Add a new Vector function
562 Handle(GEOM_Function) aFunction =
563 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
565 //Check if the function is set correctly
566 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
568 GEOMImpl_IVector aPI (aFunction);
570 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
571 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
572 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
574 aPI.SetPoint1(aRef1);
575 aPI.SetPoint2(aRef2);
577 //Compute the Vector value
580 if (!GetSolver()->ComputeFunction(aFunction)) {
581 SetErrorCode("Vector driver failed");
585 catch (Standard_Failure) {
586 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
587 SetErrorCode(aFail->GetMessageString());
591 //Make a Python command
592 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
593 << thePnt1 << ", " << thePnt2 << ")";
600 //=============================================================================
604 //=============================================================================
605 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
606 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
610 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
612 //Add a new Line object
613 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
615 //Add a new Line function
616 Handle(GEOM_Function) aFunction =
617 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
619 //Check if the function is set correctly
620 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
622 GEOMImpl_ILine aPI (aFunction);
624 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
625 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
626 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
628 aPI.SetPoint1(aRef1);
629 aPI.SetPoint2(aRef2);
631 //Compute the Line value
634 if (!GetSolver()->ComputeFunction(aFunction)) {
635 SetErrorCode("Line driver failed");
639 catch (Standard_Failure) {
640 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
641 SetErrorCode(aFail->GetMessageString());
645 //Make a Python command
646 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
647 << thePnt << ", " << theDir << ")";
653 //=============================================================================
657 //=============================================================================
658 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
659 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
663 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
665 //Add a new Line object
666 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
668 //Add a new Line function
669 Handle(GEOM_Function) aFunction =
670 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
672 //Check if the function is set correctly
673 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
675 GEOMImpl_ILine aPI (aFunction);
677 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
678 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
679 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
681 aPI.SetPoint1(aRef1);
682 aPI.SetPoint2(aRef2);
684 //Compute the Line value
687 if (!GetSolver()->ComputeFunction(aFunction)) {
688 SetErrorCode("Line driver failed");
692 catch (Standard_Failure) {
693 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
694 SetErrorCode(aFail->GetMessageString());
698 //Make a Python command
699 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
700 << thePnt1 << ", " << thePnt2 << ")";
706 //=============================================================================
710 //=============================================================================
711 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
712 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
716 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
718 //Add a new Line object
719 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
721 //Add a new Line function
722 Handle(GEOM_Function) aFunction =
723 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
725 //Check if the function is set correctly
726 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
728 GEOMImpl_ILine aPI (aFunction);
730 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
731 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
732 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
737 //Compute the Line value
740 if (!GetSolver()->ComputeFunction(aFunction)) {
741 SetErrorCode("Line driver failed");
745 catch (Standard_Failure) {
746 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
747 SetErrorCode(aFail->GetMessageString());
751 //Make a Python command
752 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
753 << theFace1 << ", " << theFace2 << ")";
759 //=============================================================================
763 //=============================================================================
764 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
765 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
766 Handle(GEOM_Object) thePnt3, double theSize)
770 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
772 //Add a new Plane object
773 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
775 //Add a new Plane function
776 Handle(GEOM_Function) aFunction =
777 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
779 //Check if the function is set correctly
780 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
782 GEOMImpl_IPlane aPI (aFunction);
784 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
785 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
786 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
787 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
789 aPI.SetPoint1(aRef1);
790 aPI.SetPoint2(aRef2);
791 aPI.SetPoint3(aRef3);
792 aPI.SetSize(theSize);
794 //Compute the Plane value
797 if (!GetSolver()->ComputeFunction(aFunction)) {
798 SetErrorCode("Plane driver failed");
802 catch (Standard_Failure) {
803 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
804 SetErrorCode(aFail->GetMessageString());
808 //Make a Python command
809 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
810 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
816 //=============================================================================
820 //=============================================================================
821 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
822 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
827 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
829 //Add a new Plane object
830 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
832 //Add a new Plane function
833 Handle(GEOM_Function) aFunction =
834 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
836 //Check if the function is set correctly
837 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
839 GEOMImpl_IPlane aPI (aFunction);
841 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
842 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
843 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
845 aPI.SetPoint(aRefPnt);
846 aPI.SetVector(aRefVec);
847 aPI.SetSize(theSize);
849 //Compute the Plane value
852 if (!GetSolver()->ComputeFunction(aFunction)) {
853 SetErrorCode("Plane driver failed");
857 catch (Standard_Failure) {
858 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
859 SetErrorCode(aFail->GetMessageString());
863 //Make a Python command
864 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
865 << thePnt << ", " << theVec << ", " << theSize << ")";
871 //=============================================================================
875 //=============================================================================
876 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
877 (Handle(GEOM_Object) theFace, double theSize)
881 if (theFace.IsNull()) return NULL;
883 //Add a new Plane object
884 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
886 //Add a new Plane function
887 Handle(GEOM_Function) aFunction =
888 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
890 //Check if the function is set correctly
891 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
893 GEOMImpl_IPlane aPI (aFunction);
895 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
896 if (aRef.IsNull()) return NULL;
899 aPI.SetSize(theSize);
901 //Compute the Plane value
904 if (!GetSolver()->ComputeFunction(aFunction)) {
905 SetErrorCode("Plane driver failed");
909 catch (Standard_Failure) {
910 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
911 SetErrorCode(aFail->GetMessageString());
915 //Make a Python command
916 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
917 << theFace << ", " << theSize << ")";
923 //=============================================================================
927 //=============================================================================
928 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
929 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
934 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
936 //Add a new Plane object
937 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
939 //Add a new Plane function
940 Handle(GEOM_Function) aFunction =
941 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
943 //Check if the function is set correctly
944 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
946 GEOMImpl_IPlane aPI (aFunction);
948 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
949 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
950 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
952 aPI.SetVector1(aRefVec1);
953 aPI.SetVector2(aRefVec2);
954 aPI.SetSize(theSize);
956 //Compute the Plane value
959 if (!GetSolver()->ComputeFunction(aFunction)) {
960 SetErrorCode("Plane driver failed");
964 catch (Standard_Failure) {
965 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
966 SetErrorCode(aFail->GetMessageString());
970 //Make a Python command
971 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
972 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
978 //=============================================================================
982 //=============================================================================
983 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
984 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
988 //Add a new Plane object
989 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
991 //Add a new Plane function
992 Handle(GEOM_Function) aFunction =
993 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
995 //Check if the function is set correctly
996 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
998 GEOMImpl_IPlane aPI (aFunction);
1000 if ( !theLCS.IsNull() ) {
1001 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1005 aPI.SetSize(theSize);
1006 aPI.SetOrientation(theOrientation);
1008 //Compute the Plane value
1011 if (!GetSolver()->ComputeFunction(aFunction)) {
1012 SetErrorCode("Plane driver failed");
1016 catch (Standard_Failure) {
1017 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1018 SetErrorCode(aFail->GetMessageString());
1022 //Make a Python command
1023 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1024 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1031 //=============================================================================
1035 //=============================================================================
1036 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1037 (double theOX, double theOY, double theOZ,
1038 double theXDX, double theXDY, double theXDZ,
1039 double theYDX, double theYDY, double theYDZ)
1043 //Add a new Marker object
1044 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1046 //Add a new Marker function
1047 Handle(GEOM_Function) aFunction =
1048 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1049 if (aFunction.IsNull()) return NULL;
1051 //Check if the function is set correctly
1052 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1054 GEOMImpl_IMarker aPI(aFunction);
1056 aPI.SetOrigin(theOX, theOY, theOZ);
1057 aPI.SetXDir(theXDX, theXDY, theXDZ);
1058 aPI.SetYDir(theYDX, theYDY, theYDZ);
1060 //Compute the marker value
1063 if (!GetSolver()->ComputeFunction(aFunction)) {
1064 SetErrorCode("Marker driver failed");
1068 catch (Standard_Failure) {
1069 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1070 SetErrorCode(aFail->GetMessageString());
1074 //Make a Python command
1075 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1076 << theOX << ", " << theOY << ", " << theOZ << ", "
1077 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1078 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1084 //=============================================================================
1086 * MakeMarkerFromShape
1088 //=============================================================================
1089 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1090 (const Handle(GEOM_Object)& theShape)
1094 //Add a new Marker object
1095 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1097 //Add a new Marker function
1098 Handle(GEOM_Function) aFunction =
1099 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1100 if (aFunction.IsNull()) return NULL;
1102 //Check if the function is set correctly
1103 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1105 GEOMImpl_IMarker aPI(aFunction);
1107 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1108 if (aRefShape.IsNull()) return NULL;
1110 aPI.SetShape(aRefShape);
1112 //Compute the marker value
1115 if (!GetSolver()->ComputeFunction(aFunction)) {
1116 SetErrorCode("Marker driver failed");
1120 catch (Standard_Failure) {
1121 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1122 SetErrorCode(aFail->GetMessageString());
1126 //Make a Python command
1127 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1133 //=============================================================================
1135 * MakeMarkerPntTwoVec
1137 //=============================================================================
1138 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1139 (const Handle(GEOM_Object)& theOrigin,
1140 const Handle(GEOM_Object)& theXVec,
1141 const Handle(GEOM_Object)& theYVec)
1145 //Add a new Marker object
1146 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1148 //Add a new Marker function
1149 Handle(GEOM_Function) aFunction =
1150 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1151 if (aFunction.IsNull()) return NULL;
1153 //Check if the function is set correctly
1154 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1156 GEOMImpl_IMarker aPI(aFunction);
1158 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1159 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1160 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1161 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1163 aPI.SetOrigin(aRefOrigin);
1164 aPI.SetXVec(aRefXVec);
1165 aPI.SetYVec(aRefYVec);
1167 //Compute the marker value
1170 if (!GetSolver()->ComputeFunction(aFunction)) {
1171 SetErrorCode("Marker driver failed");
1175 catch (Standard_Failure) {
1176 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1177 SetErrorCode(aFail->GetMessageString());
1181 //Make a Python command
1182 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1183 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1189 //=============================================================================
1191 * MakeTangentPlaneOnFace
1193 //=============================================================================
1195 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1202 if (theFace.IsNull()) return NULL;
1204 //Add a new Plane object
1205 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1207 //Add a new Plane function
1208 Handle(GEOM_Function) aFunction =
1209 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1211 //Check if the function is set correctly
1212 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1214 GEOMImpl_IPlane aPI (aFunction);
1216 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1217 if (aRef.IsNull()) return NULL;
1220 aPI.SetSize(theSize);
1221 aPI.SetParameterU(theParamU);
1222 aPI.SetParameterV(theParamV);
1224 //Compute the Plane value
1227 if (!GetSolver()->ComputeFunction(aFunction)) {
1228 SetErrorCode("Plane driver failed");
1232 catch (Standard_Failure) {
1233 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1234 SetErrorCode(aFail->GetMessageString());
1238 //Make a Python command
1239 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1240 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";