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
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_I3DPrimOperations.hxx>
27 #include "utilities.h"
29 #include <Utils_ExceptHandlers.hxx>
31 #include <TFunction_DriverTable.hxx>
32 #include <TFunction_Driver.hxx>
33 #include <TFunction_Logbook.hxx>
34 #include <TDF_Tool.hxx>
36 #include <GEOM_Function.hxx>
37 #include <GEOM_PythonDump.hxx>
39 #include <GEOMImpl_Types.hxx>
41 #include <GEOMImpl_BoxDriver.hxx>
42 #include <GEOMImpl_FaceDriver.hxx>
43 #include <GEOMImpl_DiskDriver.hxx>
44 #include <GEOMImpl_CylinderDriver.hxx>
45 #include <GEOMImpl_ConeDriver.hxx>
46 #include <GEOMImpl_SphereDriver.hxx>
47 #include <GEOMImpl_TorusDriver.hxx>
48 #include <GEOMImpl_PrismDriver.hxx>
49 #include <GEOMImpl_PipeDriver.hxx>
50 #include <GEOMImpl_RevolutionDriver.hxx>
51 #include <GEOMImpl_ShapeDriver.hxx>
52 #include <GEOMImpl_FillingDriver.hxx>
53 #include <GEOMImpl_ThruSectionsDriver.hxx>
55 #include <GEOMImpl_IBox.hxx>
56 #include <GEOMImpl_IFace.hxx>
57 #include <GEOMImpl_IDisk.hxx>
58 #include <GEOMImpl_ICylinder.hxx>
59 #include <GEOMImpl_ICone.hxx>
60 #include <GEOMImpl_ISphere.hxx>
61 #include <GEOMImpl_ITorus.hxx>
62 #include <GEOMImpl_IPrism.hxx>
63 #include <GEOMImpl_IPipe.hxx>
64 #include <GEOMImpl_IRevolution.hxx>
65 #include <GEOMImpl_IFilling.hxx>
66 #include <GEOMImpl_IThruSections.hxx>
67 #include <GEOMImpl_IPipeDiffSect.hxx>
68 #include <GEOMImpl_IPipeShellSect.hxx>
69 #include <GEOMImpl_IPipeBiNormal.hxx>
71 #include <Precision.hxx>
73 #include <Standard_Failure.hxx>
74 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
76 //=============================================================================
80 //=============================================================================
81 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
82 : GEOM_IOperations(theEngine, theDocID)
84 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
87 //=============================================================================
91 //=============================================================================
92 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
94 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
98 //=============================================================================
102 //=============================================================================
103 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
107 //Add a new Box object
108 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
110 //Add a new Box function with DX_DY_DZ parameters
111 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
112 if (aFunction.IsNull()) return NULL;
114 //Check if the function is set correctly
115 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
117 GEOMImpl_IBox aBI (aFunction);
123 //Compute the box value
125 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
128 if (!GetSolver()->ComputeFunction(aFunction)) {
129 SetErrorCode("Box driver failed");
133 catch (Standard_Failure) {
134 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
135 SetErrorCode(aFail->GetMessageString());
139 //Make a Python command
140 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
141 << theDX << ", " << theDY << ", " << theDZ << ")";
148 //=============================================================================
152 //=============================================================================
153 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
154 Handle(GEOM_Object) thePnt2)
158 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
160 //Add a new Box object
161 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
163 //Add a new Box function for creation a box relatively to two points
164 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
165 if (aFunction.IsNull()) return NULL;
167 //Check if the function is set correctly
168 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
170 GEOMImpl_IBox aBI (aFunction);
172 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
173 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
175 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
177 aBI.SetRef1(aRefFunction1);
178 aBI.SetRef2(aRefFunction2);
180 //Compute the Box value
182 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
185 if (!GetSolver()->ComputeFunction(aFunction)) {
186 SetErrorCode("Box driver failed");
190 catch (Standard_Failure) {
191 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
192 SetErrorCode(aFail->GetMessageString());
196 //Make a Python command
197 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
198 << thePnt1 << ", " << thePnt2 << ")";
204 //=============================================================================
208 //=============================================================================
209 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
213 if (theH == 0 || theW == 0) return NULL;
215 //Add a new Face object
216 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
218 //Add a new Box function for creation a box relatively to two points
219 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
220 if (aFunction.IsNull()) return NULL;
222 //Check if the function is set correctly
223 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
225 GEOMImpl_IFace aFI (aFunction);
229 aFI.SetOrientation(theOrientation);
233 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
236 if (!GetSolver()->ComputeFunction(aFunction)) {
237 SetErrorCode("Face driver failed");
241 catch (Standard_Failure) {
242 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
243 SetErrorCode(aFail->GetMessageString());
247 //Make a Python command
248 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
249 << theH << ", " << theW << ", " << theOrientation << ")";
255 //=============================================================================
259 //=============================================================================
260 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
261 double theH, double theW)
265 if (theObj.IsNull()) return NULL;
267 //Add a new Face object
268 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
270 //Add a new Box function for creation a box relatively to two points
271 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
272 if (aFunction.IsNull()) return NULL;
274 //Check if the function is set correctly
275 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
277 GEOMImpl_IFace aFI (aFunction);
279 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
281 if (aRefFunction1.IsNull())
284 aFI.SetRef1(aRefFunction1);
290 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
293 if (!GetSolver()->ComputeFunction(aFunction)) {
294 SetErrorCode("Face driver failed");
298 catch (Standard_Failure) {
299 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
300 SetErrorCode(aFail->GetMessageString());
304 //Make a Python command
305 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
306 << theObj << ", " << theH << ", " << theW << ")";
312 //=============================================================================
316 //=============================================================================
317 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
318 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
322 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
324 //Add a new Disk object
325 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
327 //Add a new Disk function for creation a disk relatively to point and vector
328 Handle(GEOM_Function) aFunction =
329 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
330 if (aFunction.IsNull()) return NULL;
332 //Check if the function is set correctly
333 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
335 GEOMImpl_IDisk aCI (aFunction);
337 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
338 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
340 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
342 aCI.SetCenter(aRefPnt);
343 aCI.SetVector(aRefVec);
346 //Compute the Disk value
348 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
351 if (!GetSolver()->ComputeFunction(aFunction)) {
352 SetErrorCode("Disk driver failed");
356 catch (Standard_Failure) {
357 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
358 SetErrorCode(aFail->GetMessageString());
362 //Make a Python command
363 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
364 << thePnt << ", " << theVec << ", " << theR << ")";
370 //=============================================================================
374 //=============================================================================
375 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
376 Handle(GEOM_Object) thePnt2,
377 Handle(GEOM_Object) thePnt3)
381 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
383 //Add a new Disk object
384 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
386 //Add a new Disk function for creation a disk relatively to three points
387 Handle(GEOM_Function) aFunction =
388 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
389 if (aFunction.IsNull()) return NULL;
391 //Check if the function is set correctly
392 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
394 GEOMImpl_IDisk aCI (aFunction);
396 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
397 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
398 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
400 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
402 aCI.SetPoint1(aRefPnt1);
403 aCI.SetPoint2(aRefPnt2);
404 aCI.SetPoint3(aRefPnt3);
406 //Compute the Disk value
408 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
411 if (!GetSolver()->ComputeFunction(aFunction)) {
412 SetErrorCode("Disk driver failed");
416 catch (Standard_Failure) {
417 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
418 SetErrorCode(aFail->GetMessageString());
422 //Make a Python command
423 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
424 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
430 //=============================================================================
434 //=============================================================================
435 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
439 if (theR == 0 ) return NULL;
441 //Add a new Disk object
442 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
444 //Add a new Box function for creation a box relatively to two points
445 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
446 if (aFunction.IsNull()) return NULL;
448 //Check if the function is set correctly
449 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
451 GEOMImpl_IDisk aDI (aFunction);
454 aDI.SetOrientation(theOrientation);
458 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
461 if (!GetSolver()->ComputeFunction(aFunction)) {
462 SetErrorCode("Disk driver failed");
466 catch (Standard_Failure) {
467 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
468 SetErrorCode(aFail->GetMessageString());
472 //Make a Python command
473 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
474 << theR << ", " << theOrientation << ")";
480 //=============================================================================
484 //=============================================================================
485 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
489 //Add a new Cylinder object
490 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
492 //Add a new Cylinder function with R and H parameters
493 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
494 if (aFunction.IsNull()) return NULL;
496 //Check if the function is set correctly
497 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
499 GEOMImpl_ICylinder aCI (aFunction);
504 //Compute the Cylinder value
506 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
509 if (!GetSolver()->ComputeFunction(aFunction)) {
510 SetErrorCode("Cylinder driver failed");
514 catch (Standard_Failure) {
515 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
516 SetErrorCode(aFail->GetMessageString());
520 //Make a Python command
521 GEOM::TPythonDump(aFunction) << aCylinder
522 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
529 //=============================================================================
531 * MakeCylinderPntVecRH
533 //=============================================================================
534 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
535 Handle(GEOM_Object) theVec,
536 double theR, double theH)
540 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
542 //Add a new Cylinder object
543 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
545 //Add a new Cylinder function for creation a cylinder relatively to point and vector
546 Handle(GEOM_Function) aFunction =
547 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
548 if (aFunction.IsNull()) return NULL;
550 //Check if the function is set correctly
551 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
553 GEOMImpl_ICylinder aCI (aFunction);
555 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
556 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
558 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
560 aCI.SetPoint(aRefPnt);
561 aCI.SetVector(aRefVec);
565 //Compute the Cylinder value
567 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
570 if (!GetSolver()->ComputeFunction(aFunction)) {
571 SetErrorCode("Cylinder driver failed");
575 catch (Standard_Failure) {
576 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
577 SetErrorCode(aFail->GetMessageString());
581 //Make a Python command
582 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
583 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
590 //=============================================================================
594 //=============================================================================
595 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
600 //Add a new Cone object
601 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
603 //Add a new Cone function with R and H parameters
604 Handle(GEOM_Function) aFunction =
605 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
606 if (aFunction.IsNull()) return NULL;
608 //Check if the function is set correctly
609 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
611 GEOMImpl_ICone aCI (aFunction);
617 //Compute the Cone value
619 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
622 if (!GetSolver()->ComputeFunction(aFunction)) {
623 SetErrorCode("Cone driver failed");
627 catch (Standard_Failure) {
628 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
629 SetErrorCode(aFail->GetMessageString());
633 //Make a Python command
634 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
635 << theR1 << ", " << theR2 << ", " << theH << ")";
642 //=============================================================================
644 * MakeConePntVecR1R2H
646 //=============================================================================
647 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
648 Handle(GEOM_Object) theVec,
649 double theR1, double theR2,
654 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
656 //Add a new Cone object
657 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
659 //Add a new Cone function for creation a cone relatively to point and vector
660 Handle(GEOM_Function) aFunction =
661 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
662 if (aFunction.IsNull()) return NULL;
664 //Check if the function is set correctly
665 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
667 GEOMImpl_ICone aCI (aFunction);
669 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
670 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
672 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
674 aCI.SetPoint(aRefPnt);
675 aCI.SetVector(aRefVec);
680 //Compute the Cone value
682 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
685 if (!GetSolver()->ComputeFunction(aFunction)) {
686 SetErrorCode("Cone driver failed");
690 catch (Standard_Failure) {
691 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
692 SetErrorCode(aFail->GetMessageString());
696 //Make a Python command
697 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
698 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
705 //=============================================================================
709 //=============================================================================
710 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
714 //Add a new Sphere object
715 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
717 //Add a new Sphere function with R parameter
718 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
719 if (aFunction.IsNull()) return NULL;
721 //Check if the function is set correctly
722 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
724 GEOMImpl_ISphere aCI (aFunction);
728 //Compute the Sphere value
730 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
733 if (!GetSolver()->ComputeFunction(aFunction)) {
734 SetErrorCode("Sphere driver failed");
738 catch (Standard_Failure) {
739 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
740 SetErrorCode(aFail->GetMessageString());
744 //Make a Python command
745 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
752 //=============================================================================
756 //=============================================================================
757 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
762 if (thePnt.IsNull()) return NULL;
764 //Add a new Point object
765 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
767 //Add a new Sphere function for creation a sphere relatively to point
768 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
769 if (aFunction.IsNull()) return NULL;
771 //Check if the function is set correctly
772 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
774 GEOMImpl_ISphere aCI (aFunction);
776 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
778 if (aRefPnt.IsNull()) return NULL;
780 aCI.SetPoint(aRefPnt);
783 //Compute the Sphere value
785 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
788 if (!GetSolver()->ComputeFunction(aFunction)) {
789 SetErrorCode("Sphere driver failed");
793 catch (Standard_Failure) {
794 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
795 SetErrorCode(aFail->GetMessageString());
799 //Make a Python command
800 GEOM::TPythonDump(aFunction) << aSphere
801 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
808 //=============================================================================
812 //=============================================================================
813 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
814 (double theRMajor, double theRMinor)
818 //Add a new Torus object
819 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
821 //Add a new Torus function
822 Handle(GEOM_Function) aFunction =
823 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
824 if (aFunction.IsNull()) return NULL;
826 //Check if the function is set correctly
827 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
829 GEOMImpl_ITorus aCI (aFunction);
831 aCI.SetRMajor(theRMajor);
832 aCI.SetRMinor(theRMinor);
834 //Compute the Torus value
836 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
839 if (!GetSolver()->ComputeFunction(aFunction)) {
840 SetErrorCode("Torus driver failed");
844 catch (Standard_Failure) {
845 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
846 SetErrorCode(aFail->GetMessageString());
850 //Make a Python command
851 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
852 << theRMajor << ", " << theRMinor << ")";
858 //=============================================================================
862 //=============================================================================
863 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
864 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
865 double theRMajor, double theRMinor)
869 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
871 //Add a new Torus object
872 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
874 //Add a new Torus function
875 Handle(GEOM_Function) aFunction =
876 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
877 if (aFunction.IsNull()) return NULL;
879 //Check if the function is set correctly
880 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
882 GEOMImpl_ITorus aCI (aFunction);
884 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
885 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
887 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
889 aCI.SetCenter(aRefPnt);
890 aCI.SetVector(aRefVec);
891 aCI.SetRMajor(theRMajor);
892 aCI.SetRMinor(theRMinor);
894 //Compute the Torus value
896 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
899 if (!GetSolver()->ComputeFunction(aFunction)) {
900 SetErrorCode("Torus driver failed");
904 catch (Standard_Failure) {
905 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
906 SetErrorCode(aFail->GetMessageString());
910 //Make a Python command
911 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
912 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
919 //=============================================================================
923 //=============================================================================
924 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
925 Handle(GEOM_Object) theVec,
926 double theH, double theScaleFactor)
930 if (theBase.IsNull() || theVec.IsNull()) return NULL;
932 //Add a new Prism object
933 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
935 //Add a new Prism function for creation a Prism relatively to vector
936 Handle(GEOM_Function) aFunction =
937 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
938 if (aFunction.IsNull()) return NULL;
940 //Check if the function is set correctly
941 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
943 GEOMImpl_IPrism aCI (aFunction);
945 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
946 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
948 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
950 aCI.SetBase(aRefBase);
951 aCI.SetVector(aRefVec);
953 aCI.SetScale(theScaleFactor);
955 //Compute the Prism value
957 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
960 if (!GetSolver()->ComputeFunction(aFunction)) {
961 //SetErrorCode("Prism driver failed");
962 SetErrorCode("Extrusion can not be created, check input data");
966 catch (Standard_Failure) {
967 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
968 SetErrorCode(aFail->GetMessageString());
972 //Make a Python command
973 GEOM::TPythonDump pd (aFunction);
974 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
975 if (theScaleFactor > Precision::Confusion())
976 pd << ", " << theScaleFactor << ")";
984 //=============================================================================
988 //=============================================================================
989 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
990 Handle(GEOM_Object) theVec,
995 if (theBase.IsNull() || theVec.IsNull()) return NULL;
997 //Add a new Prism object
998 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1000 //Add a new Prism function for creation a Prism relatively to vector
1001 Handle(GEOM_Function) aFunction =
1002 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1003 if (aFunction.IsNull()) return NULL;
1005 //Check if the function is set correctly
1006 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1008 GEOMImpl_IPrism aCI (aFunction);
1010 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1011 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1013 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1015 aCI.SetBase(aRefBase);
1016 aCI.SetVector(aRefVec);
1019 //Compute the Prism value
1021 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1024 if (!GetSolver()->ComputeFunction(aFunction)) {
1025 //SetErrorCode("Prism driver failed");
1026 SetErrorCode("Extrusion can not be created, check input data");
1030 catch (Standard_Failure) {
1031 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1032 SetErrorCode(aFail->GetMessageString());
1036 //Make a Python command
1037 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1038 << theBase << ", " << theVec << ", " << theH << ")";
1044 //=============================================================================
1048 //=============================================================================
1049 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1050 (Handle(GEOM_Object) theBase,
1051 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1052 double theScaleFactor)
1056 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1058 //Add a new Prism object
1059 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1061 //Add a new Prism function for creation a Prism relatively to two points
1062 Handle(GEOM_Function) aFunction =
1063 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1064 if (aFunction.IsNull()) return NULL;
1066 //Check if the function is set correctly
1067 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1069 GEOMImpl_IPrism aCI (aFunction);
1071 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1072 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1073 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1075 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1077 aCI.SetBase(aRefBase);
1078 aCI.SetFirstPoint(aRefPnt1);
1079 aCI.SetLastPoint(aRefPnt2);
1080 aCI.SetScale(theScaleFactor);
1082 //Compute the Prism value
1084 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1087 if (!GetSolver()->ComputeFunction(aFunction)) {
1088 //SetErrorCode("Prism driver failed");
1089 SetErrorCode("Extrusion can not be created, check input data");
1093 catch (Standard_Failure) {
1094 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1095 SetErrorCode(aFail->GetMessageString());
1099 //Make a Python command
1100 GEOM::TPythonDump pd (aFunction);
1101 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1102 if (theScaleFactor > Precision::Confusion())
1103 pd << ", " << theScaleFactor << ")";
1111 //=============================================================================
1113 * MakePrismTwoPnt2Ways
1115 //=============================================================================
1116 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1117 (Handle(GEOM_Object) theBase,
1118 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1122 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1124 //Add a new Prism object
1125 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1127 //Add a new Prism function for creation a Prism relatively to two points
1128 Handle(GEOM_Function) aFunction =
1129 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1130 if (aFunction.IsNull()) return NULL;
1132 //Check if the function is set correctly
1133 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1135 GEOMImpl_IPrism aCI (aFunction);
1137 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1138 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1139 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1141 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1143 aCI.SetBase(aRefBase);
1144 aCI.SetFirstPoint(aRefPnt1);
1145 aCI.SetLastPoint(aRefPnt2);
1147 //Compute the Prism value
1149 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1152 if (!GetSolver()->ComputeFunction(aFunction)) {
1153 //SetErrorCode("Prism driver failed");
1154 SetErrorCode("Extrusion can not be created, check input data");
1158 catch (Standard_Failure) {
1159 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1160 SetErrorCode(aFail->GetMessageString());
1164 //Make a Python command
1165 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1166 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1172 //=============================================================================
1176 //=============================================================================
1177 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1178 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1179 double theScaleFactor)
1183 if (theBase.IsNull()) return NULL;
1185 //Add a new Prism object
1186 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1188 //Add a new Prism function for creation a Prism by DXDYDZ
1189 Handle(GEOM_Function) aFunction =
1190 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1191 if (aFunction.IsNull()) return NULL;
1193 //Check if the function is set correctly
1194 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1196 GEOMImpl_IPrism aCI (aFunction);
1198 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1200 if (aRefBase.IsNull()) return NULL;
1202 aCI.SetBase(aRefBase);
1206 aCI.SetScale(theScaleFactor);
1208 //Compute the Prism value
1210 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1213 if (!GetSolver()->ComputeFunction(aFunction)) {
1214 SetErrorCode("Extrusion can not be created, check input data");
1218 catch (Standard_Failure) {
1219 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1220 SetErrorCode(aFail->GetMessageString());
1224 //Make a Python command
1225 GEOM::TPythonDump pd (aFunction);
1226 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1227 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1228 if (theScaleFactor > Precision::Confusion())
1229 pd << ", " << theScaleFactor << ")";
1237 //=============================================================================
1239 * MakePrismDXDYDZ_2WAYS
1241 //=============================================================================
1242 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1243 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1247 if (theBase.IsNull()) return NULL;
1249 //Add a new Prism object
1250 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1252 //Add a new Prism function for creation a Prism by DXDYDZ
1253 Handle(GEOM_Function) aFunction =
1254 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1255 if (aFunction.IsNull()) return NULL;
1257 //Check if the function is set correctly
1258 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1260 GEOMImpl_IPrism aCI (aFunction);
1262 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1264 if (aRefBase.IsNull()) return NULL;
1266 aCI.SetBase(aRefBase);
1271 //Compute the Prism value
1273 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1276 if (!GetSolver()->ComputeFunction(aFunction)) {
1277 SetErrorCode("Extrusion can not be created, check input data");
1281 catch (Standard_Failure) {
1282 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1283 SetErrorCode(aFail->GetMessageString());
1287 //Make a Python command
1288 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1289 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1295 //=============================================================================
1299 //=============================================================================
1300 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1301 Handle(GEOM_Object) thePath)
1305 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1307 //Add a new Pipe object
1308 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1310 //Add a new Pipe function
1311 Handle(GEOM_Function) aFunction =
1312 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1313 if (aFunction.IsNull()) return NULL;
1315 //Check if the function is set correctly
1316 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1318 GEOMImpl_IPipe aCI (aFunction);
1320 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1321 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1323 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1325 aCI.SetBase(aRefBase);
1326 aCI.SetPath(aRefPath);
1328 //Compute the Pipe value
1330 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1333 if (!GetSolver()->ComputeFunction(aFunction)) {
1334 SetErrorCode("Pipe driver failed");
1338 catch (Standard_Failure) {
1339 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1340 SetErrorCode(aFail->GetMessageString());
1344 //Make a Python command
1345 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1346 << theBase << ", " << thePath << ")";
1353 //=============================================================================
1355 * MakeRevolutionAxisAngle
1357 //=============================================================================
1358 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1359 Handle(GEOM_Object) theAxis,
1364 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1366 //Add a new Revolution object
1367 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1369 //Add a new Revolution function for creation a revolution relatively to axis
1370 Handle(GEOM_Function) aFunction =
1371 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1372 if (aFunction.IsNull()) return NULL;
1374 //Check if the function is set correctly
1375 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1377 GEOMImpl_IRevolution aCI (aFunction);
1379 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1380 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1382 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1384 aCI.SetBase(aRefBase);
1385 aCI.SetAxis(aRefAxis);
1386 aCI.SetAngle(theAngle);
1388 //Compute the Revolution value
1390 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1393 if (!GetSolver()->ComputeFunction(aFunction)) {
1394 SetErrorCode("Revolution driver failed");
1398 catch (Standard_Failure) {
1399 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1400 SetErrorCode(aFail->GetMessageString());
1404 //Make a Python command
1405 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1406 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1412 //=============================================================================
1414 * MakeRevolutionAxisAngle2Ways
1416 //=============================================================================
1417 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1418 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1422 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1424 //Add a new Revolution object
1425 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1427 //Add a new Revolution function for creation a revolution relatively to axis
1428 Handle(GEOM_Function) aFunction =
1429 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1430 if (aFunction.IsNull()) return NULL;
1432 //Check if the function is set correctly
1433 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1435 GEOMImpl_IRevolution aCI (aFunction);
1437 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1438 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1440 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1442 aCI.SetBase(aRefBase);
1443 aCI.SetAxis(aRefAxis);
1444 aCI.SetAngle(theAngle);
1446 //Compute the Revolution value
1448 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1451 if (!GetSolver()->ComputeFunction(aFunction)) {
1452 SetErrorCode("Revolution driver failed");
1456 catch (Standard_Failure) {
1457 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1458 SetErrorCode(aFail->GetMessageString());
1462 //Make a Python command
1463 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1464 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1470 //=============================================================================
1474 //=============================================================================
1475 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1476 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1477 double theTol2D, double theTol3D, int theNbIter,
1478 int theMethod, bool isApprox)
1482 if (theShape.IsNull()) return NULL;
1484 //Add a new Filling object
1485 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1487 //Add a new Filling function for creation a filling from a compound
1488 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1489 if (aFunction.IsNull()) return NULL;
1491 //Check if the function is set correctly
1492 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1494 GEOMImpl_IFilling aFI (aFunction);
1496 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1498 if (aRefShape.IsNull()) return NULL;
1500 aFI.SetShape(aRefShape);
1501 aFI.SetMinDeg(theMinDeg);
1502 aFI.SetMaxDeg(theMaxDeg);
1503 aFI.SetTol2D(theTol2D);
1504 aFI.SetTol3D(theTol3D);
1505 aFI.SetNbIter(theNbIter);
1506 aFI.SetApprox(isApprox);
1507 aFI.SetMethod(theMethod);
1509 //Compute the Solid value
1511 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1514 if (!GetSolver()->ComputeFunction(aFunction)) {
1515 SetErrorCode("Filling driver failed");
1519 catch (Standard_Failure) {
1520 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1521 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1522 SetErrorCode("B-Spline surface construction failed");
1524 SetErrorCode(aFail->GetMessageString());
1528 //Make a Python command
1529 GEOM::TPythonDump pd (aFunction);
1530 pd << aFilling << " = geompy.MakeFilling("
1531 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1532 << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
1533 if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
1534 else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
1535 else pd << "GEOM.FOM_Default";
1537 pd << ", " << isApprox ;
1544 //=============================================================================
1548 //=============================================================================
1549 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1550 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1555 Handle(GEOM_Object) anObj;
1557 if(theSeqSections.IsNull())
1560 Standard_Integer nbObj = theSeqSections->Length();
1564 //Add a new ThruSections object
1565 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1568 //Add a new ThruSections function
1570 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1571 Handle(GEOM_Function) aFunction =
1572 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1573 if (aFunction.IsNull()) return anObj;
1575 //Check if the function is set correctly
1576 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1578 GEOMImpl_IThruSections aCI (aFunction);
1580 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1582 Standard_Integer i =1;
1583 for( ; i <= nbObj; i++) {
1585 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1589 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1590 if(!aSectObj.IsNull())
1592 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1593 if(!aRefSect.IsNull())
1594 aSeqSections->Append(aRefSect);
1598 if(!aSeqSections->Length())
1601 aCI.SetSections(aSeqSections);
1602 aCI.SetSolidMode(theModeSolid);
1603 aCI.SetPrecision(thePreci);
1605 //Compute the ThruSections value
1607 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1610 if (!GetSolver()->ComputeFunction(aFunction)) {
1611 SetErrorCode("ThruSections driver failed");
1615 catch (Standard_Failure) {
1616 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1617 SetErrorCode(aFail->GetMessageString());
1621 //Make a Python command
1622 GEOM::TPythonDump pyDump(aFunction);
1623 pyDump << aThruSect << " = geompy.MakeThruSections([";
1625 for(i =1 ; i <= nbObj; i++) {
1627 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1631 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1632 if(!aSectObj.IsNull()) {
1639 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1646 //=============================================================================
1648 * MakePipeWithDifferentSections
1650 //=============================================================================
1651 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1652 const Handle(TColStd_HSequenceOfTransient)& theBases,
1653 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1654 const Handle(GEOM_Object)& thePath,
1655 bool theWithContact,
1656 bool theWithCorrections)
1658 Handle(GEOM_Object) anObj;
1660 if(theBases.IsNull())
1663 Standard_Integer nbBases = theBases->Length();
1668 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1669 //Add a new Pipe object
1670 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1672 //Add a new Pipe function
1674 Handle(GEOM_Function) aFunction =
1675 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1676 if (aFunction.IsNull()) return anObj;
1678 //Check if the function is set correctly
1679 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1681 GEOMImpl_IPipeDiffSect aCI (aFunction);
1683 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1684 if(aRefPath.IsNull())
1687 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1688 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1690 Standard_Integer i =1;
1691 for( ; i <= nbBases; i++) {
1693 Handle(Standard_Transient) anItem = theBases->Value(i);
1697 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1700 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1701 if(aRefBase.IsNull())
1705 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1706 if(anItemLoc.IsNull())
1709 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1712 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1713 if(aRefLoc.IsNull())
1715 aSeqLocs->Append(aRefLoc);
1717 aSeqBases->Append(aRefBase);
1720 if(!aSeqBases->Length())
1723 aCI.SetBases(aSeqBases);
1724 aCI.SetLocations(aSeqLocs);
1725 aCI.SetPath(aRefPath);
1726 aCI.SetWithContactMode(theWithContact);
1727 aCI.SetWithCorrectionMode(theWithCorrections);
1729 //Compute the Pipe value
1731 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1734 if (!GetSolver()->ComputeFunction(aFunction)) {
1735 SetErrorCode("Pipe with defferent section driver failed");
1739 catch (Standard_Failure) {
1740 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1741 SetErrorCode(aFail->GetMessageString());
1745 //Make a Python command
1746 GEOM::TPythonDump pyDump(aFunction);
1747 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1749 for(i =1 ; i <= nbBases; i++) {
1751 Handle(Standard_Transient) anItem = theBases->Value(i);
1755 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1756 if(!anObj.IsNull()) {
1765 for(i =1 ; i <= nbLocs; i++) {
1767 Handle(Standard_Transient) anItem = theLocations->Value(i);
1771 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1772 if(!anObj.IsNull()) {
1779 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1786 //=============================================================================
1788 * MakePipeWithShellSections
1790 //=============================================================================
1791 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1792 const Handle(TColStd_HSequenceOfTransient)& theBases,
1793 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1794 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1795 const Handle(GEOM_Object)& thePath,
1796 bool theWithContact,
1797 bool theWithCorrections)
1799 Handle(GEOM_Object) anObj;
1801 if(theBases.IsNull())
1804 Standard_Integer nbBases = theBases->Length();
1809 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1811 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1813 //Add a new Pipe object
1814 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1816 //Add a new Pipe function
1818 Handle(GEOM_Function) aFunction =
1819 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1820 if (aFunction.IsNull()) return anObj;
1822 //Check if the function is set correctly
1823 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1825 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1826 GEOMImpl_IPipeShellSect aCI (aFunction);
1828 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1829 if(aRefPath.IsNull())
1832 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1833 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1834 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1836 Standard_Integer i =1;
1837 for( ; i <= nbBases; i++) {
1839 Handle(Standard_Transient) anItem = theBases->Value(i);
1842 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1845 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1846 if(aRefBase.IsNull())
1849 if( nbSubBases >= nbBases ) {
1850 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1851 if(aSubItem.IsNull())
1853 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1854 if(aSubBase.IsNull())
1856 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1857 if(aRefSubBase.IsNull())
1859 aSeqSubBases->Append(aRefSubBase);
1863 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1864 if(anItemLoc.IsNull())
1866 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1869 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1870 if(aRefLoc.IsNull())
1872 aSeqLocs->Append(aRefLoc);
1875 aSeqBases->Append(aRefBase);
1878 if(!aSeqBases->Length())
1881 aCI.SetBases(aSeqBases);
1882 aCI.SetSubBases(aSeqSubBases);
1883 aCI.SetLocations(aSeqLocs);
1884 aCI.SetPath(aRefPath);
1885 aCI.SetWithContactMode(theWithContact);
1886 aCI.SetWithCorrectionMode(theWithCorrections);
1888 //Compute the Pipe value
1890 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1893 if (!GetSolver()->ComputeFunction(aFunction)) {
1894 SetErrorCode("Pipe with shell sections driver failed");
1898 catch (Standard_Failure) {
1899 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1900 SetErrorCode(aFail->GetMessageString());
1904 //Make a Python command
1905 GEOM::TPythonDump pyDump(aFunction);
1906 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1908 for(i =1 ; i <= nbBases; i++) {
1910 Handle(Standard_Transient) anItem = theBases->Value(i);
1914 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1915 if(!anObj.IsNull()) {
1924 for(i =1 ; i <= nbSubBases; i++) {
1926 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1930 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1931 if(!anObj.IsNull()) {
1940 for(i =1 ; i <= nbLocs; i++) {
1942 Handle(Standard_Transient) anItem = theLocations->Value(i);
1946 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1947 if(!anObj.IsNull()) {
1954 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1962 //=============================================================================
1964 * MakePipeShellsWithoutPath
1966 //=============================================================================
1967 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1968 const Handle(TColStd_HSequenceOfTransient)& theBases,
1969 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1971 Handle(GEOM_Object) anObj;
1973 if(theBases.IsNull())
1976 Standard_Integer nbBases = theBases->Length();
1981 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1983 //Add a new Pipe object
1984 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1986 //Add a new Pipe function
1988 Handle(GEOM_Function) aFunction =
1989 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1990 if (aFunction.IsNull()) return anObj;
1992 //Check if the function is set correctly
1993 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1995 GEOMImpl_IPipeShellSect aCI (aFunction);
1997 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1998 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2000 Standard_Integer i =1;
2001 for( ; i <= nbBases; i++) {
2003 Handle(Standard_Transient) anItem = theBases->Value(i);
2006 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2009 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2010 if(aRefBase.IsNull())
2014 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2015 if(anItemLoc.IsNull())
2017 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2020 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2021 if(aRefLoc.IsNull())
2023 aSeqLocs->Append(aRefLoc);
2026 aSeqBases->Append(aRefBase);
2029 if(!aSeqBases->Length())
2032 aCI.SetBases(aSeqBases);
2033 aCI.SetLocations(aSeqLocs);
2035 //Compute the Pipe value
2037 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2040 if (!GetSolver()->ComputeFunction(aFunction)) {
2041 SetErrorCode("Pipe with shell sections without path driver failed");
2045 catch (Standard_Failure) {
2046 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2047 SetErrorCode(aFail->GetMessageString());
2051 //Make a Python command
2052 GEOM::TPythonDump pyDump(aFunction);
2053 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2055 for(i =1 ; i <= nbBases; i++) {
2057 Handle(Standard_Transient) anItem = theBases->Value(i);
2061 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2062 if(!anObj.IsNull()) {
2071 for(i =1 ; i <= nbLocs; i++) {
2073 Handle(Standard_Transient) anItem = theLocations->Value(i);
2077 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2078 if(!anObj.IsNull()) {
2093 //=============================================================================
2095 * MakePipeBiNormalAlongVector
2097 //=============================================================================
2098 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2099 Handle(GEOM_Object) thePath,
2100 Handle(GEOM_Object) theVec)
2104 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2106 //Add a new Pipe object
2107 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2109 //Add a new Pipe function
2110 Handle(GEOM_Function) aFunction =
2111 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2112 if (aFunction.IsNull()) return NULL;
2114 //Check if the function is set correctly
2115 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2117 GEOMImpl_IPipeBiNormal aCI (aFunction);
2119 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2120 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2121 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2123 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2125 aCI.SetBase(aRefBase);
2126 aCI.SetPath(aRefPath);
2127 aCI.SetVector(aRefVec);
2129 //Compute the Pipe value
2131 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2134 if (!GetSolver()->ComputeFunction(aFunction)) {
2135 SetErrorCode("Pipe driver failed");
2139 catch (Standard_Failure) {
2140 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2141 SetErrorCode(aFail->GetMessageString());
2145 //Make a Python command
2146 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2147 << theBase << ", " << thePath << ", " << theVec << ")";