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
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;
214 case PointOn_Face: fType = POINT_FACE_ANY; 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);
259 aPI.SetSurface(aRefFunction);
264 //Compute the point value
266 #if OCC_VERSION_LARGE > 0x06010000
269 if (!GetSolver()->ComputeFunction(aFunction)) {
270 SetErrorCode("Point driver failed");
274 catch (Standard_Failure) {
275 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
276 SetErrorCode(aFail->GetMessageString());
280 //Make a Python command
281 switch( theLocation )
283 case PointOn_CurveByParam:
284 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
285 << theGeomObj << ", " << theParam1 << ")";
287 case PointOn_CurveByLength:
288 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
289 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
291 case PointOn_CurveByCoord:
292 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
293 << theGeomObj << ", " << theParam1
294 << ", " << theParam2 << ", " << theParam3 << ")";
296 case PointOn_SurfaceByParam:
297 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
298 << theGeomObj << ", " << theParam1
299 << ", " << theParam2 << ")";
301 case PointOn_SurfaceByCoord:
302 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
303 << theGeomObj << ", " << theParam1
304 << ", " << theParam2 << ", " << theParam3 << ")";
307 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
308 << theGeomObj << ")";
317 //=============================================================================
321 //=============================================================================
322 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
323 (Handle(GEOM_Object) theCurve, double theParameter)
325 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
328 //=============================================================================
330 * MakePointOnCurveByCoord
332 //=============================================================================
333 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
334 (Handle(GEOM_Object) theCurve,
339 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
342 //=============================================================================
344 * MakePointOnCurveByLength
346 //=============================================================================
347 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
348 (Handle(GEOM_Object) theCurve,
350 Handle(GEOM_Object) theStartPoint)
352 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
355 //=============================================================================
359 //=============================================================================
360 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
361 (Handle(GEOM_Object) theSurface,
362 double theUParameter,
363 double theVParameter)
365 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
368 //=============================================================================
370 * MakePointOnSurfaceByCoord
372 //=============================================================================
373 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
374 (Handle(GEOM_Object) theSurface,
379 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
382 //=============================================================================
386 //=============================================================================
387 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
389 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
392 //=============================================================================
394 * MakePointOnLinesIntersection
396 //=============================================================================
397 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
398 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
402 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
404 //Add a new Point object
405 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
407 //Add a new Point function for creation a point relativley another point
408 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
410 //Check if the function is set correctly
411 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
413 GEOMImpl_IPoint aPI (aFunction);
415 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
416 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
417 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
422 //Compute the point value
424 #if OCC_VERSION_LARGE > 0x06010000
427 if (!GetSolver()->ComputeFunction(aFunction)) {
428 SetErrorCode("Point driver failed");
432 catch (Standard_Failure) {
433 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
434 SetErrorCode(aFail->GetMessageString());
438 //Make a Python command
439 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
440 << theLine1 << ", " << theLine2 << ")";
446 //=============================================================================
450 //=============================================================================
451 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
452 (const Handle(GEOM_Object)& theCurve, double theParameter)
456 if (theCurve.IsNull()) return NULL;
458 //Add a new Vector object
459 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
461 //Add a new Point function for creation a point relativley another point
462 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
464 //Check if the function is set correctly
465 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
467 GEOMImpl_IVector aVI (aFunction);
469 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
470 if (aRefFunction.IsNull()) return NULL;
472 aVI.SetCurve(aRefFunction);
473 aVI.SetParameter(theParameter);
475 //Compute the vector value
477 #if OCC_VERSION_LARGE > 0x06010000
480 if (!GetSolver()->ComputeFunction(aFunction)) {
481 SetErrorCode("Vector driver failed");
485 catch (Standard_Failure) {
486 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
487 SetErrorCode(aFail->GetMessageString());
491 //Make a Python command
492 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
493 << theCurve << ", " << theParameter << ")";
499 //=============================================================================
503 //=============================================================================
504 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
505 (double theDX, double theDY, double theDZ)
509 //Add a new Vector object
510 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
512 //Add a new Vector function with DXDYDZ parameters
513 Handle(GEOM_Function) aFunction =
514 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
515 if (aFunction.IsNull()) return NULL;
517 //Check if the function is set correctly
518 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
520 GEOMImpl_IVector aPI (aFunction);
526 //Compute the Vector value
528 #if OCC_VERSION_LARGE > 0x06010000
531 if (!GetSolver()->ComputeFunction(aFunction)) {
532 SetErrorCode("Vector driver failed");
536 catch (Standard_Failure) {
537 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
538 SetErrorCode(aFail->GetMessageString());
542 //Make a Python command
543 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
544 << theDX << ", " << theDY << ", " << theDZ << ")";
550 //=============================================================================
554 //=============================================================================
555 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
556 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
560 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
562 //Add a new Vector object
563 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
565 //Add a new Vector function
566 Handle(GEOM_Function) aFunction =
567 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
569 //Check if the function is set correctly
570 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
572 GEOMImpl_IVector aPI (aFunction);
574 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
575 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
576 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
578 aPI.SetPoint1(aRef1);
579 aPI.SetPoint2(aRef2);
581 //Compute the Vector value
583 #if OCC_VERSION_LARGE > 0x06010000
586 if (!GetSolver()->ComputeFunction(aFunction)) {
587 SetErrorCode("Vector driver failed");
591 catch (Standard_Failure) {
592 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
593 SetErrorCode(aFail->GetMessageString());
597 //Make a Python command
598 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
599 << thePnt1 << ", " << thePnt2 << ")";
606 //=============================================================================
610 //=============================================================================
611 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
612 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
616 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
618 //Add a new Line object
619 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
621 //Add a new Line function
622 Handle(GEOM_Function) aFunction =
623 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
625 //Check if the function is set correctly
626 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
628 GEOMImpl_ILine aPI (aFunction);
630 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
631 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
632 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
634 aPI.SetPoint1(aRef1);
635 aPI.SetPoint2(aRef2);
637 //Compute the Line value
639 #if OCC_VERSION_LARGE > 0x06010000
642 if (!GetSolver()->ComputeFunction(aFunction)) {
643 SetErrorCode("Line driver failed");
647 catch (Standard_Failure) {
648 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
649 SetErrorCode(aFail->GetMessageString());
653 //Make a Python command
654 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
655 << thePnt << ", " << theDir << ")";
661 //=============================================================================
665 //=============================================================================
666 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
667 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
671 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
673 //Add a new Line object
674 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
676 //Add a new Line function
677 Handle(GEOM_Function) aFunction =
678 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
680 //Check if the function is set correctly
681 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
683 GEOMImpl_ILine aPI (aFunction);
685 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
686 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
687 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
689 aPI.SetPoint1(aRef1);
690 aPI.SetPoint2(aRef2);
692 //Compute the Line value
694 #if OCC_VERSION_LARGE > 0x06010000
697 if (!GetSolver()->ComputeFunction(aFunction)) {
698 SetErrorCode("Line driver failed");
702 catch (Standard_Failure) {
703 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
704 SetErrorCode(aFail->GetMessageString());
708 //Make a Python command
709 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
710 << thePnt1 << ", " << thePnt2 << ")";
716 //=============================================================================
720 //=============================================================================
721 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
722 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
726 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
728 //Add a new Line object
729 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
731 //Add a new Line function
732 Handle(GEOM_Function) aFunction =
733 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
735 //Check if the function is set correctly
736 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
738 GEOMImpl_ILine aPI (aFunction);
740 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
741 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
742 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
747 //Compute the Line value
749 #if OCC_VERSION_LARGE > 0x06010000
752 if (!GetSolver()->ComputeFunction(aFunction)) {
753 SetErrorCode("Line driver failed");
757 catch (Standard_Failure) {
758 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
759 SetErrorCode(aFail->GetMessageString());
763 //Make a Python command
764 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
765 << theFace1 << ", " << theFace2 << ")";
771 //=============================================================================
775 //=============================================================================
776 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
777 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
778 Handle(GEOM_Object) thePnt3, double theSize)
782 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
784 //Add a new Plane object
785 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
787 //Add a new Plane function
788 Handle(GEOM_Function) aFunction =
789 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
791 //Check if the function is set correctly
792 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
794 GEOMImpl_IPlane aPI (aFunction);
796 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
797 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
798 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
799 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
801 aPI.SetPoint1(aRef1);
802 aPI.SetPoint2(aRef2);
803 aPI.SetPoint3(aRef3);
804 aPI.SetSize(theSize);
806 //Compute the Plane value
808 #if OCC_VERSION_LARGE > 0x06010000
811 if (!GetSolver()->ComputeFunction(aFunction)) {
812 SetErrorCode("Plane driver failed");
816 catch (Standard_Failure) {
817 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
818 SetErrorCode(aFail->GetMessageString());
822 //Make a Python command
823 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
824 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
830 //=============================================================================
834 //=============================================================================
835 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
836 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
841 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
843 //Add a new Plane object
844 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
846 //Add a new Plane function
847 Handle(GEOM_Function) aFunction =
848 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
850 //Check if the function is set correctly
851 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
853 GEOMImpl_IPlane aPI (aFunction);
855 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
856 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
857 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
859 aPI.SetPoint(aRefPnt);
860 aPI.SetVector(aRefVec);
861 aPI.SetSize(theSize);
863 //Compute the Plane value
865 #if OCC_VERSION_LARGE > 0x06010000
868 if (!GetSolver()->ComputeFunction(aFunction)) {
869 SetErrorCode("Plane driver failed");
873 catch (Standard_Failure) {
874 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
875 SetErrorCode(aFail->GetMessageString());
879 //Make a Python command
880 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
881 << thePnt << ", " << theVec << ", " << theSize << ")";
887 //=============================================================================
891 //=============================================================================
892 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
893 (Handle(GEOM_Object) theFace, double theSize)
897 if (theFace.IsNull()) return NULL;
899 //Add a new Plane object
900 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
902 //Add a new Plane function
903 Handle(GEOM_Function) aFunction =
904 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
906 //Check if the function is set correctly
907 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
909 GEOMImpl_IPlane aPI (aFunction);
911 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
912 if (aRef.IsNull()) return NULL;
915 aPI.SetSize(theSize);
917 //Compute the Plane value
919 #if OCC_VERSION_LARGE > 0x06010000
922 if (!GetSolver()->ComputeFunction(aFunction)) {
923 SetErrorCode("Plane driver failed");
927 catch (Standard_Failure) {
928 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
929 SetErrorCode(aFail->GetMessageString());
933 //Make a Python command
934 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
935 << theFace << ", " << theSize << ")";
941 //=============================================================================
945 //=============================================================================
946 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
947 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
952 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
954 //Add a new Plane object
955 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
957 //Add a new Plane function
958 Handle(GEOM_Function) aFunction =
959 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
961 //Check if the function is set correctly
962 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
964 GEOMImpl_IPlane aPI (aFunction);
966 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
967 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
968 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
970 aPI.SetVector1(aRefVec1);
971 aPI.SetVector2(aRefVec2);
972 aPI.SetSize(theSize);
974 //Compute the Plane value
976 #if OCC_VERSION_LARGE > 0x06010000
979 if (!GetSolver()->ComputeFunction(aFunction)) {
980 SetErrorCode("Plane driver failed");
984 catch (Standard_Failure) {
985 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
986 SetErrorCode(aFail->GetMessageString());
990 //Make a Python command
991 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
992 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
998 //=============================================================================
1002 //=============================================================================
1003 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
1004 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
1008 //Add a new Plane object
1009 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1011 //Add a new Plane function
1012 Handle(GEOM_Function) aFunction =
1013 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
1015 //Check if the function is set correctly
1016 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1018 GEOMImpl_IPlane aPI (aFunction);
1020 if ( !theLCS.IsNull() ) {
1021 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1025 aPI.SetSize(theSize);
1026 aPI.SetOrientation(theOrientation);
1028 //Compute the Plane value
1030 #if OCC_VERSION_LARGE > 0x06010000
1033 if (!GetSolver()->ComputeFunction(aFunction)) {
1034 SetErrorCode("Plane driver failed");
1038 catch (Standard_Failure) {
1039 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1040 SetErrorCode(aFail->GetMessageString());
1044 //Make a Python command
1045 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1046 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1053 //=============================================================================
1057 //=============================================================================
1058 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1059 (double theOX, double theOY, double theOZ,
1060 double theXDX, double theXDY, double theXDZ,
1061 double theYDX, double theYDY, double theYDZ)
1065 //Add a new Marker object
1066 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1068 //Add a new Marker function
1069 Handle(GEOM_Function) aFunction =
1070 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1071 if (aFunction.IsNull()) return NULL;
1073 //Check if the function is set correctly
1074 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1076 GEOMImpl_IMarker aPI(aFunction);
1078 aPI.SetOrigin(theOX, theOY, theOZ);
1079 aPI.SetXDir(theXDX, theXDY, theXDZ);
1080 aPI.SetYDir(theYDX, theYDY, theYDZ);
1082 //Compute the marker value
1084 #if OCC_VERSION_LARGE > 0x06010000
1087 if (!GetSolver()->ComputeFunction(aFunction)) {
1088 SetErrorCode("Marker driver failed");
1092 catch (Standard_Failure) {
1093 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1094 SetErrorCode(aFail->GetMessageString());
1098 //Make a Python command
1099 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1100 << theOX << ", " << theOY << ", " << theOZ << ", "
1101 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1102 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1108 //=============================================================================
1110 * MakeMarkerFromShape
1112 //=============================================================================
1113 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1114 (const Handle(GEOM_Object)& theShape)
1118 //Add a new Marker object
1119 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1121 //Add a new Marker function
1122 Handle(GEOM_Function) aFunction =
1123 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1124 if (aFunction.IsNull()) return NULL;
1126 //Check if the function is set correctly
1127 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1129 GEOMImpl_IMarker aPI(aFunction);
1131 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1132 if (aRefShape.IsNull()) return NULL;
1134 aPI.SetShape(aRefShape);
1136 //Compute the marker value
1138 #if OCC_VERSION_LARGE > 0x06010000
1141 if (!GetSolver()->ComputeFunction(aFunction)) {
1142 SetErrorCode("Marker driver failed");
1146 catch (Standard_Failure) {
1147 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1148 SetErrorCode(aFail->GetMessageString());
1152 //Make a Python command
1153 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1159 //=============================================================================
1161 * MakeMarkerPntTwoVec
1163 //=============================================================================
1164 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1165 (const Handle(GEOM_Object)& theOrigin,
1166 const Handle(GEOM_Object)& theXVec,
1167 const Handle(GEOM_Object)& theYVec)
1171 //Add a new Marker object
1172 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1174 //Add a new Marker function
1175 Handle(GEOM_Function) aFunction =
1176 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1177 if (aFunction.IsNull()) return NULL;
1179 //Check if the function is set correctly
1180 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1182 GEOMImpl_IMarker aPI(aFunction);
1184 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1185 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1186 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1187 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1189 aPI.SetOrigin(aRefOrigin);
1190 aPI.SetXVec(aRefXVec);
1191 aPI.SetYVec(aRefYVec);
1193 //Compute the marker value
1195 #if OCC_VERSION_LARGE > 0x06010000
1198 if (!GetSolver()->ComputeFunction(aFunction)) {
1199 SetErrorCode("Marker driver failed");
1203 catch (Standard_Failure) {
1204 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1205 SetErrorCode(aFail->GetMessageString());
1209 //Make a Python command
1210 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1211 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1217 //=============================================================================
1219 * MakeTangentPlaneOnFace
1221 //=============================================================================
1223 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1230 if (theFace.IsNull()) return NULL;
1232 //Add a new Plane object
1233 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1235 //Add a new Plane function
1236 Handle(GEOM_Function) aFunction =
1237 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1239 //Check if the function is set correctly
1240 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1242 GEOMImpl_IPlane aPI (aFunction);
1244 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1245 if (aRef.IsNull()) return NULL;
1248 aPI.SetSize(theSize);
1249 aPI.SetParameterU(theParamU);
1250 aPI.SetParameterV(theParamV);
1252 //Compute the Plane value
1254 #if OCC_VERSION_LARGE > 0x06010000
1257 if (!GetSolver()->ComputeFunction(aFunction)) {
1258 SetErrorCode("Plane driver failed");
1262 catch (Standard_Failure) {
1263 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1264 SetErrorCode(aFail->GetMessageString());
1268 //Make a Python command
1269 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1270 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";