1 // Copyright (C) 2007-2008 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.
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
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_IBasicOperations.hxx>
26 #include "utilities.h"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TFunction_Logbook.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
106 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
109 if (!GetSolver()->ComputeFunction(aFunction)) {
110 SetErrorCode("Point driver failed");
114 catch (Standard_Failure) {
115 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
116 SetErrorCode(aFail->GetMessageString());
120 //Make a Python command
121 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
122 << theX << ", " << theY << ", " << theZ << ")";
128 //=============================================================================
130 * MakePointWithReference
132 //=============================================================================
133 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
134 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
138 if (theReference.IsNull()) return NULL;
140 //Add a new Point object
141 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
143 //Add a new Point function for creation a point relativley another point
144 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
146 //Check if the function is set correctly
147 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
149 GEOMImpl_IPoint aPI(aFunction);
151 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
152 if (aRefFunction.IsNull()) return NULL;
154 aPI.SetRef(aRefFunction);
159 //Compute the point value
161 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
164 if (!GetSolver()->ComputeFunction(aFunction)) {
165 SetErrorCode("Point driver failed");
169 catch (Standard_Failure) {
170 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
171 SetErrorCode(aFail->GetMessageString());
175 //Make a Python command
176 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
177 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
183 //=============================================================================
187 //=============================================================================
188 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
189 (Handle(GEOM_Object) theGeomObj,
193 const PointLocation theLocation)
197 if (theGeomObj.IsNull()) return NULL;
199 //Add a new Point object
200 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
202 //Add a new Point function for creation a point relativley another point
203 int fType = POINT_CURVE_PAR;
204 switch( theLocation )
206 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
207 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
208 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
209 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; 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);
228 case PointOn_CurveByCoord:
229 aPI.SetCurve(aRefFunction);
234 case PointOn_SurfaceByParam:
235 aPI.SetSurface(aRefFunction);
236 aPI.SetParameter(theParam1);
237 aPI.SetParameter2(theParam2);
239 case PointOn_SurfaceByCoord:
240 aPI.SetSurface(aRefFunction);
247 //Compute the point value
249 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
252 if (!GetSolver()->ComputeFunction(aFunction)) {
253 SetErrorCode("Point driver failed");
257 catch (Standard_Failure) {
258 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
259 SetErrorCode(aFail->GetMessageString());
263 //Make a Python command
264 switch( theLocation )
266 case PointOn_CurveByParam:
267 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
268 << theGeomObj << ", " << theParam1 << ")";
270 case PointOn_CurveByCoord:
271 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
272 << theGeomObj << ", " << theParam1
273 << ", " << theParam2 << ", " << theParam3 << ")";
275 case PointOn_SurfaceByParam:
276 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
277 << theGeomObj << ", " << theParam1
278 << ", " << theParam2 << ")";
280 case PointOn_SurfaceByCoord:
281 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
282 << theGeomObj << ", " << theParam1
283 << ", " << theParam2 << ", " << theParam3 << ")";
291 //=============================================================================
295 //=============================================================================
296 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
297 (Handle(GEOM_Object) theCurve, double theParameter)
299 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
302 //=============================================================================
304 * MakePointOnCurveByCoord
306 //=============================================================================
307 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
308 (Handle(GEOM_Object) theCurve,
313 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
316 //=============================================================================
320 //=============================================================================
321 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
322 (Handle(GEOM_Object) theSurface,
323 double theUParameter,
324 double theVParameter)
326 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
329 //=============================================================================
331 * MakePointOnSurfaceByCoord
333 //=============================================================================
334 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
335 (Handle(GEOM_Object) theSurface,
340 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
344 //=============================================================================
346 * MakePointOnLinesIntersection
348 //=============================================================================
349 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
350 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
354 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
356 //Add a new Point object
357 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
359 //Add a new Point function for creation a point relativley another point
360 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
362 //Check if the function is set correctly
363 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
365 GEOMImpl_IPoint aPI (aFunction);
367 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
368 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
369 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
374 //Compute the point value
376 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
379 if (!GetSolver()->ComputeFunction(aFunction)) {
380 SetErrorCode("Point driver failed");
384 catch (Standard_Failure) {
385 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
386 SetErrorCode(aFail->GetMessageString());
390 //Make a Python command
391 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
392 << theLine1 << ", " << theLine2 << ")";
398 //=============================================================================
402 //=============================================================================
403 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
404 (const Handle(GEOM_Object)& theCurve, double theParameter)
408 if (theCurve.IsNull()) return NULL;
410 //Add a new Vector object
411 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
413 //Add a new Point function for creation a point relativley another point
414 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
416 //Check if the function is set correctly
417 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
419 GEOMImpl_IVector aVI (aFunction);
421 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
422 if (aRefFunction.IsNull()) return NULL;
424 aVI.SetCurve(aRefFunction);
425 aVI.SetParameter(theParameter);
427 //Compute the vector value
429 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
432 if (!GetSolver()->ComputeFunction(aFunction)) {
433 SetErrorCode("Vector driver failed");
437 catch (Standard_Failure) {
438 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
439 SetErrorCode(aFail->GetMessageString());
443 //Make a Python command
444 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
445 << theCurve << ", " << theParameter << ")";
451 //=============================================================================
455 //=============================================================================
456 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
457 (double theDX, double theDY, double theDZ)
461 //Add a new Vector object
462 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
464 //Add a new Vector function with DXDYDZ parameters
465 Handle(GEOM_Function) aFunction =
466 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
467 if (aFunction.IsNull()) return NULL;
469 //Check if the function is set correctly
470 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
472 GEOMImpl_IVector aPI (aFunction);
478 //Compute the Vector value
480 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
483 if (!GetSolver()->ComputeFunction(aFunction)) {
484 SetErrorCode("Vector driver failed");
488 catch (Standard_Failure) {
489 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
490 SetErrorCode(aFail->GetMessageString());
494 //Make a Python command
495 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
496 << theDX << ", " << theDY << ", " << theDZ << ")";
502 //=============================================================================
506 //=============================================================================
507 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
508 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
512 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
514 //Add a new Vector object
515 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
517 //Add a new Vector function
518 Handle(GEOM_Function) aFunction =
519 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
521 //Check if the function is set correctly
522 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
524 GEOMImpl_IVector aPI (aFunction);
526 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
527 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
528 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
530 aPI.SetPoint1(aRef1);
531 aPI.SetPoint2(aRef2);
533 //Compute the Vector value
535 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
538 if (!GetSolver()->ComputeFunction(aFunction)) {
539 SetErrorCode("Vector driver failed");
543 catch (Standard_Failure) {
544 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
545 SetErrorCode(aFail->GetMessageString());
549 //Make a Python command
550 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
551 << thePnt1 << ", " << thePnt2 << ")";
558 //=============================================================================
562 //=============================================================================
563 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
564 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
568 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
570 //Add a new Line object
571 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
573 //Add a new Line function
574 Handle(GEOM_Function) aFunction =
575 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
577 //Check if the function is set correctly
578 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
580 GEOMImpl_ILine aPI (aFunction);
582 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
583 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
584 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
586 aPI.SetPoint1(aRef1);
587 aPI.SetPoint2(aRef2);
589 //Compute the Line value
591 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
594 if (!GetSolver()->ComputeFunction(aFunction)) {
595 SetErrorCode("Line driver failed");
599 catch (Standard_Failure) {
600 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
601 SetErrorCode(aFail->GetMessageString());
605 //Make a Python command
606 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
607 << thePnt << ", " << theDir << ")";
613 //=============================================================================
617 //=============================================================================
618 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
619 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
623 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
625 //Add a new Line object
626 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
628 //Add a new Line function
629 Handle(GEOM_Function) aFunction =
630 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
632 //Check if the function is set correctly
633 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
635 GEOMImpl_ILine aPI (aFunction);
637 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
638 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
639 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
641 aPI.SetPoint1(aRef1);
642 aPI.SetPoint2(aRef2);
644 //Compute the Line value
646 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
649 if (!GetSolver()->ComputeFunction(aFunction)) {
650 SetErrorCode("Line driver failed");
654 catch (Standard_Failure) {
655 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
656 SetErrorCode(aFail->GetMessageString());
660 //Make a Python command
661 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
662 << thePnt1 << ", " << thePnt2 << ")";
668 //=============================================================================
672 //=============================================================================
673 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
674 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
678 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
680 //Add a new Line object
681 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
683 //Add a new Line function
684 Handle(GEOM_Function) aFunction =
685 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
687 //Check if the function is set correctly
688 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
690 GEOMImpl_ILine aPI (aFunction);
692 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
693 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
694 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
699 //Compute the Line value
701 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
704 if (!GetSolver()->ComputeFunction(aFunction)) {
705 SetErrorCode("Line driver failed");
709 catch (Standard_Failure) {
710 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
711 SetErrorCode(aFail->GetMessageString());
715 //Make a Python command
716 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
717 << theFace1 << ", " << theFace2 << ")";
723 //=============================================================================
727 //=============================================================================
728 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
729 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
730 Handle(GEOM_Object) thePnt3, double theSize)
734 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
736 //Add a new Plane object
737 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
739 //Add a new Plane function
740 Handle(GEOM_Function) aFunction =
741 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
743 //Check if the function is set correctly
744 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
746 GEOMImpl_IPlane aPI (aFunction);
748 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
749 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
750 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
751 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
753 aPI.SetPoint1(aRef1);
754 aPI.SetPoint2(aRef2);
755 aPI.SetPoint3(aRef3);
756 aPI.SetSize(theSize);
758 //Compute the Plane value
760 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
763 if (!GetSolver()->ComputeFunction(aFunction)) {
764 SetErrorCode("Plane driver failed");
768 catch (Standard_Failure) {
769 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
770 SetErrorCode(aFail->GetMessageString());
774 //Make a Python command
775 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
776 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
782 //=============================================================================
786 //=============================================================================
787 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
788 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
793 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
795 //Add a new Plane object
796 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
798 //Add a new Plane function
799 Handle(GEOM_Function) aFunction =
800 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
802 //Check if the function is set correctly
803 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
805 GEOMImpl_IPlane aPI (aFunction);
807 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
808 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
809 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
811 aPI.SetPoint(aRefPnt);
812 aPI.SetVector(aRefVec);
813 aPI.SetSize(theSize);
815 //Compute the Plane value
817 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
820 if (!GetSolver()->ComputeFunction(aFunction)) {
821 SetErrorCode("Plane driver failed");
825 catch (Standard_Failure) {
826 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
827 SetErrorCode(aFail->GetMessageString());
831 //Make a Python command
832 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
833 << thePnt << ", " << theVec << ", " << theSize << ")";
839 //=============================================================================
843 //=============================================================================
844 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
845 (Handle(GEOM_Object) theFace, double theSize)
849 if (theFace.IsNull()) return NULL;
851 //Add a new Plane object
852 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
854 //Add a new Plane function
855 Handle(GEOM_Function) aFunction =
856 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
858 //Check if the function is set correctly
859 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
861 GEOMImpl_IPlane aPI (aFunction);
863 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
864 if (aRef.IsNull()) return NULL;
867 aPI.SetSize(theSize);
869 //Compute the Plane value
871 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
874 if (!GetSolver()->ComputeFunction(aFunction)) {
875 SetErrorCode("Plane driver failed");
879 catch (Standard_Failure) {
880 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
881 SetErrorCode(aFail->GetMessageString());
885 //Make a Python command
886 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
887 << theFace << ", " << theSize << ")";
893 //=============================================================================
897 //=============================================================================
898 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
899 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
904 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
906 //Add a new Plane object
907 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
909 //Add a new Plane function
910 Handle(GEOM_Function) aFunction =
911 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
913 //Check if the function is set correctly
914 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
916 GEOMImpl_IPlane aPI (aFunction);
918 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
919 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
920 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
922 aPI.SetVector1(aRefVec1);
923 aPI.SetVector2(aRefVec2);
924 aPI.SetSize(theSize);
926 //Compute the Plane value
928 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
931 if (!GetSolver()->ComputeFunction(aFunction)) {
932 SetErrorCode("Plane driver failed");
936 catch (Standard_Failure) {
937 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
938 SetErrorCode(aFail->GetMessageString());
942 //Make a Python command
943 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
944 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
950 //=============================================================================
954 //=============================================================================
955 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
956 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
960 //Add a new Plane object
961 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
963 //Add a new Plane function
964 Handle(GEOM_Function) aFunction =
965 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
967 //Check if the function is set correctly
968 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
970 GEOMImpl_IPlane aPI (aFunction);
972 if ( !theLCS.IsNull() ) {
973 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
977 aPI.SetSize(theSize);
978 aPI.SetOrientation(theOrientation);
980 //Compute the Plane value
982 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
985 if (!GetSolver()->ComputeFunction(aFunction)) {
986 SetErrorCode("Plane driver failed");
990 catch (Standard_Failure) {
991 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
992 SetErrorCode(aFail->GetMessageString());
996 //Make a Python command
997 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
998 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1005 //=============================================================================
1009 //=============================================================================
1010 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1011 (double theOX, double theOY, double theOZ,
1012 double theXDX, double theXDY, double theXDZ,
1013 double theYDX, double theYDY, double theYDZ)
1017 //Add a new Marker object
1018 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1020 //Add a new Marker function
1021 Handle(GEOM_Function) aFunction =
1022 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1023 if (aFunction.IsNull()) return NULL;
1025 //Check if the function is set correctly
1026 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1028 GEOMImpl_IMarker aPI(aFunction);
1030 aPI.SetOrigin(theOX, theOY, theOZ);
1031 aPI.SetXDir(theXDX, theXDY, theXDZ);
1032 aPI.SetYDir(theYDX, theYDY, theYDZ);
1034 //Compute the marker value
1036 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1039 if (!GetSolver()->ComputeFunction(aFunction)) {
1040 SetErrorCode("Marker driver failed");
1044 catch (Standard_Failure) {
1045 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1046 SetErrorCode(aFail->GetMessageString());
1050 //Make a Python command
1051 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1052 << theOX << ", " << theOY << ", " << theOZ << ", "
1053 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1054 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1060 //=============================================================================
1062 * MakeMarkerFromShape
1064 //=============================================================================
1065 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1066 (const Handle(GEOM_Object)& theShape)
1070 //Add a new Marker object
1071 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1073 //Add a new Marker function
1074 Handle(GEOM_Function) aFunction =
1075 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1076 if (aFunction.IsNull()) return NULL;
1078 //Check if the function is set correctly
1079 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1081 GEOMImpl_IMarker aPI(aFunction);
1083 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1084 if (aRefShape.IsNull()) return NULL;
1086 aPI.SetShape(aRefShape);
1088 //Compute the marker value
1090 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1093 if (!GetSolver()->ComputeFunction(aFunction)) {
1094 SetErrorCode("Marker driver failed");
1098 catch (Standard_Failure) {
1099 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1100 SetErrorCode(aFail->GetMessageString());
1104 //Make a Python command
1105 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1111 //=============================================================================
1113 * MakeMarkerPntTwoVec
1115 //=============================================================================
1116 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1117 (const Handle(GEOM_Object)& theOrigin,
1118 const Handle(GEOM_Object)& theXVec,
1119 const Handle(GEOM_Object)& theYVec)
1123 //Add a new Marker object
1124 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1126 //Add a new Marker function
1127 Handle(GEOM_Function) aFunction =
1128 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1129 if (aFunction.IsNull()) return NULL;
1131 //Check if the function is set correctly
1132 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1134 GEOMImpl_IMarker aPI(aFunction);
1136 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1137 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1138 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1139 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1141 aPI.SetOrigin(aRefOrigin);
1142 aPI.SetXVec(aRefXVec);
1143 aPI.SetYVec(aRefYVec);
1145 //Compute the marker value
1147 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1150 if (!GetSolver()->ComputeFunction(aFunction)) {
1151 SetErrorCode("Marker driver failed");
1155 catch (Standard_Failure) {
1156 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1157 SetErrorCode(aFail->GetMessageString());
1161 //Make a Python command
1162 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1163 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1169 //=============================================================================
1171 * MakeTangentPlaneOnFace
1173 //=============================================================================
1175 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1182 if (theFace.IsNull()) return NULL;
1184 //Add a new Plane object
1185 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1187 //Add a new Plane function
1188 Handle(GEOM_Function) aFunction =
1189 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1191 //Check if the function is set correctly
1192 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1194 GEOMImpl_IPlane aPI (aFunction);
1196 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1197 if (aRef.IsNull()) return NULL;
1200 aPI.SetSize(theSize);
1201 aPI.SetParameterU(theParamU);
1202 aPI.SetParameterV(theParamV);
1204 //Compute the Plane value
1206 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1209 if (!GetSolver()->ComputeFunction(aFunction)) {
1210 SetErrorCode("Plane driver failed");
1214 catch (Standard_Failure) {
1215 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1216 SetErrorCode(aFail->GetMessageString());
1220 //Make a Python command
1221 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1222 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";