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
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_IBasicOperations.hxx>
27 #include "utilities.h"
29 #include <Utils_ExceptHandlers.hxx>
31 #include <TFunction_DriverTable.hxx>
32 #include <TFunction_Driver.hxx>
33 #include <TFunction_Logbook.hxx>
34 #include <TDF_Tool.hxx>
36 #include <GEOM_Function.hxx>
37 #include <GEOM_PythonDump.hxx>
39 #include <GEOMImpl_PointDriver.hxx>
40 #include <GEOMImpl_VectorDriver.hxx>
41 #include <GEOMImpl_LineDriver.hxx>
42 #include <GEOMImpl_PlaneDriver.hxx>
43 #include <GEOMImpl_MarkerDriver.hxx>
45 #include <GEOMImpl_IPoint.hxx>
46 #include <GEOMImpl_IVector.hxx>
47 #include <GEOMImpl_ILine.hxx>
48 #include <GEOMImpl_IPlane.hxx>
49 #include <GEOMImpl_IMarker.hxx>
51 #include <GEOMImpl_Types.hxx>
53 #include <Standard_Failure.hxx>
54 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
56 //=============================================================================
60 //=============================================================================
61 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
62 : GEOM_IOperations(theEngine, theDocID)
64 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
67 //=============================================================================
71 //=============================================================================
72 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
74 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
78 //=============================================================================
82 //=============================================================================
83 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
84 (double theX, double theY, double theZ)
88 //Add a new Point object
89 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
91 //Add a new Point function with XYZ parameters
92 Handle(GEOM_Function) aFunction =
93 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
94 if (aFunction.IsNull()) return NULL;
96 //Check if the function is set correctly
97 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
99 GEOMImpl_IPoint aPI(aFunction);
105 //Compute the point value
107 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
110 if (!GetSolver()->ComputeFunction(aFunction)) {
111 SetErrorCode("Point driver failed");
115 catch (Standard_Failure) {
116 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
117 SetErrorCode(aFail->GetMessageString());
121 //Make a Python command
122 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
123 << theX << ", " << theY << ", " << theZ << ")";
129 //=============================================================================
131 * MakePointWithReference
133 //=============================================================================
134 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
135 (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
139 if (theReference.IsNull()) return NULL;
141 //Add a new Point object
142 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
144 //Add a new Point function for creation a point relativley another point
145 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
147 //Check if the function is set correctly
148 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
150 GEOMImpl_IPoint aPI(aFunction);
152 Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
153 if (aRefFunction.IsNull()) return NULL;
155 aPI.SetRef(aRefFunction);
160 //Compute the point value
162 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
165 if (!GetSolver()->ComputeFunction(aFunction)) {
166 SetErrorCode("Point driver failed");
170 catch (Standard_Failure) {
171 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
172 SetErrorCode(aFail->GetMessageString());
176 //Make a Python command
177 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
178 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
184 //=============================================================================
188 //=============================================================================
189 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
190 (Handle(GEOM_Object) theGeomObj,
194 const PointLocation theLocation,
195 Handle(GEOM_Object) theRefPoint)
199 if (theGeomObj.IsNull()) return NULL;
201 //Add a new Point object
202 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
204 //Add a new Point function for creation a point relativley another point
205 int fType = POINT_CURVE_PAR;
206 switch( theLocation )
208 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
209 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
210 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
211 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
212 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
215 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
217 //Check if the function is set correctly
218 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
220 GEOMImpl_IPoint aPI (aFunction);
222 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
223 if (aRefFunction.IsNull()) return NULL;
225 switch( theLocation )
227 case PointOn_CurveByParam:
228 aPI.SetCurve(aRefFunction);
229 aPI.SetParameter(theParam1);
231 case PointOn_CurveByLength:
232 aPI.SetCurve(aRefFunction);
233 aPI.SetLength(theParam1);
234 if (!theRefPoint.IsNull()) {
235 Handle(GEOM_Function) aRefPoint = theRefPoint->GetLastFunction();
236 aPI.SetRef(aRefPoint);
239 case PointOn_CurveByCoord:
240 aPI.SetCurve(aRefFunction);
245 case PointOn_SurfaceByParam:
246 aPI.SetSurface(aRefFunction);
247 aPI.SetParameter(theParam1);
248 aPI.SetParameter2(theParam2);
250 case PointOn_SurfaceByCoord:
251 aPI.SetSurface(aRefFunction);
258 //Compute the point value
260 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
263 if (!GetSolver()->ComputeFunction(aFunction)) {
264 SetErrorCode("Point driver failed");
268 catch (Standard_Failure) {
269 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
270 SetErrorCode(aFail->GetMessageString());
274 //Make a Python command
275 switch( theLocation )
277 case PointOn_CurveByParam:
278 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
279 << theGeomObj << ", " << theParam1 << ")";
281 case PointOn_CurveByLength:
282 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
283 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
285 case PointOn_CurveByCoord:
286 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
287 << theGeomObj << ", " << theParam1
288 << ", " << theParam2 << ", " << theParam3 << ")";
290 case PointOn_SurfaceByParam:
291 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
292 << theGeomObj << ", " << theParam1
293 << ", " << theParam2 << ")";
295 case PointOn_SurfaceByCoord:
296 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
297 << theGeomObj << ", " << theParam1
298 << ", " << theParam2 << ", " << theParam3 << ")";
306 //=============================================================================
310 //=============================================================================
311 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
312 (Handle(GEOM_Object) theCurve, double theParameter)
314 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
317 //=============================================================================
319 * MakePointOnCurveByCoord
321 //=============================================================================
322 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
323 (Handle(GEOM_Object) theCurve,
328 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
331 //=============================================================================
333 * MakePointOnCurveByLength
335 //=============================================================================
336 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
337 (Handle(GEOM_Object) theCurve,
339 Handle(GEOM_Object) theStartPoint)
341 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theStartPoint);
344 //=============================================================================
348 //=============================================================================
349 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
350 (Handle(GEOM_Object) theSurface,
351 double theUParameter,
352 double theVParameter)
354 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
357 //=============================================================================
359 * MakePointOnSurfaceByCoord
361 //=============================================================================
362 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
363 (Handle(GEOM_Object) theSurface,
368 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
372 //=============================================================================
374 * MakePointOnLinesIntersection
376 //=============================================================================
377 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
378 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
382 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
384 //Add a new Point object
385 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
387 //Add a new Point function for creation a point relativley another point
388 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
390 //Check if the function is set correctly
391 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
393 GEOMImpl_IPoint aPI (aFunction);
395 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
396 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
397 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
402 //Compute the point value
404 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
407 if (!GetSolver()->ComputeFunction(aFunction)) {
408 SetErrorCode("Point driver failed");
412 catch (Standard_Failure) {
413 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
414 SetErrorCode(aFail->GetMessageString());
418 //Make a Python command
419 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
420 << theLine1 << ", " << theLine2 << ")";
426 //=============================================================================
430 //=============================================================================
431 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
432 (const Handle(GEOM_Object)& theCurve, double theParameter)
436 if (theCurve.IsNull()) return NULL;
438 //Add a new Vector object
439 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
441 //Add a new Point function for creation a point relativley another point
442 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
444 //Check if the function is set correctly
445 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
447 GEOMImpl_IVector aVI (aFunction);
449 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
450 if (aRefFunction.IsNull()) return NULL;
452 aVI.SetCurve(aRefFunction);
453 aVI.SetParameter(theParameter);
455 //Compute the vector value
457 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
460 if (!GetSolver()->ComputeFunction(aFunction)) {
461 SetErrorCode("Vector driver failed");
465 catch (Standard_Failure) {
466 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
467 SetErrorCode(aFail->GetMessageString());
471 //Make a Python command
472 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
473 << theCurve << ", " << theParameter << ")";
479 //=============================================================================
483 //=============================================================================
484 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
485 (double theDX, double theDY, double theDZ)
489 //Add a new Vector object
490 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
492 //Add a new Vector function with DXDYDZ parameters
493 Handle(GEOM_Function) aFunction =
494 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
495 if (aFunction.IsNull()) return NULL;
497 //Check if the function is set correctly
498 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
500 GEOMImpl_IVector aPI (aFunction);
506 //Compute the Vector value
508 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
511 if (!GetSolver()->ComputeFunction(aFunction)) {
512 SetErrorCode("Vector driver failed");
516 catch (Standard_Failure) {
517 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
518 SetErrorCode(aFail->GetMessageString());
522 //Make a Python command
523 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
524 << theDX << ", " << theDY << ", " << theDZ << ")";
530 //=============================================================================
534 //=============================================================================
535 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
536 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
540 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
542 //Add a new Vector object
543 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
545 //Add a new Vector function
546 Handle(GEOM_Function) aFunction =
547 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
549 //Check if the function is set correctly
550 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
552 GEOMImpl_IVector aPI (aFunction);
554 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
555 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
556 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
558 aPI.SetPoint1(aRef1);
559 aPI.SetPoint2(aRef2);
561 //Compute the Vector value
563 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
566 if (!GetSolver()->ComputeFunction(aFunction)) {
567 SetErrorCode("Vector driver failed");
571 catch (Standard_Failure) {
572 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
573 SetErrorCode(aFail->GetMessageString());
577 //Make a Python command
578 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
579 << thePnt1 << ", " << thePnt2 << ")";
586 //=============================================================================
590 //=============================================================================
591 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
592 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
596 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
598 //Add a new Line object
599 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
601 //Add a new Line function
602 Handle(GEOM_Function) aFunction =
603 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
605 //Check if the function is set correctly
606 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
608 GEOMImpl_ILine aPI (aFunction);
610 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
611 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
612 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
614 aPI.SetPoint1(aRef1);
615 aPI.SetPoint2(aRef2);
617 //Compute the Line value
619 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
622 if (!GetSolver()->ComputeFunction(aFunction)) {
623 SetErrorCode("Line driver failed");
627 catch (Standard_Failure) {
628 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
629 SetErrorCode(aFail->GetMessageString());
633 //Make a Python command
634 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
635 << thePnt << ", " << theDir << ")";
641 //=============================================================================
645 //=============================================================================
646 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
647 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
651 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
653 //Add a new Line object
654 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
656 //Add a new Line function
657 Handle(GEOM_Function) aFunction =
658 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
660 //Check if the function is set correctly
661 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
663 GEOMImpl_ILine aPI (aFunction);
665 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
666 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
667 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
669 aPI.SetPoint1(aRef1);
670 aPI.SetPoint2(aRef2);
672 //Compute the Line value
674 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
677 if (!GetSolver()->ComputeFunction(aFunction)) {
678 SetErrorCode("Line driver failed");
682 catch (Standard_Failure) {
683 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
684 SetErrorCode(aFail->GetMessageString());
688 //Make a Python command
689 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
690 << thePnt1 << ", " << thePnt2 << ")";
696 //=============================================================================
700 //=============================================================================
701 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
702 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
706 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
708 //Add a new Line object
709 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
711 //Add a new Line function
712 Handle(GEOM_Function) aFunction =
713 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
715 //Check if the function is set correctly
716 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
718 GEOMImpl_ILine aPI (aFunction);
720 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
721 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
722 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
727 //Compute the Line value
729 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
732 if (!GetSolver()->ComputeFunction(aFunction)) {
733 SetErrorCode("Line driver failed");
737 catch (Standard_Failure) {
738 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
739 SetErrorCode(aFail->GetMessageString());
743 //Make a Python command
744 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
745 << theFace1 << ", " << theFace2 << ")";
751 //=============================================================================
755 //=============================================================================
756 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
757 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
758 Handle(GEOM_Object) thePnt3, double theSize)
762 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
764 //Add a new Plane object
765 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
767 //Add a new Plane function
768 Handle(GEOM_Function) aFunction =
769 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
771 //Check if the function is set correctly
772 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
774 GEOMImpl_IPlane aPI (aFunction);
776 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
777 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
778 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
779 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
781 aPI.SetPoint1(aRef1);
782 aPI.SetPoint2(aRef2);
783 aPI.SetPoint3(aRef3);
784 aPI.SetSize(theSize);
786 //Compute the Plane value
788 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
791 if (!GetSolver()->ComputeFunction(aFunction)) {
792 SetErrorCode("Plane driver failed");
796 catch (Standard_Failure) {
797 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
798 SetErrorCode(aFail->GetMessageString());
802 //Make a Python command
803 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
804 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
810 //=============================================================================
814 //=============================================================================
815 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
816 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
821 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
823 //Add a new Plane object
824 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
826 //Add a new Plane function
827 Handle(GEOM_Function) aFunction =
828 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
830 //Check if the function is set correctly
831 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
833 GEOMImpl_IPlane aPI (aFunction);
835 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
836 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
837 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
839 aPI.SetPoint(aRefPnt);
840 aPI.SetVector(aRefVec);
841 aPI.SetSize(theSize);
843 //Compute the Plane value
845 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
848 if (!GetSolver()->ComputeFunction(aFunction)) {
849 SetErrorCode("Plane driver failed");
853 catch (Standard_Failure) {
854 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
855 SetErrorCode(aFail->GetMessageString());
859 //Make a Python command
860 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
861 << thePnt << ", " << theVec << ", " << theSize << ")";
867 //=============================================================================
871 //=============================================================================
872 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
873 (Handle(GEOM_Object) theFace, double theSize)
877 if (theFace.IsNull()) return NULL;
879 //Add a new Plane object
880 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
882 //Add a new Plane function
883 Handle(GEOM_Function) aFunction =
884 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
886 //Check if the function is set correctly
887 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
889 GEOMImpl_IPlane aPI (aFunction);
891 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
892 if (aRef.IsNull()) return NULL;
895 aPI.SetSize(theSize);
897 //Compute the Plane value
899 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
902 if (!GetSolver()->ComputeFunction(aFunction)) {
903 SetErrorCode("Plane driver failed");
907 catch (Standard_Failure) {
908 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
909 SetErrorCode(aFail->GetMessageString());
913 //Make a Python command
914 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
915 << theFace << ", " << theSize << ")";
921 //=============================================================================
925 //=============================================================================
926 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
927 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
932 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
934 //Add a new Plane object
935 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
937 //Add a new Plane function
938 Handle(GEOM_Function) aFunction =
939 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
941 //Check if the function is set correctly
942 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
944 GEOMImpl_IPlane aPI (aFunction);
946 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
947 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
948 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
950 aPI.SetVector1(aRefVec1);
951 aPI.SetVector2(aRefVec2);
952 aPI.SetSize(theSize);
954 //Compute the Plane value
956 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
959 if (!GetSolver()->ComputeFunction(aFunction)) {
960 SetErrorCode("Plane driver failed");
964 catch (Standard_Failure) {
965 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
966 SetErrorCode(aFail->GetMessageString());
970 //Make a Python command
971 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
972 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
978 //=============================================================================
982 //=============================================================================
983 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
984 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
988 //Add a new Plane object
989 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
991 //Add a new Plane function
992 Handle(GEOM_Function) aFunction =
993 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
995 //Check if the function is set correctly
996 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
998 GEOMImpl_IPlane aPI (aFunction);
1000 if ( !theLCS.IsNull() ) {
1001 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1005 aPI.SetSize(theSize);
1006 aPI.SetOrientation(theOrientation);
1008 //Compute the Plane value
1010 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1013 if (!GetSolver()->ComputeFunction(aFunction)) {
1014 SetErrorCode("Plane driver failed");
1018 catch (Standard_Failure) {
1019 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1020 SetErrorCode(aFail->GetMessageString());
1024 //Make a Python command
1025 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1026 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1033 //=============================================================================
1037 //=============================================================================
1038 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1039 (double theOX, double theOY, double theOZ,
1040 double theXDX, double theXDY, double theXDZ,
1041 double theYDX, double theYDY, double theYDZ)
1045 //Add a new Marker object
1046 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1048 //Add a new Marker function
1049 Handle(GEOM_Function) aFunction =
1050 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1051 if (aFunction.IsNull()) return NULL;
1053 //Check if the function is set correctly
1054 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1056 GEOMImpl_IMarker aPI(aFunction);
1058 aPI.SetOrigin(theOX, theOY, theOZ);
1059 aPI.SetXDir(theXDX, theXDY, theXDZ);
1060 aPI.SetYDir(theYDX, theYDY, theYDZ);
1062 //Compute the marker value
1064 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1067 if (!GetSolver()->ComputeFunction(aFunction)) {
1068 SetErrorCode("Marker driver failed");
1072 catch (Standard_Failure) {
1073 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1074 SetErrorCode(aFail->GetMessageString());
1078 //Make a Python command
1079 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1080 << theOX << ", " << theOY << ", " << theOZ << ", "
1081 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1082 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1088 //=============================================================================
1090 * MakeMarkerFromShape
1092 //=============================================================================
1093 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1094 (const Handle(GEOM_Object)& theShape)
1098 //Add a new Marker object
1099 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1101 //Add a new Marker function
1102 Handle(GEOM_Function) aFunction =
1103 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1104 if (aFunction.IsNull()) return NULL;
1106 //Check if the function is set correctly
1107 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1109 GEOMImpl_IMarker aPI(aFunction);
1111 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1112 if (aRefShape.IsNull()) return NULL;
1114 aPI.SetShape(aRefShape);
1116 //Compute the marker value
1118 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1121 if (!GetSolver()->ComputeFunction(aFunction)) {
1122 SetErrorCode("Marker driver failed");
1126 catch (Standard_Failure) {
1127 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1128 SetErrorCode(aFail->GetMessageString());
1132 //Make a Python command
1133 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1139 //=============================================================================
1141 * MakeMarkerPntTwoVec
1143 //=============================================================================
1144 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1145 (const Handle(GEOM_Object)& theOrigin,
1146 const Handle(GEOM_Object)& theXVec,
1147 const Handle(GEOM_Object)& theYVec)
1151 //Add a new Marker object
1152 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1154 //Add a new Marker function
1155 Handle(GEOM_Function) aFunction =
1156 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1157 if (aFunction.IsNull()) return NULL;
1159 //Check if the function is set correctly
1160 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1162 GEOMImpl_IMarker aPI(aFunction);
1164 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1165 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1166 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1167 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1169 aPI.SetOrigin(aRefOrigin);
1170 aPI.SetXVec(aRefXVec);
1171 aPI.SetYVec(aRefYVec);
1173 //Compute the marker value
1175 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1178 if (!GetSolver()->ComputeFunction(aFunction)) {
1179 SetErrorCode("Marker driver failed");
1183 catch (Standard_Failure) {
1184 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1185 SetErrorCode(aFail->GetMessageString());
1189 //Make a Python command
1190 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1191 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1197 //=============================================================================
1199 * MakeTangentPlaneOnFace
1201 //=============================================================================
1203 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1210 if (theFace.IsNull()) return NULL;
1212 //Add a new Plane object
1213 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1215 //Add a new Plane function
1216 Handle(GEOM_Function) aFunction =
1217 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1219 //Check if the function is set correctly
1220 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1222 GEOMImpl_IPlane aPI (aFunction);
1224 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1225 if (aRef.IsNull()) return NULL;
1228 aPI.SetSize(theSize);
1229 aPI.SetParameterU(theParamU);
1230 aPI.SetParameterV(theParamV);
1232 //Compute the Plane value
1234 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1237 if (!GetSolver()->ComputeFunction(aFunction)) {
1238 SetErrorCode("Plane driver failed");
1242 catch (Standard_Failure) {
1243 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1244 SetErrorCode(aFail->GetMessageString());
1248 //Make a Python command
1249 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1250 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";