1 // Copyright (C) 2007-2010 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)
198 if (theGeomObj.IsNull()) return NULL;
200 //Add a new Point object
201 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
203 //Add a new Point function for creation a point relativley another point
204 int fType = POINT_CURVE_PAR;
205 switch( theLocation )
207 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
208 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
209 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
210 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
211 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
214 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
216 //Check if the function is set correctly
217 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
219 GEOMImpl_IPoint aPI (aFunction);
221 Handle(GEOM_Function) aRefFunction = theGeomObj->GetLastFunction();
222 if (aRefFunction.IsNull()) return NULL;
224 switch( theLocation )
226 case PointOn_CurveByParam:
227 aPI.SetCurve(aRefFunction);
228 aPI.SetParameter(theParam1);
230 case PointOn_CurveByLength:
231 aPI.SetCurve(aRefFunction);
232 aPI.SetLength(theParam1);
234 case PointOn_CurveByCoord:
235 aPI.SetCurve(aRefFunction);
240 case PointOn_SurfaceByParam:
241 aPI.SetSurface(aRefFunction);
242 aPI.SetParameter(theParam1);
243 aPI.SetParameter2(theParam2);
245 case PointOn_SurfaceByCoord:
246 aPI.SetSurface(aRefFunction);
253 //Compute the point value
255 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
258 if (!GetSolver()->ComputeFunction(aFunction)) {
259 SetErrorCode("Point driver failed");
263 catch (Standard_Failure) {
264 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
265 SetErrorCode(aFail->GetMessageString());
269 //Make a Python command
270 switch( theLocation )
272 case PointOn_CurveByParam:
273 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
274 << theGeomObj << ", " << theParam1 << ")";
276 case PointOn_CurveByLength:
277 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
278 << theGeomObj << ", " << theParam1 << ")";
280 case PointOn_CurveByCoord:
281 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
282 << theGeomObj << ", " << theParam1
283 << ", " << theParam2 << ", " << theParam3 << ")";
285 case PointOn_SurfaceByParam:
286 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
287 << theGeomObj << ", " << theParam1
288 << ", " << theParam2 << ")";
290 case PointOn_SurfaceByCoord:
291 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
292 << theGeomObj << ", " << theParam1
293 << ", " << theParam2 << ", " << theParam3 << ")";
301 //=============================================================================
305 //=============================================================================
306 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
307 (Handle(GEOM_Object) theCurve, double theParameter)
309 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam);
312 //=============================================================================
314 * MakePointOnCurveByCoord
316 //=============================================================================
317 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
318 (Handle(GEOM_Object) theCurve,
323 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
326 //=============================================================================
328 * MakePointOnCurveByLength
330 //=============================================================================
331 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
332 (Handle(GEOM_Object) theCurve, double theLength)
334 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength);
337 //=============================================================================
341 //=============================================================================
342 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
343 (Handle(GEOM_Object) theSurface,
344 double theUParameter,
345 double theVParameter)
347 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
350 //=============================================================================
352 * MakePointOnSurfaceByCoord
354 //=============================================================================
355 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
356 (Handle(GEOM_Object) theSurface,
361 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
365 //=============================================================================
367 * MakePointOnLinesIntersection
369 //=============================================================================
370 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
371 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
375 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
377 //Add a new Point object
378 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
380 //Add a new Point function for creation a point relativley another point
381 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
383 //Check if the function is set correctly
384 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
386 GEOMImpl_IPoint aPI (aFunction);
388 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
389 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
390 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
395 //Compute the point value
397 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
400 if (!GetSolver()->ComputeFunction(aFunction)) {
401 SetErrorCode("Point driver failed");
405 catch (Standard_Failure) {
406 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
407 SetErrorCode(aFail->GetMessageString());
411 //Make a Python command
412 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
413 << theLine1 << ", " << theLine2 << ")";
419 //=============================================================================
423 //=============================================================================
424 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
425 (const Handle(GEOM_Object)& theCurve, double theParameter)
429 if (theCurve.IsNull()) return NULL;
431 //Add a new Vector object
432 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
434 //Add a new Point function for creation a point relativley another point
435 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
437 //Check if the function is set correctly
438 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
440 GEOMImpl_IVector aVI (aFunction);
442 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
443 if (aRefFunction.IsNull()) return NULL;
445 aVI.SetCurve(aRefFunction);
446 aVI.SetParameter(theParameter);
448 //Compute the vector value
450 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
453 if (!GetSolver()->ComputeFunction(aFunction)) {
454 SetErrorCode("Vector driver failed");
458 catch (Standard_Failure) {
459 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
460 SetErrorCode(aFail->GetMessageString());
464 //Make a Python command
465 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
466 << theCurve << ", " << theParameter << ")";
472 //=============================================================================
476 //=============================================================================
477 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
478 (double theDX, double theDY, double theDZ)
482 //Add a new Vector object
483 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
485 //Add a new Vector function with DXDYDZ parameters
486 Handle(GEOM_Function) aFunction =
487 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
488 if (aFunction.IsNull()) return NULL;
490 //Check if the function is set correctly
491 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
493 GEOMImpl_IVector aPI (aFunction);
499 //Compute the Vector value
501 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
504 if (!GetSolver()->ComputeFunction(aFunction)) {
505 SetErrorCode("Vector driver failed");
509 catch (Standard_Failure) {
510 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
511 SetErrorCode(aFail->GetMessageString());
515 //Make a Python command
516 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
517 << theDX << ", " << theDY << ", " << theDZ << ")";
523 //=============================================================================
527 //=============================================================================
528 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
529 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
533 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
535 //Add a new Vector object
536 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
538 //Add a new Vector function
539 Handle(GEOM_Function) aFunction =
540 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
542 //Check if the function is set correctly
543 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
545 GEOMImpl_IVector aPI (aFunction);
547 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
548 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
549 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
551 aPI.SetPoint1(aRef1);
552 aPI.SetPoint2(aRef2);
554 //Compute the Vector value
556 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
559 if (!GetSolver()->ComputeFunction(aFunction)) {
560 SetErrorCode("Vector driver failed");
564 catch (Standard_Failure) {
565 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
566 SetErrorCode(aFail->GetMessageString());
570 //Make a Python command
571 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
572 << thePnt1 << ", " << thePnt2 << ")";
579 //=============================================================================
583 //=============================================================================
584 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
585 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
589 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
591 //Add a new Line object
592 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
594 //Add a new Line function
595 Handle(GEOM_Function) aFunction =
596 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
598 //Check if the function is set correctly
599 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
601 GEOMImpl_ILine aPI (aFunction);
603 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
604 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
605 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
607 aPI.SetPoint1(aRef1);
608 aPI.SetPoint2(aRef2);
610 //Compute the Line value
612 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
615 if (!GetSolver()->ComputeFunction(aFunction)) {
616 SetErrorCode("Line driver failed");
620 catch (Standard_Failure) {
621 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
622 SetErrorCode(aFail->GetMessageString());
626 //Make a Python command
627 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
628 << thePnt << ", " << theDir << ")";
634 //=============================================================================
638 //=============================================================================
639 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
640 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
644 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
646 //Add a new Line object
647 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
649 //Add a new Line function
650 Handle(GEOM_Function) aFunction =
651 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
653 //Check if the function is set correctly
654 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
656 GEOMImpl_ILine aPI (aFunction);
658 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
659 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
660 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
662 aPI.SetPoint1(aRef1);
663 aPI.SetPoint2(aRef2);
665 //Compute the Line value
667 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
670 if (!GetSolver()->ComputeFunction(aFunction)) {
671 SetErrorCode("Line driver failed");
675 catch (Standard_Failure) {
676 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
677 SetErrorCode(aFail->GetMessageString());
681 //Make a Python command
682 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
683 << thePnt1 << ", " << thePnt2 << ")";
689 //=============================================================================
693 //=============================================================================
694 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
695 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
699 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
701 //Add a new Line object
702 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
704 //Add a new Line function
705 Handle(GEOM_Function) aFunction =
706 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
708 //Check if the function is set correctly
709 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
711 GEOMImpl_ILine aPI (aFunction);
713 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
714 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
715 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
720 //Compute the Line value
722 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
725 if (!GetSolver()->ComputeFunction(aFunction)) {
726 SetErrorCode("Line driver failed");
730 catch (Standard_Failure) {
731 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
732 SetErrorCode(aFail->GetMessageString());
736 //Make a Python command
737 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
738 << theFace1 << ", " << theFace2 << ")";
744 //=============================================================================
748 //=============================================================================
749 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
750 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
751 Handle(GEOM_Object) thePnt3, double theSize)
755 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
757 //Add a new Plane object
758 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
760 //Add a new Plane function
761 Handle(GEOM_Function) aFunction =
762 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
764 //Check if the function is set correctly
765 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
767 GEOMImpl_IPlane aPI (aFunction);
769 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
770 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
771 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
772 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
774 aPI.SetPoint1(aRef1);
775 aPI.SetPoint2(aRef2);
776 aPI.SetPoint3(aRef3);
777 aPI.SetSize(theSize);
779 //Compute the Plane value
781 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
784 if (!GetSolver()->ComputeFunction(aFunction)) {
785 SetErrorCode("Plane driver failed");
789 catch (Standard_Failure) {
790 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
791 SetErrorCode(aFail->GetMessageString());
795 //Make a Python command
796 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
797 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
803 //=============================================================================
807 //=============================================================================
808 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
809 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
814 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
816 //Add a new Plane object
817 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
819 //Add a new Plane function
820 Handle(GEOM_Function) aFunction =
821 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
823 //Check if the function is set correctly
824 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
826 GEOMImpl_IPlane aPI (aFunction);
828 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
829 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
830 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
832 aPI.SetPoint(aRefPnt);
833 aPI.SetVector(aRefVec);
834 aPI.SetSize(theSize);
836 //Compute the Plane value
838 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
841 if (!GetSolver()->ComputeFunction(aFunction)) {
842 SetErrorCode("Plane driver failed");
846 catch (Standard_Failure) {
847 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
848 SetErrorCode(aFail->GetMessageString());
852 //Make a Python command
853 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
854 << thePnt << ", " << theVec << ", " << theSize << ")";
860 //=============================================================================
864 //=============================================================================
865 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
866 (Handle(GEOM_Object) theFace, double theSize)
870 if (theFace.IsNull()) return NULL;
872 //Add a new Plane object
873 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
875 //Add a new Plane function
876 Handle(GEOM_Function) aFunction =
877 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
879 //Check if the function is set correctly
880 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
882 GEOMImpl_IPlane aPI (aFunction);
884 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
885 if (aRef.IsNull()) return NULL;
888 aPI.SetSize(theSize);
890 //Compute the Plane value
892 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
895 if (!GetSolver()->ComputeFunction(aFunction)) {
896 SetErrorCode("Plane driver failed");
900 catch (Standard_Failure) {
901 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
902 SetErrorCode(aFail->GetMessageString());
906 //Make a Python command
907 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
908 << theFace << ", " << theSize << ")";
914 //=============================================================================
918 //=============================================================================
919 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
920 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
925 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
927 //Add a new Plane object
928 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
930 //Add a new Plane function
931 Handle(GEOM_Function) aFunction =
932 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
934 //Check if the function is set correctly
935 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
937 GEOMImpl_IPlane aPI (aFunction);
939 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
940 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
941 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
943 aPI.SetVector1(aRefVec1);
944 aPI.SetVector2(aRefVec2);
945 aPI.SetSize(theSize);
947 //Compute the Plane value
949 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
952 if (!GetSolver()->ComputeFunction(aFunction)) {
953 SetErrorCode("Plane driver failed");
957 catch (Standard_Failure) {
958 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
959 SetErrorCode(aFail->GetMessageString());
963 //Make a Python command
964 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
965 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
971 //=============================================================================
975 //=============================================================================
976 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
977 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
981 //Add a new Plane object
982 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
984 //Add a new Plane function
985 Handle(GEOM_Function) aFunction =
986 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
988 //Check if the function is set correctly
989 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
991 GEOMImpl_IPlane aPI (aFunction);
993 if ( !theLCS.IsNull() ) {
994 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
998 aPI.SetSize(theSize);
999 aPI.SetOrientation(theOrientation);
1001 //Compute the Plane value
1003 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1006 if (!GetSolver()->ComputeFunction(aFunction)) {
1007 SetErrorCode("Plane driver failed");
1011 catch (Standard_Failure) {
1012 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1013 SetErrorCode(aFail->GetMessageString());
1017 //Make a Python command
1018 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1019 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1026 //=============================================================================
1030 //=============================================================================
1031 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1032 (double theOX, double theOY, double theOZ,
1033 double theXDX, double theXDY, double theXDZ,
1034 double theYDX, double theYDY, double theYDZ)
1038 //Add a new Marker object
1039 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1041 //Add a new Marker function
1042 Handle(GEOM_Function) aFunction =
1043 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1044 if (aFunction.IsNull()) return NULL;
1046 //Check if the function is set correctly
1047 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1049 GEOMImpl_IMarker aPI(aFunction);
1051 aPI.SetOrigin(theOX, theOY, theOZ);
1052 aPI.SetXDir(theXDX, theXDY, theXDZ);
1053 aPI.SetYDir(theYDX, theYDY, theYDZ);
1055 //Compute the marker value
1057 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1060 if (!GetSolver()->ComputeFunction(aFunction)) {
1061 SetErrorCode("Marker driver failed");
1065 catch (Standard_Failure) {
1066 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1067 SetErrorCode(aFail->GetMessageString());
1071 //Make a Python command
1072 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1073 << theOX << ", " << theOY << ", " << theOZ << ", "
1074 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1075 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1081 //=============================================================================
1083 * MakeMarkerFromShape
1085 //=============================================================================
1086 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1087 (const Handle(GEOM_Object)& theShape)
1091 //Add a new Marker object
1092 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1094 //Add a new Marker function
1095 Handle(GEOM_Function) aFunction =
1096 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1097 if (aFunction.IsNull()) return NULL;
1099 //Check if the function is set correctly
1100 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1102 GEOMImpl_IMarker aPI(aFunction);
1104 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1105 if (aRefShape.IsNull()) return NULL;
1107 aPI.SetShape(aRefShape);
1109 //Compute the marker value
1111 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1114 if (!GetSolver()->ComputeFunction(aFunction)) {
1115 SetErrorCode("Marker driver failed");
1119 catch (Standard_Failure) {
1120 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1121 SetErrorCode(aFail->GetMessageString());
1125 //Make a Python command
1126 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
1132 //=============================================================================
1134 * MakeMarkerPntTwoVec
1136 //=============================================================================
1137 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
1138 (const Handle(GEOM_Object)& theOrigin,
1139 const Handle(GEOM_Object)& theXVec,
1140 const Handle(GEOM_Object)& theYVec)
1144 //Add a new Marker object
1145 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1147 //Add a new Marker function
1148 Handle(GEOM_Function) aFunction =
1149 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
1150 if (aFunction.IsNull()) return NULL;
1152 //Check if the function is set correctly
1153 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1155 GEOMImpl_IMarker aPI(aFunction);
1157 Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
1158 Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
1159 Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
1160 if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
1162 aPI.SetOrigin(aRefOrigin);
1163 aPI.SetXVec(aRefXVec);
1164 aPI.SetYVec(aRefYVec);
1166 //Compute the marker value
1168 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1171 if (!GetSolver()->ComputeFunction(aFunction)) {
1172 SetErrorCode("Marker driver failed");
1176 catch (Standard_Failure) {
1177 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1178 SetErrorCode(aFail->GetMessageString());
1182 //Make a Python command
1183 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1184 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1190 //=============================================================================
1192 * MakeTangentPlaneOnFace
1194 //=============================================================================
1196 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1203 if (theFace.IsNull()) return NULL;
1205 //Add a new Plane object
1206 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1208 //Add a new Plane function
1209 Handle(GEOM_Function) aFunction =
1210 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1212 //Check if the function is set correctly
1213 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1215 GEOMImpl_IPlane aPI (aFunction);
1217 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1218 if (aRef.IsNull()) return NULL;
1221 aPI.SetSize(theSize);
1222 aPI.SetParameterU(theParamU);
1223 aPI.SetParameterV(theParamV);
1225 //Compute the Plane value
1227 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1230 if (!GetSolver()->ComputeFunction(aFunction)) {
1231 SetErrorCode("Plane driver failed");
1235 catch (Standard_Failure) {
1236 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1237 SetErrorCode(aFail->GetMessageString());
1241 //Make a Python command
1242 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1243 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";