1 // Copyright (C) 2007-2012 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 <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;
217 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
219 //Check if the function is set correctly
220 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
222 GEOMImpl_IPoint aPI (aFunction);
224 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
225 if (aRefFunction.IsNull()) return NULL;
227 switch( theLocation )
229 case PointOn_CurveByParam:
230 aPI.SetCurve(aRefFunction);
231 aPI.SetParameter(theParam1);
233 case PointOn_CurveByLength:
234 aPI.SetCurve(aRefFunction);
235 aPI.SetLength(theParam1);
236 if (!theRefPoint.IsNull()) {
237 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
238 aPI.SetRef(aRefPoint);
241 case PointOn_CurveByCoord:
242 aPI.SetCurve(aRefFunction);
247 case PointOn_SurfaceByParam:
248 aPI.SetSurface(aRefFunction);
249 aPI.SetParameter(theParam1);
250 aPI.SetParameter2(theParam2);
252 case PointOn_SurfaceByCoord:
253 aPI.SetSurface(aRefFunction);
260 //Compute the point value
262 #if OCC_VERSION_LARGE > 0x06010000
265 if (!GetSolver()->ComputeFunction(aFunction)) {
266 SetErrorCode("Point driver failed");
270 catch (Standard_Failure) {
271 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
272 SetErrorCode(aFail->GetMessageString());
276 //Make a Python command
277 switch( theLocation )
279 case PointOn_CurveByParam:
280 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
281 << theGeomObj << ", " << theParam1 << ")";
283 case PointOn_CurveByLength:
284 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
285 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
287 case PointOn_CurveByCoord:
288 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
289 << theGeomObj << ", " << theParam1
290 << ", " << theParam2 << ", " << theParam3 << ")";
292 case PointOn_SurfaceByParam:
293 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
294 << theGeomObj << ", " << theParam1
295 << ", " << theParam2 << ")";
297 case PointOn_SurfaceByCoord:
298 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
299 << theGeomObj << ", " << theParam1
300 << ", " << theParam2 << ", " << theParam3 << ")";
308 //=============================================================================
312 //=============================================================================
313 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
314 (Handle(GEOM_Object) theCurve, double theParameter)
316 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
319 //=============================================================================
321 * MakePointOnCurveByCoord
323 //=============================================================================
324 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
325 (Handle(GEOM_Object) theCurve,
330 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
333 //=============================================================================
335 * MakePointOnCurveByLength
337 //=============================================================================
338 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
339 (Handle(GEOM_Object) theCurve,
341 Handle(GEOM_Object) theStartPoint)
343 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
346 //=============================================================================
350 //=============================================================================
351 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
352 (Handle(GEOM_Object) theSurface,
353 double theUParameter,
354 double theVParameter)
356 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
359 //=============================================================================
361 * MakePointOnSurfaceByCoord
363 //=============================================================================
364 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
365 (Handle(GEOM_Object) theSurface,
370 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
374 //=============================================================================
376 * MakePointOnLinesIntersection
378 //=============================================================================
379 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
380 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
384 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
386 //Add a new Point object
387 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
389 //Add a new Point function for creation a point relativley another point
390 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
392 //Check if the function is set correctly
393 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
395 GEOMImpl_IPoint aPI (aFunction);
397 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
398 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
399 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
404 //Compute the point value
406 #if OCC_VERSION_LARGE > 0x06010000
409 if (!GetSolver()->ComputeFunction(aFunction)) {
410 SetErrorCode("Point driver failed");
414 catch (Standard_Failure) {
415 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
416 SetErrorCode(aFail->GetMessageString());
420 //Make a Python command
421 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
422 << theLine1 << ", " << theLine2 << ")";
428 //=============================================================================
432 //=============================================================================
433 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
434 (const Handle(GEOM_Object)& theCurve, double theParameter)
438 if (theCurve.IsNull()) return NULL;
440 //Add a new Vector object
441 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
443 //Add a new Point function for creation a point relativley another point
444 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
446 //Check if the function is set correctly
447 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
449 GEOMImpl_IVector aVI (aFunction);
451 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
452 if (aRefFunction.IsNull()) return NULL;
454 aVI.SetCurve(aRefFunction);
455 aVI.SetParameter(theParameter);
457 //Compute the vector value
459 #if OCC_VERSION_LARGE > 0x06010000
462 if (!GetSolver()->ComputeFunction(aFunction)) {
463 SetErrorCode("Vector driver failed");
467 catch (Standard_Failure) {
468 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
469 SetErrorCode(aFail->GetMessageString());
473 //Make a Python command
474 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
475 << theCurve << ", " << theParameter << ")";
481 //=============================================================================
485 //=============================================================================
486 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
487 (double theDX, double theDY, double theDZ)
491 //Add a new Vector object
492 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
494 //Add a new Vector function with DXDYDZ parameters
495 Handle(GEOM_Function) aFunction =
496 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
497 if (aFunction.IsNull()) return NULL;
499 //Check if the function is set correctly
500 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
502 GEOMImpl_IVector aPI (aFunction);
508 //Compute the Vector value
510 #if OCC_VERSION_LARGE > 0x06010000
513 if (!GetSolver()->ComputeFunction(aFunction)) {
514 SetErrorCode("Vector driver failed");
518 catch (Standard_Failure) {
519 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
520 SetErrorCode(aFail->GetMessageString());
524 //Make a Python command
525 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
526 << theDX << ", " << theDY << ", " << theDZ << ")";
532 //=============================================================================
536 //=============================================================================
537 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
538 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
542 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
544 //Add a new Vector object
545 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
547 //Add a new Vector function
548 Handle(GEOM_Function) aFunction =
549 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
551 //Check if the function is set correctly
552 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
554 GEOMImpl_IVector aPI (aFunction);
556 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
557 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
558 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
560 aPI.SetPoint1(aRef1);
561 aPI.SetPoint2(aRef2);
563 //Compute the Vector value
565 #if OCC_VERSION_LARGE > 0x06010000
568 if (!GetSolver()->ComputeFunction(aFunction)) {
569 SetErrorCode("Vector driver failed");
573 catch (Standard_Failure) {
574 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
575 SetErrorCode(aFail->GetMessageString());
579 //Make a Python command
580 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
581 << thePnt1 << ", " << thePnt2 << ")";
588 //=============================================================================
592 //=============================================================================
593 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
594 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
598 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
600 //Add a new Line object
601 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
603 //Add a new Line function
604 Handle(GEOM_Function) aFunction =
605 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
607 //Check if the function is set correctly
608 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
610 GEOMImpl_ILine aPI (aFunction);
612 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
613 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
614 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
616 aPI.SetPoint1(aRef1);
617 aPI.SetPoint2(aRef2);
619 //Compute the Line value
621 #if OCC_VERSION_LARGE > 0x06010000
624 if (!GetSolver()->ComputeFunction(aFunction)) {
625 SetErrorCode("Line driver failed");
629 catch (Standard_Failure) {
630 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
631 SetErrorCode(aFail->GetMessageString());
635 //Make a Python command
636 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
637 << thePnt << ", " << theDir << ")";
643 //=============================================================================
647 //=============================================================================
648 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
649 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
653 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
655 //Add a new Line object
656 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
658 //Add a new Line function
659 Handle(GEOM_Function) aFunction =
660 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
662 //Check if the function is set correctly
663 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
665 GEOMImpl_ILine aPI (aFunction);
667 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
668 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
669 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
671 aPI.SetPoint1(aRef1);
672 aPI.SetPoint2(aRef2);
674 //Compute the Line value
676 #if OCC_VERSION_LARGE > 0x06010000
679 if (!GetSolver()->ComputeFunction(aFunction)) {
680 SetErrorCode("Line driver failed");
684 catch (Standard_Failure) {
685 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
686 SetErrorCode(aFail->GetMessageString());
690 //Make a Python command
691 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
692 << thePnt1 << ", " << thePnt2 << ")";
698 //=============================================================================
702 //=============================================================================
703 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
704 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
708 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
710 //Add a new Line object
711 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
713 //Add a new Line function
714 Handle(GEOM_Function) aFunction =
715 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
717 //Check if the function is set correctly
718 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
720 GEOMImpl_ILine aPI (aFunction);
722 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
723 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
724 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
729 //Compute the Line value
731 #if OCC_VERSION_LARGE > 0x06010000
734 if (!GetSolver()->ComputeFunction(aFunction)) {
735 SetErrorCode("Line driver failed");
739 catch (Standard_Failure) {
740 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
741 SetErrorCode(aFail->GetMessageString());
745 //Make a Python command
746 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
747 << theFace1 << ", " << theFace2 << ")";
753 //=============================================================================
757 //=============================================================================
758 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
759 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
760 Handle(GEOM_Object) thePnt3, double theSize)
764 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
766 //Add a new Plane object
767 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
769 //Add a new Plane function
770 Handle(GEOM_Function) aFunction =
771 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
773 //Check if the function is set correctly
774 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
776 GEOMImpl_IPlane aPI (aFunction);
778 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
779 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
780 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
781 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
783 aPI.SetPoint1(aRef1);
784 aPI.SetPoint2(aRef2);
785 aPI.SetPoint3(aRef3);
786 aPI.SetSize(theSize);
788 //Compute the Plane value
790 #if OCC_VERSION_LARGE > 0x06010000
793 if (!GetSolver()->ComputeFunction(aFunction)) {
794 SetErrorCode("Plane driver failed");
798 catch (Standard_Failure) {
799 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
800 SetErrorCode(aFail->GetMessageString());
804 //Make a Python command
805 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
806 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
812 //=============================================================================
816 //=============================================================================
817 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
818 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
823 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
825 //Add a new Plane object
826 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
828 //Add a new Plane function
829 Handle(GEOM_Function) aFunction =
830 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
832 //Check if the function is set correctly
833 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
835 GEOMImpl_IPlane aPI (aFunction);
837 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
838 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
839 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
841 aPI.SetPoint(aRefPnt);
842 aPI.SetVector(aRefVec);
843 aPI.SetSize(theSize);
845 //Compute the Plane value
847 #if OCC_VERSION_LARGE > 0x06010000
850 if (!GetSolver()->ComputeFunction(aFunction)) {
851 SetErrorCode("Plane driver failed");
855 catch (Standard_Failure) {
856 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
857 SetErrorCode(aFail->GetMessageString());
861 //Make a Python command
862 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
863 << thePnt << ", " << theVec << ", " << theSize << ")";
869 //=============================================================================
873 //=============================================================================
874 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
875 (Handle(GEOM_Object) theFace, double theSize)
879 if (theFace.IsNull()) return NULL;
881 //Add a new Plane object
882 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
884 //Add a new Plane function
885 Handle(GEOM_Function) aFunction =
886 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
888 //Check if the function is set correctly
889 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
891 GEOMImpl_IPlane aPI (aFunction);
893 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
894 if (aRef.IsNull()) return NULL;
897 aPI.SetSize(theSize);
899 //Compute the Plane value
901 #if OCC_VERSION_LARGE > 0x06010000
904 if (!GetSolver()->ComputeFunction(aFunction)) {
905 SetErrorCode("Plane driver failed");
909 catch (Standard_Failure) {
910 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
911 SetErrorCode(aFail->GetMessageString());
915 //Make a Python command
916 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
917 << theFace << ", " << theSize << ")";
923 //=============================================================================
927 //=============================================================================
928 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
929 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
934 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
936 //Add a new Plane object
937 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
939 //Add a new Plane function
940 Handle(GEOM_Function) aFunction =
941 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
943 //Check if the function is set correctly
944 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
946 GEOMImpl_IPlane aPI (aFunction);
948 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
949 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
950 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
952 aPI.SetVector1(aRefVec1);
953 aPI.SetVector2(aRefVec2);
954 aPI.SetSize(theSize);
956 //Compute the Plane value
958 #if OCC_VERSION_LARGE > 0x06010000
961 if (!GetSolver()->ComputeFunction(aFunction)) {
962 SetErrorCode("Plane driver failed");
966 catch (Standard_Failure) {
967 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
968 SetErrorCode(aFail->GetMessageString());
972 //Make a Python command
973 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
974 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
980 //=============================================================================
984 //=============================================================================
985 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
986 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
990 //Add a new Plane object
991 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
993 //Add a new Plane function
994 Handle(GEOM_Function) aFunction =
995 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
997 //Check if the function is set correctly
998 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1000 GEOMImpl_IPlane aPI (aFunction);
1002 if ( !theLCS.IsNull() ) {
1003 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1007 aPI.SetSize(theSize);
1008 aPI.SetOrientation(theOrientation);
1010 //Compute the Plane value
1012 #if OCC_VERSION_LARGE > 0x06010000
1015 if (!GetSolver()->ComputeFunction(aFunction)) {
1016 SetErrorCode("Plane driver failed");
1020 catch (Standard_Failure) {
1021 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1022 SetErrorCode(aFail->GetMessageString());
1026 //Make a Python command
1027 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1028 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1035 //=============================================================================
1039 //=============================================================================
1040 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1041 (double theOX, double theOY, double theOZ,
1042 double theXDX, double theXDY, double theXDZ,
1043 double theYDX, double theYDY, double theYDZ)
1047 //Add a new Marker object
1048 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1050 //Add a new Marker function
1051 Handle(GEOM_Function) aFunction =
1052 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1053 if (aFunction.IsNull()) return NULL;
1055 //Check if the function is set correctly
1056 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1058 GEOMImpl_IMarker aPI(aFunction);
1060 aPI.SetOrigin(theOX, theOY, theOZ);
1061 aPI.SetXDir(theXDX, theXDY, theXDZ);
1062 aPI.SetYDir(theYDX, theYDY, theYDZ);
1064 //Compute the marker value
1066 #if OCC_VERSION_LARGE > 0x06010000
1069 if (!GetSolver()->ComputeFunction(aFunction)) {
1070 SetErrorCode("Marker driver failed");
1074 catch (Standard_Failure) {
1075 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1076 SetErrorCode(aFail->GetMessageString());
1080 //Make a Python command
1081 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1082 << theOX << ", " << theOY << ", " << theOZ << ", "
1083 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1084 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1090 //=============================================================================
1092 * MakeMarkerFromShape
1094 //=============================================================================
1095 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1096 (const Handle(GEOM_Object)& theShape)
1100 //Add a new Marker object
1101 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1103 //Add a new Marker function
1104 Handle(GEOM_Function) aFunction =
1105 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1106 if (aFunction.IsNull()) return NULL;
1108 //Check if the function is set correctly
1109 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1111 GEOMImpl_IMarker aPI(aFunction);
1113 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1114 if (aRefShape.IsNull()) return NULL;
1116 aPI.SetShape(aRefShape);
1118 //Compute the marker value
1120 #if OCC_VERSION_LARGE > 0x06010000
1123 if (!GetSolver()->ComputeFunction(aFunction)) {
1124 SetErrorCode("Marker driver failed");
1128 catch (Standard_Failure) {
1129 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1130 SetErrorCode(aFail->GetMessageString());
1134 //Make a Python command
1135 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1141 //=============================================================================
1143 * MakeMarkerPntTwoVec
1145 //=============================================================================
1146 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1147 (const Handle(GEOM_Object)& theOrigin,
1148 const Handle(GEOM_Object)& theXVec,
1149 const Handle(GEOM_Object)& theYVec)
1153 //Add a new Marker object
1154 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1156 //Add a new Marker function
1157 Handle(GEOM_Function) aFunction =
1158 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1159 if (aFunction.IsNull()) return NULL;
1161 //Check if the function is set correctly
1162 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1164 GEOMImpl_IMarker aPI(aFunction);
1166 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1167 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1168 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1169 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1171 aPI.SetOrigin(aRefOrigin);
1172 aPI.SetXVec(aRefXVec);
1173 aPI.SetYVec(aRefYVec);
1175 //Compute the marker value
1177 #if OCC_VERSION_LARGE > 0x06010000
1180 if (!GetSolver()->ComputeFunction(aFunction)) {
1181 SetErrorCode("Marker driver failed");
1185 catch (Standard_Failure) {
1186 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1187 SetErrorCode(aFail->GetMessageString());
1191 //Make a Python command
1192 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1193 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1199 //=============================================================================
1201 * MakeTangentPlaneOnFace
1203 //=============================================================================
1205 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1212 if (theFace.IsNull()) return NULL;
1214 //Add a new Plane object
1215 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1217 //Add a new Plane function
1218 Handle(GEOM_Function) aFunction =
1219 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1221 //Check if the function is set correctly
1222 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1224 GEOMImpl_IPlane aPI (aFunction);
1226 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1227 if (aRef.IsNull()) return NULL;
1230 aPI.SetSize(theSize);
1231 aPI.SetParameterU(theParamU);
1232 aPI.SetParameterV(theParamV);
1234 //Compute the Plane value
1236 #if OCC_VERSION_LARGE > 0x06010000
1239 if (!GetSolver()->ComputeFunction(aFunction)) {
1240 SetErrorCode("Plane driver failed");
1244 catch (Standard_Failure) {
1245 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1246 SetErrorCode(aFail->GetMessageString());
1250 //Make a Python command
1251 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1252 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";