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
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,
194 Handle(GEOM_Object) theRefPoint)
198 if (theGeomObj.IsNull()) return NULL;
200 //Add a new Point object
201 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
203 //Add a new Point function for creation a point relativley another point
204 int fType = POINT_CURVE_PAR;
205 switch( theLocation )
207 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
208 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
209 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
210 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
211 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
214 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
216 //Check if the function is set correctly
217 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
219 GEOMImpl_IPoint aPI (aFunction);
221 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
222 if (aRefFunction.IsNull()) return NULL;
224 switch( theLocation )
226 case PointOn_CurveByParam:
227 aPI.SetCurve(aRefFunction);
228 aPI.SetParameter(theParam1);
230 case PointOn_CurveByLength:
231 aPI.SetCurve(aRefFunction);
232 aPI.SetLength(theParam1);
233 if (!theRefPoint.IsNull()) {
234 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
235 aPI.SetRef(aRefPoint);
238 case PointOn_CurveByCoord:
239 aPI.SetCurve(aRefFunction);
244 case PointOn_SurfaceByParam:
245 aPI.SetSurface(aRefFunction);
246 aPI.SetParameter(theParam1);
247 aPI.SetParameter2(theParam2);
249 case PointOn_SurfaceByCoord:
250 aPI.SetSurface(aRefFunction);
257 //Compute the point value
259 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
262 if (!GetSolver()->ComputeFunction(aFunction)) {
263 SetErrorCode("Point driver failed");
267 catch (Standard_Failure) {
268 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
269 SetErrorCode(aFail->GetMessageString());
273 //Make a Python command
274 switch( theLocation )
276 case PointOn_CurveByParam:
277 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
278 << theGeomObj << ", " << theParam1 << ")";
280 case PointOn_CurveByLength:
281 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
282 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
284 case PointOn_CurveByCoord:
285 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
286 << theGeomObj << ", " << theParam1
287 << ", " << theParam2 << ", " << theParam3 << ")";
289 case PointOn_SurfaceByParam:
290 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
291 << theGeomObj << ", " << theParam1
292 << ", " << theParam2 << ")";
294 case PointOn_SurfaceByCoord:
295 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
296 << theGeomObj << ", " << theParam1
297 << ", " << theParam2 << ", " << theParam3 << ")";
305 //=============================================================================
309 //=============================================================================
310 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
311 (Handle(GEOM_Object) theCurve, double theParameter)
313 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
316 //=============================================================================
318 * MakePointOnCurveByCoord
320 //=============================================================================
321 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
322 (Handle(GEOM_Object) theCurve,
327 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
330 //=============================================================================
332 * MakePointOnCurveByLength
334 //=============================================================================
335 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
336 (Handle(GEOM_Object) theCurve,
338 Handle(GEOM_Object) theStartPoint)
340 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
343 //=============================================================================
347 //=============================================================================
348 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
349 (Handle(GEOM_Object) theSurface,
350 double theUParameter,
351 double theVParameter)
353 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
356 //=============================================================================
358 * MakePointOnSurfaceByCoord
360 //=============================================================================
361 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
362 (Handle(GEOM_Object) theSurface,
367 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
371 //=============================================================================
373 * MakePointOnLinesIntersection
375 //=============================================================================
376 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
377 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
381 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
383 //Add a new Point object
384 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
386 //Add a new Point function for creation a point relativley another point
387 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
389 //Check if the function is set correctly
390 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
392 GEOMImpl_IPoint aPI (aFunction);
394 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
395 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
396 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
401 //Compute the point value
403 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
406 if (!GetSolver()->ComputeFunction(aFunction)) {
407 SetErrorCode("Point driver failed");
411 catch (Standard_Failure) {
412 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
413 SetErrorCode(aFail->GetMessageString());
417 //Make a Python command
418 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
419 << theLine1 << ", " << theLine2 << ")";
425 //=============================================================================
429 //=============================================================================
430 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
431 (const Handle(GEOM_Object)& theCurve, double theParameter)
435 if (theCurve.IsNull()) return NULL;
437 //Add a new Vector object
438 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
440 //Add a new Point function for creation a point relativley another point
441 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
443 //Check if the function is set correctly
444 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
446 GEOMImpl_IVector aVI (aFunction);
448 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
449 if (aRefFunction.IsNull()) return NULL;
451 aVI.SetCurve(aRefFunction);
452 aVI.SetParameter(theParameter);
454 //Compute the vector value
456 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
459 if (!GetSolver()->ComputeFunction(aFunction)) {
460 SetErrorCode("Vector driver failed");
464 catch (Standard_Failure) {
465 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
466 SetErrorCode(aFail->GetMessageString());
470 //Make a Python command
471 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
472 << theCurve << ", " << theParameter << ")";
478 //=============================================================================
482 //=============================================================================
483 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
484 (double theDX, double theDY, double theDZ)
488 //Add a new Vector object
489 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
491 //Add a new Vector function with DXDYDZ parameters
492 Handle(GEOM_Function) aFunction =
493 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
494 if (aFunction.IsNull()) return NULL;
496 //Check if the function is set correctly
497 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
499 GEOMImpl_IVector aPI (aFunction);
505 //Compute the Vector value
507 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
510 if (!GetSolver()->ComputeFunction(aFunction)) {
511 SetErrorCode("Vector driver failed");
515 catch (Standard_Failure) {
516 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
517 SetErrorCode(aFail->GetMessageString());
521 //Make a Python command
522 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
523 << theDX << ", " << theDY << ", " << theDZ << ")";
529 //=============================================================================
533 //=============================================================================
534 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
535 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
539 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
541 //Add a new Vector object
542 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
544 //Add a new Vector function
545 Handle(GEOM_Function) aFunction =
546 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
548 //Check if the function is set correctly
549 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
551 GEOMImpl_IVector aPI (aFunction);
553 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
554 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
555 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
557 aPI.SetPoint1(aRef1);
558 aPI.SetPoint2(aRef2);
560 //Compute the Vector value
562 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
565 if (!GetSolver()->ComputeFunction(aFunction)) {
566 SetErrorCode("Vector driver failed");
570 catch (Standard_Failure) {
571 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
572 SetErrorCode(aFail->GetMessageString());
576 //Make a Python command
577 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
578 << thePnt1 << ", " << thePnt2 << ")";
585 //=============================================================================
589 //=============================================================================
590 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
591 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
595 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
597 //Add a new Line object
598 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
600 //Add a new Line function
601 Handle(GEOM_Function) aFunction =
602 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
604 //Check if the function is set correctly
605 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
607 GEOMImpl_ILine aPI (aFunction);
609 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
610 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
611 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
613 aPI.SetPoint1(aRef1);
614 aPI.SetPoint2(aRef2);
616 //Compute the Line value
618 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
621 if (!GetSolver()->ComputeFunction(aFunction)) {
622 SetErrorCode("Line driver failed");
626 catch (Standard_Failure) {
627 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
628 SetErrorCode(aFail->GetMessageString());
632 //Make a Python command
633 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
634 << thePnt << ", " << theDir << ")";
640 //=============================================================================
644 //=============================================================================
645 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
646 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
650 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
652 //Add a new Line object
653 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
655 //Add a new Line function
656 Handle(GEOM_Function) aFunction =
657 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
659 //Check if the function is set correctly
660 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
662 GEOMImpl_ILine aPI (aFunction);
664 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
665 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
666 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
668 aPI.SetPoint1(aRef1);
669 aPI.SetPoint2(aRef2);
671 //Compute the Line value
673 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
676 if (!GetSolver()->ComputeFunction(aFunction)) {
677 SetErrorCode("Line driver failed");
681 catch (Standard_Failure) {
682 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
683 SetErrorCode(aFail->GetMessageString());
687 //Make a Python command
688 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
689 << thePnt1 << ", " << thePnt2 << ")";
695 //=============================================================================
699 //=============================================================================
700 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
701 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
705 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
707 //Add a new Line object
708 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
710 //Add a new Line function
711 Handle(GEOM_Function) aFunction =
712 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
714 //Check if the function is set correctly
715 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
717 GEOMImpl_ILine aPI (aFunction);
719 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
720 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
721 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
726 //Compute the Line value
728 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
731 if (!GetSolver()->ComputeFunction(aFunction)) {
732 SetErrorCode("Line driver failed");
736 catch (Standard_Failure) {
737 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
738 SetErrorCode(aFail->GetMessageString());
742 //Make a Python command
743 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
744 << theFace1 << ", " << theFace2 << ")";
750 //=============================================================================
754 //=============================================================================
755 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
756 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
757 Handle(GEOM_Object) thePnt3, double theSize)
761 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
763 //Add a new Plane object
764 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
766 //Add a new Plane function
767 Handle(GEOM_Function) aFunction =
768 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
770 //Check if the function is set correctly
771 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
773 GEOMImpl_IPlane aPI (aFunction);
775 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
776 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
777 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
778 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
780 aPI.SetPoint1(aRef1);
781 aPI.SetPoint2(aRef2);
782 aPI.SetPoint3(aRef3);
783 aPI.SetSize(theSize);
785 //Compute the Plane value
787 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
790 if (!GetSolver()->ComputeFunction(aFunction)) {
791 SetErrorCode("Plane driver failed");
795 catch (Standard_Failure) {
796 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
797 SetErrorCode(aFail->GetMessageString());
801 //Make a Python command
802 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
803 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
809 //=============================================================================
813 //=============================================================================
814 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
815 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
820 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
822 //Add a new Plane object
823 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
825 //Add a new Plane function
826 Handle(GEOM_Function) aFunction =
827 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
829 //Check if the function is set correctly
830 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
832 GEOMImpl_IPlane aPI (aFunction);
834 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
835 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
836 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
838 aPI.SetPoint(aRefPnt);
839 aPI.SetVector(aRefVec);
840 aPI.SetSize(theSize);
842 //Compute the Plane value
844 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
847 if (!GetSolver()->ComputeFunction(aFunction)) {
848 SetErrorCode("Plane driver failed");
852 catch (Standard_Failure) {
853 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
854 SetErrorCode(aFail->GetMessageString());
858 //Make a Python command
859 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
860 << thePnt << ", " << theVec << ", " << theSize << ")";
866 //=============================================================================
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
872 (Handle(GEOM_Object) theFace, double theSize)
876 if (theFace.IsNull()) return NULL;
878 //Add a new Plane object
879 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
881 //Add a new Plane function
882 Handle(GEOM_Function) aFunction =
883 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
885 //Check if the function is set correctly
886 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
888 GEOMImpl_IPlane aPI (aFunction);
890 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
891 if (aRef.IsNull()) return NULL;
894 aPI.SetSize(theSize);
896 //Compute the Plane value
898 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
901 if (!GetSolver()->ComputeFunction(aFunction)) {
902 SetErrorCode("Plane driver failed");
906 catch (Standard_Failure) {
907 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
908 SetErrorCode(aFail->GetMessageString());
912 //Make a Python command
913 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
914 << theFace << ", " << theSize << ")";
920 //=============================================================================
924 //=============================================================================
925 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
926 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
931 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
933 //Add a new Plane object
934 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
936 //Add a new Plane function
937 Handle(GEOM_Function) aFunction =
938 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
940 //Check if the function is set correctly
941 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
943 GEOMImpl_IPlane aPI (aFunction);
945 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
946 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
947 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
949 aPI.SetVector1(aRefVec1);
950 aPI.SetVector2(aRefVec2);
951 aPI.SetSize(theSize);
953 //Compute the Plane value
955 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
958 if (!GetSolver()->ComputeFunction(aFunction)) {
959 SetErrorCode("Plane driver failed");
963 catch (Standard_Failure) {
964 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
965 SetErrorCode(aFail->GetMessageString());
969 //Make a Python command
970 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
971 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
977 //=============================================================================
981 //=============================================================================
982 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
983 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
987 //Add a new Plane object
988 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
990 //Add a new Plane function
991 Handle(GEOM_Function) aFunction =
992 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
994 //Check if the function is set correctly
995 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
997 GEOMImpl_IPlane aPI (aFunction);
999 if ( !theLCS.IsNull() ) {
1000 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1004 aPI.SetSize(theSize);
1005 aPI.SetOrientation(theOrientation);
1007 //Compute the Plane value
1009 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1012 if (!GetSolver()->ComputeFunction(aFunction)) {
1013 SetErrorCode("Plane driver failed");
1017 catch (Standard_Failure) {
1018 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1019 SetErrorCode(aFail->GetMessageString());
1023 //Make a Python command
1024 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1025 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1032 //=============================================================================
1036 //=============================================================================
1037 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1038 (double theOX, double theOY, double theOZ,
1039 double theXDX, double theXDY, double theXDZ,
1040 double theYDX, double theYDY, double theYDZ)
1044 //Add a new Marker object
1045 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1047 //Add a new Marker function
1048 Handle(GEOM_Function) aFunction =
1049 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1050 if (aFunction.IsNull()) return NULL;
1052 //Check if the function is set correctly
1053 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1055 GEOMImpl_IMarker aPI(aFunction);
1057 aPI.SetOrigin(theOX, theOY, theOZ);
1058 aPI.SetXDir(theXDX, theXDY, theXDZ);
1059 aPI.SetYDir(theYDX, theYDY, theYDZ);
1061 //Compute the marker value
1063 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1066 if (!GetSolver()->ComputeFunction(aFunction)) {
1067 SetErrorCode("Marker driver failed");
1071 catch (Standard_Failure) {
1072 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1073 SetErrorCode(aFail->GetMessageString());
1077 //Make a Python command
1078 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1079 << theOX << ", " << theOY << ", " << theOZ << ", "
1080 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1081 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1087 //=============================================================================
1089 * MakeMarkerFromShape
1091 //=============================================================================
1092 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1093 (const Handle(GEOM_Object)& theShape)
1097 //Add a new Marker object
1098 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1100 //Add a new Marker function
1101 Handle(GEOM_Function) aFunction =
1102 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1103 if (aFunction.IsNull()) return NULL;
1105 //Check if the function is set correctly
1106 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1108 GEOMImpl_IMarker aPI(aFunction);
1110 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1111 if (aRefShape.IsNull()) return NULL;
1113 aPI.SetShape(aRefShape);
1115 //Compute the marker value
1117 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1120 if (!GetSolver()->ComputeFunction(aFunction)) {
1121 SetErrorCode("Marker driver failed");
1125 catch (Standard_Failure) {
1126 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1127 SetErrorCode(aFail->GetMessageString());
1131 //Make a Python command
1132 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1138 //=============================================================================
1140 * MakeMarkerPntTwoVec
1142 //=============================================================================
1143 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1144 (const Handle(GEOM_Object)& theOrigin,
1145 const Handle(GEOM_Object)& theXVec,
1146 const Handle(GEOM_Object)& theYVec)
1150 //Add a new Marker object
1151 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1153 //Add a new Marker function
1154 Handle(GEOM_Function) aFunction =
1155 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1156 if (aFunction.IsNull()) return NULL;
1158 //Check if the function is set correctly
1159 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1161 GEOMImpl_IMarker aPI(aFunction);
1163 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1164 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1165 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1166 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1168 aPI.SetOrigin(aRefOrigin);
1169 aPI.SetXVec(aRefXVec);
1170 aPI.SetYVec(aRefYVec);
1172 //Compute the marker value
1174 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1177 if (!GetSolver()->ComputeFunction(aFunction)) {
1178 SetErrorCode("Marker driver failed");
1182 catch (Standard_Failure) {
1183 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1184 SetErrorCode(aFail->GetMessageString());
1188 //Make a Python command
1189 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1190 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1196 //=============================================================================
1198 * MakeTangentPlaneOnFace
1200 //=============================================================================
1202 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1209 if (theFace.IsNull()) return NULL;
1211 //Add a new Plane object
1212 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1214 //Add a new Plane function
1215 Handle(GEOM_Function) aFunction =
1216 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1218 //Check if the function is set correctly
1219 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1221 GEOMImpl_IPlane aPI (aFunction);
1223 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1224 if (aRef.IsNull()) return NULL;
1227 aPI.SetSize(theSize);
1228 aPI.SetParameterU(theParamU);
1229 aPI.SetParameterV(theParamV);
1231 //Compute the Plane value
1233 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1236 if (!GetSolver()->ComputeFunction(aFunction)) {
1237 SetErrorCode("Plane driver failed");
1241 catch (Standard_Failure) {
1242 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1243 SetErrorCode(aFail->GetMessageString());
1247 //Make a Python command
1248 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1249 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";