1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include <Basics_OCCTVersion.hxx>
27 #include <GEOMImpl_I3DPrimOperations.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_Types.hxx>
43 #include <GEOMImpl_BoxDriver.hxx>
44 #include <GEOMImpl_FaceDriver.hxx>
45 #include <GEOMImpl_DiskDriver.hxx>
46 #include <GEOMImpl_CylinderDriver.hxx>
47 #include <GEOMImpl_ConeDriver.hxx>
48 #include <GEOMImpl_SphereDriver.hxx>
49 #include <GEOMImpl_TorusDriver.hxx>
50 #include <GEOMImpl_PrismDriver.hxx>
51 #include <GEOMImpl_PipeDriver.hxx>
52 #include <GEOMImpl_RevolutionDriver.hxx>
53 #include <GEOMImpl_ShapeDriver.hxx>
54 #include <GEOMImpl_FillingDriver.hxx>
55 #include <GEOMImpl_ThruSectionsDriver.hxx>
57 #include <GEOMImpl_IBox.hxx>
58 #include <GEOMImpl_IFace.hxx>
59 #include <GEOMImpl_IDisk.hxx>
60 #include <GEOMImpl_ICylinder.hxx>
61 #include <GEOMImpl_ICone.hxx>
62 #include <GEOMImpl_ISphere.hxx>
63 #include <GEOMImpl_ITorus.hxx>
64 #include <GEOMImpl_IPrism.hxx>
65 #include <GEOMImpl_IPipe.hxx>
66 #include <GEOMImpl_IRevolution.hxx>
67 #include <GEOMImpl_IFilling.hxx>
68 #include <GEOMImpl_IThruSections.hxx>
69 #include <GEOMImpl_IPipeDiffSect.hxx>
70 #include <GEOMImpl_IPipeShellSect.hxx>
71 #include <GEOMImpl_IPipeBiNormal.hxx>
73 #include <Precision.hxx>
75 #include <Standard_Failure.hxx>
76 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
78 //=============================================================================
82 //=============================================================================
83 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
84 : GEOM_IOperations(theEngine, theDocID)
86 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
89 //=============================================================================
93 //=============================================================================
94 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
96 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
100 //=============================================================================
104 //=============================================================================
105 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
109 //Add a new Box object
110 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
112 //Add a new Box function with DX_DY_DZ parameters
113 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
114 if (aFunction.IsNull()) return NULL;
116 //Check if the function is set correctly
117 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
119 GEOMImpl_IBox aBI (aFunction);
125 //Compute the box value
127 #if OCC_VERSION_LARGE > 0x06010000
130 if (!GetSolver()->ComputeFunction(aFunction)) {
131 SetErrorCode("Box driver failed");
135 catch (Standard_Failure) {
136 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
137 SetErrorCode(aFail->GetMessageString());
141 //Make a Python command
142 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
143 << theDX << ", " << theDY << ", " << theDZ << ")";
150 //=============================================================================
154 //=============================================================================
155 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
156 Handle(GEOM_Object) thePnt2)
160 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
162 //Add a new Box object
163 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
165 //Add a new Box function for creation a box relatively to two points
166 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
167 if (aFunction.IsNull()) return NULL;
169 //Check if the function is set correctly
170 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
172 GEOMImpl_IBox aBI (aFunction);
174 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
175 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
177 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
179 aBI.SetRef1(aRefFunction1);
180 aBI.SetRef2(aRefFunction2);
182 //Compute the Box value
184 #if OCC_VERSION_LARGE > 0x06010000
187 if (!GetSolver()->ComputeFunction(aFunction)) {
188 SetErrorCode("Box driver failed");
192 catch (Standard_Failure) {
193 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
194 SetErrorCode(aFail->GetMessageString());
198 //Make a Python command
199 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
200 << thePnt1 << ", " << thePnt2 << ")";
206 //=============================================================================
210 //=============================================================================
211 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
215 if (theH == 0 || theW == 0) return NULL;
217 //Add a new Face object
218 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
220 //Add a new Box function for creation a box relatively to two points
221 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
222 if (aFunction.IsNull()) return NULL;
224 //Check if the function is set correctly
225 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
227 GEOMImpl_IFace aFI (aFunction);
231 aFI.SetOrientation(theOrientation);
235 #if OCC_VERSION_LARGE > 0x06010000
238 if (!GetSolver()->ComputeFunction(aFunction)) {
239 SetErrorCode("Face driver failed");
243 catch (Standard_Failure) {
244 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
245 SetErrorCode(aFail->GetMessageString());
249 //Make a Python command
250 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
251 << theH << ", " << theW << ", " << theOrientation << ")";
257 //=============================================================================
261 //=============================================================================
262 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
263 double theH, double theW)
267 if (theObj.IsNull()) return NULL;
269 //Add a new Face object
270 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
272 //Add a new Box function for creation a box relatively to two points
273 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
274 if (aFunction.IsNull()) return NULL;
276 //Check if the function is set correctly
277 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
279 GEOMImpl_IFace aFI (aFunction);
281 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
283 if (aRefFunction1.IsNull())
286 aFI.SetRef1(aRefFunction1);
292 #if OCC_VERSION_LARGE > 0x06010000
295 if (!GetSolver()->ComputeFunction(aFunction)) {
296 SetErrorCode("Face driver failed");
300 catch (Standard_Failure) {
301 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
302 SetErrorCode(aFail->GetMessageString());
306 //Make a Python command
307 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
308 << theObj << ", " << theH << ", " << theW << ")";
314 //=============================================================================
318 //=============================================================================
319 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
320 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
324 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
326 //Add a new Disk object
327 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
329 //Add a new Disk function for creation a disk relatively to point and vector
330 Handle(GEOM_Function) aFunction =
331 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
332 if (aFunction.IsNull()) return NULL;
334 //Check if the function is set correctly
335 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
337 GEOMImpl_IDisk aCI (aFunction);
339 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
340 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
342 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
344 aCI.SetCenter(aRefPnt);
345 aCI.SetVector(aRefVec);
348 //Compute the Disk value
350 #if OCC_VERSION_LARGE > 0x06010000
353 if (!GetSolver()->ComputeFunction(aFunction)) {
354 SetErrorCode("Disk driver failed");
358 catch (Standard_Failure) {
359 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
360 SetErrorCode(aFail->GetMessageString());
364 //Make a Python command
365 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
366 << thePnt << ", " << theVec << ", " << theR << ")";
372 //=============================================================================
376 //=============================================================================
377 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
378 Handle(GEOM_Object) thePnt2,
379 Handle(GEOM_Object) thePnt3)
383 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
385 //Add a new Disk object
386 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
388 //Add a new Disk function for creation a disk relatively to three points
389 Handle(GEOM_Function) aFunction =
390 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
391 if (aFunction.IsNull()) return NULL;
393 //Check if the function is set correctly
394 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
396 GEOMImpl_IDisk aCI (aFunction);
398 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
399 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
400 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
402 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
404 aCI.SetPoint1(aRefPnt1);
405 aCI.SetPoint2(aRefPnt2);
406 aCI.SetPoint3(aRefPnt3);
408 //Compute the Disk value
410 #if OCC_VERSION_LARGE > 0x06010000
413 if (!GetSolver()->ComputeFunction(aFunction)) {
414 SetErrorCode("Disk driver failed");
418 catch (Standard_Failure) {
419 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
420 SetErrorCode(aFail->GetMessageString());
424 //Make a Python command
425 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
426 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
432 //=============================================================================
436 //=============================================================================
437 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
441 if (theR == 0 ) return NULL;
443 //Add a new Disk object
444 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
446 //Add a new Box function for creation a box relatively to two points
447 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
448 if (aFunction.IsNull()) return NULL;
450 //Check if the function is set correctly
451 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
453 GEOMImpl_IDisk aDI (aFunction);
456 aDI.SetOrientation(theOrientation);
460 #if OCC_VERSION_LARGE > 0x06010000
463 if (!GetSolver()->ComputeFunction(aFunction)) {
464 SetErrorCode("Disk driver failed");
468 catch (Standard_Failure) {
469 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
470 SetErrorCode(aFail->GetMessageString());
474 //Make a Python command
475 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
476 << theR << ", " << theOrientation << ")";
482 //=============================================================================
486 //=============================================================================
487 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
491 //Add a new Cylinder object
492 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
494 //Add a new Cylinder function with R and H parameters
495 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
496 if (aFunction.IsNull()) return NULL;
498 //Check if the function is set correctly
499 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
501 GEOMImpl_ICylinder aCI (aFunction);
506 //Compute the Cylinder value
508 #if OCC_VERSION_LARGE > 0x06010000
511 if (!GetSolver()->ComputeFunction(aFunction)) {
512 SetErrorCode("Cylinder 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) << aCylinder
524 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
531 //=============================================================================
533 * MakeCylinderPntVecRH
535 //=============================================================================
536 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
537 Handle(GEOM_Object) theVec,
538 double theR, double theH)
542 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
544 //Add a new Cylinder object
545 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
547 //Add a new Cylinder function for creation a cylinder relatively to point and vector
548 Handle(GEOM_Function) aFunction =
549 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
550 if (aFunction.IsNull()) return NULL;
552 //Check if the function is set correctly
553 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
555 GEOMImpl_ICylinder aCI (aFunction);
557 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
558 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
560 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
562 aCI.SetPoint(aRefPnt);
563 aCI.SetVector(aRefVec);
567 //Compute the Cylinder value
569 #if OCC_VERSION_LARGE > 0x06010000
572 if (!GetSolver()->ComputeFunction(aFunction)) {
573 SetErrorCode("Cylinder driver failed");
577 catch (Standard_Failure) {
578 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
579 SetErrorCode(aFail->GetMessageString());
583 //Make a Python command
584 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
585 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
592 //=============================================================================
596 //=============================================================================
597 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
602 //Add a new Cone object
603 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
605 //Add a new Cone function with R and H parameters
606 Handle(GEOM_Function) aFunction =
607 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
608 if (aFunction.IsNull()) return NULL;
610 //Check if the function is set correctly
611 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
613 GEOMImpl_ICone aCI (aFunction);
619 //Compute the Cone value
621 #if OCC_VERSION_LARGE > 0x06010000
624 if (!GetSolver()->ComputeFunction(aFunction)) {
625 SetErrorCode("Cone driver failed");
629 catch (Standard_Failure) {
630 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
631 SetErrorCode(aFail->GetMessageString());
635 //Make a Python command
636 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
637 << theR1 << ", " << theR2 << ", " << theH << ")";
644 //=============================================================================
646 * MakeConePntVecR1R2H
648 //=============================================================================
649 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
650 Handle(GEOM_Object) theVec,
651 double theR1, double theR2,
656 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
658 //Add a new Cone object
659 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
661 //Add a new Cone function for creation a cone relatively to point and vector
662 Handle(GEOM_Function) aFunction =
663 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
664 if (aFunction.IsNull()) return NULL;
666 //Check if the function is set correctly
667 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
669 GEOMImpl_ICone aCI (aFunction);
671 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
672 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
674 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
676 aCI.SetPoint(aRefPnt);
677 aCI.SetVector(aRefVec);
682 //Compute the Cone value
684 #if OCC_VERSION_LARGE > 0x06010000
687 if (!GetSolver()->ComputeFunction(aFunction)) {
688 SetErrorCode("Cone driver failed");
692 catch (Standard_Failure) {
693 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
694 SetErrorCode(aFail->GetMessageString());
698 //Make a Python command
699 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
700 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
707 //=============================================================================
711 //=============================================================================
712 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
716 //Add a new Sphere object
717 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
719 //Add a new Sphere function with R parameter
720 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
721 if (aFunction.IsNull()) return NULL;
723 //Check if the function is set correctly
724 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
726 GEOMImpl_ISphere aCI (aFunction);
730 //Compute the Sphere value
732 #if OCC_VERSION_LARGE > 0x06010000
735 if (!GetSolver()->ComputeFunction(aFunction)) {
736 SetErrorCode("Sphere driver failed");
740 catch (Standard_Failure) {
741 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
742 SetErrorCode(aFail->GetMessageString());
746 //Make a Python command
747 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
754 //=============================================================================
758 //=============================================================================
759 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
764 if (thePnt.IsNull()) return NULL;
766 //Add a new Point object
767 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
769 //Add a new Sphere function for creation a sphere relatively to point
770 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
771 if (aFunction.IsNull()) return NULL;
773 //Check if the function is set correctly
774 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
776 GEOMImpl_ISphere aCI (aFunction);
778 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
780 if (aRefPnt.IsNull()) return NULL;
782 aCI.SetPoint(aRefPnt);
785 //Compute the Sphere value
787 #if OCC_VERSION_LARGE > 0x06010000
790 if (!GetSolver()->ComputeFunction(aFunction)) {
791 SetErrorCode("Sphere driver failed");
795 catch (Standard_Failure) {
796 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
797 SetErrorCode(aFail->GetMessageString());
801 //Make a Python command
802 GEOM::TPythonDump(aFunction) << aSphere
803 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
810 //=============================================================================
814 //=============================================================================
815 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
816 (double theRMajor, double theRMinor)
820 //Add a new Torus object
821 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
823 //Add a new Torus function
824 Handle(GEOM_Function) aFunction =
825 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
826 if (aFunction.IsNull()) return NULL;
828 //Check if the function is set correctly
829 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
831 GEOMImpl_ITorus aCI (aFunction);
833 aCI.SetRMajor(theRMajor);
834 aCI.SetRMinor(theRMinor);
836 //Compute the Torus value
838 #if OCC_VERSION_LARGE > 0x06010000
841 if (!GetSolver()->ComputeFunction(aFunction)) {
842 SetErrorCode("Torus 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) << anEll << " = geompy.MakeTorusRR("
854 << theRMajor << ", " << theRMinor << ")";
860 //=============================================================================
864 //=============================================================================
865 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
866 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
867 double theRMajor, double theRMinor)
871 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
873 //Add a new Torus object
874 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
876 //Add a new Torus function
877 Handle(GEOM_Function) aFunction =
878 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
879 if (aFunction.IsNull()) return NULL;
881 //Check if the function is set correctly
882 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
884 GEOMImpl_ITorus aCI (aFunction);
886 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
887 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
889 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
891 aCI.SetCenter(aRefPnt);
892 aCI.SetVector(aRefVec);
893 aCI.SetRMajor(theRMajor);
894 aCI.SetRMinor(theRMinor);
896 //Compute the Torus value
898 #if OCC_VERSION_LARGE > 0x06010000
901 if (!GetSolver()->ComputeFunction(aFunction)) {
902 SetErrorCode("Torus driver failed");
906 catch (Standard_Failure) {
907 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
908 SetErrorCode(aFail->GetMessageString());
912 //Make a Python command
913 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
914 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
921 //=============================================================================
925 //=============================================================================
926 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
927 Handle(GEOM_Object) theVec,
928 double theH, double theScaleFactor)
932 if (theBase.IsNull() || theVec.IsNull()) return NULL;
934 //Add a new Prism object
935 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
937 //Add a new Prism function for creation a Prism relatively to vector
938 Handle(GEOM_Function) aFunction =
939 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
940 if (aFunction.IsNull()) return NULL;
942 //Check if the function is set correctly
943 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
945 GEOMImpl_IPrism aCI (aFunction);
947 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
948 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
950 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
952 aCI.SetBase(aRefBase);
953 aCI.SetVector(aRefVec);
955 aCI.SetScale(theScaleFactor);
957 //Compute the Prism value
959 #if OCC_VERSION_LARGE > 0x06010000
962 if (!GetSolver()->ComputeFunction(aFunction)) {
963 //SetErrorCode("Prism driver failed");
964 SetErrorCode("Extrusion can not be created, check input data");
968 catch (Standard_Failure) {
969 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
970 SetErrorCode(aFail->GetMessageString());
974 //Make a Python command
975 GEOM::TPythonDump pd (aFunction);
976 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
977 if (theScaleFactor > Precision::Confusion())
978 pd << ", " << theScaleFactor << ")";
986 //=============================================================================
990 //=============================================================================
991 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
992 Handle(GEOM_Object) theVec,
997 if (theBase.IsNull() || theVec.IsNull()) return NULL;
999 //Add a new Prism object
1000 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1002 //Add a new Prism function for creation a Prism relatively to vector
1003 Handle(GEOM_Function) aFunction =
1004 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1005 if (aFunction.IsNull()) return NULL;
1007 //Check if the function is set correctly
1008 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1010 GEOMImpl_IPrism aCI (aFunction);
1012 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1013 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1015 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1017 aCI.SetBase(aRefBase);
1018 aCI.SetVector(aRefVec);
1021 //Compute the Prism value
1023 #if OCC_VERSION_LARGE > 0x06010000
1026 if (!GetSolver()->ComputeFunction(aFunction)) {
1027 //SetErrorCode("Prism driver failed");
1028 SetErrorCode("Extrusion can not be created, check input data");
1032 catch (Standard_Failure) {
1033 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1034 SetErrorCode(aFail->GetMessageString());
1038 //Make a Python command
1039 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1040 << theBase << ", " << theVec << ", " << theH << ")";
1046 //=============================================================================
1050 //=============================================================================
1051 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1052 (Handle(GEOM_Object) theBase,
1053 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1054 double theScaleFactor)
1058 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1060 //Add a new Prism object
1061 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1063 //Add a new Prism function for creation a Prism relatively to two points
1064 Handle(GEOM_Function) aFunction =
1065 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1066 if (aFunction.IsNull()) return NULL;
1068 //Check if the function is set correctly
1069 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1071 GEOMImpl_IPrism aCI (aFunction);
1073 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1074 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1075 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1077 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1079 aCI.SetBase(aRefBase);
1080 aCI.SetFirstPoint(aRefPnt1);
1081 aCI.SetLastPoint(aRefPnt2);
1082 aCI.SetScale(theScaleFactor);
1084 //Compute the Prism value
1086 #if OCC_VERSION_LARGE > 0x06010000
1089 if (!GetSolver()->ComputeFunction(aFunction)) {
1090 //SetErrorCode("Prism driver failed");
1091 SetErrorCode("Extrusion can not be created, check input data");
1095 catch (Standard_Failure) {
1096 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1097 SetErrorCode(aFail->GetMessageString());
1101 //Make a Python command
1102 GEOM::TPythonDump pd (aFunction);
1103 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1104 if (theScaleFactor > Precision::Confusion())
1105 pd << ", " << theScaleFactor << ")";
1113 //=============================================================================
1115 * MakePrismTwoPnt2Ways
1117 //=============================================================================
1118 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1119 (Handle(GEOM_Object) theBase,
1120 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1124 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1126 //Add a new Prism object
1127 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1129 //Add a new Prism function for creation a Prism relatively to two points
1130 Handle(GEOM_Function) aFunction =
1131 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1132 if (aFunction.IsNull()) return NULL;
1134 //Check if the function is set correctly
1135 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1137 GEOMImpl_IPrism aCI (aFunction);
1139 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1140 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1141 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1143 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1145 aCI.SetBase(aRefBase);
1146 aCI.SetFirstPoint(aRefPnt1);
1147 aCI.SetLastPoint(aRefPnt2);
1149 //Compute the Prism value
1151 #if OCC_VERSION_LARGE > 0x06010000
1154 if (!GetSolver()->ComputeFunction(aFunction)) {
1155 //SetErrorCode("Prism driver failed");
1156 SetErrorCode("Extrusion can not be created, check input data");
1160 catch (Standard_Failure) {
1161 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1162 SetErrorCode(aFail->GetMessageString());
1166 //Make a Python command
1167 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1168 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1174 //=============================================================================
1178 //=============================================================================
1179 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1180 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1181 double theScaleFactor)
1185 if (theBase.IsNull()) return NULL;
1187 //Add a new Prism object
1188 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1190 //Add a new Prism function for creation a Prism by DXDYDZ
1191 Handle(GEOM_Function) aFunction =
1192 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1193 if (aFunction.IsNull()) return NULL;
1195 //Check if the function is set correctly
1196 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1198 GEOMImpl_IPrism aCI (aFunction);
1200 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1202 if (aRefBase.IsNull()) return NULL;
1204 aCI.SetBase(aRefBase);
1208 aCI.SetScale(theScaleFactor);
1210 //Compute the Prism value
1212 #if OCC_VERSION_LARGE > 0x06010000
1215 if (!GetSolver()->ComputeFunction(aFunction)) {
1216 SetErrorCode("Extrusion can not be created, check input data");
1220 catch (Standard_Failure) {
1221 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1222 SetErrorCode(aFail->GetMessageString());
1226 //Make a Python command
1227 GEOM::TPythonDump pd (aFunction);
1228 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1229 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1230 if (theScaleFactor > Precision::Confusion())
1231 pd << ", " << theScaleFactor << ")";
1239 //=============================================================================
1241 * MakePrismDXDYDZ_2WAYS
1243 //=============================================================================
1244 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1245 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1249 if (theBase.IsNull()) return NULL;
1251 //Add a new Prism object
1252 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1254 //Add a new Prism function for creation a Prism by DXDYDZ
1255 Handle(GEOM_Function) aFunction =
1256 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1257 if (aFunction.IsNull()) return NULL;
1259 //Check if the function is set correctly
1260 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1262 GEOMImpl_IPrism aCI (aFunction);
1264 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1266 if (aRefBase.IsNull()) return NULL;
1268 aCI.SetBase(aRefBase);
1273 //Compute the Prism value
1275 #if OCC_VERSION_LARGE > 0x06010000
1278 if (!GetSolver()->ComputeFunction(aFunction)) {
1279 SetErrorCode("Extrusion can not be created, check input data");
1283 catch (Standard_Failure) {
1284 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1285 SetErrorCode(aFail->GetMessageString());
1289 //Make a Python command
1290 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1291 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1297 //=============================================================================
1301 //=============================================================================
1302 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1303 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1307 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1309 Handle(GEOM_Object) aPrism = NULL;
1313 //Add a new Extruded Boss object
1314 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1318 //Add a new Extruded Cut object
1319 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1322 //Add a new Prism function for the creation of a Draft Prism feature
1323 Handle(GEOM_Function) aFunction =
1324 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1325 if (aFunction.IsNull()) return NULL;
1327 //Check if the function is set correctly
1328 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1330 GEOMImpl_IPrism aCI (aFunction);
1332 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1333 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1335 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1338 aCI.SetBase(aRefBase);
1339 aCI.SetInitShape(aRefInit);
1340 aCI.SetH(theHeight);
1341 aCI.SetDraftAngle(theAngle);
1347 //Compute the Draft Prism Feature value
1349 #if OCC_VERSION_LARGE > 0x06010000
1352 if (!GetSolver()->ComputeFunction(aFunction)) {
1353 SetErrorCode("Extrusion can not be created, check input data");
1357 catch (Standard_Failure) {
1358 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1359 SetErrorCode(aFail->GetMessageString());
1363 //Make a Python command
1366 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1367 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1371 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1372 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1379 //=============================================================================
1383 //=============================================================================
1384 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1385 Handle(GEOM_Object) thePath)
1389 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1391 //Add a new Pipe object
1392 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1394 //Add a new Pipe function
1395 Handle(GEOM_Function) aFunction =
1396 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1397 if (aFunction.IsNull()) return NULL;
1399 //Check if the function is set correctly
1400 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1402 GEOMImpl_IPipe aCI (aFunction);
1404 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1405 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1407 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1409 aCI.SetBase(aRefBase);
1410 aCI.SetPath(aRefPath);
1412 //Compute the Pipe value
1414 #if OCC_VERSION_LARGE > 0x06010000
1417 if (!GetSolver()->ComputeFunction(aFunction)) {
1418 SetErrorCode("Pipe driver failed");
1422 catch (Standard_Failure) {
1423 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1424 SetErrorCode(aFail->GetMessageString());
1428 //Make a Python command
1429 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1430 << theBase << ", " << thePath << ")";
1437 //=============================================================================
1439 * MakeRevolutionAxisAngle
1441 //=============================================================================
1442 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1443 Handle(GEOM_Object) theAxis,
1448 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1450 //Add a new Revolution object
1451 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1453 //Add a new Revolution function for creation a revolution relatively to axis
1454 Handle(GEOM_Function) aFunction =
1455 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1456 if (aFunction.IsNull()) return NULL;
1458 //Check if the function is set correctly
1459 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1461 GEOMImpl_IRevolution aCI (aFunction);
1463 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1464 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1466 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1468 aCI.SetBase(aRefBase);
1469 aCI.SetAxis(aRefAxis);
1470 aCI.SetAngle(theAngle);
1472 //Compute the Revolution value
1474 #if OCC_VERSION_LARGE > 0x06010000
1477 if (!GetSolver()->ComputeFunction(aFunction)) {
1478 SetErrorCode("Revolution driver failed");
1482 catch (Standard_Failure) {
1483 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1484 SetErrorCode(aFail->GetMessageString());
1488 //Make a Python command
1489 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1490 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1496 //=============================================================================
1498 * MakeRevolutionAxisAngle2Ways
1500 //=============================================================================
1501 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1502 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1506 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1508 //Add a new Revolution object
1509 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1511 //Add a new Revolution function for creation a revolution relatively to axis
1512 Handle(GEOM_Function) aFunction =
1513 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1514 if (aFunction.IsNull()) return NULL;
1516 //Check if the function is set correctly
1517 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1519 GEOMImpl_IRevolution aCI (aFunction);
1521 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1522 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1524 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1526 aCI.SetBase(aRefBase);
1527 aCI.SetAxis(aRefAxis);
1528 aCI.SetAngle(theAngle);
1530 //Compute the Revolution value
1532 #if OCC_VERSION_LARGE > 0x06010000
1535 if (!GetSolver()->ComputeFunction(aFunction)) {
1536 SetErrorCode("Revolution driver failed");
1540 catch (Standard_Failure) {
1541 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1542 SetErrorCode(aFail->GetMessageString());
1546 //Make a Python command
1547 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1548 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1554 //=============================================================================
1558 //=============================================================================
1559 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1560 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1561 double theTol2D, double theTol3D, int theNbIter,
1562 int theMethod, bool isApprox)
1566 if (theShape.IsNull()) return NULL;
1568 //Add a new Filling object
1569 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1571 //Add a new Filling function for creation a filling from a compound
1572 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1573 if (aFunction.IsNull()) return NULL;
1575 //Check if the function is set correctly
1576 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1578 GEOMImpl_IFilling aFI (aFunction);
1580 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1582 if (aRefShape.IsNull()) return NULL;
1584 aFI.SetShape(aRefShape);
1585 aFI.SetMinDeg(theMinDeg);
1586 aFI.SetMaxDeg(theMaxDeg);
1587 aFI.SetTol2D(theTol2D);
1588 aFI.SetTol3D(theTol3D);
1589 aFI.SetNbIter(theNbIter);
1590 aFI.SetApprox(isApprox);
1591 aFI.SetMethod(theMethod);
1593 //Compute the Solid value
1595 #if OCC_VERSION_LARGE > 0x06010000
1598 if (!GetSolver()->ComputeFunction(aFunction)) {
1599 SetErrorCode("Filling driver failed");
1603 catch (Standard_Failure) {
1604 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1605 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1606 SetErrorCode("B-Spline surface construction failed");
1608 SetErrorCode(aFail->GetMessageString());
1612 //Make a Python command
1613 GEOM::TPythonDump pd (aFunction);
1614 pd << aFilling << " = geompy.MakeFilling("
1615 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1616 << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
1617 if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
1618 else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
1619 else pd << "GEOM.FOM_Default";
1621 pd << ", " << isApprox ;
1628 //=============================================================================
1632 //=============================================================================
1633 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1634 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1639 Handle(GEOM_Object) anObj;
1641 if(theSeqSections.IsNull())
1644 Standard_Integer nbObj = theSeqSections->Length();
1648 //Add a new ThruSections object
1649 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1652 //Add a new ThruSections function
1654 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1655 Handle(GEOM_Function) aFunction =
1656 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1657 if (aFunction.IsNull()) return anObj;
1659 //Check if the function is set correctly
1660 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1662 GEOMImpl_IThruSections aCI (aFunction);
1664 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1666 Standard_Integer i =1;
1667 for( ; i <= nbObj; i++) {
1669 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1673 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1674 if(!aSectObj.IsNull())
1676 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1677 if(!aRefSect.IsNull())
1678 aSeqSections->Append(aRefSect);
1682 if(!aSeqSections->Length())
1685 aCI.SetSections(aSeqSections);
1686 aCI.SetSolidMode(theModeSolid);
1687 aCI.SetPrecision(thePreci);
1689 //Compute the ThruSections value
1691 #if OCC_VERSION_LARGE > 0x06010000
1694 if (!GetSolver()->ComputeFunction(aFunction)) {
1695 SetErrorCode("ThruSections driver failed");
1699 catch (Standard_Failure) {
1700 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1701 SetErrorCode(aFail->GetMessageString());
1705 //Make a Python command
1706 GEOM::TPythonDump pyDump(aFunction);
1707 pyDump << aThruSect << " = geompy.MakeThruSections([";
1709 for(i =1 ; i <= nbObj; i++) {
1711 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1715 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1716 if(!aSectObj.IsNull()) {
1723 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1730 //=============================================================================
1732 * MakePipeWithDifferentSections
1734 //=============================================================================
1735 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1736 const Handle(TColStd_HSequenceOfTransient)& theBases,
1737 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1738 const Handle(GEOM_Object)& thePath,
1739 bool theWithContact,
1740 bool theWithCorrections)
1742 Handle(GEOM_Object) anObj;
1744 if(theBases.IsNull())
1747 Standard_Integer nbBases = theBases->Length();
1752 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1753 //Add a new Pipe object
1754 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1756 //Add a new Pipe function
1758 Handle(GEOM_Function) aFunction =
1759 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1760 if (aFunction.IsNull()) return anObj;
1762 //Check if the function is set correctly
1763 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1765 GEOMImpl_IPipeDiffSect aCI (aFunction);
1767 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1768 if(aRefPath.IsNull())
1771 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1772 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1774 Standard_Integer i =1;
1775 for( ; i <= nbBases; i++) {
1777 Handle(Standard_Transient) anItem = theBases->Value(i);
1781 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1784 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1785 if(aRefBase.IsNull())
1789 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1790 if(anItemLoc.IsNull())
1793 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1796 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1797 if(aRefLoc.IsNull())
1799 aSeqLocs->Append(aRefLoc);
1801 aSeqBases->Append(aRefBase);
1804 if(!aSeqBases->Length())
1807 aCI.SetBases(aSeqBases);
1808 aCI.SetLocations(aSeqLocs);
1809 aCI.SetPath(aRefPath);
1810 aCI.SetWithContactMode(theWithContact);
1811 aCI.SetWithCorrectionMode(theWithCorrections);
1813 //Compute the Pipe value
1815 #if OCC_VERSION_LARGE > 0x06010000
1818 if (!GetSolver()->ComputeFunction(aFunction)) {
1819 SetErrorCode("Pipe with defferent section driver failed");
1823 catch (Standard_Failure) {
1824 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1825 SetErrorCode(aFail->GetMessageString());
1829 //Make a Python command
1830 GEOM::TPythonDump pyDump(aFunction);
1831 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1833 for(i =1 ; i <= nbBases; i++) {
1835 Handle(Standard_Transient) anItem = theBases->Value(i);
1839 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1840 if(!anObj.IsNull()) {
1849 for(i =1 ; i <= nbLocs; i++) {
1851 Handle(Standard_Transient) anItem = theLocations->Value(i);
1855 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1856 if(!anObj.IsNull()) {
1863 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1870 //=============================================================================
1872 * MakePipeWithShellSections
1874 //=============================================================================
1875 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1876 const Handle(TColStd_HSequenceOfTransient)& theBases,
1877 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1878 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1879 const Handle(GEOM_Object)& thePath,
1880 bool theWithContact,
1881 bool theWithCorrections)
1883 Handle(GEOM_Object) anObj;
1885 if(theBases.IsNull())
1888 Standard_Integer nbBases = theBases->Length();
1893 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1895 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1897 //Add a new Pipe object
1898 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1900 //Add a new Pipe function
1902 Handle(GEOM_Function) aFunction =
1903 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1904 if (aFunction.IsNull()) return anObj;
1906 //Check if the function is set correctly
1907 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1909 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1910 GEOMImpl_IPipeShellSect aCI (aFunction);
1912 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1913 if(aRefPath.IsNull())
1916 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1917 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1918 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1920 Standard_Integer i =1;
1921 for( ; i <= nbBases; i++) {
1923 Handle(Standard_Transient) anItem = theBases->Value(i);
1926 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1929 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1930 if(aRefBase.IsNull())
1933 if( nbSubBases >= nbBases ) {
1934 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1935 if(aSubItem.IsNull())
1937 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1938 if(aSubBase.IsNull())
1940 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1941 if(aRefSubBase.IsNull())
1943 aSeqSubBases->Append(aRefSubBase);
1947 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1948 if(anItemLoc.IsNull())
1950 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1953 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1954 if(aRefLoc.IsNull())
1956 aSeqLocs->Append(aRefLoc);
1959 aSeqBases->Append(aRefBase);
1962 if(!aSeqBases->Length())
1965 aCI.SetBases(aSeqBases);
1966 aCI.SetSubBases(aSeqSubBases);
1967 aCI.SetLocations(aSeqLocs);
1968 aCI.SetPath(aRefPath);
1969 aCI.SetWithContactMode(theWithContact);
1970 aCI.SetWithCorrectionMode(theWithCorrections);
1972 //Compute the Pipe value
1974 #if OCC_VERSION_LARGE > 0x06010000
1977 if (!GetSolver()->ComputeFunction(aFunction)) {
1978 SetErrorCode("Pipe with shell sections driver failed");
1982 catch (Standard_Failure) {
1983 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1984 SetErrorCode(aFail->GetMessageString());
1988 //Make a Python command
1989 GEOM::TPythonDump pyDump(aFunction);
1990 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1992 for(i =1 ; i <= nbBases; i++) {
1994 Handle(Standard_Transient) anItem = theBases->Value(i);
1998 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1999 if(!anObj.IsNull()) {
2008 for(i =1 ; i <= nbSubBases; i++) {
2010 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2014 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2015 if(!anObj.IsNull()) {
2024 for(i =1 ; i <= nbLocs; i++) {
2026 Handle(Standard_Transient) anItem = theLocations->Value(i);
2030 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2031 if(!anObj.IsNull()) {
2038 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2046 //=============================================================================
2048 * MakePipeShellsWithoutPath
2050 //=============================================================================
2051 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2052 const Handle(TColStd_HSequenceOfTransient)& theBases,
2053 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2055 Handle(GEOM_Object) anObj;
2057 if(theBases.IsNull())
2060 Standard_Integer nbBases = theBases->Length();
2065 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2067 //Add a new Pipe object
2068 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2070 //Add a new Pipe function
2072 Handle(GEOM_Function) aFunction =
2073 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2074 if (aFunction.IsNull()) return anObj;
2076 //Check if the function is set correctly
2077 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2079 GEOMImpl_IPipeShellSect aCI (aFunction);
2081 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2082 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2084 Standard_Integer i =1;
2085 for( ; i <= nbBases; i++) {
2087 Handle(Standard_Transient) anItem = theBases->Value(i);
2090 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2093 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2094 if(aRefBase.IsNull())
2098 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2099 if(anItemLoc.IsNull())
2101 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2104 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2105 if(aRefLoc.IsNull())
2107 aSeqLocs->Append(aRefLoc);
2110 aSeqBases->Append(aRefBase);
2113 if(!aSeqBases->Length())
2116 aCI.SetBases(aSeqBases);
2117 aCI.SetLocations(aSeqLocs);
2119 //Compute the Pipe value
2121 #if OCC_VERSION_LARGE > 0x06010000
2124 if (!GetSolver()->ComputeFunction(aFunction)) {
2125 SetErrorCode("Pipe with shell sections without path driver failed");
2129 catch (Standard_Failure) {
2130 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2131 SetErrorCode(aFail->GetMessageString());
2135 //Make a Python command
2136 GEOM::TPythonDump pyDump(aFunction);
2137 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2139 for(i =1 ; i <= nbBases; i++) {
2141 Handle(Standard_Transient) anItem = theBases->Value(i);
2145 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2146 if(!anObj.IsNull()) {
2155 for(i =1 ; i <= nbLocs; i++) {
2157 Handle(Standard_Transient) anItem = theLocations->Value(i);
2161 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2162 if(!anObj.IsNull()) {
2177 //=============================================================================
2179 * MakePipeBiNormalAlongVector
2181 //=============================================================================
2182 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2183 Handle(GEOM_Object) thePath,
2184 Handle(GEOM_Object) theVec)
2188 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2190 //Add a new Pipe object
2191 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2193 //Add a new Pipe function
2194 Handle(GEOM_Function) aFunction =
2195 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2196 if (aFunction.IsNull()) return NULL;
2198 //Check if the function is set correctly
2199 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2201 GEOMImpl_IPipeBiNormal aCI (aFunction);
2203 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2204 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2205 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2207 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2209 aCI.SetBase(aRefBase);
2210 aCI.SetPath(aRefPath);
2211 aCI.SetVector(aRefVec);
2213 //Compute the Pipe value
2215 #if OCC_VERSION_LARGE > 0x06010000
2218 if (!GetSolver()->ComputeFunction(aFunction)) {
2219 SetErrorCode("Pipe driver failed");
2223 catch (Standard_Failure) {
2224 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2225 SetErrorCode(aFail->GetMessageString());
2229 //Make a Python command
2230 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2231 << theBase << ", " << thePath << ", " << theVec << ")";