1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_IBasicOperations.hxx>
26 #include "utilities.h"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TFunction_Logbook.hxx>
33 #include <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_PointDriver.hxx>
39 #include <GEOMImpl_VectorDriver.hxx>
40 #include <GEOMImpl_LineDriver.hxx>
41 #include <GEOMImpl_PlaneDriver.hxx>
42 #include <GEOMImpl_MarkerDriver.hxx>
44 #include <GEOMImpl_IPoint.hxx>
45 #include <GEOMImpl_IVector.hxx>
46 #include <GEOMImpl_ILine.hxx>
47 #include <GEOMImpl_IPlane.hxx>
48 #include <GEOMImpl_IMarker.hxx>
50 #include <GEOMImpl_Types.hxx>
52 #include <Standard_Failure.hxx>
53 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
55 //=============================================================================
59 //=============================================================================
60 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
61 : GEOM_IOperations(theEngine, theDocID)
63 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
66 //=============================================================================
70 //=============================================================================
71 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
73 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
77 //=============================================================================
81 //=============================================================================
82 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
83 (double theX, double theY, double theZ)
87 //Add a new Point object
88 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
90 //Add a new Point function with XYZ parameters
91 Handle(GEOM_Function) aFunction =
92 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
93 if (aFunction.IsNull()) return NULL;
95 //Check if the function is set correctly
96 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
98 GEOMImpl_IPoint aPI(aFunction);
104 //Compute the point value
106 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
109 if (!GetSolver()->ComputeFunction(aFunction)) {
110 SetErrorCode("Point driver failed");
114 catch (Standard_Failure) {
115 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
116 SetErrorCode(aFail->GetMessageString());
120 //Make a Python command
121 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
122 << theX << ", " << theY << ", " << theZ << ")";
128 //=============================================================================
130 * MakePointWithReference
132 //=============================================================================
133 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
134 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
138 if (theReference.IsNull()) return NULL;
140 //Add a new Point object
141 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
143 //Add a new Point function for creation a point relativley another point
144 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
146 //Check if the function is set correctly
147 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
149 GEOMImpl_IPoint aPI(aFunction);
151 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
152 if (aRefFunction.IsNull()) return NULL;
154 aPI.SetRef(aRefFunction);
159 //Compute the point value
161 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
164 if (!GetSolver()->ComputeFunction(aFunction)) {
165 SetErrorCode("Point driver failed");
169 catch (Standard_Failure) {
170 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
171 SetErrorCode(aFail->GetMessageString());
175 //Make a Python command
176 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
177 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
183 //=============================================================================
187 //=============================================================================
188 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
189 (Handle(GEOM_Object) theCurve, double theParameter)
193 if (theCurve.IsNull()) return NULL;
195 //Add a new Point object
196 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
198 //Add a new Point function for creation a point relativley another point
199 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_CURVE_PAR);
201 //Check if the function is set correctly
202 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
204 GEOMImpl_IPoint aPI (aFunction);
206 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
207 if (aRefFunction.IsNull()) return NULL;
209 aPI.SetCurve(aRefFunction);
210 aPI.SetParameter(theParameter);
212 //Compute the point value
214 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
217 if (!GetSolver()->ComputeFunction(aFunction)) {
218 SetErrorCode("Point driver failed");
222 catch (Standard_Failure) {
223 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
224 SetErrorCode(aFail->GetMessageString());
228 //Make a Python command
229 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
230 << theCurve << ", " << theParameter << ")";
237 //=============================================================================
241 //=============================================================================
242 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
243 (Handle(GEOM_Object) theSurface, double theUParameter, double theVParameter)
247 if (theSurface.IsNull()) return NULL;
249 //Add a new Point object
250 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
252 //Add a new Point function for creation a point relativley another point
253 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(),
256 //Check if the function is set correctly
257 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
259 GEOMImpl_IPoint aPI (aFunction);
261 Handle(GEOM_Function) aRefFunction = theSurface->GetLastFunction();
262 if (aRefFunction.IsNull()) return NULL;
264 aPI.SetSurface(aRefFunction);
265 aPI.SetParameter(theUParameter);
266 aPI.SetParameter2(theVParameter);
268 //Compute the point value
270 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
273 if (!GetSolver()->ComputeFunction(aFunction)) {
274 SetErrorCode("Point driver failed");
278 catch (Standard_Failure) {
279 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
280 SetErrorCode(aFail->GetMessageString());
284 //Make a Python command
285 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
286 << theSurface << ", " << theUParameter
287 << ", " << theVParameter << ")";
294 //=============================================================================
296 * MakePointOnLinesIntersection
298 //=============================================================================
299 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
300 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
304 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
306 //Add a new Point object
307 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
309 //Add a new Point function for creation a point relativley another point
310 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
312 //Check if the function is set correctly
313 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
315 GEOMImpl_IPoint aPI (aFunction);
317 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
318 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
319 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
324 //Compute the point value
326 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
329 if (!GetSolver()->ComputeFunction(aFunction)) {
330 SetErrorCode("Point driver failed");
334 catch (Standard_Failure) {
335 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
336 SetErrorCode(aFail->GetMessageString());
340 //Make a Python command
341 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
342 << theLine1 << ", " << theLine2 << ")";
348 //=============================================================================
352 //=============================================================================
353 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
354 (const Handle(GEOM_Object)& theCurve, double theParameter)
358 if (theCurve.IsNull()) return NULL;
360 //Add a new Vector object
361 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
363 //Add a new Point function for creation a point relativley another point
364 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
366 //Check if the function is set correctly
367 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
369 GEOMImpl_IVector aVI (aFunction);
371 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
372 if (aRefFunction.IsNull()) return NULL;
374 aVI.SetCurve(aRefFunction);
375 aVI.SetParameter(theParameter);
377 //Compute the vector value
379 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
382 if (!GetSolver()->ComputeFunction(aFunction)) {
383 SetErrorCode("Vector driver failed");
387 catch (Standard_Failure) {
388 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
389 SetErrorCode(aFail->GetMessageString());
393 //Make a Python command
394 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
395 << theCurve << ", " << theParameter << ")";
401 //=============================================================================
405 //=============================================================================
406 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
407 (double theDX, double theDY, double theDZ)
411 //Add a new Vector object
412 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
414 //Add a new Vector function with DXDYDZ parameters
415 Handle(GEOM_Function) aFunction =
416 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
417 if (aFunction.IsNull()) return NULL;
419 //Check if the function is set correctly
420 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
422 GEOMImpl_IVector aPI (aFunction);
428 //Compute the Vector value
430 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
433 if (!GetSolver()->ComputeFunction(aFunction)) {
434 SetErrorCode("Vector driver failed");
438 catch (Standard_Failure) {
439 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
440 SetErrorCode(aFail->GetMessageString());
444 //Make a Python command
445 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
446 << theDX << ", " << theDY << ", " << theDZ << ")";
452 //=============================================================================
456 //=============================================================================
457 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
458 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
462 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
464 //Add a new Vector object
465 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
467 //Add a new Vector function
468 Handle(GEOM_Function) aFunction =
469 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
471 //Check if the function is set correctly
472 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
474 GEOMImpl_IVector aPI (aFunction);
476 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
477 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
478 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
480 aPI.SetPoint1(aRef1);
481 aPI.SetPoint2(aRef2);
483 //Compute the Vector value
485 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
488 if (!GetSolver()->ComputeFunction(aFunction)) {
489 SetErrorCode("Vector driver failed");
493 catch (Standard_Failure) {
494 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
495 SetErrorCode(aFail->GetMessageString());
499 //Make a Python command
500 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
501 << thePnt1 << ", " << thePnt2 << ")";
508 //=============================================================================
512 //=============================================================================
513 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
514 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
518 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
520 //Add a new Line object
521 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
523 //Add a new Line function
524 Handle(GEOM_Function) aFunction =
525 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
527 //Check if the function is set correctly
528 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
530 GEOMImpl_ILine aPI (aFunction);
532 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
533 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
534 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
536 aPI.SetPoint1(aRef1);
537 aPI.SetPoint2(aRef2);
539 //Compute the Line value
541 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
544 if (!GetSolver()->ComputeFunction(aFunction)) {
545 SetErrorCode("Line driver failed");
549 catch (Standard_Failure) {
550 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
551 SetErrorCode(aFail->GetMessageString());
555 //Make a Python command
556 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
557 << thePnt << ", " << theDir << ")";
563 //=============================================================================
567 //=============================================================================
568 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
569 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
573 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
575 //Add a new Line object
576 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
578 //Add a new Line function
579 Handle(GEOM_Function) aFunction =
580 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
582 //Check if the function is set correctly
583 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
585 GEOMImpl_ILine aPI (aFunction);
587 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
588 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
589 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
591 aPI.SetPoint1(aRef1);
592 aPI.SetPoint2(aRef2);
594 //Compute the Line value
596 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
599 if (!GetSolver()->ComputeFunction(aFunction)) {
600 SetErrorCode("Line driver failed");
604 catch (Standard_Failure) {
605 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
606 SetErrorCode(aFail->GetMessageString());
610 //Make a Python command
611 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
612 << thePnt1 << ", " << thePnt2 << ")";
618 //=============================================================================
622 //=============================================================================
623 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
624 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
628 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
630 //Add a new Line object
631 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
633 //Add a new Line function
634 Handle(GEOM_Function) aFunction =
635 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
637 //Check if the function is set correctly
638 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
640 GEOMImpl_ILine aPI (aFunction);
642 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
643 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
644 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
649 //Compute the Line value
651 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
654 if (!GetSolver()->ComputeFunction(aFunction)) {
655 SetErrorCode("Line driver failed");
659 catch (Standard_Failure) {
660 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
661 SetErrorCode(aFail->GetMessageString());
665 //Make a Python command
666 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
667 << theFace1 << ", " << theFace2 << ")";
673 //=============================================================================
677 //=============================================================================
678 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
679 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
680 Handle(GEOM_Object) thePnt3, double theSize)
684 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
686 //Add a new Plane object
687 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
689 //Add a new Plane function
690 Handle(GEOM_Function) aFunction =
691 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
693 //Check if the function is set correctly
694 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
696 GEOMImpl_IPlane aPI (aFunction);
698 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
699 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
700 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
701 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
703 aPI.SetPoint1(aRef1);
704 aPI.SetPoint2(aRef2);
705 aPI.SetPoint3(aRef3);
706 aPI.SetSize(theSize);
708 //Compute the Plane value
710 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
713 if (!GetSolver()->ComputeFunction(aFunction)) {
714 SetErrorCode("Plane driver failed");
718 catch (Standard_Failure) {
719 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
720 SetErrorCode(aFail->GetMessageString());
724 //Make a Python command
725 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
726 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
732 //=============================================================================
736 //=============================================================================
737 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
738 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
743 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
745 //Add a new Plane object
746 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
748 //Add a new Plane function
749 Handle(GEOM_Function) aFunction =
750 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
752 //Check if the function is set correctly
753 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
755 GEOMImpl_IPlane aPI (aFunction);
757 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
758 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
759 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
761 aPI.SetPoint(aRefPnt);
762 aPI.SetVector(aRefVec);
763 aPI.SetSize(theSize);
765 //Compute the Plane value
767 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
770 if (!GetSolver()->ComputeFunction(aFunction)) {
771 SetErrorCode("Plane driver failed");
775 catch (Standard_Failure) {
776 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
777 SetErrorCode(aFail->GetMessageString());
781 //Make a Python command
782 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
783 << thePnt << ", " << theVec << ", " << theSize << ")";
789 //=============================================================================
793 //=============================================================================
794 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
795 (Handle(GEOM_Object) theFace, double theSize)
799 if (theFace.IsNull()) return NULL;
801 //Add a new Plane object
802 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
804 //Add a new Plane function
805 Handle(GEOM_Function) aFunction =
806 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
808 //Check if the function is set correctly
809 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
811 GEOMImpl_IPlane aPI (aFunction);
813 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
814 if (aRef.IsNull()) return NULL;
817 aPI.SetSize(theSize);
819 //Compute the Plane value
821 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
824 if (!GetSolver()->ComputeFunction(aFunction)) {
825 SetErrorCode("Plane driver failed");
829 catch (Standard_Failure) {
830 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
831 SetErrorCode(aFail->GetMessageString());
835 //Make a Python command
836 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
837 << theFace << ", " << theSize << ")";
844 //=============================================================================
848 //=============================================================================
849 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
850 (double theOX, double theOY, double theOZ,
851 double theXDX, double theXDY, double theXDZ,
852 double theYDX, double theYDY, double theYDZ)
856 //Add a new Marker object
857 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
859 //Add a new Marker function
860 Handle(GEOM_Function) aFunction =
861 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
862 if (aFunction.IsNull()) return NULL;
864 //Check if the function is set correctly
865 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
867 GEOMImpl_IMarker aPI(aFunction);
869 aPI.SetOrigin(theOX, theOY, theOZ);
870 aPI.SetXDir(theXDX, theXDY, theXDZ);
871 aPI.SetYDir(theYDX, theYDY, theYDZ);
873 //Compute the marker value
875 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
878 if (!GetSolver()->ComputeFunction(aFunction)) {
879 SetErrorCode("Marker driver failed");
883 catch (Standard_Failure) {
884 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
885 SetErrorCode(aFail->GetMessageString());
889 //Make a Python command
890 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
891 << theOX << ", " << theOY << ", " << theOZ << ", "
892 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
893 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
899 //=============================================================================
901 * MakeTangentPlaneOnFace
903 //=============================================================================
905 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
912 if (theFace.IsNull()) return NULL;
914 //Add a new Plane object
915 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
917 //Add a new Plane function
918 Handle(GEOM_Function) aFunction =
919 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
921 //Check if the function is set correctly
922 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
924 GEOMImpl_IPlane aPI (aFunction);
926 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
927 if (aRef.IsNull()) return NULL;
930 aPI.SetSize(theSize);
931 aPI.SetParameterU(theParamU);
932 aPI.SetParameterV(theParamV);
934 //Compute the Plane value
936 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
939 if (!GetSolver()->ComputeFunction(aFunction)) {
940 SetErrorCode("Plane driver failed");
944 catch (Standard_Failure) {
945 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
946 SetErrorCode(aFail->GetMessageString());
950 //Make a Python command
951 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
952 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";