1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_I3DPrimOperations.hxx>
24 #include "utilities.h"
26 #include <Utils_ExceptHandlers.hxx>
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
36 #include <GEOMImpl_Types.hxx>
38 #include <GEOMImpl_BoxDriver.hxx>
39 #include <GEOMImpl_FaceDriver.hxx>
40 #include <GEOMImpl_DiskDriver.hxx>
41 #include <GEOMImpl_CylinderDriver.hxx>
42 #include <GEOMImpl_ConeDriver.hxx>
43 #include <GEOMImpl_SphereDriver.hxx>
44 #include <GEOMImpl_TorusDriver.hxx>
45 #include <GEOMImpl_PrismDriver.hxx>
46 #include <GEOMImpl_PipeDriver.hxx>
47 #include <GEOMImpl_RevolutionDriver.hxx>
48 #include <GEOMImpl_ShapeDriver.hxx>
49 #include <GEOMImpl_FillingDriver.hxx>
50 #include <GEOMImpl_ThruSectionsDriver.hxx>
52 #include <GEOMImpl_IBox.hxx>
53 #include <GEOMImpl_IFace.hxx>
54 #include <GEOMImpl_IDisk.hxx>
55 #include <GEOMImpl_ICylinder.hxx>
56 #include <GEOMImpl_ICone.hxx>
57 #include <GEOMImpl_ISphere.hxx>
58 #include <GEOMImpl_ITorus.hxx>
59 #include <GEOMImpl_IPrism.hxx>
60 #include <GEOMImpl_IPipe.hxx>
61 #include <GEOMImpl_IRevolution.hxx>
62 #include <GEOMImpl_IShapes.hxx>
63 #include <GEOMImpl_IFilling.hxx>
64 #include <GEOMImpl_IThruSections.hxx>
65 #include <GEOMImpl_IPipeDiffSect.hxx>
66 #include <GEOMImpl_IPipeShellSect.hxx>
68 #include <Standard_Failure.hxx>
69 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
71 //=============================================================================
75 //=============================================================================
76 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
77 : GEOM_IOperations(theEngine, theDocID)
79 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
82 //=============================================================================
86 //=============================================================================
87 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
89 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
93 //=============================================================================
97 //=============================================================================
98 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
102 //Add a new Box object
103 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
105 //Add a new Box function with DX_DY_DZ parameters
106 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
107 if (aFunction.IsNull()) return NULL;
109 //Check if the function is set correctly
110 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
112 GEOMImpl_IBox aBI (aFunction);
118 //Compute the box value
120 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
123 if (!GetSolver()->ComputeFunction(aFunction)) {
124 SetErrorCode("Box driver failed");
128 catch (Standard_Failure) {
129 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
130 SetErrorCode(aFail->GetMessageString());
134 //Make a Python command
135 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
136 << theDX << ", " << theDY << ", " << theDZ << ")";
143 //=============================================================================
147 //=============================================================================
148 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
149 Handle(GEOM_Object) thePnt2)
153 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
155 //Add a new Box object
156 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
158 //Add a new Box function for creation a box relatively to two points
159 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
160 if (aFunction.IsNull()) return NULL;
162 //Check if the function is set correctly
163 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
165 GEOMImpl_IBox aBI (aFunction);
167 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
168 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
170 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
172 aBI.SetRef1(aRefFunction1);
173 aBI.SetRef2(aRefFunction2);
175 //Compute the Box value
177 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
180 if (!GetSolver()->ComputeFunction(aFunction)) {
181 SetErrorCode("Box driver failed");
185 catch (Standard_Failure) {
186 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
187 SetErrorCode(aFail->GetMessageString());
191 //Make a Python command
192 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
193 << thePnt1 << ", " << thePnt2 << ")";
199 //=============================================================================
203 //=============================================================================
204 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
208 if (theH == 0 || theW == 0) return NULL;
210 //Add a new Face object
211 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
213 //Add a new Box function for creation a box relatively to two points
214 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
215 if (aFunction.IsNull()) return NULL;
217 //Check if the function is set correctly
218 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
220 GEOMImpl_IFace aFI (aFunction);
224 aFI.SetOrientation(theOrientation);
228 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
231 if (!GetSolver()->ComputeFunction(aFunction)) {
232 SetErrorCode("Face driver failed");
236 catch (Standard_Failure) {
237 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
238 SetErrorCode(aFail->GetMessageString());
242 //Make a Python command
243 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
244 << theH << ", " << theW << ", " << theOrientation << ")";
250 //=============================================================================
254 //=============================================================================
255 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
256 double theH, double theW)
260 if (theObj.IsNull()) return NULL;
262 //Add a new Face object
263 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
265 //Add a new Box function for creation a box relatively to two points
266 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
267 if (aFunction.IsNull()) return NULL;
269 //Check if the function is set correctly
270 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
272 GEOMImpl_IFace aFI (aFunction);
274 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
276 if (aRefFunction1.IsNull())
279 aFI.SetRef1(aRefFunction1);
285 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
288 if (!GetSolver()->ComputeFunction(aFunction)) {
289 SetErrorCode("Face driver failed");
293 catch (Standard_Failure) {
294 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
295 SetErrorCode(aFail->GetMessageString());
299 //Make a Python command
300 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
301 << theObj << ", " << theH << ", " << theW << ")";
307 //=============================================================================
311 //=============================================================================
312 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
313 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
317 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
319 //Add a new Disk object
320 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
322 //Add a new Disk function for creation a disk relatively to point and vector
323 Handle(GEOM_Function) aFunction =
324 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
325 if (aFunction.IsNull()) return NULL;
327 //Check if the function is set correctly
328 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
330 GEOMImpl_IDisk aCI (aFunction);
332 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
333 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
335 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
337 aCI.SetCenter(aRefPnt);
338 aCI.SetVector(aRefVec);
341 //Compute the Disk value
343 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
346 if (!GetSolver()->ComputeFunction(aFunction)) {
347 SetErrorCode("Disk driver failed");
351 catch (Standard_Failure) {
352 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
353 SetErrorCode(aFail->GetMessageString());
357 //Make a Python command
358 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
359 << thePnt << ", " << theVec << ", " << theR << ")";
365 //=============================================================================
369 //=============================================================================
370 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
371 Handle(GEOM_Object) thePnt2,
372 Handle(GEOM_Object) thePnt3)
376 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
378 //Add a new Disk object
379 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
381 //Add a new Disk function for creation a disk relatively to three points
382 Handle(GEOM_Function) aFunction =
383 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
384 if (aFunction.IsNull()) return NULL;
386 //Check if the function is set correctly
387 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
389 GEOMImpl_IDisk aCI (aFunction);
391 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
392 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
393 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
395 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
397 aCI.SetPoint1(aRefPnt1);
398 aCI.SetPoint2(aRefPnt2);
399 aCI.SetPoint3(aRefPnt3);
401 //Compute the Disk value
403 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
406 if (!GetSolver()->ComputeFunction(aFunction)) {
407 SetErrorCode("Disk driver failed");
411 catch (Standard_Failure) {
412 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
413 SetErrorCode(aFail->GetMessageString());
417 //Make a Python command
418 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
419 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
425 //=============================================================================
429 //=============================================================================
430 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
434 if (theR == 0 ) return NULL;
436 //Add a new Disk object
437 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
439 //Add a new Box function for creation a box relatively to two points
440 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
441 if (aFunction.IsNull()) return NULL;
443 //Check if the function is set correctly
444 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
446 GEOMImpl_IDisk aDI (aFunction);
449 aDI.SetOrientation(theOrientation);
453 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
456 if (!GetSolver()->ComputeFunction(aFunction)) {
457 SetErrorCode("Disk driver failed");
461 catch (Standard_Failure) {
462 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
463 SetErrorCode(aFail->GetMessageString());
467 //Make a Python command
468 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
469 << theR << ", " << theOrientation << ")";
475 //=============================================================================
479 //=============================================================================
480 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
484 //Add a new Cylinder object
485 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
487 //Add a new Cylinder function with R and H parameters
488 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
489 if (aFunction.IsNull()) return NULL;
491 //Check if the function is set correctly
492 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
494 GEOMImpl_ICylinder aCI (aFunction);
499 //Compute the Cylinder value
501 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
504 if (!GetSolver()->ComputeFunction(aFunction)) {
505 SetErrorCode("Cylinder driver failed");
509 catch (Standard_Failure) {
510 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
511 SetErrorCode(aFail->GetMessageString());
515 //Make a Python command
516 GEOM::TPythonDump(aFunction) << aCylinder
517 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
524 //=============================================================================
526 * MakeCylinderPntVecRH
528 //=============================================================================
529 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
530 Handle(GEOM_Object) theVec,
531 double theR, double theH)
535 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
537 //Add a new Cylinder object
538 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
540 //Add a new Cylinder function for creation a cylinder relatively to point and vector
541 Handle(GEOM_Function) aFunction =
542 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
543 if (aFunction.IsNull()) return NULL;
545 //Check if the function is set correctly
546 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
548 GEOMImpl_ICylinder aCI (aFunction);
550 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
551 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
553 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
555 aCI.SetPoint(aRefPnt);
556 aCI.SetVector(aRefVec);
560 //Compute the Cylinder value
562 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
565 if (!GetSolver()->ComputeFunction(aFunction)) {
566 SetErrorCode("Cylinder driver failed");
570 catch (Standard_Failure) {
571 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
572 SetErrorCode(aFail->GetMessageString());
576 //Make a Python command
577 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
578 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
585 //=============================================================================
589 //=============================================================================
590 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
595 //Add a new Cone object
596 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
598 //Add a new Cone function with R and H parameters
599 Handle(GEOM_Function) aFunction =
600 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
601 if (aFunction.IsNull()) return NULL;
603 //Check if the function is set correctly
604 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
606 GEOMImpl_ICone aCI (aFunction);
612 //Compute the Cone value
614 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
617 if (!GetSolver()->ComputeFunction(aFunction)) {
618 SetErrorCode("Cone driver failed");
622 catch (Standard_Failure) {
623 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
624 SetErrorCode(aFail->GetMessageString());
628 //Make a Python command
629 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
630 << theR1 << ", " << theR2 << ", " << theH << ")";
637 //=============================================================================
639 * MakeConePntVecR1R2H
641 //=============================================================================
642 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
643 Handle(GEOM_Object) theVec,
644 double theR1, double theR2,
649 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
651 //Add a new Cone object
652 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
654 //Add a new Cone function for creation a cone relatively to point and vector
655 Handle(GEOM_Function) aFunction =
656 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
657 if (aFunction.IsNull()) return NULL;
659 //Check if the function is set correctly
660 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
662 GEOMImpl_ICone aCI (aFunction);
664 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
665 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
667 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
669 aCI.SetPoint(aRefPnt);
670 aCI.SetVector(aRefVec);
675 //Compute the Cone value
677 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
680 if (!GetSolver()->ComputeFunction(aFunction)) {
681 SetErrorCode("Cone driver failed");
685 catch (Standard_Failure) {
686 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
687 SetErrorCode(aFail->GetMessageString());
691 //Make a Python command
692 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
693 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
700 //=============================================================================
704 //=============================================================================
705 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
709 //Add a new Sphere object
710 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
712 //Add a new Sphere function with R parameter
713 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
714 if (aFunction.IsNull()) return NULL;
716 //Check if the function is set correctly
717 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
719 GEOMImpl_ISphere aCI (aFunction);
723 //Compute the Sphere value
725 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
728 if (!GetSolver()->ComputeFunction(aFunction)) {
729 SetErrorCode("Sphere driver failed");
733 catch (Standard_Failure) {
734 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
735 SetErrorCode(aFail->GetMessageString());
739 //Make a Python command
740 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
747 //=============================================================================
751 //=============================================================================
752 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
757 if (thePnt.IsNull()) return NULL;
759 //Add a new Point object
760 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
762 //Add a new Sphere function for creation a sphere relatively to point
763 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
764 if (aFunction.IsNull()) return NULL;
766 //Check if the function is set correctly
767 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
769 GEOMImpl_ISphere aCI (aFunction);
771 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
773 if (aRefPnt.IsNull()) return NULL;
775 aCI.SetPoint(aRefPnt);
778 //Compute the Sphere value
780 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
783 if (!GetSolver()->ComputeFunction(aFunction)) {
784 SetErrorCode("Sphere driver failed");
788 catch (Standard_Failure) {
789 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
790 SetErrorCode(aFail->GetMessageString());
794 //Make a Python command
795 GEOM::TPythonDump(aFunction) << aSphere
796 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
803 //=============================================================================
807 //=============================================================================
808 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
809 (double theRMajor, double theRMinor)
813 //Add a new Torus object
814 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
816 //Add a new Torus function
817 Handle(GEOM_Function) aFunction =
818 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
819 if (aFunction.IsNull()) return NULL;
821 //Check if the function is set correctly
822 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
824 GEOMImpl_ITorus aCI (aFunction);
826 aCI.SetRMajor(theRMajor);
827 aCI.SetRMinor(theRMinor);
829 //Compute the Torus value
831 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
834 if (!GetSolver()->ComputeFunction(aFunction)) {
835 SetErrorCode("Torus driver failed");
839 catch (Standard_Failure) {
840 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
841 SetErrorCode(aFail->GetMessageString());
845 //Make a Python command
846 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
847 << theRMajor << ", " << theRMinor << ")";
853 //=============================================================================
857 //=============================================================================
858 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
859 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
860 double theRMajor, double theRMinor)
864 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
866 //Add a new Torus object
867 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
869 //Add a new Torus function
870 Handle(GEOM_Function) aFunction =
871 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
872 if (aFunction.IsNull()) return NULL;
874 //Check if the function is set correctly
875 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
877 GEOMImpl_ITorus aCI (aFunction);
879 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
880 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
882 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
884 aCI.SetCenter(aRefPnt);
885 aCI.SetVector(aRefVec);
886 aCI.SetRMajor(theRMajor);
887 aCI.SetRMinor(theRMinor);
889 //Compute the Torus value
891 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
894 if (!GetSolver()->ComputeFunction(aFunction)) {
895 SetErrorCode("Torus driver failed");
899 catch (Standard_Failure) {
900 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
901 SetErrorCode(aFail->GetMessageString());
905 //Make a Python command
906 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
907 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
914 //=============================================================================
918 //=============================================================================
919 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
920 Handle(GEOM_Object) theVec,
925 if (theBase.IsNull() || theVec.IsNull()) return NULL;
927 //Add a new Prism object
928 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
930 //Add a new Prism function for creation a Prism relatively to vector
931 Handle(GEOM_Function) aFunction =
932 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
933 if (aFunction.IsNull()) return NULL;
935 //Check if the function is set correctly
936 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
938 GEOMImpl_IPrism aCI (aFunction);
940 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
941 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
943 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
945 aCI.SetBase(aRefBase);
946 aCI.SetVector(aRefVec);
949 //Compute the Prism value
951 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
954 if (!GetSolver()->ComputeFunction(aFunction)) {
955 //SetErrorCode("Prism driver failed");
956 SetErrorCode("Extrusion can not be created, check input data");
960 catch (Standard_Failure) {
961 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
962 SetErrorCode(aFail->GetMessageString());
966 //Make a Python command
967 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
968 << theBase << ", " << theVec << ", " << theH << ")";
974 //=============================================================================
978 //=============================================================================
979 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
980 Handle(GEOM_Object) theVec,
985 if (theBase.IsNull() || theVec.IsNull()) return NULL;
987 //Add a new Prism object
988 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
990 //Add a new Prism function for creation a Prism relatively to vector
991 Handle(GEOM_Function) aFunction =
992 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
993 if (aFunction.IsNull()) return NULL;
995 //Check if the function is set correctly
996 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
998 GEOMImpl_IPrism aCI (aFunction);
1000 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1001 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1003 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1005 aCI.SetBase(aRefBase);
1006 aCI.SetVector(aRefVec);
1009 //Compute the Prism value
1011 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1014 if (!GetSolver()->ComputeFunction(aFunction)) {
1015 //SetErrorCode("Prism driver failed");
1016 SetErrorCode("Extrusion can not be created, check input data");
1020 catch (Standard_Failure) {
1021 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1022 SetErrorCode(aFail->GetMessageString());
1026 //Make a Python command
1027 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1028 << theBase << ", " << theVec << ", " << theH << ")";
1034 //=============================================================================
1038 //=============================================================================
1039 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1040 (Handle(GEOM_Object) theBase,
1041 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1045 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1047 //Add a new Prism object
1048 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1050 //Add a new Prism function for creation a Prism relatively to two points
1051 Handle(GEOM_Function) aFunction =
1052 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1053 if (aFunction.IsNull()) return NULL;
1055 //Check if the function is set correctly
1056 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1058 GEOMImpl_IPrism aCI (aFunction);
1060 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1061 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1062 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1064 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1066 aCI.SetBase(aRefBase);
1067 aCI.SetFirstPoint(aRefPnt1);
1068 aCI.SetLastPoint(aRefPnt2);
1070 //Compute the Prism value
1072 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1075 if (!GetSolver()->ComputeFunction(aFunction)) {
1076 //SetErrorCode("Prism driver failed");
1077 SetErrorCode("Extrusion can not be created, check input data");
1081 catch (Standard_Failure) {
1082 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1083 SetErrorCode(aFail->GetMessageString());
1087 //Make a Python command
1088 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
1089 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1095 //=============================================================================
1097 * MakePrismTwoPnt2Ways
1099 //=============================================================================
1100 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1101 (Handle(GEOM_Object) theBase,
1102 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1106 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1108 //Add a new Prism object
1109 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1111 //Add a new Prism function for creation a Prism relatively to two points
1112 Handle(GEOM_Function) aFunction =
1113 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1114 if (aFunction.IsNull()) return NULL;
1116 //Check if the function is set correctly
1117 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1119 GEOMImpl_IPrism aCI (aFunction);
1121 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1122 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1123 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1125 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1127 aCI.SetBase(aRefBase);
1128 aCI.SetFirstPoint(aRefPnt1);
1129 aCI.SetLastPoint(aRefPnt2);
1131 //Compute the Prism value
1133 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1136 if (!GetSolver()->ComputeFunction(aFunction)) {
1137 //SetErrorCode("Prism driver failed");
1138 SetErrorCode("Extrusion can not be created, check input data");
1142 catch (Standard_Failure) {
1143 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1144 SetErrorCode(aFail->GetMessageString());
1148 //Make a Python command
1149 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1150 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1156 //=============================================================================
1160 //=============================================================================
1161 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1162 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1166 if (theBase.IsNull()) return NULL;
1168 //Add a new Prism object
1169 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1171 //Add a new Prism function for creation a Prism by DXDYDZ
1172 Handle(GEOM_Function) aFunction =
1173 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1174 if (aFunction.IsNull()) return NULL;
1176 //Check if the function is set correctly
1177 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1179 GEOMImpl_IPrism aCI (aFunction);
1181 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1183 if (aRefBase.IsNull()) return NULL;
1185 aCI.SetBase(aRefBase);
1190 //Compute the Prism value
1192 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1195 if (!GetSolver()->ComputeFunction(aFunction)) {
1196 SetErrorCode("Extrusion can not be created, check input data");
1200 catch (Standard_Failure) {
1201 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1202 SetErrorCode(aFail->GetMessageString());
1206 //Make a Python command
1207 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ("
1208 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1214 //=============================================================================
1216 * MakePrismDXDYDZ_2WAYS
1218 //=============================================================================
1219 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1220 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1224 if (theBase.IsNull()) return NULL;
1226 //Add a new Prism object
1227 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1229 //Add a new Prism function for creation a Prism by DXDYDZ
1230 Handle(GEOM_Function) aFunction =
1231 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1232 if (aFunction.IsNull()) return NULL;
1234 //Check if the function is set correctly
1235 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1237 GEOMImpl_IPrism aCI (aFunction);
1239 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1241 if (aRefBase.IsNull()) return NULL;
1243 aCI.SetBase(aRefBase);
1248 //Compute the Prism value
1250 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1253 if (!GetSolver()->ComputeFunction(aFunction)) {
1254 SetErrorCode("Extrusion can not be created, check input data");
1258 catch (Standard_Failure) {
1259 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1260 SetErrorCode(aFail->GetMessageString());
1264 //Make a Python command
1265 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1266 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1272 //=============================================================================
1276 //=============================================================================
1277 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1278 Handle(GEOM_Object) thePath)
1282 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1284 //Add a new Pipe object
1285 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1287 //Add a new Pipe function
1288 Handle(GEOM_Function) aFunction =
1289 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1290 if (aFunction.IsNull()) return NULL;
1292 //Check if the function is set correctly
1293 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1295 GEOMImpl_IPipe aCI (aFunction);
1297 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1298 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1300 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1302 aCI.SetBase(aRefBase);
1303 aCI.SetPath(aRefPath);
1305 //Compute the Pipe value
1307 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1310 if (!GetSolver()->ComputeFunction(aFunction)) {
1311 SetErrorCode("Pipe driver failed");
1315 catch (Standard_Failure) {
1316 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1317 SetErrorCode(aFail->GetMessageString());
1321 //Make a Python command
1322 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1323 << theBase << ", " << thePath << ")";
1330 //=============================================================================
1332 * MakeRevolutionAxisAngle
1334 //=============================================================================
1335 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1336 Handle(GEOM_Object) theAxis,
1341 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1343 //Add a new Revolution object
1344 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1346 //Add a new Revolution function for creation a revolution relatively to axis
1347 Handle(GEOM_Function) aFunction =
1348 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1349 if (aFunction.IsNull()) return NULL;
1351 //Check if the function is set correctly
1352 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1354 GEOMImpl_IRevolution aCI (aFunction);
1356 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1357 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1359 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1361 aCI.SetBase(aRefBase);
1362 aCI.SetAxis(aRefAxis);
1363 aCI.SetAngle(theAngle);
1365 //Compute the Revolution value
1367 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1370 if (!GetSolver()->ComputeFunction(aFunction)) {
1371 SetErrorCode("Revolution driver failed");
1375 catch (Standard_Failure) {
1376 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1377 SetErrorCode(aFail->GetMessageString());
1381 //Make a Python command
1382 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1383 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1389 //=============================================================================
1391 * MakeRevolutionAxisAngle2Ways
1393 //=============================================================================
1394 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1395 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1399 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1401 //Add a new Revolution object
1402 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1404 //Add a new Revolution function for creation a revolution relatively to axis
1405 Handle(GEOM_Function) aFunction =
1406 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1407 if (aFunction.IsNull()) return NULL;
1409 //Check if the function is set correctly
1410 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1412 GEOMImpl_IRevolution aCI (aFunction);
1414 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1415 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1417 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1419 aCI.SetBase(aRefBase);
1420 aCI.SetAxis(aRefAxis);
1421 aCI.SetAngle(theAngle);
1423 //Compute the Revolution value
1425 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1428 if (!GetSolver()->ComputeFunction(aFunction)) {
1429 SetErrorCode("Revolution driver failed");
1433 catch (Standard_Failure) {
1434 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1435 SetErrorCode(aFail->GetMessageString());
1439 //Make a Python command
1440 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1441 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1447 //=============================================================================
1451 //=============================================================================
1452 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
1456 if (theShell.IsNull()) return NULL;
1458 //Add a new Solid object
1459 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
1461 //Add a new Solid function for creation a solid from a shell
1462 Handle(GEOM_Function) aFunction =
1463 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
1464 if (aFunction.IsNull()) return NULL;
1466 //Check if the function is set correctly
1467 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
1469 GEOMImpl_IShapes aCI (aFunction);
1471 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
1473 if (aRefShell.IsNull()) return NULL;
1475 aCI.SetBase(aRefShell);
1477 //Compute the Solid value
1479 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1482 if (!GetSolver()->ComputeFunction(aFunction)) {
1483 SetErrorCode("Solid driver failed");
1487 catch (Standard_Failure) {
1488 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1489 SetErrorCode(aFail->GetMessageString());
1493 //Make a Python command
1494 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
1500 //=============================================================================
1504 //=============================================================================
1505 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1506 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1507 double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1511 if (theShape.IsNull()) return NULL;
1513 //Add a new Filling object
1514 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1516 //Add a new Filling function for creation a filling from a compound
1517 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1518 if (aFunction.IsNull()) return NULL;
1520 //Check if the function is set correctly
1521 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1523 GEOMImpl_IFilling aFI (aFunction);
1525 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1527 if (aRefShape.IsNull()) return NULL;
1529 aFI.SetShape(aRefShape);
1530 aFI.SetMinDeg(theMinDeg);
1531 aFI.SetMaxDeg(theMaxDeg);
1532 aFI.SetTol2D(theTol2D);
1533 aFI.SetTol3D(theTol3D);
1534 aFI.SetNbIter(theNbIter);
1535 aFI.SetApprox(isApprox);
1537 //Compute the Solid value
1539 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1542 if (!GetSolver()->ComputeFunction(aFunction)) {
1543 SetErrorCode("Filling driver failed");
1547 catch (Standard_Failure) {
1548 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1549 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1550 SetErrorCode("B-Spline surface construction failed");
1552 SetErrorCode(aFail->GetMessageString());
1556 //Make a Python command
1557 GEOM::TPythonDump pd (aFunction);
1558 pd << aFilling << " = geompy.MakeFilling("
1559 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1560 << theTol2D << ", " << theTol3D << ", " << theNbIter;
1562 pd << ", " << isApprox;
1569 //=============================================================================
1573 //=============================================================================
1574 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1575 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1580 Handle(GEOM_Object) anObj;
1582 if(theSeqSections.IsNull())
1585 Standard_Integer nbObj = theSeqSections->Length();
1589 //Add a new ThruSections object
1590 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1593 //Add a new ThruSections function
1595 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1596 Handle(GEOM_Function) aFunction =
1597 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1598 if (aFunction.IsNull()) return anObj;
1600 //Check if the function is set correctly
1601 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1603 GEOMImpl_IThruSections aCI (aFunction);
1605 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1607 Standard_Integer i =1;
1608 for( ; i <= nbObj; i++) {
1610 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1614 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1615 if(!aSectObj.IsNull())
1617 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1618 if(!aRefSect.IsNull())
1619 aSeqSections->Append(aRefSect);
1623 if(!aSeqSections->Length())
1626 aCI.SetSections(aSeqSections);
1627 aCI.SetSolidMode(theModeSolid);
1628 aCI.SetPrecision(thePreci);
1630 //Compute the ThruSections value
1632 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1635 if (!GetSolver()->ComputeFunction(aFunction)) {
1636 SetErrorCode("ThruSections driver failed");
1640 catch (Standard_Failure) {
1641 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1642 SetErrorCode(aFail->GetMessageString());
1646 //Make a Python command
1647 GEOM::TPythonDump pyDump(aFunction);
1648 pyDump << aThruSect << " = geompy.MakeThruSections([";
1650 for(i =1 ; i <= nbObj; i++) {
1652 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1656 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1657 if(!aSectObj.IsNull()) {
1664 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1673 //=============================================================================
1675 * MakePipeWithDifferentSections
1677 //=============================================================================
1678 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1679 const Handle(TColStd_HSequenceOfTransient)& theBases,
1680 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1681 const Handle(GEOM_Object)& thePath,
1682 bool theWithContact,
1683 bool theWithCorrections)
1685 Handle(GEOM_Object) anObj;
1687 if(theBases.IsNull())
1690 Standard_Integer nbBases = theBases->Length();
1695 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1696 //Add a new Pipe object
1697 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1699 //Add a new Pipe function
1701 Handle(GEOM_Function) aFunction =
1702 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1703 if (aFunction.IsNull()) return anObj;
1705 //Check if the function is set correctly
1706 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1708 GEOMImpl_IPipeDiffSect aCI (aFunction);
1710 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1711 if(aRefPath.IsNull())
1714 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1715 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1717 Standard_Integer i =1;
1718 for( ; i <= nbBases; i++) {
1720 Handle(Standard_Transient) anItem = theBases->Value(i);
1724 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1727 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1728 if(aRefBase.IsNull())
1732 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1733 if(anItemLoc.IsNull())
1736 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1739 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1740 if(aRefLoc.IsNull())
1742 aSeqLocs->Append(aRefLoc);
1744 aSeqBases->Append(aRefBase);
1747 if(!aSeqBases->Length())
1750 aCI.SetBases(aSeqBases);
1751 aCI.SetLocations(aSeqLocs);
1752 aCI.SetPath(aRefPath);
1753 aCI.SetWithContactMode(theWithContact);
1754 aCI.SetWithCorrectionMode(theWithCorrections);
1756 //Compute the Pipe value
1758 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1761 if (!GetSolver()->ComputeFunction(aFunction)) {
1762 SetErrorCode("Pipe with defferent section driver failed");
1766 catch (Standard_Failure) {
1767 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1768 SetErrorCode(aFail->GetMessageString());
1772 //Make a Python command
1773 GEOM::TPythonDump pyDump(aFunction);
1774 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1776 for(i =1 ; i <= nbBases; i++) {
1778 Handle(Standard_Transient) anItem = theBases->Value(i);
1782 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1783 if(!anObj.IsNull()) {
1793 for(i =1 ; i <= nbLocs; i++) {
1795 Handle(Standard_Transient) anItem = theLocations->Value(i);
1799 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1800 if(!anObj.IsNull()) {
1807 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1816 //=============================================================================
1818 * MakePipeWithShellSections
1820 //=============================================================================
1821 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1822 const Handle(TColStd_HSequenceOfTransient)& theBases,
1823 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1824 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1825 const Handle(GEOM_Object)& thePath,
1826 bool theWithContact,
1827 bool theWithCorrections)
1829 Handle(GEOM_Object) anObj;
1831 if(theBases.IsNull())
1834 Standard_Integer nbBases = theBases->Length();
1839 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1841 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1843 //Add a new Pipe object
1844 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1846 //Add a new Pipe function
1848 Handle(GEOM_Function) aFunction =
1849 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1850 if (aFunction.IsNull()) return anObj;
1852 //Check if the function is set correctly
1853 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1855 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1856 GEOMImpl_IPipeShellSect aCI (aFunction);
1858 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1859 if(aRefPath.IsNull())
1862 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1863 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1864 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1866 Standard_Integer i =1;
1867 for( ; i <= nbBases; i++) {
1869 Handle(Standard_Transient) anItem = theBases->Value(i);
1872 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1875 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1876 if(aRefBase.IsNull())
1879 if( nbSubBases >= nbBases ) {
1880 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1881 if(aSubItem.IsNull())
1883 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1884 if(aSubBase.IsNull())
1886 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1887 if(aRefSubBase.IsNull())
1889 aSeqSubBases->Append(aRefSubBase);
1893 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1894 if(anItemLoc.IsNull())
1896 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1899 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1900 if(aRefLoc.IsNull())
1902 aSeqLocs->Append(aRefLoc);
1905 aSeqBases->Append(aRefBase);
1908 if(!aSeqBases->Length())
1911 aCI.SetBases(aSeqBases);
1912 aCI.SetSubBases(aSeqSubBases);
1913 aCI.SetLocations(aSeqLocs);
1914 aCI.SetPath(aRefPath);
1915 aCI.SetWithContactMode(theWithContact);
1916 aCI.SetWithCorrectionMode(theWithCorrections);
1918 //Compute the Pipe value
1920 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1923 if (!GetSolver()->ComputeFunction(aFunction)) {
1924 SetErrorCode("Pipe with shell sections driver failed");
1928 catch (Standard_Failure) {
1929 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1930 SetErrorCode(aFail->GetMessageString());
1934 //Make a Python command
1935 GEOM::TPythonDump pyDump(aFunction);
1936 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1938 for(i =1 ; i <= nbBases; i++) {
1940 Handle(Standard_Transient) anItem = theBases->Value(i);
1944 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1945 if(!anObj.IsNull()) {
1955 for(i =1 ; i <= nbSubBases; i++) {
1957 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1961 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1962 if(!anObj.IsNull()) {
1972 for(i =1 ; i <= nbLocs; i++) {
1974 Handle(Standard_Transient) anItem = theLocations->Value(i);
1978 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1979 if(!anObj.IsNull()) {
1986 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1994 //=============================================================================
1996 * MakePipeShellsWithoutPath
1998 //=============================================================================
1999 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2000 const Handle(TColStd_HSequenceOfTransient)& theBases,
2001 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2003 Handle(GEOM_Object) anObj;
2005 if(theBases.IsNull())
2008 Standard_Integer nbBases = theBases->Length();
2013 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2015 //Add a new Pipe object
2016 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2018 //Add a new Pipe function
2020 Handle(GEOM_Function) aFunction =
2021 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2022 if (aFunction.IsNull()) return anObj;
2024 //Check if the function is set correctly
2025 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2027 GEOMImpl_IPipeShellSect aCI (aFunction);
2029 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2030 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2032 Standard_Integer i =1;
2033 for( ; i <= nbBases; i++) {
2035 Handle(Standard_Transient) anItem = theBases->Value(i);
2038 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2041 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2042 if(aRefBase.IsNull())
2046 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2047 if(anItemLoc.IsNull())
2049 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2052 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2053 if(aRefLoc.IsNull())
2055 aSeqLocs->Append(aRefLoc);
2058 aSeqBases->Append(aRefBase);
2061 if(!aSeqBases->Length())
2064 aCI.SetBases(aSeqBases);
2065 aCI.SetLocations(aSeqLocs);
2067 //Compute the Pipe value
2069 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2072 if (!GetSolver()->ComputeFunction(aFunction)) {
2073 SetErrorCode("Pipe with shell sections without path driver failed");
2077 catch (Standard_Failure) {
2078 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2079 SetErrorCode(aFail->GetMessageString());
2083 //Make a Python command
2084 GEOM::TPythonDump pyDump(aFunction);
2085 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2087 for(i =1 ; i <= nbBases; i++) {
2089 Handle(Standard_Transient) anItem = theBases->Value(i);
2093 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2094 if(!anObj.IsNull()) {
2104 for(i =1 ; i <= nbLocs; i++) {
2106 Handle(Standard_Transient) anItem = theLocations->Value(i);
2110 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2111 if(!anObj.IsNull()) {