1 // Copyright (C) 2007-2010 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 <Standard_Failure.hxx>
72 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
74 //=============================================================================
78 //=============================================================================
79 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
80 : GEOM_IOperations(theEngine, theDocID)
82 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
85 //=============================================================================
89 //=============================================================================
90 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
92 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
96 //=============================================================================
100 //=============================================================================
101 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
105 //Add a new Box object
106 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
108 //Add a new Box function with DX_DY_DZ parameters
109 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
110 if (aFunction.IsNull()) return NULL;
112 //Check if the function is set correctly
113 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
115 GEOMImpl_IBox aBI (aFunction);
121 //Compute the box value
123 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
126 if (!GetSolver()->ComputeFunction(aFunction)) {
127 SetErrorCode("Box driver failed");
131 catch (Standard_Failure) {
132 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
133 SetErrorCode(aFail->GetMessageString());
137 //Make a Python command
138 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
139 << theDX << ", " << theDY << ", " << theDZ << ")";
146 //=============================================================================
150 //=============================================================================
151 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
152 Handle(GEOM_Object) thePnt2)
156 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
158 //Add a new Box object
159 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
161 //Add a new Box function for creation a box relatively to two points
162 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
163 if (aFunction.IsNull()) return NULL;
165 //Check if the function is set correctly
166 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
168 GEOMImpl_IBox aBI (aFunction);
170 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
171 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
173 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
175 aBI.SetRef1(aRefFunction1);
176 aBI.SetRef2(aRefFunction2);
178 //Compute the Box value
180 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
183 if (!GetSolver()->ComputeFunction(aFunction)) {
184 SetErrorCode("Box driver failed");
188 catch (Standard_Failure) {
189 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
190 SetErrorCode(aFail->GetMessageString());
194 //Make a Python command
195 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
196 << thePnt1 << ", " << thePnt2 << ")";
202 //=============================================================================
206 //=============================================================================
207 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
211 if (theH == 0 || theW == 0) return NULL;
213 //Add a new Face object
214 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
216 //Add a new Box function for creation a box relatively to two points
217 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
218 if (aFunction.IsNull()) return NULL;
220 //Check if the function is set correctly
221 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
223 GEOMImpl_IFace aFI (aFunction);
227 aFI.SetOrientation(theOrientation);
231 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
234 if (!GetSolver()->ComputeFunction(aFunction)) {
235 SetErrorCode("Face driver failed");
239 catch (Standard_Failure) {
240 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
241 SetErrorCode(aFail->GetMessageString());
245 //Make a Python command
246 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
247 << theH << ", " << theW << ", " << theOrientation << ")";
253 //=============================================================================
257 //=============================================================================
258 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
259 double theH, double theW)
263 if (theObj.IsNull()) return NULL;
265 //Add a new Face object
266 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
268 //Add a new Box function for creation a box relatively to two points
269 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
270 if (aFunction.IsNull()) return NULL;
272 //Check if the function is set correctly
273 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
275 GEOMImpl_IFace aFI (aFunction);
277 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
279 if (aRefFunction1.IsNull())
282 aFI.SetRef1(aRefFunction1);
288 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
291 if (!GetSolver()->ComputeFunction(aFunction)) {
292 SetErrorCode("Face driver failed");
296 catch (Standard_Failure) {
297 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
298 SetErrorCode(aFail->GetMessageString());
302 //Make a Python command
303 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
304 << theObj << ", " << theH << ", " << theW << ")";
310 //=============================================================================
314 //=============================================================================
315 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
316 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
320 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
322 //Add a new Disk object
323 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
325 //Add a new Disk function for creation a disk relatively to point and vector
326 Handle(GEOM_Function) aFunction =
327 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
328 if (aFunction.IsNull()) return NULL;
330 //Check if the function is set correctly
331 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
333 GEOMImpl_IDisk aCI (aFunction);
335 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
336 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
338 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
340 aCI.SetCenter(aRefPnt);
341 aCI.SetVector(aRefVec);
344 //Compute the Disk value
346 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
349 if (!GetSolver()->ComputeFunction(aFunction)) {
350 SetErrorCode("Disk driver failed");
354 catch (Standard_Failure) {
355 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
356 SetErrorCode(aFail->GetMessageString());
360 //Make a Python command
361 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
362 << thePnt << ", " << theVec << ", " << theR << ")";
368 //=============================================================================
372 //=============================================================================
373 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
374 Handle(GEOM_Object) thePnt2,
375 Handle(GEOM_Object) thePnt3)
379 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
381 //Add a new Disk object
382 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
384 //Add a new Disk function for creation a disk relatively to three points
385 Handle(GEOM_Function) aFunction =
386 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
387 if (aFunction.IsNull()) return NULL;
389 //Check if the function is set correctly
390 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
392 GEOMImpl_IDisk aCI (aFunction);
394 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
395 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
396 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
398 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
400 aCI.SetPoint1(aRefPnt1);
401 aCI.SetPoint2(aRefPnt2);
402 aCI.SetPoint3(aRefPnt3);
404 //Compute the Disk value
406 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
409 if (!GetSolver()->ComputeFunction(aFunction)) {
410 SetErrorCode("Disk driver failed");
414 catch (Standard_Failure) {
415 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
416 SetErrorCode(aFail->GetMessageString());
420 //Make a Python command
421 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
422 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
428 //=============================================================================
432 //=============================================================================
433 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
437 if (theR == 0 ) return NULL;
439 //Add a new Disk object
440 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
442 //Add a new Box function for creation a box relatively to two points
443 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
444 if (aFunction.IsNull()) return NULL;
446 //Check if the function is set correctly
447 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
449 GEOMImpl_IDisk aDI (aFunction);
452 aDI.SetOrientation(theOrientation);
456 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
459 if (!GetSolver()->ComputeFunction(aFunction)) {
460 SetErrorCode("Disk driver failed");
464 catch (Standard_Failure) {
465 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
466 SetErrorCode(aFail->GetMessageString());
470 //Make a Python command
471 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
472 << theR << ", " << theOrientation << ")";
478 //=============================================================================
482 //=============================================================================
483 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
487 //Add a new Cylinder object
488 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
490 //Add a new Cylinder function with R and H parameters
491 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
492 if (aFunction.IsNull()) return NULL;
494 //Check if the function is set correctly
495 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
497 GEOMImpl_ICylinder aCI (aFunction);
502 //Compute the Cylinder value
504 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
507 if (!GetSolver()->ComputeFunction(aFunction)) {
508 SetErrorCode("Cylinder driver failed");
512 catch (Standard_Failure) {
513 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
514 SetErrorCode(aFail->GetMessageString());
518 //Make a Python command
519 GEOM::TPythonDump(aFunction) << aCylinder
520 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
527 //=============================================================================
529 * MakeCylinderPntVecRH
531 //=============================================================================
532 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
533 Handle(GEOM_Object) theVec,
534 double theR, double theH)
538 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
540 //Add a new Cylinder object
541 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
543 //Add a new Cylinder function for creation a cylinder relatively to point and vector
544 Handle(GEOM_Function) aFunction =
545 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
546 if (aFunction.IsNull()) return NULL;
548 //Check if the function is set correctly
549 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
551 GEOMImpl_ICylinder aCI (aFunction);
553 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
554 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
556 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
558 aCI.SetPoint(aRefPnt);
559 aCI.SetVector(aRefVec);
563 //Compute the Cylinder value
565 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
568 if (!GetSolver()->ComputeFunction(aFunction)) {
569 SetErrorCode("Cylinder driver failed");
573 catch (Standard_Failure) {
574 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
575 SetErrorCode(aFail->GetMessageString());
579 //Make a Python command
580 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
581 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
588 //=============================================================================
592 //=============================================================================
593 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
598 //Add a new Cone object
599 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
601 //Add a new Cone function with R and H parameters
602 Handle(GEOM_Function) aFunction =
603 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
604 if (aFunction.IsNull()) return NULL;
606 //Check if the function is set correctly
607 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
609 GEOMImpl_ICone aCI (aFunction);
615 //Compute the Cone value
617 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
620 if (!GetSolver()->ComputeFunction(aFunction)) {
621 SetErrorCode("Cone driver failed");
625 catch (Standard_Failure) {
626 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
627 SetErrorCode(aFail->GetMessageString());
631 //Make a Python command
632 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
633 << theR1 << ", " << theR2 << ", " << theH << ")";
640 //=============================================================================
642 * MakeConePntVecR1R2H
644 //=============================================================================
645 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
646 Handle(GEOM_Object) theVec,
647 double theR1, double theR2,
652 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
654 //Add a new Cone object
655 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
657 //Add a new Cone function for creation a cone relatively to point and vector
658 Handle(GEOM_Function) aFunction =
659 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
660 if (aFunction.IsNull()) return NULL;
662 //Check if the function is set correctly
663 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
665 GEOMImpl_ICone aCI (aFunction);
667 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
668 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
670 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
672 aCI.SetPoint(aRefPnt);
673 aCI.SetVector(aRefVec);
678 //Compute the Cone value
680 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
683 if (!GetSolver()->ComputeFunction(aFunction)) {
684 SetErrorCode("Cone driver failed");
688 catch (Standard_Failure) {
689 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
690 SetErrorCode(aFail->GetMessageString());
694 //Make a Python command
695 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
696 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
703 //=============================================================================
707 //=============================================================================
708 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
712 //Add a new Sphere object
713 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
715 //Add a new Sphere function with R parameter
716 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
717 if (aFunction.IsNull()) return NULL;
719 //Check if the function is set correctly
720 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
722 GEOMImpl_ISphere aCI (aFunction);
726 //Compute the Sphere value
728 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
731 if (!GetSolver()->ComputeFunction(aFunction)) {
732 SetErrorCode("Sphere driver failed");
736 catch (Standard_Failure) {
737 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
738 SetErrorCode(aFail->GetMessageString());
742 //Make a Python command
743 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
750 //=============================================================================
754 //=============================================================================
755 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
760 if (thePnt.IsNull()) return NULL;
762 //Add a new Point object
763 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
765 //Add a new Sphere function for creation a sphere relatively to point
766 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
767 if (aFunction.IsNull()) return NULL;
769 //Check if the function is set correctly
770 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
772 GEOMImpl_ISphere aCI (aFunction);
774 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
776 if (aRefPnt.IsNull()) return NULL;
778 aCI.SetPoint(aRefPnt);
781 //Compute the Sphere value
783 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
786 if (!GetSolver()->ComputeFunction(aFunction)) {
787 SetErrorCode("Sphere driver failed");
791 catch (Standard_Failure) {
792 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
793 SetErrorCode(aFail->GetMessageString());
797 //Make a Python command
798 GEOM::TPythonDump(aFunction) << aSphere
799 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
806 //=============================================================================
810 //=============================================================================
811 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
812 (double theRMajor, double theRMinor)
816 //Add a new Torus object
817 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
819 //Add a new Torus function
820 Handle(GEOM_Function) aFunction =
821 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
822 if (aFunction.IsNull()) return NULL;
824 //Check if the function is set correctly
825 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
827 GEOMImpl_ITorus aCI (aFunction);
829 aCI.SetRMajor(theRMajor);
830 aCI.SetRMinor(theRMinor);
832 //Compute the Torus value
834 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
837 if (!GetSolver()->ComputeFunction(aFunction)) {
838 SetErrorCode("Torus driver failed");
842 catch (Standard_Failure) {
843 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
844 SetErrorCode(aFail->GetMessageString());
848 //Make a Python command
849 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
850 << theRMajor << ", " << theRMinor << ")";
856 //=============================================================================
860 //=============================================================================
861 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
862 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
863 double theRMajor, double theRMinor)
867 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
869 //Add a new Torus object
870 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
872 //Add a new Torus function
873 Handle(GEOM_Function) aFunction =
874 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
875 if (aFunction.IsNull()) return NULL;
877 //Check if the function is set correctly
878 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
880 GEOMImpl_ITorus aCI (aFunction);
882 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
883 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
885 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
887 aCI.SetCenter(aRefPnt);
888 aCI.SetVector(aRefVec);
889 aCI.SetRMajor(theRMajor);
890 aCI.SetRMinor(theRMinor);
892 //Compute the Torus value
894 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
897 if (!GetSolver()->ComputeFunction(aFunction)) {
898 SetErrorCode("Torus driver failed");
902 catch (Standard_Failure) {
903 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
904 SetErrorCode(aFail->GetMessageString());
908 //Make a Python command
909 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
910 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
917 //=============================================================================
921 //=============================================================================
922 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
923 Handle(GEOM_Object) theVec,
928 if (theBase.IsNull() || theVec.IsNull()) return NULL;
930 //Add a new Prism object
931 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
933 //Add a new Prism function for creation a Prism relatively to vector
934 Handle(GEOM_Function) aFunction =
935 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
936 if (aFunction.IsNull()) return NULL;
938 //Check if the function is set correctly
939 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
941 GEOMImpl_IPrism aCI (aFunction);
943 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
944 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
946 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
948 aCI.SetBase(aRefBase);
949 aCI.SetVector(aRefVec);
952 //Compute the Prism value
954 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
957 if (!GetSolver()->ComputeFunction(aFunction)) {
958 //SetErrorCode("Prism driver failed");
959 SetErrorCode("Extrusion can not be created, check input data");
963 catch (Standard_Failure) {
964 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
965 SetErrorCode(aFail->GetMessageString());
969 //Make a Python command
970 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
971 << theBase << ", " << theVec << ", " << theH << ")";
977 //=============================================================================
981 //=============================================================================
982 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
983 Handle(GEOM_Object) theVec,
988 if (theBase.IsNull() || theVec.IsNull()) return NULL;
990 //Add a new Prism object
991 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
993 //Add a new Prism function for creation a Prism relatively to vector
994 Handle(GEOM_Function) aFunction =
995 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
996 if (aFunction.IsNull()) return NULL;
998 //Check if the function is set correctly
999 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1001 GEOMImpl_IPrism aCI (aFunction);
1003 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1004 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1006 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1008 aCI.SetBase(aRefBase);
1009 aCI.SetVector(aRefVec);
1012 //Compute the Prism value
1014 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1017 if (!GetSolver()->ComputeFunction(aFunction)) {
1018 //SetErrorCode("Prism driver failed");
1019 SetErrorCode("Extrusion can not be created, check input data");
1023 catch (Standard_Failure) {
1024 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1025 SetErrorCode(aFail->GetMessageString());
1029 //Make a Python command
1030 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1031 << theBase << ", " << theVec << ", " << theH << ")";
1037 //=============================================================================
1041 //=============================================================================
1042 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1043 (Handle(GEOM_Object) theBase,
1044 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1048 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1050 //Add a new Prism object
1051 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1053 //Add a new Prism function for creation a Prism relatively to two points
1054 Handle(GEOM_Function) aFunction =
1055 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1056 if (aFunction.IsNull()) return NULL;
1058 //Check if the function is set correctly
1059 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1061 GEOMImpl_IPrism aCI (aFunction);
1063 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1064 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1065 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1067 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1069 aCI.SetBase(aRefBase);
1070 aCI.SetFirstPoint(aRefPnt1);
1071 aCI.SetLastPoint(aRefPnt2);
1073 //Compute the Prism value
1075 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1078 if (!GetSolver()->ComputeFunction(aFunction)) {
1079 //SetErrorCode("Prism driver failed");
1080 SetErrorCode("Extrusion can not be created, check input data");
1084 catch (Standard_Failure) {
1085 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1086 SetErrorCode(aFail->GetMessageString());
1090 //Make a Python command
1091 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
1092 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1098 //=============================================================================
1100 * MakePrismTwoPnt2Ways
1102 //=============================================================================
1103 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1104 (Handle(GEOM_Object) theBase,
1105 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1109 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1111 //Add a new Prism object
1112 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1114 //Add a new Prism function for creation a Prism relatively to two points
1115 Handle(GEOM_Function) aFunction =
1116 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1117 if (aFunction.IsNull()) return NULL;
1119 //Check if the function is set correctly
1120 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1122 GEOMImpl_IPrism aCI (aFunction);
1124 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1125 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1126 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1128 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1130 aCI.SetBase(aRefBase);
1131 aCI.SetFirstPoint(aRefPnt1);
1132 aCI.SetLastPoint(aRefPnt2);
1134 //Compute the Prism value
1136 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1139 if (!GetSolver()->ComputeFunction(aFunction)) {
1140 //SetErrorCode("Prism driver failed");
1141 SetErrorCode("Extrusion can not be created, check input data");
1145 catch (Standard_Failure) {
1146 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1147 SetErrorCode(aFail->GetMessageString());
1151 //Make a Python command
1152 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1153 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1159 //=============================================================================
1163 //=============================================================================
1164 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1165 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1169 if (theBase.IsNull()) return NULL;
1171 //Add a new Prism object
1172 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1174 //Add a new Prism function for creation a Prism by DXDYDZ
1175 Handle(GEOM_Function) aFunction =
1176 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1177 if (aFunction.IsNull()) return NULL;
1179 //Check if the function is set correctly
1180 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1182 GEOMImpl_IPrism aCI (aFunction);
1184 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1186 if (aRefBase.IsNull()) return NULL;
1188 aCI.SetBase(aRefBase);
1193 //Compute the Prism value
1195 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1198 if (!GetSolver()->ComputeFunction(aFunction)) {
1199 SetErrorCode("Extrusion can not be created, check input data");
1203 catch (Standard_Failure) {
1204 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1205 SetErrorCode(aFail->GetMessageString());
1209 //Make a Python command
1210 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ("
1211 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1217 //=============================================================================
1219 * MakePrismDXDYDZ_2WAYS
1221 //=============================================================================
1222 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1223 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1227 if (theBase.IsNull()) return NULL;
1229 //Add a new Prism object
1230 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1232 //Add a new Prism function for creation a Prism by DXDYDZ
1233 Handle(GEOM_Function) aFunction =
1234 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1235 if (aFunction.IsNull()) return NULL;
1237 //Check if the function is set correctly
1238 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1240 GEOMImpl_IPrism aCI (aFunction);
1242 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1244 if (aRefBase.IsNull()) return NULL;
1246 aCI.SetBase(aRefBase);
1251 //Compute the Prism value
1253 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1256 if (!GetSolver()->ComputeFunction(aFunction)) {
1257 SetErrorCode("Extrusion can not be created, check input data");
1261 catch (Standard_Failure) {
1262 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1263 SetErrorCode(aFail->GetMessageString());
1267 //Make a Python command
1268 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1269 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1275 //=============================================================================
1279 //=============================================================================
1280 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1281 Handle(GEOM_Object) thePath)
1285 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1287 //Add a new Pipe object
1288 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1290 //Add a new Pipe function
1291 Handle(GEOM_Function) aFunction =
1292 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1293 if (aFunction.IsNull()) return NULL;
1295 //Check if the function is set correctly
1296 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1298 GEOMImpl_IPipe aCI (aFunction);
1300 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1301 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1303 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1305 aCI.SetBase(aRefBase);
1306 aCI.SetPath(aRefPath);
1308 //Compute the Pipe value
1310 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1313 if (!GetSolver()->ComputeFunction(aFunction)) {
1314 SetErrorCode("Pipe driver failed");
1318 catch (Standard_Failure) {
1319 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1320 SetErrorCode(aFail->GetMessageString());
1324 //Make a Python command
1325 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1326 << theBase << ", " << thePath << ")";
1333 //=============================================================================
1335 * MakeRevolutionAxisAngle
1337 //=============================================================================
1338 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1339 Handle(GEOM_Object) theAxis,
1344 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1346 //Add a new Revolution object
1347 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1349 //Add a new Revolution function for creation a revolution relatively to axis
1350 Handle(GEOM_Function) aFunction =
1351 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1352 if (aFunction.IsNull()) return NULL;
1354 //Check if the function is set correctly
1355 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1357 GEOMImpl_IRevolution aCI (aFunction);
1359 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1360 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1362 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1364 aCI.SetBase(aRefBase);
1365 aCI.SetAxis(aRefAxis);
1366 aCI.SetAngle(theAngle);
1368 //Compute the Revolution value
1370 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1373 if (!GetSolver()->ComputeFunction(aFunction)) {
1374 SetErrorCode("Revolution driver failed");
1378 catch (Standard_Failure) {
1379 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1380 SetErrorCode(aFail->GetMessageString());
1384 //Make a Python command
1385 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1386 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1392 //=============================================================================
1394 * MakeRevolutionAxisAngle2Ways
1396 //=============================================================================
1397 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1398 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1402 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1404 //Add a new Revolution object
1405 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1407 //Add a new Revolution function for creation a revolution relatively to axis
1408 Handle(GEOM_Function) aFunction =
1409 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1410 if (aFunction.IsNull()) return NULL;
1412 //Check if the function is set correctly
1413 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1415 GEOMImpl_IRevolution aCI (aFunction);
1417 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1418 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1420 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1422 aCI.SetBase(aRefBase);
1423 aCI.SetAxis(aRefAxis);
1424 aCI.SetAngle(theAngle);
1426 //Compute the Revolution value
1428 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1431 if (!GetSolver()->ComputeFunction(aFunction)) {
1432 SetErrorCode("Revolution driver failed");
1436 catch (Standard_Failure) {
1437 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1438 SetErrorCode(aFail->GetMessageString());
1442 //Make a Python command
1443 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1444 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1450 //=============================================================================
1454 //=============================================================================
1455 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1456 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1457 double theTol2D, double theTol3D, int theNbIter,
1458 int theMethod, bool isApprox)
1462 if (theShape.IsNull()) return NULL;
1464 //Add a new Filling object
1465 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1467 //Add a new Filling function for creation a filling from a compound
1468 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1469 if (aFunction.IsNull()) return NULL;
1471 //Check if the function is set correctly
1472 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1474 GEOMImpl_IFilling aFI (aFunction);
1476 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1478 if (aRefShape.IsNull()) return NULL;
1480 aFI.SetShape(aRefShape);
1481 aFI.SetMinDeg(theMinDeg);
1482 aFI.SetMaxDeg(theMaxDeg);
1483 aFI.SetTol2D(theTol2D);
1484 aFI.SetTol3D(theTol3D);
1485 aFI.SetNbIter(theNbIter);
1486 aFI.SetApprox(isApprox);
1487 aFI.SetMethod(theMethod);
1489 //Compute the Solid value
1491 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1494 if (!GetSolver()->ComputeFunction(aFunction)) {
1495 SetErrorCode("Filling driver failed");
1499 catch (Standard_Failure) {
1500 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1501 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1502 SetErrorCode("B-Spline surface construction failed");
1504 SetErrorCode(aFail->GetMessageString());
1508 //Make a Python command
1509 GEOM::TPythonDump pd (aFunction);
1510 pd << aFilling << " = geompy.MakeFilling("
1511 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1512 << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
1513 if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
1514 else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
1515 else pd << "GEOM.FOM_Default";
1517 pd << ", " << isApprox ;
1524 //=============================================================================
1528 //=============================================================================
1529 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1530 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1535 Handle(GEOM_Object) anObj;
1537 if(theSeqSections.IsNull())
1540 Standard_Integer nbObj = theSeqSections->Length();
1544 //Add a new ThruSections object
1545 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1548 //Add a new ThruSections function
1550 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1551 Handle(GEOM_Function) aFunction =
1552 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1553 if (aFunction.IsNull()) return anObj;
1555 //Check if the function is set correctly
1556 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1558 GEOMImpl_IThruSections aCI (aFunction);
1560 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1562 Standard_Integer i =1;
1563 for( ; i <= nbObj; i++) {
1565 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1569 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1570 if(!aSectObj.IsNull())
1572 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1573 if(!aRefSect.IsNull())
1574 aSeqSections->Append(aRefSect);
1578 if(!aSeqSections->Length())
1581 aCI.SetSections(aSeqSections);
1582 aCI.SetSolidMode(theModeSolid);
1583 aCI.SetPrecision(thePreci);
1585 //Compute the ThruSections value
1587 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1590 if (!GetSolver()->ComputeFunction(aFunction)) {
1591 SetErrorCode("ThruSections driver failed");
1595 catch (Standard_Failure) {
1596 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1597 SetErrorCode(aFail->GetMessageString());
1601 //Make a Python command
1602 GEOM::TPythonDump pyDump(aFunction);
1603 pyDump << aThruSect << " = geompy.MakeThruSections([";
1605 for(i =1 ; i <= nbObj; i++) {
1607 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1611 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1612 if(!aSectObj.IsNull()) {
1619 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1628 //=============================================================================
1630 * MakePipeWithDifferentSections
1632 //=============================================================================
1633 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1634 const Handle(TColStd_HSequenceOfTransient)& theBases,
1635 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1636 const Handle(GEOM_Object)& thePath,
1637 bool theWithContact,
1638 bool theWithCorrections)
1640 Handle(GEOM_Object) anObj;
1642 if(theBases.IsNull())
1645 Standard_Integer nbBases = theBases->Length();
1650 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1651 //Add a new Pipe object
1652 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1654 //Add a new Pipe function
1656 Handle(GEOM_Function) aFunction =
1657 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1658 if (aFunction.IsNull()) return anObj;
1660 //Check if the function is set correctly
1661 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1663 GEOMImpl_IPipeDiffSect aCI (aFunction);
1665 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1666 if(aRefPath.IsNull())
1669 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1670 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1672 Standard_Integer i =1;
1673 for( ; i <= nbBases; i++) {
1675 Handle(Standard_Transient) anItem = theBases->Value(i);
1679 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1682 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1683 if(aRefBase.IsNull())
1687 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1688 if(anItemLoc.IsNull())
1691 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1694 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1695 if(aRefLoc.IsNull())
1697 aSeqLocs->Append(aRefLoc);
1699 aSeqBases->Append(aRefBase);
1702 if(!aSeqBases->Length())
1705 aCI.SetBases(aSeqBases);
1706 aCI.SetLocations(aSeqLocs);
1707 aCI.SetPath(aRefPath);
1708 aCI.SetWithContactMode(theWithContact);
1709 aCI.SetWithCorrectionMode(theWithCorrections);
1711 //Compute the Pipe value
1713 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1716 if (!GetSolver()->ComputeFunction(aFunction)) {
1717 SetErrorCode("Pipe with defferent section driver failed");
1721 catch (Standard_Failure) {
1722 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1723 SetErrorCode(aFail->GetMessageString());
1727 //Make a Python command
1728 GEOM::TPythonDump pyDump(aFunction);
1729 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1731 for(i =1 ; i <= nbBases; i++) {
1733 Handle(Standard_Transient) anItem = theBases->Value(i);
1737 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1738 if(!anObj.IsNull()) {
1748 for(i =1 ; i <= nbLocs; i++) {
1750 Handle(Standard_Transient) anItem = theLocations->Value(i);
1754 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1755 if(!anObj.IsNull()) {
1762 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1771 //=============================================================================
1773 * MakePipeWithShellSections
1775 //=============================================================================
1776 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1777 const Handle(TColStd_HSequenceOfTransient)& theBases,
1778 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1779 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1780 const Handle(GEOM_Object)& thePath,
1781 bool theWithContact,
1782 bool theWithCorrections)
1784 Handle(GEOM_Object) anObj;
1786 if(theBases.IsNull())
1789 Standard_Integer nbBases = theBases->Length();
1794 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1796 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1798 //Add a new Pipe object
1799 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1801 //Add a new Pipe function
1803 Handle(GEOM_Function) aFunction =
1804 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1805 if (aFunction.IsNull()) return anObj;
1807 //Check if the function is set correctly
1808 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1810 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1811 GEOMImpl_IPipeShellSect aCI (aFunction);
1813 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1814 if(aRefPath.IsNull())
1817 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1818 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1819 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1821 Standard_Integer i =1;
1822 for( ; i <= nbBases; i++) {
1824 Handle(Standard_Transient) anItem = theBases->Value(i);
1827 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1830 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1831 if(aRefBase.IsNull())
1834 if( nbSubBases >= nbBases ) {
1835 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1836 if(aSubItem.IsNull())
1838 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1839 if(aSubBase.IsNull())
1841 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1842 if(aRefSubBase.IsNull())
1844 aSeqSubBases->Append(aRefSubBase);
1848 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1849 if(anItemLoc.IsNull())
1851 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1854 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1855 if(aRefLoc.IsNull())
1857 aSeqLocs->Append(aRefLoc);
1860 aSeqBases->Append(aRefBase);
1863 if(!aSeqBases->Length())
1866 aCI.SetBases(aSeqBases);
1867 aCI.SetSubBases(aSeqSubBases);
1868 aCI.SetLocations(aSeqLocs);
1869 aCI.SetPath(aRefPath);
1870 aCI.SetWithContactMode(theWithContact);
1871 aCI.SetWithCorrectionMode(theWithCorrections);
1873 //Compute the Pipe value
1875 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1878 if (!GetSolver()->ComputeFunction(aFunction)) {
1879 SetErrorCode("Pipe with shell sections driver failed");
1883 catch (Standard_Failure) {
1884 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1885 SetErrorCode(aFail->GetMessageString());
1889 //Make a Python command
1890 GEOM::TPythonDump pyDump(aFunction);
1891 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1893 for(i =1 ; i <= nbBases; i++) {
1895 Handle(Standard_Transient) anItem = theBases->Value(i);
1899 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1900 if(!anObj.IsNull()) {
1910 for(i =1 ; i <= nbSubBases; i++) {
1912 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1916 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1917 if(!anObj.IsNull()) {
1927 for(i =1 ; i <= nbLocs; i++) {
1929 Handle(Standard_Transient) anItem = theLocations->Value(i);
1933 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1934 if(!anObj.IsNull()) {
1941 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1949 //=============================================================================
1951 * MakePipeShellsWithoutPath
1953 //=============================================================================
1954 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1955 const Handle(TColStd_HSequenceOfTransient)& theBases,
1956 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1958 Handle(GEOM_Object) anObj;
1960 if(theBases.IsNull())
1963 Standard_Integer nbBases = theBases->Length();
1968 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1970 //Add a new Pipe object
1971 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1973 //Add a new Pipe function
1975 Handle(GEOM_Function) aFunction =
1976 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1977 if (aFunction.IsNull()) return anObj;
1979 //Check if the function is set correctly
1980 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1982 GEOMImpl_IPipeShellSect aCI (aFunction);
1984 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1985 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1987 Standard_Integer i =1;
1988 for( ; i <= nbBases; i++) {
1990 Handle(Standard_Transient) anItem = theBases->Value(i);
1993 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1996 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1997 if(aRefBase.IsNull())
2001 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2002 if(anItemLoc.IsNull())
2004 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2007 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2008 if(aRefLoc.IsNull())
2010 aSeqLocs->Append(aRefLoc);
2013 aSeqBases->Append(aRefBase);
2016 if(!aSeqBases->Length())
2019 aCI.SetBases(aSeqBases);
2020 aCI.SetLocations(aSeqLocs);
2022 //Compute the Pipe value
2024 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2027 if (!GetSolver()->ComputeFunction(aFunction)) {
2028 SetErrorCode("Pipe with shell sections without path driver failed");
2032 catch (Standard_Failure) {
2033 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2034 SetErrorCode(aFail->GetMessageString());
2038 //Make a Python command
2039 GEOM::TPythonDump pyDump(aFunction);
2040 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2042 for(i =1 ; i <= nbBases; i++) {
2044 Handle(Standard_Transient) anItem = theBases->Value(i);
2048 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2049 if(!anObj.IsNull()) {
2059 for(i =1 ; i <= nbLocs; i++) {
2061 Handle(Standard_Transient) anItem = theLocations->Value(i);
2065 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2066 if(!anObj.IsNull()) {
2081 //=============================================================================
2083 * MakePipeBiNormalAlongVector
2085 //=============================================================================
2086 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2087 Handle(GEOM_Object) thePath,
2088 Handle(GEOM_Object) theVec)
2092 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2094 //Add a new Pipe object
2095 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2097 //Add a new Pipe function
2098 Handle(GEOM_Function) aFunction =
2099 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2100 if (aFunction.IsNull()) return NULL;
2102 //Check if the function is set correctly
2103 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2105 GEOMImpl_IPipeBiNormal aCI (aFunction);
2107 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2108 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2109 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2111 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2113 aCI.SetBase(aRefBase);
2114 aCI.SetPath(aRefPath);
2115 aCI.SetVector(aRefVec);
2117 //Compute the Pipe value
2119 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2122 if (!GetSolver()->ComputeFunction(aFunction)) {
2123 SetErrorCode("Pipe driver failed");
2127 catch (Standard_Failure) {
2128 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2129 SetErrorCode(aFail->GetMessageString());
2133 //Make a Python command
2134 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2135 << theBase << ", " << thePath << ", " << theVec << ")";