1 // Copyright (C) 2007-2010 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
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 <TFunction_Logbook.hxx>
34 #include <TDF_Tool.hxx>
36 #include <GEOM_Function.hxx>
37 #include <GEOM_PythonDump.hxx>
39 #include <GEOMImpl_PointDriver.hxx>
40 #include <GEOMImpl_VectorDriver.hxx>
41 #include <GEOMImpl_LineDriver.hxx>
42 #include <GEOMImpl_PlaneDriver.hxx>
43 #include <GEOMImpl_MarkerDriver.hxx>
45 #include <GEOMImpl_IPoint.hxx>
46 #include <GEOMImpl_IVector.hxx>
47 #include <GEOMImpl_ILine.hxx>
48 #include <GEOMImpl_IPlane.hxx>
49 #include <GEOMImpl_IMarker.hxx>
51 #include <GEOMImpl_Types.hxx>
53 #include <Standard_Failure.hxx>
54 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
56 //=============================================================================
60 //=============================================================================
61 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
62 : GEOM_IOperations(theEngine, theDocID)
64 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
67 //=============================================================================
71 //=============================================================================
72 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
74 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
78 //=============================================================================
82 //=============================================================================
83 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
84 (double theX, double theY, double theZ)
88 //Add a new Point object
89 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
91 //Add a new Point function with XYZ parameters
92 Handle(GEOM_Function) aFunction =
93 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
94 if (aFunction.IsNull()) return NULL;
96 //Check if the function is set correctly
97 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
99 GEOMImpl_IPoint aPI(aFunction);
105 //Compute the point value
107 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
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
162 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
165 if (!GetSolver()->ComputeFunction(aFunction)) {
166 SetErrorCode("Point driver failed");
170 catch (Standard_Failure) {
171 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
172 SetErrorCode(aFail->GetMessageString());
176 //Make a Python command
177 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
178 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
184 //=============================================================================
188 //=============================================================================
189 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
190 (Handle(GEOM_Object) theGeomObj,
194 const PointLocation theLocation)
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_CurveByCoord: fType = POINT_CURVE_COORD; break;
209 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
210 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
213 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
215 //Check if the function is set correctly
216 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
218 GEOMImpl_IPoint aPI (aFunction);
220 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
221 if (aRefFunction.IsNull()) return NULL;
223 switch( theLocation )
225 case PointOn_CurveByParam:
226 aPI.SetCurve(aRefFunction);
227 aPI.SetParameter(theParam1);
229 case PointOn_CurveByCoord:
230 aPI.SetCurve(aRefFunction);
235 case PointOn_SurfaceByParam:
236 aPI.SetSurface(aRefFunction);
237 aPI.SetParameter(theParam1);
238 aPI.SetParameter2(theParam2);
240 case PointOn_SurfaceByCoord:
241 aPI.SetSurface(aRefFunction);
248 //Compute the point value
250 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
253 if (!GetSolver()->ComputeFunction(aFunction)) {
254 SetErrorCode("Point driver failed");
258 catch (Standard_Failure) {
259 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
260 SetErrorCode(aFail->GetMessageString());
264 //Make a Python command
265 switch( theLocation )
267 case PointOn_CurveByParam:
268 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
269 << theGeomObj << ", " << theParam1 << ")";
271 case PointOn_CurveByCoord:
272 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
273 << theGeomObj << ", " << theParam1
274 << ", " << theParam2 << ", " << theParam3 << ")";
276 case PointOn_SurfaceByParam:
277 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
278 << theGeomObj << ", " << theParam1
279 << ", " << theParam2 << ")";
281 case PointOn_SurfaceByCoord:
282 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
283 << theGeomObj << ", " << theParam1
284 << ", " << theParam2 << ", " << theParam3 << ")";
292 //=============================================================================
296 //=============================================================================
297 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
298 (Handle(GEOM_Object) theCurve, double theParameter)
300 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
303 //=============================================================================
305 * MakePointOnCurveByCoord
307 //=============================================================================
308 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
309 (Handle(GEOM_Object) theCurve,
314 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
317 //=============================================================================
321 //=============================================================================
322 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
323 (Handle(GEOM_Object) theSurface,
324 double theUParameter,
325 double theVParameter)
327 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
330 //=============================================================================
332 * MakePointOnSurfaceByCoord
334 //=============================================================================
335 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
336 (Handle(GEOM_Object) theSurface,
341 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
345 //=============================================================================
347 * MakePointOnLinesIntersection
349 //=============================================================================
350 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
351 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
355 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
357 //Add a new Point object
358 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
360 //Add a new Point function for creation a point relativley another point
361 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
363 //Check if the function is set correctly
364 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
366 GEOMImpl_IPoint aPI (aFunction);
368 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
369 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
370 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
375 //Compute the point value
377 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
380 if (!GetSolver()->ComputeFunction(aFunction)) {
381 SetErrorCode("Point driver failed");
385 catch (Standard_Failure) {
386 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
387 SetErrorCode(aFail->GetMessageString());
391 //Make a Python command
392 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
393 << theLine1 << ", " << theLine2 << ")";
399 //=============================================================================
403 //=============================================================================
404 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
405 (const Handle(GEOM_Object)& theCurve, double theParameter)
409 if (theCurve.IsNull()) return NULL;
411 //Add a new Vector object
412 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
414 //Add a new Point function for creation a point relativley another point
415 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
417 //Check if the function is set correctly
418 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
420 GEOMImpl_IVector aVI (aFunction);
422 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
423 if (aRefFunction.IsNull()) return NULL;
425 aVI.SetCurve(aRefFunction);
426 aVI.SetParameter(theParameter);
428 //Compute the vector value
430 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
433 if (!GetSolver()->ComputeFunction(aFunction)) {
434 SetErrorCode("Vector driver failed");
438 catch (Standard_Failure) {
439 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
440 SetErrorCode(aFail->GetMessageString());
444 //Make a Python command
445 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
446 << theCurve << ", " << theParameter << ")";
452 //=============================================================================
456 //=============================================================================
457 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
458 (double theDX, double theDY, double theDZ)
462 //Add a new Vector object
463 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
465 //Add a new Vector function with DXDYDZ parameters
466 Handle(GEOM_Function) aFunction =
467 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
468 if (aFunction.IsNull()) return NULL;
470 //Check if the function is set correctly
471 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
473 GEOMImpl_IVector aPI (aFunction);
479 //Compute the Vector value
481 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
484 if (!GetSolver()->ComputeFunction(aFunction)) {
485 SetErrorCode("Vector driver failed");
489 catch (Standard_Failure) {
490 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
491 SetErrorCode(aFail->GetMessageString());
495 //Make a Python command
496 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
497 << theDX << ", " << theDY << ", " << theDZ << ")";
503 //=============================================================================
507 //=============================================================================
508 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
509 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
513 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
515 //Add a new Vector object
516 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
518 //Add a new Vector function
519 Handle(GEOM_Function) aFunction =
520 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
522 //Check if the function is set correctly
523 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
525 GEOMImpl_IVector aPI (aFunction);
527 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
528 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
529 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
531 aPI.SetPoint1(aRef1);
532 aPI.SetPoint2(aRef2);
534 //Compute the Vector value
536 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
539 if (!GetSolver()->ComputeFunction(aFunction)) {
540 SetErrorCode("Vector driver failed");
544 catch (Standard_Failure) {
545 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
546 SetErrorCode(aFail->GetMessageString());
550 //Make a Python command
551 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
552 << thePnt1 << ", " << thePnt2 << ")";
559 //=============================================================================
563 //=============================================================================
564 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
565 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
569 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
571 //Add a new Line object
572 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
574 //Add a new Line function
575 Handle(GEOM_Function) aFunction =
576 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
578 //Check if the function is set correctly
579 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
581 GEOMImpl_ILine aPI (aFunction);
583 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
584 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
585 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
587 aPI.SetPoint1(aRef1);
588 aPI.SetPoint2(aRef2);
590 //Compute the Line value
592 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
595 if (!GetSolver()->ComputeFunction(aFunction)) {
596 SetErrorCode("Line driver failed");
600 catch (Standard_Failure) {
601 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
602 SetErrorCode(aFail->GetMessageString());
606 //Make a Python command
607 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
608 << thePnt << ", " << theDir << ")";
614 //=============================================================================
618 //=============================================================================
619 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
620 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
624 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
626 //Add a new Line object
627 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
629 //Add a new Line function
630 Handle(GEOM_Function) aFunction =
631 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
633 //Check if the function is set correctly
634 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
636 GEOMImpl_ILine aPI (aFunction);
638 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
639 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
640 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
642 aPI.SetPoint1(aRef1);
643 aPI.SetPoint2(aRef2);
645 //Compute the Line value
647 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
650 if (!GetSolver()->ComputeFunction(aFunction)) {
651 SetErrorCode("Line driver failed");
655 catch (Standard_Failure) {
656 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
657 SetErrorCode(aFail->GetMessageString());
661 //Make a Python command
662 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
663 << thePnt1 << ", " << thePnt2 << ")";
669 //=============================================================================
673 //=============================================================================
674 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
675 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
679 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
681 //Add a new Line object
682 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
684 //Add a new Line function
685 Handle(GEOM_Function) aFunction =
686 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
688 //Check if the function is set correctly
689 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
691 GEOMImpl_ILine aPI (aFunction);
693 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
694 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
695 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
700 //Compute the Line value
702 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
705 if (!GetSolver()->ComputeFunction(aFunction)) {
706 SetErrorCode("Line driver failed");
710 catch (Standard_Failure) {
711 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
712 SetErrorCode(aFail->GetMessageString());
716 //Make a Python command
717 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
718 << theFace1 << ", " << theFace2 << ")";
724 //=============================================================================
728 //=============================================================================
729 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
730 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
731 Handle(GEOM_Object) thePnt3, double theSize)
735 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
737 //Add a new Plane object
738 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
740 //Add a new Plane function
741 Handle(GEOM_Function) aFunction =
742 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
744 //Check if the function is set correctly
745 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
747 GEOMImpl_IPlane aPI (aFunction);
749 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
750 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
751 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
752 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
754 aPI.SetPoint1(aRef1);
755 aPI.SetPoint2(aRef2);
756 aPI.SetPoint3(aRef3);
757 aPI.SetSize(theSize);
759 //Compute the Plane value
761 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
764 if (!GetSolver()->ComputeFunction(aFunction)) {
765 SetErrorCode("Plane driver failed");
769 catch (Standard_Failure) {
770 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
771 SetErrorCode(aFail->GetMessageString());
775 //Make a Python command
776 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
777 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
783 //=============================================================================
787 //=============================================================================
788 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
789 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
794 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
796 //Add a new Plane object
797 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
799 //Add a new Plane function
800 Handle(GEOM_Function) aFunction =
801 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
803 //Check if the function is set correctly
804 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
806 GEOMImpl_IPlane aPI (aFunction);
808 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
809 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
810 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
812 aPI.SetPoint(aRefPnt);
813 aPI.SetVector(aRefVec);
814 aPI.SetSize(theSize);
816 //Compute the Plane value
818 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
821 if (!GetSolver()->ComputeFunction(aFunction)) {
822 SetErrorCode("Plane driver failed");
826 catch (Standard_Failure) {
827 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
828 SetErrorCode(aFail->GetMessageString());
832 //Make a Python command
833 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
834 << thePnt << ", " << theVec << ", " << theSize << ")";
840 //=============================================================================
844 //=============================================================================
845 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
846 (Handle(GEOM_Object) theFace, double theSize)
850 if (theFace.IsNull()) return NULL;
852 //Add a new Plane object
853 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
855 //Add a new Plane function
856 Handle(GEOM_Function) aFunction =
857 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
859 //Check if the function is set correctly
860 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
862 GEOMImpl_IPlane aPI (aFunction);
864 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
865 if (aRef.IsNull()) return NULL;
868 aPI.SetSize(theSize);
870 //Compute the Plane value
872 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
875 if (!GetSolver()->ComputeFunction(aFunction)) {
876 SetErrorCode("Plane driver failed");
880 catch (Standard_Failure) {
881 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
882 SetErrorCode(aFail->GetMessageString());
886 //Make a Python command
887 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
888 << theFace << ", " << theSize << ")";
894 //=============================================================================
898 //=============================================================================
899 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
900 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
905 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
907 //Add a new Plane object
908 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
910 //Add a new Plane function
911 Handle(GEOM_Function) aFunction =
912 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
914 //Check if the function is set correctly
915 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
917 GEOMImpl_IPlane aPI (aFunction);
919 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
920 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
921 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
923 aPI.SetVector1(aRefVec1);
924 aPI.SetVector2(aRefVec2);
925 aPI.SetSize(theSize);
927 //Compute the Plane value
929 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
932 if (!GetSolver()->ComputeFunction(aFunction)) {
933 SetErrorCode("Plane driver failed");
937 catch (Standard_Failure) {
938 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
939 SetErrorCode(aFail->GetMessageString());
943 //Make a Python command
944 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
945 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
951 //=============================================================================
955 //=============================================================================
956 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
957 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
961 //Add a new Plane object
962 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
964 //Add a new Plane function
965 Handle(GEOM_Function) aFunction =
966 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
968 //Check if the function is set correctly
969 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
971 GEOMImpl_IPlane aPI (aFunction);
973 if ( !theLCS.IsNull() ) {
974 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
978 aPI.SetSize(theSize);
979 aPI.SetOrientation(theOrientation);
981 //Compute the Plane value
983 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
986 if (!GetSolver()->ComputeFunction(aFunction)) {
987 SetErrorCode("Plane driver failed");
991 catch (Standard_Failure) {
992 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
993 SetErrorCode(aFail->GetMessageString());
997 //Make a Python command
998 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
999 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1006 //=============================================================================
1010 //=============================================================================
1011 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1012 (double theOX, double theOY, double theOZ,
1013 double theXDX, double theXDY, double theXDZ,
1014 double theYDX, double theYDY, double theYDZ)
1018 //Add a new Marker object
1019 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1021 //Add a new Marker function
1022 Handle(GEOM_Function) aFunction =
1023 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1024 if (aFunction.IsNull()) return NULL;
1026 //Check if the function is set correctly
1027 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1029 GEOMImpl_IMarker aPI(aFunction);
1031 aPI.SetOrigin(theOX, theOY, theOZ);
1032 aPI.SetXDir(theXDX, theXDY, theXDZ);
1033 aPI.SetYDir(theYDX, theYDY, theYDZ);
1035 //Compute the marker value
1037 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1040 if (!GetSolver()->ComputeFunction(aFunction)) {
1041 SetErrorCode("Marker driver failed");
1045 catch (Standard_Failure) {
1046 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1047 SetErrorCode(aFail->GetMessageString());
1051 //Make a Python command
1052 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1053 << theOX << ", " << theOY << ", " << theOZ << ", "
1054 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1055 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1061 //=============================================================================
1063 * MakeMarkerFromShape
1065 //=============================================================================
1066 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1067 (const Handle(GEOM_Object)& theShape)
1071 //Add a new Marker object
1072 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1074 //Add a new Marker function
1075 Handle(GEOM_Function) aFunction =
1076 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1077 if (aFunction.IsNull()) return NULL;
1079 //Check if the function is set correctly
1080 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1082 GEOMImpl_IMarker aPI(aFunction);
1084 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1085 if (aRefShape.IsNull()) return NULL;
1087 aPI.SetShape(aRefShape);
1089 //Compute the marker value
1091 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1094 if (!GetSolver()->ComputeFunction(aFunction)) {
1095 SetErrorCode("Marker driver failed");
1099 catch (Standard_Failure) {
1100 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1101 SetErrorCode(aFail->GetMessageString());
1105 //Make a Python command
1106 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1112 //=============================================================================
1114 * MakeMarkerPntTwoVec
1116 //=============================================================================
1117 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1118 (const Handle(GEOM_Object)& theOrigin,
1119 const Handle(GEOM_Object)& theXVec,
1120 const Handle(GEOM_Object)& theYVec)
1124 //Add a new Marker object
1125 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1127 //Add a new Marker function
1128 Handle(GEOM_Function) aFunction =
1129 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1130 if (aFunction.IsNull()) return NULL;
1132 //Check if the function is set correctly
1133 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1135 GEOMImpl_IMarker aPI(aFunction);
1137 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1138 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1139 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1140 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1142 aPI.SetOrigin(aRefOrigin);
1143 aPI.SetXVec(aRefXVec);
1144 aPI.SetYVec(aRefYVec);
1146 //Compute the marker value
1148 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1151 if (!GetSolver()->ComputeFunction(aFunction)) {
1152 SetErrorCode("Marker driver failed");
1156 catch (Standard_Failure) {
1157 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1158 SetErrorCode(aFail->GetMessageString());
1162 //Make a Python command
1163 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1164 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1170 //=============================================================================
1172 * MakeTangentPlaneOnFace
1174 //=============================================================================
1176 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1183 if (theFace.IsNull()) return NULL;
1185 //Add a new Plane object
1186 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1188 //Add a new Plane function
1189 Handle(GEOM_Function) aFunction =
1190 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1192 //Check if the function is set correctly
1193 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1195 GEOMImpl_IPlane aPI (aFunction);
1197 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1198 if (aRef.IsNull()) return NULL;
1201 aPI.SetSize(theSize);
1202 aPI.SetParameterU(theParamU);
1203 aPI.SetParameterV(theParamV);
1205 //Compute the Plane value
1207 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1210 if (!GetSolver()->ComputeFunction(aFunction)) {
1211 SetErrorCode("Plane driver failed");
1215 catch (Standard_Failure) {
1216 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1217 SetErrorCode(aFail->GetMessageString());
1221 //Make a Python command
1222 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1223 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";