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,
199 if (theGeomObj.IsNull()) return NULL;
201 //Add a new Point object
202 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
204 //Add a new Point function for creation a point relativley another point
205 int fType = POINT_CURVE_PAR;
206 switch( theLocation )
208 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
209 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
210 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
211 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
212 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; 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);
231 case PointOn_CurveByLength:
232 aPI.SetCurve(aRefFunction);
233 aPI.SetLength(theParam1);
234 aPI.SetReversed(theReverse);
236 case PointOn_CurveByCoord:
237 aPI.SetCurve(aRefFunction);
242 case PointOn_SurfaceByParam:
243 aPI.SetSurface(aRefFunction);
244 aPI.SetParameter(theParam1);
245 aPI.SetParameter2(theParam2);
247 case PointOn_SurfaceByCoord:
248 aPI.SetSurface(aRefFunction);
255 //Compute the point value
257 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
260 if (!GetSolver()->ComputeFunction(aFunction)) {
261 SetErrorCode("Point driver failed");
265 catch (Standard_Failure) {
266 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
267 SetErrorCode(aFail->GetMessageString());
271 //Make a Python command
272 switch( theLocation )
274 case PointOn_CurveByParam:
275 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
276 << theGeomObj << ", " << theParam1 << ")";
278 case PointOn_CurveByLength:
279 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
280 << theGeomObj << ", " << theParam1 << ", " << theReverse << ")";
282 case PointOn_CurveByCoord:
283 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
284 << theGeomObj << ", " << theParam1
285 << ", " << theParam2 << ", " << theParam3 << ")";
287 case PointOn_SurfaceByParam:
288 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
289 << theGeomObj << ", " << theParam1
290 << ", " << theParam2 << ")";
292 case PointOn_SurfaceByCoord:
293 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
294 << theGeomObj << ", " << theParam1
295 << ", " << theParam2 << ", " << theParam3 << ")";
303 //=============================================================================
307 //=============================================================================
308 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
309 (Handle(GEOM_Object) theCurve, double theParameter)
311 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
314 //=============================================================================
316 * MakePointOnCurveByCoord
318 //=============================================================================
319 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
320 (Handle(GEOM_Object) theCurve,
325 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
328 //=============================================================================
330 * MakePointOnCurveByLength
332 //=============================================================================
333 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
334 (Handle(GEOM_Object) theCurve,
338 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theReverse);
341 //=============================================================================
345 //=============================================================================
346 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
347 (Handle(GEOM_Object) theSurface,
348 double theUParameter,
349 double theVParameter)
351 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
354 //=============================================================================
356 * MakePointOnSurfaceByCoord
358 //=============================================================================
359 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
360 (Handle(GEOM_Object) theSurface,
365 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
369 //=============================================================================
371 * MakePointOnLinesIntersection
373 //=============================================================================
374 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
375 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
379 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
381 //Add a new Point object
382 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
384 //Add a new Point function for creation a point relativley another point
385 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
387 //Check if the function is set correctly
388 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
390 GEOMImpl_IPoint aPI (aFunction);
392 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
393 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
394 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
399 //Compute the point value
401 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
404 if (!GetSolver()->ComputeFunction(aFunction)) {
405 SetErrorCode("Point driver failed");
409 catch (Standard_Failure) {
410 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
411 SetErrorCode(aFail->GetMessageString());
415 //Make a Python command
416 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
417 << theLine1 << ", " << theLine2 << ")";
423 //=============================================================================
427 //=============================================================================
428 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
429 (const Handle(GEOM_Object)& theCurve, double theParameter)
433 if (theCurve.IsNull()) return NULL;
435 //Add a new Vector object
436 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
438 //Add a new Point function for creation a point relativley another point
439 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
441 //Check if the function is set correctly
442 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
444 GEOMImpl_IVector aVI (aFunction);
446 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
447 if (aRefFunction.IsNull()) return NULL;
449 aVI.SetCurve(aRefFunction);
450 aVI.SetParameter(theParameter);
452 //Compute the vector value
454 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
457 if (!GetSolver()->ComputeFunction(aFunction)) {
458 SetErrorCode("Vector driver failed");
462 catch (Standard_Failure) {
463 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
464 SetErrorCode(aFail->GetMessageString());
468 //Make a Python command
469 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
470 << theCurve << ", " << theParameter << ")";
476 //=============================================================================
480 //=============================================================================
481 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
482 (double theDX, double theDY, double theDZ)
486 //Add a new Vector object
487 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
489 //Add a new Vector function with DXDYDZ parameters
490 Handle(GEOM_Function) aFunction =
491 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
492 if (aFunction.IsNull()) return NULL;
494 //Check if the function is set correctly
495 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
497 GEOMImpl_IVector aPI (aFunction);
503 //Compute the Vector value
505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
508 if (!GetSolver()->ComputeFunction(aFunction)) {
509 SetErrorCode("Vector driver failed");
513 catch (Standard_Failure) {
514 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
515 SetErrorCode(aFail->GetMessageString());
519 //Make a Python command
520 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
521 << theDX << ", " << theDY << ", " << theDZ << ")";
527 //=============================================================================
531 //=============================================================================
532 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
533 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
537 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
539 //Add a new Vector object
540 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
542 //Add a new Vector function
543 Handle(GEOM_Function) aFunction =
544 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
546 //Check if the function is set correctly
547 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
549 GEOMImpl_IVector aPI (aFunction);
551 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
552 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
553 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
555 aPI.SetPoint1(aRef1);
556 aPI.SetPoint2(aRef2);
558 //Compute the Vector value
560 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
563 if (!GetSolver()->ComputeFunction(aFunction)) {
564 SetErrorCode("Vector driver failed");
568 catch (Standard_Failure) {
569 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
570 SetErrorCode(aFail->GetMessageString());
574 //Make a Python command
575 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
576 << thePnt1 << ", " << thePnt2 << ")";
583 //=============================================================================
587 //=============================================================================
588 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
589 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
593 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
595 //Add a new Line object
596 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
598 //Add a new Line function
599 Handle(GEOM_Function) aFunction =
600 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
602 //Check if the function is set correctly
603 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
605 GEOMImpl_ILine aPI (aFunction);
607 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
608 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
609 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
611 aPI.SetPoint1(aRef1);
612 aPI.SetPoint2(aRef2);
614 //Compute the Line value
616 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
619 if (!GetSolver()->ComputeFunction(aFunction)) {
620 SetErrorCode("Line driver failed");
624 catch (Standard_Failure) {
625 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
626 SetErrorCode(aFail->GetMessageString());
630 //Make a Python command
631 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
632 << thePnt << ", " << theDir << ")";
638 //=============================================================================
642 //=============================================================================
643 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
644 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
648 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
650 //Add a new Line object
651 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
653 //Add a new Line function
654 Handle(GEOM_Function) aFunction =
655 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
657 //Check if the function is set correctly
658 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
660 GEOMImpl_ILine aPI (aFunction);
662 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
663 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
664 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
666 aPI.SetPoint1(aRef1);
667 aPI.SetPoint2(aRef2);
669 //Compute the Line value
671 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
674 if (!GetSolver()->ComputeFunction(aFunction)) {
675 SetErrorCode("Line driver failed");
679 catch (Standard_Failure) {
680 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
681 SetErrorCode(aFail->GetMessageString());
685 //Make a Python command
686 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
687 << thePnt1 << ", " << thePnt2 << ")";
693 //=============================================================================
697 //=============================================================================
698 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
699 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
703 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
705 //Add a new Line object
706 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
708 //Add a new Line function
709 Handle(GEOM_Function) aFunction =
710 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
712 //Check if the function is set correctly
713 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
715 GEOMImpl_ILine aPI (aFunction);
717 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
718 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
719 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
724 //Compute the Line value
726 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
729 if (!GetSolver()->ComputeFunction(aFunction)) {
730 SetErrorCode("Line driver failed");
734 catch (Standard_Failure) {
735 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
736 SetErrorCode(aFail->GetMessageString());
740 //Make a Python command
741 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
742 << theFace1 << ", " << theFace2 << ")";
748 //=============================================================================
752 //=============================================================================
753 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
754 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
755 Handle(GEOM_Object) thePnt3, double theSize)
759 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
761 //Add a new Plane object
762 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
764 //Add a new Plane function
765 Handle(GEOM_Function) aFunction =
766 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
768 //Check if the function is set correctly
769 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
771 GEOMImpl_IPlane aPI (aFunction);
773 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
774 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
775 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
776 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
778 aPI.SetPoint1(aRef1);
779 aPI.SetPoint2(aRef2);
780 aPI.SetPoint3(aRef3);
781 aPI.SetSize(theSize);
783 //Compute the Plane value
785 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
788 if (!GetSolver()->ComputeFunction(aFunction)) {
789 SetErrorCode("Plane driver failed");
793 catch (Standard_Failure) {
794 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
795 SetErrorCode(aFail->GetMessageString());
799 //Make a Python command
800 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
801 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
807 //=============================================================================
811 //=============================================================================
812 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
813 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
818 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
820 //Add a new Plane object
821 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
823 //Add a new Plane function
824 Handle(GEOM_Function) aFunction =
825 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
827 //Check if the function is set correctly
828 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
830 GEOMImpl_IPlane aPI (aFunction);
832 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
833 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
834 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
836 aPI.SetPoint(aRefPnt);
837 aPI.SetVector(aRefVec);
838 aPI.SetSize(theSize);
840 //Compute the Plane value
842 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
845 if (!GetSolver()->ComputeFunction(aFunction)) {
846 SetErrorCode("Plane driver failed");
850 catch (Standard_Failure) {
851 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
852 SetErrorCode(aFail->GetMessageString());
856 //Make a Python command
857 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
858 << thePnt << ", " << theVec << ", " << theSize << ")";
864 //=============================================================================
868 //=============================================================================
869 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
870 (Handle(GEOM_Object) theFace, double theSize)
874 if (theFace.IsNull()) return NULL;
876 //Add a new Plane object
877 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
879 //Add a new Plane function
880 Handle(GEOM_Function) aFunction =
881 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
883 //Check if the function is set correctly
884 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
886 GEOMImpl_IPlane aPI (aFunction);
888 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
889 if (aRef.IsNull()) return NULL;
892 aPI.SetSize(theSize);
894 //Compute the Plane value
896 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
899 if (!GetSolver()->ComputeFunction(aFunction)) {
900 SetErrorCode("Plane driver failed");
904 catch (Standard_Failure) {
905 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
906 SetErrorCode(aFail->GetMessageString());
910 //Make a Python command
911 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
912 << theFace << ", " << theSize << ")";
918 //=============================================================================
922 //=============================================================================
923 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
924 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
929 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
931 //Add a new Plane object
932 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
934 //Add a new Plane function
935 Handle(GEOM_Function) aFunction =
936 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
938 //Check if the function is set correctly
939 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
941 GEOMImpl_IPlane aPI (aFunction);
943 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
944 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
945 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
947 aPI.SetVector1(aRefVec1);
948 aPI.SetVector2(aRefVec2);
949 aPI.SetSize(theSize);
951 //Compute the Plane value
953 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
956 if (!GetSolver()->ComputeFunction(aFunction)) {
957 SetErrorCode("Plane driver failed");
961 catch (Standard_Failure) {
962 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
963 SetErrorCode(aFail->GetMessageString());
967 //Make a Python command
968 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
969 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
975 //=============================================================================
979 //=============================================================================
980 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
981 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
985 //Add a new Plane object
986 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
988 //Add a new Plane function
989 Handle(GEOM_Function) aFunction =
990 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
992 //Check if the function is set correctly
993 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
995 GEOMImpl_IPlane aPI (aFunction);
997 if ( !theLCS.IsNull() ) {
998 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1002 aPI.SetSize(theSize);
1003 aPI.SetOrientation(theOrientation);
1005 //Compute the Plane value
1007 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1010 if (!GetSolver()->ComputeFunction(aFunction)) {
1011 SetErrorCode("Plane driver failed");
1015 catch (Standard_Failure) {
1016 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1017 SetErrorCode(aFail->GetMessageString());
1021 //Make a Python command
1022 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1023 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1030 //=============================================================================
1034 //=============================================================================
1035 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1036 (double theOX, double theOY, double theOZ,
1037 double theXDX, double theXDY, double theXDZ,
1038 double theYDX, double theYDY, double theYDZ)
1042 //Add a new Marker object
1043 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1045 //Add a new Marker function
1046 Handle(GEOM_Function) aFunction =
1047 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1048 if (aFunction.IsNull()) return NULL;
1050 //Check if the function is set correctly
1051 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1053 GEOMImpl_IMarker aPI(aFunction);
1055 aPI.SetOrigin(theOX, theOY, theOZ);
1056 aPI.SetXDir(theXDX, theXDY, theXDZ);
1057 aPI.SetYDir(theYDX, theYDY, theYDZ);
1059 //Compute the marker value
1061 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1064 if (!GetSolver()->ComputeFunction(aFunction)) {
1065 SetErrorCode("Marker driver failed");
1069 catch (Standard_Failure) {
1070 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1071 SetErrorCode(aFail->GetMessageString());
1075 //Make a Python command
1076 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1077 << theOX << ", " << theOY << ", " << theOZ << ", "
1078 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1079 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1085 //=============================================================================
1087 * MakeMarkerFromShape
1089 //=============================================================================
1090 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1091 (const Handle(GEOM_Object)& theShape)
1095 //Add a new Marker object
1096 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1098 //Add a new Marker function
1099 Handle(GEOM_Function) aFunction =
1100 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1101 if (aFunction.IsNull()) return NULL;
1103 //Check if the function is set correctly
1104 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1106 GEOMImpl_IMarker aPI(aFunction);
1108 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1109 if (aRefShape.IsNull()) return NULL;
1111 aPI.SetShape(aRefShape);
1113 //Compute the marker value
1115 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1118 if (!GetSolver()->ComputeFunction(aFunction)) {
1119 SetErrorCode("Marker driver failed");
1123 catch (Standard_Failure) {
1124 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1125 SetErrorCode(aFail->GetMessageString());
1129 //Make a Python command
1130 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1136 //=============================================================================
1138 * MakeMarkerPntTwoVec
1140 //=============================================================================
1141 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1142 (const Handle(GEOM_Object)& theOrigin,
1143 const Handle(GEOM_Object)& theXVec,
1144 const Handle(GEOM_Object)& theYVec)
1148 //Add a new Marker object
1149 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1151 //Add a new Marker function
1152 Handle(GEOM_Function) aFunction =
1153 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1154 if (aFunction.IsNull()) return NULL;
1156 //Check if the function is set correctly
1157 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1159 GEOMImpl_IMarker aPI(aFunction);
1161 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1162 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1163 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1164 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1166 aPI.SetOrigin(aRefOrigin);
1167 aPI.SetXVec(aRefXVec);
1168 aPI.SetYVec(aRefYVec);
1170 //Compute the marker value
1172 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1175 if (!GetSolver()->ComputeFunction(aFunction)) {
1176 SetErrorCode("Marker driver failed");
1180 catch (Standard_Failure) {
1181 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1182 SetErrorCode(aFail->GetMessageString());
1186 //Make a Python command
1187 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1188 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1194 //=============================================================================
1196 * MakeTangentPlaneOnFace
1198 //=============================================================================
1200 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1207 if (theFace.IsNull()) return NULL;
1209 //Add a new Plane object
1210 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1212 //Add a new Plane function
1213 Handle(GEOM_Function) aFunction =
1214 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1216 //Check if the function is set correctly
1217 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1219 GEOMImpl_IPlane aPI (aFunction);
1221 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1222 if (aRef.IsNull()) return NULL;
1225 aPI.SetSize(theSize);
1226 aPI.SetParameterU(theParamU);
1227 aPI.SetParameterV(theParamV);
1229 //Compute the Plane value
1231 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1234 if (!GetSolver()->ComputeFunction(aFunction)) {
1235 SetErrorCode("Plane driver failed");
1239 catch (Standard_Failure) {
1240 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1241 SetErrorCode(aFail->GetMessageString());
1245 //Make a Python command
1246 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1247 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";