1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_IBasicOperations.hxx>
27 #include <Basics_OCCTVersion.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_PointDriver.hxx>
42 #include <GEOMImpl_VectorDriver.hxx>
43 #include <GEOMImpl_LineDriver.hxx>
44 #include <GEOMImpl_PlaneDriver.hxx>
45 #include <GEOMImpl_MarkerDriver.hxx>
47 #include <GEOMImpl_IPoint.hxx>
48 #include <GEOMImpl_IVector.hxx>
49 #include <GEOMImpl_ILine.hxx>
50 #include <GEOMImpl_IPlane.hxx>
51 #include <GEOMImpl_IMarker.hxx>
53 #include <GEOMImpl_Types.hxx>
55 #include <Standard_Failure.hxx>
56 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
58 //=============================================================================
62 //=============================================================================
63 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
64 : GEOM_IOperations(theEngine, theDocID)
66 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
69 //=============================================================================
73 //=============================================================================
74 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
76 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
80 //=============================================================================
84 //=============================================================================
85 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
86 (double theX, double theY, double theZ)
90 //Add a new Point object
91 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
93 //Add a new Point function with XYZ parameters
94 Handle(GEOM_Function) aFunction =
95 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
96 if (aFunction.IsNull()) return NULL;
98 //Check if the function is set correctly
99 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
101 GEOMImpl_IPoint aPI(aFunction);
107 //Compute the point value
109 #if OCC_VERSION_LARGE > 0x06010000
112 if (!GetSolver()->ComputeFunction(aFunction)) {
113 SetErrorCode("Point driver failed");
117 catch (Standard_Failure) {
118 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
119 SetErrorCode(aFail->GetMessageString());
123 //Make a Python command
124 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
125 << theX << ", " << theY << ", " << theZ << ")";
131 //=============================================================================
133 * MakePointWithReference
135 //=============================================================================
136 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
137 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
141 if (theReference.IsNull()) return NULL;
143 //Add a new Point object
144 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
146 //Add a new Point function for creation a point relativley another point
147 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
149 //Check if the function is set correctly
150 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
152 GEOMImpl_IPoint aPI(aFunction);
154 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
155 if (aRefFunction.IsNull()) return NULL;
157 aPI.SetRef(aRefFunction);
162 //Compute the point value
164 #if OCC_VERSION_LARGE > 0x06010000
167 if (!GetSolver()->ComputeFunction(aFunction)) {
168 SetErrorCode("Point driver failed");
172 catch (Standard_Failure) {
173 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
174 SetErrorCode(aFail->GetMessageString());
178 //Make a Python command
179 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
180 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
186 //=============================================================================
190 //=============================================================================
191 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
192 (Handle(GEOM_Object) theGeomObj,
196 const PointLocation theLocation,
197 Handle(GEOM_Object) theRefPoint)
201 if (theGeomObj.IsNull()) return NULL;
203 //Add a new Point object
204 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
206 //Add a new Point function for creation a point relativley another point
207 int fType = POINT_CURVE_PAR;
208 switch( theLocation )
210 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
211 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
212 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
213 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
214 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
215 case PointOn_Face: fType = POINT_FACE_ANY; break;
218 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
220 //Check if the function is set correctly
221 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
223 GEOMImpl_IPoint aPI (aFunction);
225 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
226 if (aRefFunction.IsNull()) return NULL;
228 switch( theLocation )
230 case PointOn_CurveByParam:
231 aPI.SetCurve(aRefFunction);
232 aPI.SetParameter(theParam1);
234 case PointOn_CurveByLength:
235 aPI.SetCurve(aRefFunction);
236 aPI.SetLength(theParam1);
237 if (!theRefPoint.IsNull()) {
238 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
239 aPI.SetRef(aRefPoint);
242 case PointOn_CurveByCoord:
243 aPI.SetCurve(aRefFunction);
248 case PointOn_SurfaceByParam:
249 aPI.SetSurface(aRefFunction);
250 aPI.SetParameter(theParam1);
251 aPI.SetParameter2(theParam2);
253 case PointOn_SurfaceByCoord:
254 aPI.SetSurface(aRefFunction);
260 aPI.SetSurface(aRefFunction);
265 //Compute the point value
267 #if OCC_VERSION_LARGE > 0x06010000
270 if (!GetSolver()->ComputeFunction(aFunction)) {
271 SetErrorCode("Point driver failed");
275 catch (Standard_Failure) {
276 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
277 SetErrorCode(aFail->GetMessageString());
281 //Make a Python command
282 switch( theLocation )
284 case PointOn_CurveByParam:
285 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
286 << theGeomObj << ", " << theParam1 << ")";
288 case PointOn_CurveByLength:
289 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
290 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
292 case PointOn_CurveByCoord:
293 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
294 << theGeomObj << ", " << theParam1
295 << ", " << theParam2 << ", " << theParam3 << ")";
297 case PointOn_SurfaceByParam:
298 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
299 << theGeomObj << ", " << theParam1
300 << ", " << theParam2 << ")";
302 case PointOn_SurfaceByCoord:
303 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
304 << theGeomObj << ", " << theParam1
305 << ", " << theParam2 << ", " << theParam3 << ")";
308 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
309 << theGeomObj << ")";
318 //=============================================================================
322 //=============================================================================
323 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
324 (Handle(GEOM_Object) theCurve, double theParameter)
326 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
329 //=============================================================================
331 * MakePointOnCurveByCoord
333 //=============================================================================
334 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
335 (Handle(GEOM_Object) theCurve,
340 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
343 //=============================================================================
345 * MakePointOnCurveByLength
347 //=============================================================================
348 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
349 (Handle(GEOM_Object) theCurve,
351 Handle(GEOM_Object) theStartPoint)
353 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
356 //=============================================================================
360 //=============================================================================
361 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
362 (Handle(GEOM_Object) theSurface,
363 double theUParameter,
364 double theVParameter)
366 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
369 //=============================================================================
371 * MakePointOnSurfaceByCoord
373 //=============================================================================
374 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
375 (Handle(GEOM_Object) theSurface,
380 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
383 //=============================================================================
387 //=============================================================================
388 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
390 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
393 //=============================================================================
395 * MakePointOnLinesIntersection
397 //=============================================================================
398 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
399 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
403 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
405 //Add a new Point object
406 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
408 //Add a new Point function for creation a point relativley another point
409 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
411 //Check if the function is set correctly
412 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
414 GEOMImpl_IPoint aPI (aFunction);
416 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
417 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
418 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
423 //Compute the point value
425 #if OCC_VERSION_LARGE > 0x06010000
428 if (!GetSolver()->ComputeFunction(aFunction)) {
429 SetErrorCode("Point driver failed");
433 catch (Standard_Failure) {
434 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
435 SetErrorCode(aFail->GetMessageString());
439 //Make a Python command
440 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
441 << theLine1 << ", " << theLine2 << ")";
447 //=============================================================================
451 //=============================================================================
452 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
453 (const Handle(GEOM_Object)& theCurve, double theParameter)
457 if (theCurve.IsNull()) return NULL;
459 //Add a new Vector object
460 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
462 //Add a new Point function for creation a point relativley another point
463 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
465 //Check if the function is set correctly
466 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
468 GEOMImpl_IVector aVI (aFunction);
470 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
471 if (aRefFunction.IsNull()) return NULL;
473 aVI.SetCurve(aRefFunction);
474 aVI.SetParameter(theParameter);
476 //Compute the vector value
478 #if OCC_VERSION_LARGE > 0x06010000
481 if (!GetSolver()->ComputeFunction(aFunction)) {
482 SetErrorCode("Vector driver failed");
486 catch (Standard_Failure) {
487 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
488 SetErrorCode(aFail->GetMessageString());
492 //Make a Python command
493 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
494 << theCurve << ", " << theParameter << ")";
500 //=============================================================================
504 //=============================================================================
505 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
506 (double theDX, double theDY, double theDZ)
510 //Add a new Vector object
511 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
513 //Add a new Vector function with DXDYDZ parameters
514 Handle(GEOM_Function) aFunction =
515 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
516 if (aFunction.IsNull()) return NULL;
518 //Check if the function is set correctly
519 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
521 GEOMImpl_IVector aPI (aFunction);
527 //Compute the Vector value
529 #if OCC_VERSION_LARGE > 0x06010000
532 if (!GetSolver()->ComputeFunction(aFunction)) {
533 SetErrorCode("Vector driver failed");
537 catch (Standard_Failure) {
538 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
539 SetErrorCode(aFail->GetMessageString());
543 //Make a Python command
544 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
545 << theDX << ", " << theDY << ", " << theDZ << ")";
551 //=============================================================================
555 //=============================================================================
556 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
557 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
561 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
563 //Add a new Vector object
564 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
566 //Add a new Vector function
567 Handle(GEOM_Function) aFunction =
568 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
570 //Check if the function is set correctly
571 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
573 GEOMImpl_IVector aPI (aFunction);
575 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
576 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
577 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
579 aPI.SetPoint1(aRef1);
580 aPI.SetPoint2(aRef2);
582 //Compute the Vector value
584 #if OCC_VERSION_LARGE > 0x06010000
587 if (!GetSolver()->ComputeFunction(aFunction)) {
588 SetErrorCode("Vector driver failed");
592 catch (Standard_Failure) {
593 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
594 SetErrorCode(aFail->GetMessageString());
598 //Make a Python command
599 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
600 << thePnt1 << ", " << thePnt2 << ")";
607 //=============================================================================
611 //=============================================================================
612 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
613 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
617 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
619 //Add a new Line object
620 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
622 //Add a new Line function
623 Handle(GEOM_Function) aFunction =
624 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
626 //Check if the function is set correctly
627 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
629 GEOMImpl_ILine aPI (aFunction);
631 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
632 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
633 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
635 aPI.SetPoint1(aRef1);
636 aPI.SetPoint2(aRef2);
638 //Compute the Line value
640 #if OCC_VERSION_LARGE > 0x06010000
643 if (!GetSolver()->ComputeFunction(aFunction)) {
644 SetErrorCode("Line driver failed");
648 catch (Standard_Failure) {
649 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
650 SetErrorCode(aFail->GetMessageString());
654 //Make a Python command
655 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
656 << thePnt << ", " << theDir << ")";
662 //=============================================================================
666 //=============================================================================
667 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
668 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
672 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
674 //Add a new Line object
675 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
677 //Add a new Line function
678 Handle(GEOM_Function) aFunction =
679 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
681 //Check if the function is set correctly
682 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
684 GEOMImpl_ILine aPI (aFunction);
686 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
687 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
688 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
690 aPI.SetPoint1(aRef1);
691 aPI.SetPoint2(aRef2);
693 //Compute the Line value
695 #if OCC_VERSION_LARGE > 0x06010000
698 if (!GetSolver()->ComputeFunction(aFunction)) {
699 SetErrorCode("Line driver failed");
703 catch (Standard_Failure) {
704 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
705 SetErrorCode(aFail->GetMessageString());
709 //Make a Python command
710 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
711 << thePnt1 << ", " << thePnt2 << ")";
717 //=============================================================================
721 //=============================================================================
722 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
723 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
727 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
729 //Add a new Line object
730 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
732 //Add a new Line function
733 Handle(GEOM_Function) aFunction =
734 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
736 //Check if the function is set correctly
737 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
739 GEOMImpl_ILine aPI (aFunction);
741 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
742 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
743 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
748 //Compute the Line value
750 #if OCC_VERSION_LARGE > 0x06010000
753 if (!GetSolver()->ComputeFunction(aFunction)) {
754 SetErrorCode("Line driver failed");
758 catch (Standard_Failure) {
759 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
760 SetErrorCode(aFail->GetMessageString());
764 //Make a Python command
765 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
766 << theFace1 << ", " << theFace2 << ")";
772 //=============================================================================
776 //=============================================================================
777 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
778 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
779 Handle(GEOM_Object) thePnt3, double theSize)
783 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
785 //Add a new Plane object
786 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
788 //Add a new Plane function
789 Handle(GEOM_Function) aFunction =
790 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
792 //Check if the function is set correctly
793 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
795 GEOMImpl_IPlane aPI (aFunction);
797 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
798 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
799 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
800 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
802 aPI.SetPoint1(aRef1);
803 aPI.SetPoint2(aRef2);
804 aPI.SetPoint3(aRef3);
805 aPI.SetSize(theSize);
807 //Compute the Plane value
809 #if OCC_VERSION_LARGE > 0x06010000
812 if (!GetSolver()->ComputeFunction(aFunction)) {
813 SetErrorCode("Plane driver failed");
817 catch (Standard_Failure) {
818 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
819 SetErrorCode(aFail->GetMessageString());
823 //Make a Python command
824 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
825 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
831 //=============================================================================
835 //=============================================================================
836 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
837 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
842 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
844 //Add a new Plane object
845 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
847 //Add a new Plane function
848 Handle(GEOM_Function) aFunction =
849 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
851 //Check if the function is set correctly
852 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
854 GEOMImpl_IPlane aPI (aFunction);
856 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
857 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
858 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
860 aPI.SetPoint(aRefPnt);
861 aPI.SetVector(aRefVec);
862 aPI.SetSize(theSize);
864 //Compute the Plane value
866 #if OCC_VERSION_LARGE > 0x06010000
869 if (!GetSolver()->ComputeFunction(aFunction)) {
870 SetErrorCode("Plane driver failed");
874 catch (Standard_Failure) {
875 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
876 SetErrorCode(aFail->GetMessageString());
880 //Make a Python command
881 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
882 << thePnt << ", " << theVec << ", " << theSize << ")";
888 //=============================================================================
892 //=============================================================================
893 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
894 (Handle(GEOM_Object) theFace, double theSize)
898 if (theFace.IsNull()) return NULL;
900 //Add a new Plane object
901 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
903 //Add a new Plane function
904 Handle(GEOM_Function) aFunction =
905 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
907 //Check if the function is set correctly
908 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
910 GEOMImpl_IPlane aPI (aFunction);
912 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
913 if (aRef.IsNull()) return NULL;
916 aPI.SetSize(theSize);
918 //Compute the Plane value
920 #if OCC_VERSION_LARGE > 0x06010000
923 if (!GetSolver()->ComputeFunction(aFunction)) {
924 SetErrorCode("Plane driver failed");
928 catch (Standard_Failure) {
929 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
930 SetErrorCode(aFail->GetMessageString());
934 //Make a Python command
935 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
936 << theFace << ", " << theSize << ")";
942 //=============================================================================
946 //=============================================================================
947 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
948 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
953 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
955 //Add a new Plane object
956 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
958 //Add a new Plane function
959 Handle(GEOM_Function) aFunction =
960 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
962 //Check if the function is set correctly
963 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
965 GEOMImpl_IPlane aPI (aFunction);
967 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
968 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
969 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
971 aPI.SetVector1(aRefVec1);
972 aPI.SetVector2(aRefVec2);
973 aPI.SetSize(theSize);
975 //Compute the Plane value
977 #if OCC_VERSION_LARGE > 0x06010000
980 if (!GetSolver()->ComputeFunction(aFunction)) {
981 SetErrorCode("Plane driver failed");
985 catch (Standard_Failure) {
986 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
987 SetErrorCode(aFail->GetMessageString());
991 //Make a Python command
992 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
993 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
999 //=============================================================================
1003 //=============================================================================
1004 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
1005 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
1009 //Add a new Plane object
1010 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1012 //Add a new Plane function
1013 Handle(GEOM_Function) aFunction =
1014 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
1016 //Check if the function is set correctly
1017 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1019 GEOMImpl_IPlane aPI (aFunction);
1021 if ( !theLCS.IsNull() ) {
1022 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1026 aPI.SetSize(theSize);
1027 aPI.SetOrientation(theOrientation);
1029 //Compute the Plane value
1031 #if OCC_VERSION_LARGE > 0x06010000
1034 if (!GetSolver()->ComputeFunction(aFunction)) {
1035 SetErrorCode("Plane driver failed");
1039 catch (Standard_Failure) {
1040 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1041 SetErrorCode(aFail->GetMessageString());
1045 //Make a Python command
1046 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1047 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1054 //=============================================================================
1058 //=============================================================================
1059 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1060 (double theOX, double theOY, double theOZ,
1061 double theXDX, double theXDY, double theXDZ,
1062 double theYDX, double theYDY, double theYDZ)
1066 //Add a new Marker object
1067 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1069 //Add a new Marker function
1070 Handle(GEOM_Function) aFunction =
1071 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1072 if (aFunction.IsNull()) return NULL;
1074 //Check if the function is set correctly
1075 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1077 GEOMImpl_IMarker aPI(aFunction);
1079 aPI.SetOrigin(theOX, theOY, theOZ);
1080 aPI.SetXDir(theXDX, theXDY, theXDZ);
1081 aPI.SetYDir(theYDX, theYDY, theYDZ);
1083 //Compute the marker value
1085 #if OCC_VERSION_LARGE > 0x06010000
1088 if (!GetSolver()->ComputeFunction(aFunction)) {
1089 SetErrorCode("Marker driver failed");
1093 catch (Standard_Failure) {
1094 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1095 SetErrorCode(aFail->GetMessageString());
1099 //Make a Python command
1100 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1101 << theOX << ", " << theOY << ", " << theOZ << ", "
1102 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1103 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1109 //=============================================================================
1111 * MakeMarkerFromShape
1113 //=============================================================================
1114 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1115 (const Handle(GEOM_Object)& theShape)
1119 //Add a new Marker object
1120 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1122 //Add a new Marker function
1123 Handle(GEOM_Function) aFunction =
1124 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1125 if (aFunction.IsNull()) return NULL;
1127 //Check if the function is set correctly
1128 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1130 GEOMImpl_IMarker aPI(aFunction);
1132 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1133 if (aRefShape.IsNull()) return NULL;
1135 aPI.SetShape(aRefShape);
1137 //Compute the marker value
1139 #if OCC_VERSION_LARGE > 0x06010000
1142 if (!GetSolver()->ComputeFunction(aFunction)) {
1143 SetErrorCode("Marker driver failed");
1147 catch (Standard_Failure) {
1148 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1149 SetErrorCode(aFail->GetMessageString());
1153 //Make a Python command
1154 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1160 //=============================================================================
1162 * MakeMarkerPntTwoVec
1164 //=============================================================================
1165 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1166 (const Handle(GEOM_Object)& theOrigin,
1167 const Handle(GEOM_Object)& theXVec,
1168 const Handle(GEOM_Object)& theYVec)
1172 //Add a new Marker object
1173 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1175 //Add a new Marker function
1176 Handle(GEOM_Function) aFunction =
1177 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1178 if (aFunction.IsNull()) return NULL;
1180 //Check if the function is set correctly
1181 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1183 GEOMImpl_IMarker aPI(aFunction);
1185 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1186 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1187 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1188 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1190 aPI.SetOrigin(aRefOrigin);
1191 aPI.SetXVec(aRefXVec);
1192 aPI.SetYVec(aRefYVec);
1194 //Compute the marker value
1196 #if OCC_VERSION_LARGE > 0x06010000
1199 if (!GetSolver()->ComputeFunction(aFunction)) {
1200 SetErrorCode("Marker driver failed");
1204 catch (Standard_Failure) {
1205 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1206 SetErrorCode(aFail->GetMessageString());
1210 //Make a Python command
1211 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1212 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1218 //=============================================================================
1220 * MakeTangentPlaneOnFace
1222 //=============================================================================
1224 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1231 if (theFace.IsNull()) return NULL;
1233 //Add a new Plane object
1234 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1236 //Add a new Plane function
1237 Handle(GEOM_Function) aFunction =
1238 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1240 //Check if the function is set correctly
1241 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1243 GEOMImpl_IPlane aPI (aFunction);
1245 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1246 if (aRef.IsNull()) return NULL;
1249 aPI.SetSize(theSize);
1250 aPI.SetParameterU(theParamU);
1251 aPI.SetParameterV(theParamV);
1253 //Compute the Plane value
1255 #if OCC_VERSION_LARGE > 0x06010000
1258 if (!GetSolver()->ComputeFunction(aFunction)) {
1259 SetErrorCode("Plane driver failed");
1263 catch (Standard_Failure) {
1264 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1265 SetErrorCode(aFail->GetMessageString());
1269 //Make a Python command
1270 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1271 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";