1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 <Basics_OCCTVersion.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TDF_Tool.hxx>
37 #include <GEOM_Function.hxx>
38 #include <GEOM_PythonDump.hxx>
40 #include <GEOMImpl_PointDriver.hxx>
41 #include <GEOMImpl_VectorDriver.hxx>
42 #include <GEOMImpl_LineDriver.hxx>
43 #include <GEOMImpl_PlaneDriver.hxx>
44 #include <GEOMImpl_MarkerDriver.hxx>
46 #include <GEOMImpl_IPoint.hxx>
47 #include <GEOMImpl_IVector.hxx>
48 #include <GEOMImpl_ILine.hxx>
49 #include <GEOMImpl_IPlane.hxx>
50 #include <GEOMImpl_IMarker.hxx>
52 #include <GEOMImpl_Types.hxx>
54 #include <Standard_Failure.hxx>
55 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
57 //=============================================================================
61 //=============================================================================
62 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
63 : GEOM_IOperations(theEngine, theDocID)
65 MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
68 //=============================================================================
72 //=============================================================================
73 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
75 MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
79 //=============================================================================
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
85 (double theX, double theY, double theZ)
89 //Add a new Point object
90 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
92 //Add a new Point function with XYZ parameters
93 Handle(GEOM_Function) aFunction =
94 aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
95 if (aFunction.IsNull()) return NULL;
97 //Check if the function is set correctly
98 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
100 GEOMImpl_IPoint aPI(aFunction);
106 //Compute the point value
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
162 if (!GetSolver()->ComputeFunction(aFunction)) {
163 SetErrorCode("Point driver failed");
167 catch (Standard_Failure) {
168 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
169 SetErrorCode(aFail->GetMessageString());
173 //Make a Python command
174 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
175 << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
181 //=============================================================================
185 //=============================================================================
186 Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
187 (Handle(GEOM_Object) theGeomObj,
191 const PointLocation theLocation,
192 const bool takeOrientationIntoAccount,
193 Handle(GEOM_Object) theRefPoint)
197 if (theGeomObj.IsNull()) return NULL;
199 //Add a new Point object
200 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
202 //Add a new Point function for creation a point relativley another point
203 int fType = POINT_CURVE_PAR;
204 switch( theLocation )
206 case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
207 case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
208 case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
209 case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
210 case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
211 case PointOn_Face: fType = POINT_FACE_ANY; 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);
229 aPI.SetTakeOrientationIntoAccount(takeOrientationIntoAccount);
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);
257 aPI.SetSurface(aRefFunction);
262 //Compute the point value
265 if (!GetSolver()->ComputeFunction(aFunction)) {
266 SetErrorCode("Point driver failed");
270 catch (Standard_Failure) {
271 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
272 SetErrorCode(aFail->GetMessageString());
276 //Make a Python command
277 switch( theLocation )
279 case PointOn_CurveByParam:
280 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
281 << theGeomObj << ", " << theParam1 << ", "
282 << takeOrientationIntoAccount << ")";
284 case PointOn_CurveByLength:
285 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
286 << theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
288 case PointOn_CurveByCoord:
289 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
290 << theGeomObj << ", " << theParam1
291 << ", " << theParam2 << ", " << theParam3 << ")";
293 case PointOn_SurfaceByParam:
294 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
295 << theGeomObj << ", " << theParam1
296 << ", " << theParam2 << ")";
298 case PointOn_SurfaceByCoord:
299 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
300 << theGeomObj << ", " << theParam1
301 << ", " << theParam2 << ", " << theParam3 << ")";
304 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
305 << theGeomObj << ")";
314 //=============================================================================
318 //=============================================================================
319 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
320 (Handle(GEOM_Object) theCurve,
322 bool takeOrientationIntoAccount)
324 return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam,
325 takeOrientationIntoAccount);
328 //=============================================================================
330 * MakePointOnCurveByCoord
332 //=============================================================================
333 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
334 (Handle(GEOM_Object) theCurve,
339 return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
342 //=============================================================================
344 * MakePointOnCurveByLength
346 //=============================================================================
347 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
348 (Handle(GEOM_Object) theCurve,
350 Handle(GEOM_Object) theStartPoint)
352 return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength,
353 false, theStartPoint);
356 //=============================================================================
360 //=============================================================================
361 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface
362 (Handle(GEOM_Object) theSurface,
363 double theUParameter,
364 double theVParameter)
366 return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam);
369 //=============================================================================
371 * MakePointOnSurfaceByCoord
373 //=============================================================================
374 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
375 (Handle(GEOM_Object) theSurface,
380 return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
383 //=============================================================================
387 //=============================================================================
388 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
390 return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
393 //=============================================================================
395 * MakePointOnLinesIntersection
397 //=============================================================================
398 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnLinesIntersection
399 (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2)
403 if (theLine1.IsNull() || theLine2.IsNull()) return NULL;
405 //Add a new Point object
406 Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
408 //Add a new Point function for creation a point relativley another point
409 Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_LINES_INTERSECTION);
411 //Check if the function is set correctly
412 if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
414 GEOMImpl_IPoint aPI (aFunction);
416 Handle(GEOM_Function) aRef1 = theLine1->GetLastFunction();
417 Handle(GEOM_Function) aRef2 = theLine2->GetLastFunction();
418 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
423 //Compute the point value
426 if (!GetSolver()->ComputeFunction(aFunction)) {
427 SetErrorCode("Point driver failed");
431 catch (Standard_Failure) {
432 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
433 SetErrorCode(aFail->GetMessageString());
437 //Make a Python command
438 GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnLinesIntersection("
439 << theLine1 << ", " << theLine2 << ")";
445 //=============================================================================
449 //=============================================================================
450 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
451 (const Handle(GEOM_Object)& theCurve, double theParameter)
455 if (theCurve.IsNull()) return NULL;
457 //Add a new Vector object
458 Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
460 //Add a new Point function for creation a point relativley another point
461 Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
463 //Check if the function is set correctly
464 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
466 GEOMImpl_IVector aVI (aFunction);
468 Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
469 if (aRefFunction.IsNull()) return NULL;
471 aVI.SetCurve(aRefFunction);
472 aVI.SetParameter(theParameter);
474 //Compute the vector value
477 if (!GetSolver()->ComputeFunction(aFunction)) {
478 SetErrorCode("Vector driver failed");
482 catch (Standard_Failure) {
483 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
484 SetErrorCode(aFail->GetMessageString());
488 //Make a Python command
489 GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
490 << theCurve << ", " << theParameter << ")";
496 //=============================================================================
500 //=============================================================================
501 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
502 (double theDX, double theDY, double theDZ)
506 //Add a new Vector object
507 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
509 //Add a new Vector function with DXDYDZ parameters
510 Handle(GEOM_Function) aFunction =
511 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
512 if (aFunction.IsNull()) return NULL;
514 //Check if the function is set correctly
515 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
517 GEOMImpl_IVector aPI (aFunction);
523 //Compute the Vector value
526 if (!GetSolver()->ComputeFunction(aFunction)) {
527 SetErrorCode("Vector driver failed");
531 catch (Standard_Failure) {
532 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
533 SetErrorCode(aFail->GetMessageString());
537 //Make a Python command
538 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
539 << theDX << ", " << theDY << ", " << theDZ << ")";
545 //=============================================================================
549 //=============================================================================
550 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
551 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
555 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
557 //Add a new Vector object
558 Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
560 //Add a new Vector function
561 Handle(GEOM_Function) aFunction =
562 aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
564 //Check if the function is set correctly
565 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
567 GEOMImpl_IVector aPI (aFunction);
569 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
570 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
571 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
573 aPI.SetPoint1(aRef1);
574 aPI.SetPoint2(aRef2);
576 //Compute the Vector value
579 if (!GetSolver()->ComputeFunction(aFunction)) {
580 SetErrorCode("Vector driver failed");
584 catch (Standard_Failure) {
585 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
586 SetErrorCode(aFail->GetMessageString());
590 //Make a Python command
591 GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
592 << thePnt1 << ", " << thePnt2 << ")";
599 //=============================================================================
603 //=============================================================================
604 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
605 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
609 if (thePnt.IsNull() || theDir.IsNull()) return NULL;
611 //Add a new Line object
612 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
614 //Add a new Line function
615 Handle(GEOM_Function) aFunction =
616 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
618 //Check if the function is set correctly
619 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
621 GEOMImpl_ILine aPI (aFunction);
623 Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
624 Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
625 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
627 aPI.SetPoint1(aRef1);
628 aPI.SetPoint2(aRef2);
630 //Compute the Line value
633 if (!GetSolver()->ComputeFunction(aFunction)) {
634 SetErrorCode("Line driver failed");
638 catch (Standard_Failure) {
639 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
640 SetErrorCode(aFail->GetMessageString());
644 //Make a Python command
645 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
646 << thePnt << ", " << theDir << ")";
652 //=============================================================================
656 //=============================================================================
657 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
658 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
662 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
664 //Add a new Line object
665 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
667 //Add a new Line function
668 Handle(GEOM_Function) aFunction =
669 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
671 //Check if the function is set correctly
672 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
674 GEOMImpl_ILine aPI (aFunction);
676 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
677 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
678 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
680 aPI.SetPoint1(aRef1);
681 aPI.SetPoint2(aRef2);
683 //Compute the Line value
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Line driver failed");
691 catch (Standard_Failure) {
692 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
693 SetErrorCode(aFail->GetMessageString());
697 //Make a Python command
698 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
699 << thePnt1 << ", " << thePnt2 << ")";
705 //=============================================================================
709 //=============================================================================
710 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoFaces
711 (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2)
715 if (theFace1.IsNull() || theFace2.IsNull()) return NULL;
717 //Add a new Line object
718 Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
720 //Add a new Line function
721 Handle(GEOM_Function) aFunction =
722 aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_FACES);
724 //Check if the function is set correctly
725 if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
727 GEOMImpl_ILine aPI (aFunction);
729 Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction();
730 Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction();
731 if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
736 //Compute the Line value
739 if (!GetSolver()->ComputeFunction(aFunction)) {
740 SetErrorCode("Line driver failed");
744 catch (Standard_Failure) {
745 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
746 SetErrorCode(aFail->GetMessageString());
750 //Make a Python command
751 GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoFaces("
752 << theFace1 << ", " << theFace2 << ")";
758 //=============================================================================
762 //=============================================================================
763 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
764 (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
765 Handle(GEOM_Object) thePnt3, double theSize)
769 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
771 //Add a new Plane object
772 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
774 //Add a new Plane function
775 Handle(GEOM_Function) aFunction =
776 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
778 //Check if the function is set correctly
779 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
781 GEOMImpl_IPlane aPI (aFunction);
783 Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
784 Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
785 Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
786 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
788 aPI.SetPoint1(aRef1);
789 aPI.SetPoint2(aRef2);
790 aPI.SetPoint3(aRef3);
791 aPI.SetSize(theSize);
793 //Compute the Plane value
796 if (!GetSolver()->ComputeFunction(aFunction)) {
797 SetErrorCode("Plane driver failed");
801 catch (Standard_Failure) {
802 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
803 SetErrorCode(aFail->GetMessageString());
807 //Make a Python command
808 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
809 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
815 //=============================================================================
819 //=============================================================================
820 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
821 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
826 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
828 //Add a new Plane object
829 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
831 //Add a new Plane function
832 Handle(GEOM_Function) aFunction =
833 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
835 //Check if the function is set correctly
836 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
838 GEOMImpl_IPlane aPI (aFunction);
840 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
841 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
842 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
844 aPI.SetPoint(aRefPnt);
845 aPI.SetVector(aRefVec);
846 aPI.SetSize(theSize);
848 //Compute the Plane value
851 if (!GetSolver()->ComputeFunction(aFunction)) {
852 SetErrorCode("Plane driver failed");
856 catch (Standard_Failure) {
857 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
858 SetErrorCode(aFail->GetMessageString());
862 //Make a Python command
863 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
864 << thePnt << ", " << theVec << ", " << theSize << ")";
870 //=============================================================================
874 //=============================================================================
875 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
876 (Handle(GEOM_Object) theFace, double theSize)
880 if (theFace.IsNull()) return NULL;
882 //Add a new Plane object
883 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
885 //Add a new Plane function
886 Handle(GEOM_Function) aFunction =
887 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
889 //Check if the function is set correctly
890 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
892 GEOMImpl_IPlane aPI (aFunction);
894 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
895 if (aRef.IsNull()) return NULL;
898 aPI.SetSize(theSize);
900 //Compute the Plane value
903 if (!GetSolver()->ComputeFunction(aFunction)) {
904 SetErrorCode("Plane driver failed");
908 catch (Standard_Failure) {
909 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
910 SetErrorCode(aFail->GetMessageString());
914 //Make a Python command
915 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
916 << theFace << ", " << theSize << ")";
922 //=============================================================================
926 //=============================================================================
927 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlane2Vec
928 (Handle(GEOM_Object) theVec1, Handle(GEOM_Object) theVec2,
933 if (theVec1.IsNull() || theVec2.IsNull()) return NULL;
935 //Add a new Plane object
936 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
938 //Add a new Plane function
939 Handle(GEOM_Function) aFunction =
940 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_2_VEC);
942 //Check if the function is set correctly
943 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
945 GEOMImpl_IPlane aPI (aFunction);
947 Handle(GEOM_Function) aRefVec1 = theVec1->GetLastFunction();
948 Handle(GEOM_Function) aRefVec2 = theVec2->GetLastFunction();
949 if (aRefVec1.IsNull() || aRefVec2.IsNull()) return NULL;
951 aPI.SetVector1(aRefVec1);
952 aPI.SetVector2(aRefVec2);
953 aPI.SetSize(theSize);
955 //Compute the Plane value
958 if (!GetSolver()->ComputeFunction(aFunction)) {
959 SetErrorCode("Plane driver failed");
963 catch (Standard_Failure) {
964 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
965 SetErrorCode(aFail->GetMessageString());
969 //Make a Python command
970 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane2Vec("
971 << theVec1 << ", " << theVec2 << ", " << theSize << ")";
977 //=============================================================================
981 //=============================================================================
982 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneLCS
983 (Handle(GEOM_Object) theLCS, double theSize, int theOrientation)
987 //Add a new Plane object
988 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
990 //Add a new Plane function
991 Handle(GEOM_Function) aFunction =
992 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_LCS);
994 //Check if the function is set correctly
995 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
997 GEOMImpl_IPlane aPI (aFunction);
999 if ( !theLCS.IsNull() ) {
1000 Handle(GEOM_Function) aRef = theLCS->GetLastFunction();
1004 aPI.SetSize(theSize);
1005 aPI.SetOrientation(theOrientation);
1007 //Compute the Plane value
1010 if (!GetSolver()->ComputeFunction(aFunction)) {
1011 SetErrorCode("Plane driver failed");
1015 catch (Standard_Failure) {
1016 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1017 SetErrorCode(aFail->GetMessageString());
1021 //Make a Python command
1022 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneLCS("
1023 << theLCS << ", " << theSize << ", " << theOrientation << ")";
1030 //=============================================================================
1034 //=============================================================================
1035 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
1036 (double theOX, double theOY, double theOZ,
1037 double theXDX, double theXDY, double theXDZ,
1038 double theYDX, double theYDY, double theYDZ)
1042 //Add a new Marker object
1043 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1045 //Add a new Marker function
1046 Handle(GEOM_Function) aFunction =
1047 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
1048 if (aFunction.IsNull()) return NULL;
1050 //Check if the function is set correctly
1051 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1053 GEOMImpl_IMarker aPI(aFunction);
1055 aPI.SetOrigin(theOX, theOY, theOZ);
1056 aPI.SetXDir(theXDX, theXDY, theXDZ);
1057 aPI.SetYDir(theYDX, theYDY, theYDZ);
1059 //Compute the marker value
1062 if (!GetSolver()->ComputeFunction(aFunction)) {
1063 SetErrorCode("Marker driver failed");
1067 catch (Standard_Failure) {
1068 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1069 SetErrorCode(aFail->GetMessageString());
1073 //Make a Python command
1074 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
1075 << theOX << ", " << theOY << ", " << theOZ << ", "
1076 << theXDX << ", " << theXDY << ", " << theXDZ << ", "
1077 << theYDX << ", " << theYDY << ", " << theYDZ << ")";
1083 //=============================================================================
1085 * MakeMarkerFromShape
1087 //=============================================================================
1088 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
1089 (const Handle(GEOM_Object)& theShape)
1093 //Add a new Marker object
1094 Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
1096 //Add a new Marker function
1097 Handle(GEOM_Function) aFunction =
1098 aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
1099 if (aFunction.IsNull()) return NULL;
1101 //Check if the function is set correctly
1102 if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
1104 GEOMImpl_IMarker aPI(aFunction);
1106 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1107 if (aRefShape.IsNull()) return NULL;
1109 aPI.SetShape(aRefShape);
1111 //Compute the marker value
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
1169 if (!GetSolver()->ComputeFunction(aFunction)) {
1170 SetErrorCode("Marker driver failed");
1174 catch (Standard_Failure) {
1175 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1176 SetErrorCode(aFail->GetMessageString());
1180 //Make a Python command
1181 GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
1182 << theOrigin << ", " << theXVec << ", " << theYVec << ")";
1188 //=============================================================================
1190 * MakeTangentPlaneOnFace
1192 //=============================================================================
1194 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
1201 if (theFace.IsNull()) return NULL;
1203 //Add a new Plane object
1204 Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
1206 //Add a new Plane function
1207 Handle(GEOM_Function) aFunction =
1208 aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
1210 //Check if the function is set correctly
1211 if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
1213 GEOMImpl_IPlane aPI (aFunction);
1215 Handle(GEOM_Function) aRef = theFace->GetLastFunction();
1216 if (aRef.IsNull()) return NULL;
1219 aPI.SetSize(theSize);
1220 aPI.SetParameterU(theParamU);
1221 aPI.SetParameterV(theParamV);
1223 //Compute the Plane value
1226 if (!GetSolver()->ComputeFunction(aFunction)) {
1227 SetErrorCode("Plane driver failed");
1231 catch (Standard_Failure) {
1232 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1233 SetErrorCode(aFail->GetMessageString());
1237 //Make a Python command
1238 GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
1239 << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";