1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <Basics_OCCTVersion.hxx>
26 #include <GEOMImpl_I3DPrimOperations.hxx>
28 #include "utilities.h"
30 #include <Utils_ExceptHandlers.hxx>
32 #include <TFunction_DriverTable.hxx>
33 #include <TFunction_Driver.hxx>
34 #include <TFunction_Logbook.hxx>
35 #include <TDF_Tool.hxx>
37 #include <GEOM_Function.hxx>
38 #include <GEOM_PythonDump.hxx>
40 #include <GEOMImpl_Types.hxx>
42 #include <GEOMImpl_BoxDriver.hxx>
43 #include <GEOMImpl_FaceDriver.hxx>
44 #include <GEOMImpl_DiskDriver.hxx>
45 #include <GEOMImpl_CylinderDriver.hxx>
46 #include <GEOMImpl_ConeDriver.hxx>
47 #include <GEOMImpl_SphereDriver.hxx>
48 #include <GEOMImpl_TorusDriver.hxx>
49 #include <GEOMImpl_PrismDriver.hxx>
50 #include <GEOMImpl_PipeDriver.hxx>
51 #include <GEOMImpl_RevolutionDriver.hxx>
52 #include <GEOMImpl_ShapeDriver.hxx>
53 #include <GEOMImpl_FillingDriver.hxx>
54 #include <GEOMImpl_ThruSectionsDriver.hxx>
56 #include <GEOMImpl_IBox.hxx>
57 #include <GEOMImpl_IFace.hxx>
58 #include <GEOMImpl_IDisk.hxx>
59 #include <GEOMImpl_ICylinder.hxx>
60 #include <GEOMImpl_ICone.hxx>
61 #include <GEOMImpl_ISphere.hxx>
62 #include <GEOMImpl_ITorus.hxx>
63 #include <GEOMImpl_IPrism.hxx>
64 #include <GEOMImpl_IPipe.hxx>
65 #include <GEOMImpl_IRevolution.hxx>
66 #include <GEOMImpl_IFilling.hxx>
67 #include <GEOMImpl_IThruSections.hxx>
68 #include <GEOMImpl_IPipeDiffSect.hxx>
69 #include <GEOMImpl_IPipeShellSect.hxx>
70 #include <GEOMImpl_IPipeBiNormal.hxx>
72 #include <Precision.hxx>
74 #include <Standard_Failure.hxx>
75 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
77 //=============================================================================
81 //=============================================================================
82 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
83 : GEOM_IOperations(theEngine, theDocID)
85 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
88 //=============================================================================
92 //=============================================================================
93 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
95 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
99 //=============================================================================
103 //=============================================================================
104 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
108 //Add a new Box object
109 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
111 //Add a new Box function with DX_DY_DZ parameters
112 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
113 if (aFunction.IsNull()) return NULL;
115 //Check if the function is set correctly
116 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
118 GEOMImpl_IBox aBI (aFunction);
124 //Compute the box value
126 #if OCC_VERSION_LARGE > 0x06010000
129 if (!GetSolver()->ComputeFunction(aFunction)) {
130 SetErrorCode("Box driver failed");
134 catch (Standard_Failure) {
135 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
136 SetErrorCode(aFail->GetMessageString());
140 //Make a Python command
141 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
142 << theDX << ", " << theDY << ", " << theDZ << ")";
149 //=============================================================================
153 //=============================================================================
154 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
155 Handle(GEOM_Object) thePnt2)
159 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
161 //Add a new Box object
162 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
164 //Add a new Box function for creation a box relatively to two points
165 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
166 if (aFunction.IsNull()) return NULL;
168 //Check if the function is set correctly
169 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
171 GEOMImpl_IBox aBI (aFunction);
173 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
174 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
176 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
178 aBI.SetRef1(aRefFunction1);
179 aBI.SetRef2(aRefFunction2);
181 //Compute the Box value
183 #if OCC_VERSION_LARGE > 0x06010000
186 if (!GetSolver()->ComputeFunction(aFunction)) {
187 SetErrorCode("Box driver failed");
191 catch (Standard_Failure) {
192 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
193 SetErrorCode(aFail->GetMessageString());
197 //Make a Python command
198 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
199 << thePnt1 << ", " << thePnt2 << ")";
205 //=============================================================================
209 //=============================================================================
210 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
214 if (theH == 0 || theW == 0) return NULL;
216 //Add a new Face object
217 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
219 //Add a new Box function for creation a box relatively to two points
220 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
221 if (aFunction.IsNull()) return NULL;
223 //Check if the function is set correctly
224 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
226 GEOMImpl_IFace aFI (aFunction);
230 aFI.SetOrientation(theOrientation);
234 #if OCC_VERSION_LARGE > 0x06010000
237 if (!GetSolver()->ComputeFunction(aFunction)) {
238 SetErrorCode("Face driver failed");
242 catch (Standard_Failure) {
243 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
244 SetErrorCode(aFail->GetMessageString());
248 //Make a Python command
249 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
250 << theH << ", " << theW << ", " << theOrientation << ")";
256 //=============================================================================
260 //=============================================================================
261 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
262 double theH, double theW)
266 if (theObj.IsNull()) return NULL;
268 //Add a new Face object
269 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
271 //Add a new Box function for creation a box relatively to two points
272 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
273 if (aFunction.IsNull()) return NULL;
275 //Check if the function is set correctly
276 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
278 GEOMImpl_IFace aFI (aFunction);
280 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
282 if (aRefFunction1.IsNull())
285 aFI.SetRef1(aRefFunction1);
291 #if OCC_VERSION_LARGE > 0x06010000
294 if (!GetSolver()->ComputeFunction(aFunction)) {
295 SetErrorCode("Face driver failed");
299 catch (Standard_Failure) {
300 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
301 SetErrorCode(aFail->GetMessageString());
305 //Make a Python command
306 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
307 << theObj << ", " << theH << ", " << theW << ")";
313 //=============================================================================
317 //=============================================================================
318 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
319 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
323 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
325 //Add a new Disk object
326 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
328 //Add a new Disk function for creation a disk relatively to point and vector
329 Handle(GEOM_Function) aFunction =
330 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
331 if (aFunction.IsNull()) return NULL;
333 //Check if the function is set correctly
334 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
336 GEOMImpl_IDisk aCI (aFunction);
338 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
339 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
341 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
343 aCI.SetCenter(aRefPnt);
344 aCI.SetVector(aRefVec);
347 //Compute the Disk value
349 #if OCC_VERSION_LARGE > 0x06010000
352 if (!GetSolver()->ComputeFunction(aFunction)) {
353 SetErrorCode("Disk driver failed");
357 catch (Standard_Failure) {
358 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
359 SetErrorCode(aFail->GetMessageString());
363 //Make a Python command
364 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
365 << thePnt << ", " << theVec << ", " << theR << ")";
371 //=============================================================================
375 //=============================================================================
376 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
377 Handle(GEOM_Object) thePnt2,
378 Handle(GEOM_Object) thePnt3)
382 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
384 //Add a new Disk object
385 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
387 //Add a new Disk function for creation a disk relatively to three points
388 Handle(GEOM_Function) aFunction =
389 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
390 if (aFunction.IsNull()) return NULL;
392 //Check if the function is set correctly
393 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
395 GEOMImpl_IDisk aCI (aFunction);
397 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
398 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
399 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
401 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
403 aCI.SetPoint1(aRefPnt1);
404 aCI.SetPoint2(aRefPnt2);
405 aCI.SetPoint3(aRefPnt3);
407 //Compute the Disk value
409 #if OCC_VERSION_LARGE > 0x06010000
412 if (!GetSolver()->ComputeFunction(aFunction)) {
413 SetErrorCode("Disk driver failed");
417 catch (Standard_Failure) {
418 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
419 SetErrorCode(aFail->GetMessageString());
423 //Make a Python command
424 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
425 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
431 //=============================================================================
435 //=============================================================================
436 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
440 if (theR == 0 ) return NULL;
442 //Add a new Disk object
443 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
445 //Add a new Box function for creation a box relatively to two points
446 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
447 if (aFunction.IsNull()) return NULL;
449 //Check if the function is set correctly
450 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
452 GEOMImpl_IDisk aDI (aFunction);
455 aDI.SetOrientation(theOrientation);
459 #if OCC_VERSION_LARGE > 0x06010000
462 if (!GetSolver()->ComputeFunction(aFunction)) {
463 SetErrorCode("Disk driver failed");
467 catch (Standard_Failure) {
468 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
469 SetErrorCode(aFail->GetMessageString());
473 //Make a Python command
474 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
475 << theR << ", " << theOrientation << ")";
481 //=============================================================================
485 //=============================================================================
486 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
490 //Add a new Cylinder object
491 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
493 //Add a new Cylinder function with R and H parameters
494 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
495 if (aFunction.IsNull()) return NULL;
497 //Check if the function is set correctly
498 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
500 GEOMImpl_ICylinder aCI (aFunction);
505 //Compute the Cylinder value
507 #if OCC_VERSION_LARGE > 0x06010000
510 if (!GetSolver()->ComputeFunction(aFunction)) {
511 SetErrorCode("Cylinder driver failed");
515 catch (Standard_Failure) {
516 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
517 SetErrorCode(aFail->GetMessageString());
521 //Make a Python command
522 GEOM::TPythonDump(aFunction) << aCylinder
523 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
530 //=============================================================================
532 * MakeCylinderPntVecRH
534 //=============================================================================
535 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
536 Handle(GEOM_Object) theVec,
537 double theR, double theH)
541 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
543 //Add a new Cylinder object
544 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
546 //Add a new Cylinder function for creation a cylinder relatively to point and vector
547 Handle(GEOM_Function) aFunction =
548 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
549 if (aFunction.IsNull()) return NULL;
551 //Check if the function is set correctly
552 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
554 GEOMImpl_ICylinder aCI (aFunction);
556 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
557 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
559 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
561 aCI.SetPoint(aRefPnt);
562 aCI.SetVector(aRefVec);
566 //Compute the Cylinder value
568 #if OCC_VERSION_LARGE > 0x06010000
571 if (!GetSolver()->ComputeFunction(aFunction)) {
572 SetErrorCode("Cylinder driver failed");
576 catch (Standard_Failure) {
577 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
578 SetErrorCode(aFail->GetMessageString());
582 //Make a Python command
583 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
584 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
591 //=============================================================================
595 //=============================================================================
596 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
601 //Add a new Cone object
602 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
604 //Add a new Cone function with R and H parameters
605 Handle(GEOM_Function) aFunction =
606 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
607 if (aFunction.IsNull()) return NULL;
609 //Check if the function is set correctly
610 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
612 GEOMImpl_ICone aCI (aFunction);
618 //Compute the Cone value
620 #if OCC_VERSION_LARGE > 0x06010000
623 if (!GetSolver()->ComputeFunction(aFunction)) {
624 SetErrorCode("Cone driver failed");
628 catch (Standard_Failure) {
629 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
630 SetErrorCode(aFail->GetMessageString());
634 //Make a Python command
635 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
636 << theR1 << ", " << theR2 << ", " << theH << ")";
643 //=============================================================================
645 * MakeConePntVecR1R2H
647 //=============================================================================
648 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
649 Handle(GEOM_Object) theVec,
650 double theR1, double theR2,
655 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
657 //Add a new Cone object
658 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
660 //Add a new Cone function for creation a cone relatively to point and vector
661 Handle(GEOM_Function) aFunction =
662 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
663 if (aFunction.IsNull()) return NULL;
665 //Check if the function is set correctly
666 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
668 GEOMImpl_ICone aCI (aFunction);
670 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
671 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
673 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
675 aCI.SetPoint(aRefPnt);
676 aCI.SetVector(aRefVec);
681 //Compute the Cone value
683 #if OCC_VERSION_LARGE > 0x06010000
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Cone 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) << aCone << " = geompy.MakeCone(" << thePnt
699 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
706 //=============================================================================
710 //=============================================================================
711 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
715 //Add a new Sphere object
716 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
718 //Add a new Sphere function with R parameter
719 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
720 if (aFunction.IsNull()) return NULL;
722 //Check if the function is set correctly
723 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
725 GEOMImpl_ISphere aCI (aFunction);
729 //Compute the Sphere value
731 #if OCC_VERSION_LARGE > 0x06010000
734 if (!GetSolver()->ComputeFunction(aFunction)) {
735 SetErrorCode("Sphere driver failed");
739 catch (Standard_Failure) {
740 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
741 SetErrorCode(aFail->GetMessageString());
745 //Make a Python command
746 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
753 //=============================================================================
757 //=============================================================================
758 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
763 if (thePnt.IsNull()) return NULL;
765 //Add a new Point object
766 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
768 //Add a new Sphere function for creation a sphere relatively to point
769 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
770 if (aFunction.IsNull()) return NULL;
772 //Check if the function is set correctly
773 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
775 GEOMImpl_ISphere aCI (aFunction);
777 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
779 if (aRefPnt.IsNull()) return NULL;
781 aCI.SetPoint(aRefPnt);
784 //Compute the Sphere value
786 #if OCC_VERSION_LARGE > 0x06010000
789 if (!GetSolver()->ComputeFunction(aFunction)) {
790 SetErrorCode("Sphere driver failed");
794 catch (Standard_Failure) {
795 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
796 SetErrorCode(aFail->GetMessageString());
800 //Make a Python command
801 GEOM::TPythonDump(aFunction) << aSphere
802 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
809 //=============================================================================
813 //=============================================================================
814 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
815 (double theRMajor, double theRMinor)
819 //Add a new Torus object
820 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
822 //Add a new Torus function
823 Handle(GEOM_Function) aFunction =
824 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
825 if (aFunction.IsNull()) return NULL;
827 //Check if the function is set correctly
828 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
830 GEOMImpl_ITorus aCI (aFunction);
832 aCI.SetRMajor(theRMajor);
833 aCI.SetRMinor(theRMinor);
835 //Compute the Torus value
837 #if OCC_VERSION_LARGE > 0x06010000
840 if (!GetSolver()->ComputeFunction(aFunction)) {
841 SetErrorCode("Torus driver failed");
845 catch (Standard_Failure) {
846 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
847 SetErrorCode(aFail->GetMessageString());
851 //Make a Python command
852 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
853 << theRMajor << ", " << theRMinor << ")";
859 //=============================================================================
863 //=============================================================================
864 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
865 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
866 double theRMajor, double theRMinor)
870 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
872 //Add a new Torus object
873 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
875 //Add a new Torus function
876 Handle(GEOM_Function) aFunction =
877 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
878 if (aFunction.IsNull()) return NULL;
880 //Check if the function is set correctly
881 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
883 GEOMImpl_ITorus aCI (aFunction);
885 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
886 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
888 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
890 aCI.SetCenter(aRefPnt);
891 aCI.SetVector(aRefVec);
892 aCI.SetRMajor(theRMajor);
893 aCI.SetRMinor(theRMinor);
895 //Compute the Torus value
897 #if OCC_VERSION_LARGE > 0x06010000
900 if (!GetSolver()->ComputeFunction(aFunction)) {
901 SetErrorCode("Torus driver failed");
905 catch (Standard_Failure) {
906 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
907 SetErrorCode(aFail->GetMessageString());
911 //Make a Python command
912 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
913 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
920 //=============================================================================
924 //=============================================================================
925 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
926 Handle(GEOM_Object) theVec,
927 double theH, double theScaleFactor)
931 if (theBase.IsNull() || theVec.IsNull()) return NULL;
933 //Add a new Prism object
934 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
936 //Add a new Prism function for creation a Prism relatively to vector
937 Handle(GEOM_Function) aFunction =
938 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
939 if (aFunction.IsNull()) return NULL;
941 //Check if the function is set correctly
942 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
944 GEOMImpl_IPrism aCI (aFunction);
946 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
947 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
949 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
951 aCI.SetBase(aRefBase);
952 aCI.SetVector(aRefVec);
954 aCI.SetScale(theScaleFactor);
956 //Compute the Prism value
958 #if OCC_VERSION_LARGE > 0x06010000
961 if (!GetSolver()->ComputeFunction(aFunction)) {
962 //SetErrorCode("Prism driver failed");
963 SetErrorCode("Extrusion can not be created, check input data");
967 catch (Standard_Failure) {
968 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
969 SetErrorCode(aFail->GetMessageString());
973 //Make a Python command
974 GEOM::TPythonDump pd (aFunction);
975 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
976 if (theScaleFactor > Precision::Confusion())
977 pd << ", " << theScaleFactor << ")";
985 //=============================================================================
989 //=============================================================================
990 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
991 Handle(GEOM_Object) theVec,
996 if (theBase.IsNull() || theVec.IsNull()) return NULL;
998 //Add a new Prism object
999 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1001 //Add a new Prism function for creation a Prism relatively to vector
1002 Handle(GEOM_Function) aFunction =
1003 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1004 if (aFunction.IsNull()) return NULL;
1006 //Check if the function is set correctly
1007 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1009 GEOMImpl_IPrism aCI (aFunction);
1011 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1012 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1014 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1016 aCI.SetBase(aRefBase);
1017 aCI.SetVector(aRefVec);
1020 //Compute the Prism value
1022 #if OCC_VERSION_LARGE > 0x06010000
1025 if (!GetSolver()->ComputeFunction(aFunction)) {
1026 //SetErrorCode("Prism driver failed");
1027 SetErrorCode("Extrusion can not be created, check input data");
1031 catch (Standard_Failure) {
1032 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1033 SetErrorCode(aFail->GetMessageString());
1037 //Make a Python command
1038 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1039 << theBase << ", " << theVec << ", " << theH << ")";
1045 //=============================================================================
1049 //=============================================================================
1050 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1051 (Handle(GEOM_Object) theBase,
1052 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1053 double theScaleFactor)
1057 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1059 //Add a new Prism object
1060 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1062 //Add a new Prism function for creation a Prism relatively to two points
1063 Handle(GEOM_Function) aFunction =
1064 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1065 if (aFunction.IsNull()) return NULL;
1067 //Check if the function is set correctly
1068 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1070 GEOMImpl_IPrism aCI (aFunction);
1072 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1073 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1074 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1076 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1078 aCI.SetBase(aRefBase);
1079 aCI.SetFirstPoint(aRefPnt1);
1080 aCI.SetLastPoint(aRefPnt2);
1081 aCI.SetScale(theScaleFactor);
1083 //Compute the Prism value
1085 #if OCC_VERSION_LARGE > 0x06010000
1088 if (!GetSolver()->ComputeFunction(aFunction)) {
1089 //SetErrorCode("Prism driver failed");
1090 SetErrorCode("Extrusion can not be created, check input data");
1094 catch (Standard_Failure) {
1095 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1096 SetErrorCode(aFail->GetMessageString());
1100 //Make a Python command
1101 GEOM::TPythonDump pd (aFunction);
1102 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1103 if (theScaleFactor > Precision::Confusion())
1104 pd << ", " << theScaleFactor << ")";
1112 //=============================================================================
1114 * MakePrismTwoPnt2Ways
1116 //=============================================================================
1117 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1118 (Handle(GEOM_Object) theBase,
1119 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1123 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1125 //Add a new Prism object
1126 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1128 //Add a new Prism function for creation a Prism relatively to two points
1129 Handle(GEOM_Function) aFunction =
1130 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1131 if (aFunction.IsNull()) return NULL;
1133 //Check if the function is set correctly
1134 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1136 GEOMImpl_IPrism aCI (aFunction);
1138 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1139 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1140 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1142 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1144 aCI.SetBase(aRefBase);
1145 aCI.SetFirstPoint(aRefPnt1);
1146 aCI.SetLastPoint(aRefPnt2);
1148 //Compute the Prism value
1150 #if OCC_VERSION_LARGE > 0x06010000
1153 if (!GetSolver()->ComputeFunction(aFunction)) {
1154 //SetErrorCode("Prism driver failed");
1155 SetErrorCode("Extrusion can not be created, check input data");
1159 catch (Standard_Failure) {
1160 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1161 SetErrorCode(aFail->GetMessageString());
1165 //Make a Python command
1166 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1167 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1173 //=============================================================================
1177 //=============================================================================
1178 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1179 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1180 double theScaleFactor)
1184 if (theBase.IsNull()) return NULL;
1186 //Add a new Prism object
1187 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1189 //Add a new Prism function for creation a Prism by DXDYDZ
1190 Handle(GEOM_Function) aFunction =
1191 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1192 if (aFunction.IsNull()) return NULL;
1194 //Check if the function is set correctly
1195 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1197 GEOMImpl_IPrism aCI (aFunction);
1199 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1201 if (aRefBase.IsNull()) return NULL;
1203 aCI.SetBase(aRefBase);
1207 aCI.SetScale(theScaleFactor);
1209 //Compute the Prism value
1211 #if OCC_VERSION_LARGE > 0x06010000
1214 if (!GetSolver()->ComputeFunction(aFunction)) {
1215 SetErrorCode("Extrusion can not be created, check input data");
1219 catch (Standard_Failure) {
1220 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1221 SetErrorCode(aFail->GetMessageString());
1225 //Make a Python command
1226 GEOM::TPythonDump pd (aFunction);
1227 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1228 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1229 if (theScaleFactor > Precision::Confusion())
1230 pd << ", " << theScaleFactor << ")";
1238 //=============================================================================
1240 * MakePrismDXDYDZ_2WAYS
1242 //=============================================================================
1243 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1244 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1248 if (theBase.IsNull()) return NULL;
1250 //Add a new Prism object
1251 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1253 //Add a new Prism function for creation a Prism by DXDYDZ
1254 Handle(GEOM_Function) aFunction =
1255 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1256 if (aFunction.IsNull()) return NULL;
1258 //Check if the function is set correctly
1259 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1261 GEOMImpl_IPrism aCI (aFunction);
1263 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1265 if (aRefBase.IsNull()) return NULL;
1267 aCI.SetBase(aRefBase);
1272 //Compute the Prism value
1274 #if OCC_VERSION_LARGE > 0x06010000
1277 if (!GetSolver()->ComputeFunction(aFunction)) {
1278 SetErrorCode("Extrusion can not be created, check input data");
1282 catch (Standard_Failure) {
1283 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1284 SetErrorCode(aFail->GetMessageString());
1288 //Make a Python command
1289 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1290 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1296 //=============================================================================
1300 //=============================================================================
1301 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1302 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1306 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1308 Handle(GEOM_Object) aPrism = NULL;
1312 //Add a new Extruded Boss object
1313 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1317 //Add a new Extruded Cut object
1318 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1321 //Add a new Prism function for the creation of a Draft Prism feature
1322 Handle(GEOM_Function) aFunction =
1323 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1324 if (aFunction.IsNull()) return NULL;
1326 //Check if the function is set correctly
1327 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1329 GEOMImpl_IPrism aCI (aFunction);
1331 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1332 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1334 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1337 aCI.SetBase(aRefBase);
1338 aCI.SetInitShape(aRefInit);
1339 aCI.SetH(theHeight);
1340 aCI.SetDraftAngle(theAngle);
1346 //Compute the Draft Prism Feature value
1348 #if OCC_VERSION_LARGE > 0x06010000
1351 if (!GetSolver()->ComputeFunction(aFunction)) {
1352 SetErrorCode("Extrusion can not be created, check input data");
1356 catch (Standard_Failure) {
1357 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1358 SetErrorCode(aFail->GetMessageString());
1362 //Make a Python command
1365 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1366 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1370 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1371 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1378 //=============================================================================
1382 //=============================================================================
1383 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1384 Handle(GEOM_Object) thePath)
1388 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1390 //Add a new Pipe object
1391 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1393 //Add a new Pipe function
1394 Handle(GEOM_Function) aFunction =
1395 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1396 if (aFunction.IsNull()) return NULL;
1398 //Check if the function is set correctly
1399 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1401 GEOMImpl_IPipe aCI (aFunction);
1403 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1404 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1406 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1408 aCI.SetBase(aRefBase);
1409 aCI.SetPath(aRefPath);
1411 //Compute the Pipe value
1413 #if OCC_VERSION_LARGE > 0x06010000
1416 if (!GetSolver()->ComputeFunction(aFunction)) {
1417 SetErrorCode("Pipe driver failed");
1421 catch (Standard_Failure) {
1422 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1423 SetErrorCode(aFail->GetMessageString());
1427 //Make a Python command
1428 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1429 << theBase << ", " << thePath << ")";
1436 //=============================================================================
1438 * MakeRevolutionAxisAngle
1440 //=============================================================================
1441 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1442 Handle(GEOM_Object) theAxis,
1447 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1449 //Add a new Revolution object
1450 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1452 //Add a new Revolution function for creation a revolution relatively to axis
1453 Handle(GEOM_Function) aFunction =
1454 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1455 if (aFunction.IsNull()) return NULL;
1457 //Check if the function is set correctly
1458 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1460 GEOMImpl_IRevolution aCI (aFunction);
1462 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1463 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1465 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1467 aCI.SetBase(aRefBase);
1468 aCI.SetAxis(aRefAxis);
1469 aCI.SetAngle(theAngle);
1471 //Compute the Revolution value
1473 #if OCC_VERSION_LARGE > 0x06010000
1476 if (!GetSolver()->ComputeFunction(aFunction)) {
1477 SetErrorCode("Revolution driver failed");
1481 catch (Standard_Failure) {
1482 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1483 SetErrorCode(aFail->GetMessageString());
1487 //Make a Python command
1488 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1489 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1495 //=============================================================================
1497 * MakeRevolutionAxisAngle2Ways
1499 //=============================================================================
1500 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1501 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1505 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1507 //Add a new Revolution object
1508 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1510 //Add a new Revolution function for creation a revolution relatively to axis
1511 Handle(GEOM_Function) aFunction =
1512 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1513 if (aFunction.IsNull()) return NULL;
1515 //Check if the function is set correctly
1516 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1518 GEOMImpl_IRevolution aCI (aFunction);
1520 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1521 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1523 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1525 aCI.SetBase(aRefBase);
1526 aCI.SetAxis(aRefAxis);
1527 aCI.SetAngle(theAngle);
1529 //Compute the Revolution value
1531 #if OCC_VERSION_LARGE > 0x06010000
1534 if (!GetSolver()->ComputeFunction(aFunction)) {
1535 SetErrorCode("Revolution driver failed");
1539 catch (Standard_Failure) {
1540 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1541 SetErrorCode(aFail->GetMessageString());
1545 //Make a Python command
1546 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1547 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1553 //=============================================================================
1557 //=============================================================================
1558 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1559 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1560 double theTol2D, double theTol3D, int theNbIter,
1561 int theMethod, bool isApprox)
1565 if (theShape.IsNull()) return NULL;
1567 //Add a new Filling object
1568 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1570 //Add a new Filling function for creation a filling from a compound
1571 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1572 if (aFunction.IsNull()) return NULL;
1574 //Check if the function is set correctly
1575 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1577 GEOMImpl_IFilling aFI (aFunction);
1579 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1581 if (aRefShape.IsNull()) return NULL;
1583 aFI.SetShape(aRefShape);
1584 aFI.SetMinDeg(theMinDeg);
1585 aFI.SetMaxDeg(theMaxDeg);
1586 aFI.SetTol2D(theTol2D);
1587 aFI.SetTol3D(theTol3D);
1588 aFI.SetNbIter(theNbIter);
1589 aFI.SetApprox(isApprox);
1590 aFI.SetMethod(theMethod);
1592 //Compute the Solid value
1594 #if OCC_VERSION_LARGE > 0x06010000
1597 if (!GetSolver()->ComputeFunction(aFunction)) {
1598 SetErrorCode("Filling driver failed");
1602 catch (Standard_Failure) {
1603 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1604 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1605 SetErrorCode("B-Spline surface construction failed");
1607 SetErrorCode(aFail->GetMessageString());
1611 //Make a Python command
1612 GEOM::TPythonDump pd (aFunction);
1613 pd << aFilling << " = geompy.MakeFilling("
1614 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1615 << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
1616 if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
1617 else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
1618 else pd << "GEOM.FOM_Default";
1620 pd << ", " << isApprox ;
1627 //=============================================================================
1631 //=============================================================================
1632 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1633 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1638 Handle(GEOM_Object) anObj;
1640 if(theSeqSections.IsNull())
1643 Standard_Integer nbObj = theSeqSections->Length();
1647 //Add a new ThruSections object
1648 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1651 //Add a new ThruSections function
1653 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1654 Handle(GEOM_Function) aFunction =
1655 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1656 if (aFunction.IsNull()) return anObj;
1658 //Check if the function is set correctly
1659 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1661 GEOMImpl_IThruSections aCI (aFunction);
1663 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1665 Standard_Integer i =1;
1666 for( ; i <= nbObj; i++) {
1668 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1672 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1673 if(!aSectObj.IsNull())
1675 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1676 if(!aRefSect.IsNull())
1677 aSeqSections->Append(aRefSect);
1681 if(!aSeqSections->Length())
1684 aCI.SetSections(aSeqSections);
1685 aCI.SetSolidMode(theModeSolid);
1686 aCI.SetPrecision(thePreci);
1688 //Compute the ThruSections value
1690 #if OCC_VERSION_LARGE > 0x06010000
1693 if (!GetSolver()->ComputeFunction(aFunction)) {
1694 SetErrorCode("ThruSections driver failed");
1698 catch (Standard_Failure) {
1699 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1700 SetErrorCode(aFail->GetMessageString());
1704 //Make a Python command
1705 GEOM::TPythonDump pyDump(aFunction);
1706 pyDump << aThruSect << " = geompy.MakeThruSections([";
1708 for(i =1 ; i <= nbObj; i++) {
1710 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1714 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1715 if(!aSectObj.IsNull()) {
1722 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1729 //=============================================================================
1731 * MakePipeWithDifferentSections
1733 //=============================================================================
1734 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1735 const Handle(TColStd_HSequenceOfTransient)& theBases,
1736 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1737 const Handle(GEOM_Object)& thePath,
1738 bool theWithContact,
1739 bool theWithCorrections)
1741 Handle(GEOM_Object) anObj;
1743 if(theBases.IsNull())
1746 Standard_Integer nbBases = theBases->Length();
1751 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1752 //Add a new Pipe object
1753 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1755 //Add a new Pipe function
1757 Handle(GEOM_Function) aFunction =
1758 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1759 if (aFunction.IsNull()) return anObj;
1761 //Check if the function is set correctly
1762 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1764 GEOMImpl_IPipeDiffSect aCI (aFunction);
1766 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1767 if(aRefPath.IsNull())
1770 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1771 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1773 Standard_Integer i =1;
1774 for( ; i <= nbBases; i++) {
1776 Handle(Standard_Transient) anItem = theBases->Value(i);
1780 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1783 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1784 if(aRefBase.IsNull())
1788 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1789 if(anItemLoc.IsNull())
1792 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1795 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1796 if(aRefLoc.IsNull())
1798 aSeqLocs->Append(aRefLoc);
1800 aSeqBases->Append(aRefBase);
1803 if(!aSeqBases->Length())
1806 aCI.SetBases(aSeqBases);
1807 aCI.SetLocations(aSeqLocs);
1808 aCI.SetPath(aRefPath);
1809 aCI.SetWithContactMode(theWithContact);
1810 aCI.SetWithCorrectionMode(theWithCorrections);
1812 //Compute the Pipe value
1814 #if OCC_VERSION_LARGE > 0x06010000
1817 if (!GetSolver()->ComputeFunction(aFunction)) {
1818 SetErrorCode("Pipe with defferent section driver failed");
1822 catch (Standard_Failure) {
1823 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1824 SetErrorCode(aFail->GetMessageString());
1828 //Make a Python command
1829 GEOM::TPythonDump pyDump(aFunction);
1830 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1832 for(i =1 ; i <= nbBases; i++) {
1834 Handle(Standard_Transient) anItem = theBases->Value(i);
1838 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1839 if(!anObj.IsNull()) {
1848 for(i =1 ; i <= nbLocs; i++) {
1850 Handle(Standard_Transient) anItem = theLocations->Value(i);
1854 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1855 if(!anObj.IsNull()) {
1862 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1869 //=============================================================================
1871 * MakePipeWithShellSections
1873 //=============================================================================
1874 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1875 const Handle(TColStd_HSequenceOfTransient)& theBases,
1876 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1877 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1878 const Handle(GEOM_Object)& thePath,
1879 bool theWithContact,
1880 bool theWithCorrections)
1882 Handle(GEOM_Object) anObj;
1884 if(theBases.IsNull())
1887 Standard_Integer nbBases = theBases->Length();
1892 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1894 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1896 //Add a new Pipe object
1897 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1899 //Add a new Pipe function
1901 Handle(GEOM_Function) aFunction =
1902 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1903 if (aFunction.IsNull()) return anObj;
1905 //Check if the function is set correctly
1906 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1908 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1909 GEOMImpl_IPipeShellSect aCI (aFunction);
1911 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1912 if(aRefPath.IsNull())
1915 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1916 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1917 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1919 Standard_Integer i =1;
1920 for( ; i <= nbBases; i++) {
1922 Handle(Standard_Transient) anItem = theBases->Value(i);
1925 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1928 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1929 if(aRefBase.IsNull())
1932 if( nbSubBases >= nbBases ) {
1933 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1934 if(aSubItem.IsNull())
1936 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1937 if(aSubBase.IsNull())
1939 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1940 if(aRefSubBase.IsNull())
1942 aSeqSubBases->Append(aRefSubBase);
1946 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1947 if(anItemLoc.IsNull())
1949 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1952 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1953 if(aRefLoc.IsNull())
1955 aSeqLocs->Append(aRefLoc);
1958 aSeqBases->Append(aRefBase);
1961 if(!aSeqBases->Length())
1964 aCI.SetBases(aSeqBases);
1965 aCI.SetSubBases(aSeqSubBases);
1966 aCI.SetLocations(aSeqLocs);
1967 aCI.SetPath(aRefPath);
1968 aCI.SetWithContactMode(theWithContact);
1969 aCI.SetWithCorrectionMode(theWithCorrections);
1971 //Compute the Pipe value
1973 #if OCC_VERSION_LARGE > 0x06010000
1976 if (!GetSolver()->ComputeFunction(aFunction)) {
1977 SetErrorCode("Pipe with shell sections driver failed");
1981 catch (Standard_Failure) {
1982 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1983 SetErrorCode(aFail->GetMessageString());
1987 //Make a Python command
1988 GEOM::TPythonDump pyDump(aFunction);
1989 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1991 for(i =1 ; i <= nbBases; i++) {
1993 Handle(Standard_Transient) anItem = theBases->Value(i);
1997 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1998 if(!anObj.IsNull()) {
2007 for(i =1 ; i <= nbSubBases; i++) {
2009 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2013 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2014 if(!anObj.IsNull()) {
2023 for(i =1 ; i <= nbLocs; i++) {
2025 Handle(Standard_Transient) anItem = theLocations->Value(i);
2029 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2030 if(!anObj.IsNull()) {
2037 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2045 //=============================================================================
2047 * MakePipeShellsWithoutPath
2049 //=============================================================================
2050 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2051 const Handle(TColStd_HSequenceOfTransient)& theBases,
2052 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2054 Handle(GEOM_Object) anObj;
2056 if(theBases.IsNull())
2059 Standard_Integer nbBases = theBases->Length();
2064 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2066 //Add a new Pipe object
2067 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2069 //Add a new Pipe function
2071 Handle(GEOM_Function) aFunction =
2072 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2073 if (aFunction.IsNull()) return anObj;
2075 //Check if the function is set correctly
2076 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2078 GEOMImpl_IPipeShellSect aCI (aFunction);
2080 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2081 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2083 Standard_Integer i =1;
2084 for( ; i <= nbBases; i++) {
2086 Handle(Standard_Transient) anItem = theBases->Value(i);
2089 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2092 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2093 if(aRefBase.IsNull())
2097 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2098 if(anItemLoc.IsNull())
2100 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2103 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2104 if(aRefLoc.IsNull())
2106 aSeqLocs->Append(aRefLoc);
2109 aSeqBases->Append(aRefBase);
2112 if(!aSeqBases->Length())
2115 aCI.SetBases(aSeqBases);
2116 aCI.SetLocations(aSeqLocs);
2118 //Compute the Pipe value
2120 #if OCC_VERSION_LARGE > 0x06010000
2123 if (!GetSolver()->ComputeFunction(aFunction)) {
2124 SetErrorCode("Pipe with shell sections without path driver failed");
2128 catch (Standard_Failure) {
2129 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2130 SetErrorCode(aFail->GetMessageString());
2134 //Make a Python command
2135 GEOM::TPythonDump pyDump(aFunction);
2136 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2138 for(i =1 ; i <= nbBases; i++) {
2140 Handle(Standard_Transient) anItem = theBases->Value(i);
2144 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2145 if(!anObj.IsNull()) {
2154 for(i =1 ; i <= nbLocs; i++) {
2156 Handle(Standard_Transient) anItem = theLocations->Value(i);
2160 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2161 if(!anObj.IsNull()) {
2176 //=============================================================================
2178 * MakePipeBiNormalAlongVector
2180 //=============================================================================
2181 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2182 Handle(GEOM_Object) thePath,
2183 Handle(GEOM_Object) theVec)
2187 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2189 //Add a new Pipe object
2190 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2192 //Add a new Pipe function
2193 Handle(GEOM_Function) aFunction =
2194 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2195 if (aFunction.IsNull()) return NULL;
2197 //Check if the function is set correctly
2198 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2200 GEOMImpl_IPipeBiNormal aCI (aFunction);
2202 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2203 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2204 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2206 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2208 aCI.SetBase(aRefBase);
2209 aCI.SetPath(aRefPath);
2210 aCI.SetVector(aRefVec);
2212 //Compute the Pipe value
2214 #if OCC_VERSION_LARGE > 0x06010000
2217 if (!GetSolver()->ComputeFunction(aFunction)) {
2218 SetErrorCode("Pipe driver failed");
2222 catch (Standard_Failure) {
2223 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2224 SetErrorCode(aFail->GetMessageString());
2228 //Make a Python command
2229 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2230 << theBase << ", " << thePath << ", " << theVec << ")";