1 // Copyright (C) 2007-2011 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 <Basics_OCCTVersion.hxx>
28 #include "utilities.h"
30 #include <Utils_ExceptHandlers.hxx>
32 #include <TFunction_DriverTable.hxx>
33 #include <TFunction_Driver.hxx>
34 #include <TFunction_Logbook.hxx>
35 #include <TDF_Tool.hxx>
37 #include <GEOM_Function.hxx>
38 #include <GEOM_PythonDump.hxx>
40 #include <GEOMImpl_PointDriver.hxx>
41 #include <GEOMImpl_VectorDriver.hxx>
42 #include <GEOMImpl_LineDriver.hxx>
43 #include <GEOMImpl_PlaneDriver.hxx>
44 #include <GEOMImpl_MarkerDriver.hxx>
46 #include <GEOMImpl_IPoint.hxx>
47 #include <GEOMImpl_IVector.hxx>
48 #include <GEOMImpl_ILine.hxx>
49 #include <GEOMImpl_IPlane.hxx>
50 #include <GEOMImpl_IMarker.hxx>
52 #include <GEOMImpl_Types.hxx>
54 #include <Standard_Failure.hxx>
55 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
57 //=============================================================================
61 //=============================================================================
62 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
63 : GEOM_IOperations(theEngine, theDocID)
65 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
68 //=============================================================================
72 //=============================================================================
73 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
75 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
79 //=============================================================================
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
85 (double theX, double theY, double theZ)
89 //Add a new Point object
90 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
92 //Add a new Point function with XYZ parameters
93 Handle(GEOM_Function) aFunction =
94 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
95 if (aFunction.IsNull()) return NULL;
97 //Check if the function is set correctly
98 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
100 GEOMImpl_IPoint aPI(aFunction);
106 //Compute the point value
108 #if OCC_VERSION_LARGE > 0x06010000
111 if (!GetSolver()->ComputeFunction(aFunction)) {
112 SetErrorCode("Point driver failed");
116 catch (Standard_Failure) {
117 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
118 SetErrorCode(aFail->GetMessageString());
122 //Make a Python command
123 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
124 << theX << ", " << theY << ", " << theZ << ")";
130 //=============================================================================
132 * MakePointWithReference
134 //=============================================================================
135 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
136 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
140 if (theReference.IsNull()) return NULL;
142 //Add a new Point object
143 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
145 //Add a new Point function for creation a point relativley another point
146 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
148 //Check if the function is set correctly
149 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
151 GEOMImpl_IPoint aPI(aFunction);
153 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
154 if (aRefFunction.IsNull()) return NULL;
156 aPI.SetRef(aRefFunction);
161 //Compute the point value
163 #if OCC_VERSION_LARGE > 0x06010000
166 if (!GetSolver()->ComputeFunction(aFunction)) {
167 SetErrorCode("Point driver failed");
171 catch (Standard_Failure) {
172 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
173 SetErrorCode(aFail->GetMessageString());
177 //Make a Python command
178 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
179 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
185 //=============================================================================
189 //=============================================================================
190 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
191 (Handle(GEOM_Object) theGeomObj,
195 const PointLocation theLocation,
196 Handle(GEOM_Object) theRefPoint)
200 if (theGeomObj.IsNull()) return NULL;
202 //Add a new Point object
203 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
205 //Add a new Point function for creation a point relativley another point
206 int fType = POINT_CURVE_PAR;
207 switch( theLocation )
209 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
210 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
211 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
212 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
213 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
216 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
218 //Check if the function is set correctly
219 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
221 GEOMImpl_IPoint aPI (aFunction);
223 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
224 if (aRefFunction.IsNull()) return NULL;
226 switch( theLocation )
228 case PointOn_CurveByParam:
229 aPI.SetCurve(aRefFunction);
230 aPI.SetParameter(theParam1);
232 case PointOn_CurveByLength:
233 aPI.SetCurve(aRefFunction);
234 aPI.SetLength(theParam1);
235 if (!theRefPoint.IsNull()) {
236 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
237 aPI.SetRef(aRefPoint);
240 case PointOn_CurveByCoord:
241 aPI.SetCurve(aRefFunction);
246 case PointOn_SurfaceByParam:
247 aPI.SetSurface(aRefFunction);
248 aPI.SetParameter(theParam1);
249 aPI.SetParameter2(theParam2);
251 case PointOn_SurfaceByCoord:
252 aPI.SetSurface(aRefFunction);
259 //Compute the point value
261 #if OCC_VERSION_LARGE > 0x06010000
264 if (!GetSolver()->ComputeFunction(aFunction)) {
265 SetErrorCode("Point driver failed");
269 catch (Standard_Failure) {
270 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
271 SetErrorCode(aFail->GetMessageString());
275 //Make a Python command
276 switch( theLocation )
278 case PointOn_CurveByParam:
279 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
280 << theGeomObj << ", " << theParam1 << ")";
282 case PointOn_CurveByLength:
283 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
284 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
286 case PointOn_CurveByCoord:
287 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
288 << theGeomObj << ", " << theParam1
289 << ", " << theParam2 << ", " << theParam3 << ")";
291 case PointOn_SurfaceByParam:
292 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
293 << theGeomObj << ", " << theParam1
294 << ", " << theParam2 << ")";
296 case PointOn_SurfaceByCoord:
297 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
298 << theGeomObj << ", " << theParam1
299 << ", " << theParam2 << ", " << theParam3 << ")";
307 //=============================================================================
311 //=============================================================================
312 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
313 (Handle(GEOM_Object) theCurve, double theParameter)
315 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
318 //=============================================================================
320 * MakePointOnCurveByCoord
322 //=============================================================================
323 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
324 (Handle(GEOM_Object) theCurve,
329 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
332 //=============================================================================
334 * MakePointOnCurveByLength
336 //=============================================================================
337 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
338 (Handle(GEOM_Object) theCurve,
340 Handle(GEOM_Object) theStartPoint)
342 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
345 //=============================================================================
349 //=============================================================================
350 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
351 (Handle(GEOM_Object) theSurface,
352 double theUParameter,
353 double theVParameter)
355 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
358 //=============================================================================
360 * MakePointOnSurfaceByCoord
362 //=============================================================================
363 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
364 (Handle(GEOM_Object) theSurface,
369 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
373 //=============================================================================
375 * MakePointOnLinesIntersection
377 //=============================================================================
378 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
379 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
383 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
385 //Add a new Point object
386 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
388 //Add a new Point function for creation a point relativley another point
389 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
391 //Check if the function is set correctly
392 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
394 GEOMImpl_IPoint aPI (aFunction);
396 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
397 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
398 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
403 //Compute the point value
405 #if OCC_VERSION_LARGE > 0x06010000
408 if (!GetSolver()->ComputeFunction(aFunction)) {
409 SetErrorCode("Point driver failed");
413 catch (Standard_Failure) {
414 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
415 SetErrorCode(aFail->GetMessageString());
419 //Make a Python command
420 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
421 << theLine1 << ", " << theLine2 << ")";
427 //=============================================================================
431 //=============================================================================
432 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
433 (const Handle(GEOM_Object)& theCurve, double theParameter)
437 if (theCurve.IsNull()) return NULL;
439 //Add a new Vector object
440 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
442 //Add a new Point function for creation a point relativley another point
443 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
445 //Check if the function is set correctly
446 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
448 GEOMImpl_IVector aVI (aFunction);
450 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
451 if (aRefFunction.IsNull()) return NULL;
453 aVI.SetCurve(aRefFunction);
454 aVI.SetParameter(theParameter);
456 //Compute the vector value
458 #if OCC_VERSION_LARGE > 0x06010000
461 if (!GetSolver()->ComputeFunction(aFunction)) {
462 SetErrorCode("Vector driver failed");
466 catch (Standard_Failure) {
467 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
468 SetErrorCode(aFail->GetMessageString());
472 //Make a Python command
473 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
474 << theCurve << ", " << theParameter << ")";
480 //=============================================================================
484 //=============================================================================
485 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
486 (double theDX, double theDY, double theDZ)
490 //Add a new Vector object
491 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
493 //Add a new Vector function with DXDYDZ parameters
494 Handle(GEOM_Function) aFunction =
495 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
496 if (aFunction.IsNull()) return NULL;
498 //Check if the function is set correctly
499 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
501 GEOMImpl_IVector aPI (aFunction);
507 //Compute the Vector value
509 #if OCC_VERSION_LARGE > 0x06010000
512 if (!GetSolver()->ComputeFunction(aFunction)) {
513 SetErrorCode("Vector driver failed");
517 catch (Standard_Failure) {
518 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
519 SetErrorCode(aFail->GetMessageString());
523 //Make a Python command
524 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
525 << theDX << ", " << theDY << ", " << theDZ << ")";
531 //=============================================================================
535 //=============================================================================
536 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
537 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
541 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
543 //Add a new Vector object
544 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
546 //Add a new Vector function
547 Handle(GEOM_Function) aFunction =
548 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
550 //Check if the function is set correctly
551 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
553 GEOMImpl_IVector aPI (aFunction);
555 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
556 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
557 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
559 aPI.SetPoint1(aRef1);
560 aPI.SetPoint2(aRef2);
562 //Compute the Vector value
564 #if OCC_VERSION_LARGE > 0x06010000
567 if (!GetSolver()->ComputeFunction(aFunction)) {
568 SetErrorCode("Vector driver failed");
572 catch (Standard_Failure) {
573 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
574 SetErrorCode(aFail->GetMessageString());
578 //Make a Python command
579 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
580 << thePnt1 << ", " << thePnt2 << ")";
587 //=============================================================================
591 //=============================================================================
592 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
593 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
597 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
599 //Add a new Line object
600 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
602 //Add a new Line function
603 Handle(GEOM_Function) aFunction =
604 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
606 //Check if the function is set correctly
607 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
609 GEOMImpl_ILine aPI (aFunction);
611 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
612 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
613 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
615 aPI.SetPoint1(aRef1);
616 aPI.SetPoint2(aRef2);
618 //Compute the Line value
620 #if OCC_VERSION_LARGE > 0x06010000
623 if (!GetSolver()->ComputeFunction(aFunction)) {
624 SetErrorCode("Line driver failed");
628 catch (Standard_Failure) {
629 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
630 SetErrorCode(aFail->GetMessageString());
634 //Make a Python command
635 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
636 << thePnt << ", " << theDir << ")";
642 //=============================================================================
646 //=============================================================================
647 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
648 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
652 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
654 //Add a new Line object
655 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
657 //Add a new Line function
658 Handle(GEOM_Function) aFunction =
659 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
661 //Check if the function is set correctly
662 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
664 GEOMImpl_ILine aPI (aFunction);
666 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
667 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
668 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
670 aPI.SetPoint1(aRef1);
671 aPI.SetPoint2(aRef2);
673 //Compute the Line value
675 #if OCC_VERSION_LARGE > 0x06010000
678 if (!GetSolver()->ComputeFunction(aFunction)) {
679 SetErrorCode("Line driver failed");
683 catch (Standard_Failure) {
684 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
685 SetErrorCode(aFail->GetMessageString());
689 //Make a Python command
690 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
691 << thePnt1 << ", " << thePnt2 << ")";
697 //=============================================================================
701 //=============================================================================
702 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
703 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
707 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
709 //Add a new Line object
710 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
712 //Add a new Line function
713 Handle(GEOM_Function) aFunction =
714 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
716 //Check if the function is set correctly
717 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
719 GEOMImpl_ILine aPI (aFunction);
721 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
722 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
723 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
728 //Compute the Line value
730 #if OCC_VERSION_LARGE > 0x06010000
733 if (!GetSolver()->ComputeFunction(aFunction)) {
734 SetErrorCode("Line driver failed");
738 catch (Standard_Failure) {
739 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
740 SetErrorCode(aFail->GetMessageString());
744 //Make a Python command
745 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
746 << theFace1 << ", " << theFace2 << ")";
752 //=============================================================================
756 //=============================================================================
757 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
758 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
759 Handle(GEOM_Object) thePnt3, double theSize)
763 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
765 //Add a new Plane object
766 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
768 //Add a new Plane function
769 Handle(GEOM_Function) aFunction =
770 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
772 //Check if the function is set correctly
773 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
775 GEOMImpl_IPlane aPI (aFunction);
777 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
778 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
779 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
780 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
782 aPI.SetPoint1(aRef1);
783 aPI.SetPoint2(aRef2);
784 aPI.SetPoint3(aRef3);
785 aPI.SetSize(theSize);
787 //Compute the Plane value
789 #if OCC_VERSION_LARGE > 0x06010000
792 if (!GetSolver()->ComputeFunction(aFunction)) {
793 SetErrorCode("Plane driver failed");
797 catch (Standard_Failure) {
798 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
799 SetErrorCode(aFail->GetMessageString());
803 //Make a Python command
804 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
805 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
811 //=============================================================================
815 //=============================================================================
816 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
817 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
822 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
824 //Add a new Plane object
825 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
827 //Add a new Plane function
828 Handle(GEOM_Function) aFunction =
829 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
831 //Check if the function is set correctly
832 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
834 GEOMImpl_IPlane aPI (aFunction);
836 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
837 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
838 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
840 aPI.SetPoint(aRefPnt);
841 aPI.SetVector(aRefVec);
842 aPI.SetSize(theSize);
844 //Compute the Plane value
846 #if OCC_VERSION_LARGE > 0x06010000
849 if (!GetSolver()->ComputeFunction(aFunction)) {
850 SetErrorCode("Plane driver failed");
854 catch (Standard_Failure) {
855 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
856 SetErrorCode(aFail->GetMessageString());
860 //Make a Python command
861 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
862 << thePnt << ", " << theVec << ", " << theSize << ")";
868 //=============================================================================
872 //=============================================================================
873 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
874 (Handle(GEOM_Object) theFace, double theSize)
878 if (theFace.IsNull()) return NULL;
880 //Add a new Plane object
881 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
883 //Add a new Plane function
884 Handle(GEOM_Function) aFunction =
885 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
887 //Check if the function is set correctly
888 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
890 GEOMImpl_IPlane aPI (aFunction);
892 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
893 if (aRef.IsNull()) return NULL;
896 aPI.SetSize(theSize);
898 //Compute the Plane value
900 #if OCC_VERSION_LARGE > 0x06010000
903 if (!GetSolver()->ComputeFunction(aFunction)) {
904 SetErrorCode("Plane driver failed");
908 catch (Standard_Failure) {
909 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
910 SetErrorCode(aFail->GetMessageString());
914 //Make a Python command
915 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
916 << theFace << ", " << theSize << ")";
922 //=============================================================================
926 //=============================================================================
927 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
928 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
933 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
935 //Add a new Plane object
936 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
938 //Add a new Plane function
939 Handle(GEOM_Function) aFunction =
940 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
942 //Check if the function is set correctly
943 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
945 GEOMImpl_IPlane aPI (aFunction);
947 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
948 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
949 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
951 aPI.SetVector1(aRefVec1);
952 aPI.SetVector2(aRefVec2);
953 aPI.SetSize(theSize);
955 //Compute the Plane value
957 #if OCC_VERSION_LARGE > 0x06010000
960 if (!GetSolver()->ComputeFunction(aFunction)) {
961 SetErrorCode("Plane driver failed");
965 catch (Standard_Failure) {
966 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
967 SetErrorCode(aFail->GetMessageString());
971 //Make a Python command
972 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
973 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
979 //=============================================================================
983 //=============================================================================
984 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
985 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
989 //Add a new Plane object
990 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
992 //Add a new Plane function
993 Handle(GEOM_Function) aFunction =
994 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
996 //Check if the function is set correctly
997 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
999 GEOMImpl_IPlane aPI (aFunction);
1001 if ( !theLCS.IsNull() ) {
1002 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1006 aPI.SetSize(theSize);
1007 aPI.SetOrientation(theOrientation);
1009 //Compute the Plane value
1011 #if OCC_VERSION_LARGE > 0x06010000
1014 if (!GetSolver()->ComputeFunction(aFunction)) {
1015 SetErrorCode("Plane driver failed");
1019 catch (Standard_Failure) {
1020 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1021 SetErrorCode(aFail->GetMessageString());
1025 //Make a Python command
1026 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1027 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1034 //=============================================================================
1038 //=============================================================================
1039 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1040 (double theOX, double theOY, double theOZ,
1041 double theXDX, double theXDY, double theXDZ,
1042 double theYDX, double theYDY, double theYDZ)
1046 //Add a new Marker object
1047 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1049 //Add a new Marker function
1050 Handle(GEOM_Function) aFunction =
1051 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1052 if (aFunction.IsNull()) return NULL;
1054 //Check if the function is set correctly
1055 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1057 GEOMImpl_IMarker aPI(aFunction);
1059 aPI.SetOrigin(theOX, theOY, theOZ);
1060 aPI.SetXDir(theXDX, theXDY, theXDZ);
1061 aPI.SetYDir(theYDX, theYDY, theYDZ);
1063 //Compute the marker value
1065 #if OCC_VERSION_LARGE > 0x06010000
1068 if (!GetSolver()->ComputeFunction(aFunction)) {
1069 SetErrorCode("Marker driver failed");
1073 catch (Standard_Failure) {
1074 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1075 SetErrorCode(aFail->GetMessageString());
1079 //Make a Python command
1080 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1081 << theOX << ", " << theOY << ", " << theOZ << ", "
1082 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1083 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1089 //=============================================================================
1091 * MakeMarkerFromShape
1093 //=============================================================================
1094 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1095 (const Handle(GEOM_Object)& theShape)
1099 //Add a new Marker object
1100 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1102 //Add a new Marker function
1103 Handle(GEOM_Function) aFunction =
1104 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1105 if (aFunction.IsNull()) return NULL;
1107 //Check if the function is set correctly
1108 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1110 GEOMImpl_IMarker aPI(aFunction);
1112 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1113 if (aRefShape.IsNull()) return NULL;
1115 aPI.SetShape(aRefShape);
1117 //Compute the marker value
1119 #if OCC_VERSION_LARGE > 0x06010000
1122 if (!GetSolver()->ComputeFunction(aFunction)) {
1123 SetErrorCode("Marker driver failed");
1127 catch (Standard_Failure) {
1128 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1129 SetErrorCode(aFail->GetMessageString());
1133 //Make a Python command
1134 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1140 //=============================================================================
1142 * MakeMarkerPntTwoVec
1144 //=============================================================================
1145 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1146 (const Handle(GEOM_Object)& theOrigin,
1147 const Handle(GEOM_Object)& theXVec,
1148 const Handle(GEOM_Object)& theYVec)
1152 //Add a new Marker object
1153 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1155 //Add a new Marker function
1156 Handle(GEOM_Function) aFunction =
1157 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1158 if (aFunction.IsNull()) return NULL;
1160 //Check if the function is set correctly
1161 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1163 GEOMImpl_IMarker aPI(aFunction);
1165 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1166 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1167 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1168 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1170 aPI.SetOrigin(aRefOrigin);
1171 aPI.SetXVec(aRefXVec);
1172 aPI.SetYVec(aRefYVec);
1174 //Compute the marker value
1176 #if OCC_VERSION_LARGE > 0x06010000
1179 if (!GetSolver()->ComputeFunction(aFunction)) {
1180 SetErrorCode("Marker driver failed");
1184 catch (Standard_Failure) {
1185 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1186 SetErrorCode(aFail->GetMessageString());
1190 //Make a Python command
1191 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1192 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1198 //=============================================================================
1200 * MakeTangentPlaneOnFace
1202 //=============================================================================
1204 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1211 if (theFace.IsNull()) return NULL;
1213 //Add a new Plane object
1214 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1216 //Add a new Plane function
1217 Handle(GEOM_Function) aFunction =
1218 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1220 //Check if the function is set correctly
1221 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1223 GEOMImpl_IPlane aPI (aFunction);
1225 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1226 if (aRef.IsNull()) return NULL;
1229 aPI.SetSize(theSize);
1230 aPI.SetParameterU(theParamU);
1231 aPI.SetParameterV(theParamV);
1233 //Compute the Plane value
1235 #if OCC_VERSION_LARGE > 0x06010000
1238 if (!GetSolver()->ComputeFunction(aFunction)) {
1239 SetErrorCode("Plane driver failed");
1243 catch (Standard_Failure) {
1244 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1245 SetErrorCode(aFail->GetMessageString());
1249 //Make a Python command
1250 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1251 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";