1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <CASCatch_OCCTVersion.hxx>
26 #include <GEOMImpl_I3DPrimOperations.hxx>
28 #include "utilities.h"
30 #include <Utils_ExceptHandlers.hxx>
32 #include <TFunction_DriverTable.hxx>
33 #include <TFunction_Driver.hxx>
34 #include <TFunction_Logbook.hxx>
35 #include <TDF_Tool.hxx>
37 #include <GEOM_Function.hxx>
38 #include <GEOM_PythonDump.hxx>
40 #include <GEOMImpl_Types.hxx>
42 #include <GEOMImpl_BoxDriver.hxx>
43 #include <GEOMImpl_FaceDriver.hxx>
44 #include <GEOMImpl_DiskDriver.hxx>
45 #include <GEOMImpl_CylinderDriver.hxx>
46 #include <GEOMImpl_ConeDriver.hxx>
47 #include <GEOMImpl_SphereDriver.hxx>
48 #include <GEOMImpl_TorusDriver.hxx>
49 #include <GEOMImpl_PrismDriver.hxx>
50 #include <GEOMImpl_PipeDriver.hxx>
51 #include <GEOMImpl_RevolutionDriver.hxx>
52 #include <GEOMImpl_ShapeDriver.hxx>
53 #include <GEOMImpl_FillingDriver.hxx>
54 #include <GEOMImpl_ThruSectionsDriver.hxx>
56 #include <GEOMImpl_IBox.hxx>
57 #include <GEOMImpl_IFace.hxx>
58 #include <GEOMImpl_IDisk.hxx>
59 #include <GEOMImpl_ICylinder.hxx>
60 #include <GEOMImpl_ICone.hxx>
61 #include <GEOMImpl_ISphere.hxx>
62 #include <GEOMImpl_ITorus.hxx>
63 #include <GEOMImpl_IPrism.hxx>
64 #include <GEOMImpl_IPipe.hxx>
65 #include <GEOMImpl_IRevolution.hxx>
66 #include <GEOMImpl_IFilling.hxx>
67 #include <GEOMImpl_IThruSections.hxx>
68 #include <GEOMImpl_IPipeDiffSect.hxx>
69 #include <GEOMImpl_IPipeShellSect.hxx>
70 #include <GEOMImpl_IPipeBiNormal.hxx>
72 #include <Precision.hxx>
74 #include <Standard_Failure.hxx>
75 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
77 //=============================================================================
81 //=============================================================================
82 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
83 : GEOM_IOperations(theEngine, theDocID)
85 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
88 //=============================================================================
92 //=============================================================================
93 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
95 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
99 //=============================================================================
103 //=============================================================================
104 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
108 //Add a new Box object
109 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
111 //Add a new Box function with DX_DY_DZ parameters
112 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
113 if (aFunction.IsNull()) return NULL;
115 //Check if the function is set correctly
116 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
118 GEOMImpl_IBox aBI (aFunction);
124 //Compute the box value
126 #if OCC_VERSION_LARGE > 0x06010000
129 if (!GetSolver()->ComputeFunction(aFunction)) {
130 SetErrorCode("Box driver failed");
134 catch (Standard_Failure) {
135 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
136 SetErrorCode(aFail->GetMessageString());
140 //Make a Python command
141 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
142 << theDX << ", " << theDY << ", " << theDZ << ")";
149 //=============================================================================
153 //=============================================================================
154 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
155 Handle(GEOM_Object) thePnt2)
159 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
161 //Add a new Box object
162 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
164 //Add a new Box function for creation a box relatively to two points
165 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
166 if (aFunction.IsNull()) return NULL;
168 //Check if the function is set correctly
169 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
171 GEOMImpl_IBox aBI (aFunction);
173 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
174 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
176 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
178 aBI.SetRef1(aRefFunction1);
179 aBI.SetRef2(aRefFunction2);
181 //Compute the Box value
183 #if OCC_VERSION_LARGE > 0x06010000
186 if (!GetSolver()->ComputeFunction(aFunction)) {
187 SetErrorCode("Box driver failed");
191 catch (Standard_Failure) {
192 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
193 SetErrorCode(aFail->GetMessageString());
197 //Make a Python command
198 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
199 << thePnt1 << ", " << thePnt2 << ")";
205 //=============================================================================
209 //=============================================================================
210 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
214 if (theH == 0 || theW == 0) return NULL;
216 //Add a new Face object
217 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
219 //Add a new Box function for creation a box relatively to two points
220 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
221 if (aFunction.IsNull()) return NULL;
223 //Check if the function is set correctly
224 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
226 GEOMImpl_IFace aFI (aFunction);
230 aFI.SetOrientation(theOrientation);
234 #if OCC_VERSION_LARGE > 0x06010000
237 if (!GetSolver()->ComputeFunction(aFunction)) {
238 SetErrorCode("Face driver failed");
242 catch (Standard_Failure) {
243 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
244 SetErrorCode(aFail->GetMessageString());
248 //Make a Python command
249 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
250 << theH << ", " << theW << ", " << theOrientation << ")";
256 //=============================================================================
260 //=============================================================================
261 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
262 double theH, double theW)
266 if (theObj.IsNull()) return NULL;
268 //Add a new Face object
269 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
271 //Add a new Box function for creation a box relatively to two points
272 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
273 if (aFunction.IsNull()) return NULL;
275 //Check if the function is set correctly
276 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
278 GEOMImpl_IFace aFI (aFunction);
280 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
282 if (aRefFunction1.IsNull())
285 aFI.SetRef1(aRefFunction1);
291 #if OCC_VERSION_LARGE > 0x06010000
294 if (!GetSolver()->ComputeFunction(aFunction)) {
295 SetErrorCode("Face driver failed");
299 catch (Standard_Failure) {
300 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
301 SetErrorCode(aFail->GetMessageString());
305 //Make a Python command
306 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
307 << theObj << ", " << theH << ", " << theW << ")";
313 //=============================================================================
317 //=============================================================================
318 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
319 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
323 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
325 //Add a new Disk object
326 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
328 //Add a new Disk function for creation a disk relatively to point and vector
329 Handle(GEOM_Function) aFunction =
330 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
331 if (aFunction.IsNull()) return NULL;
333 //Check if the function is set correctly
334 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
336 GEOMImpl_IDisk aCI (aFunction);
338 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
339 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
341 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
343 aCI.SetCenter(aRefPnt);
344 aCI.SetVector(aRefVec);
347 //Compute the Disk value
349 #if OCC_VERSION_LARGE > 0x06010000
352 if (!GetSolver()->ComputeFunction(aFunction)) {
353 SetErrorCode("Disk driver failed");
357 catch (Standard_Failure) {
358 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
359 SetErrorCode(aFail->GetMessageString());
363 //Make a Python command
364 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
365 << thePnt << ", " << theVec << ", " << theR << ")";
371 //=============================================================================
375 //=============================================================================
376 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
377 Handle(GEOM_Object) thePnt2,
378 Handle(GEOM_Object) thePnt3)
382 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
384 //Add a new Disk object
385 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
387 //Add a new Disk function for creation a disk relatively to three points
388 Handle(GEOM_Function) aFunction =
389 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
390 if (aFunction.IsNull()) return NULL;
392 //Check if the function is set correctly
393 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
395 GEOMImpl_IDisk aCI (aFunction);
397 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
398 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
399 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
401 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
403 aCI.SetPoint1(aRefPnt1);
404 aCI.SetPoint2(aRefPnt2);
405 aCI.SetPoint3(aRefPnt3);
407 //Compute the Disk value
409 #if OCC_VERSION_LARGE > 0x06010000
412 if (!GetSolver()->ComputeFunction(aFunction)) {
413 SetErrorCode("Disk driver failed");
417 catch (Standard_Failure) {
418 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
419 SetErrorCode(aFail->GetMessageString());
423 //Make a Python command
424 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
425 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
431 //=============================================================================
435 //=============================================================================
436 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
440 if (theR == 0 ) return NULL;
442 //Add a new Disk object
443 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
445 //Add a new Box function for creation a box relatively to two points
446 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
447 if (aFunction.IsNull()) return NULL;
449 //Check if the function is set correctly
450 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
452 GEOMImpl_IDisk aDI (aFunction);
455 aDI.SetOrientation(theOrientation);
459 #if OCC_VERSION_LARGE > 0x06010000
462 if (!GetSolver()->ComputeFunction(aFunction)) {
463 SetErrorCode("Disk driver failed");
467 catch (Standard_Failure) {
468 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
469 SetErrorCode(aFail->GetMessageString());
473 //Make a Python command
474 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
475 << theR << ", " << theOrientation << ")";
481 //=============================================================================
485 //=============================================================================
486 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
490 //Add a new Cylinder object
491 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
493 //Add a new Cylinder function with R and H parameters
494 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
495 if (aFunction.IsNull()) return NULL;
497 //Check if the function is set correctly
498 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
500 GEOMImpl_ICylinder aCI (aFunction);
505 //Compute the Cylinder value
507 #if OCC_VERSION_LARGE > 0x06010000
510 if (!GetSolver()->ComputeFunction(aFunction)) {
511 SetErrorCode("Cylinder driver failed");
515 catch (Standard_Failure) {
516 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
517 SetErrorCode(aFail->GetMessageString());
521 //Make a Python command
522 GEOM::TPythonDump(aFunction) << aCylinder
523 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
530 //=============================================================================
532 * MakeCylinderPntVecRH
534 //=============================================================================
535 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
536 Handle(GEOM_Object) theVec,
537 double theR, double theH)
541 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
543 //Add a new Cylinder object
544 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
546 //Add a new Cylinder function for creation a cylinder relatively to point and vector
547 Handle(GEOM_Function) aFunction =
548 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
549 if (aFunction.IsNull()) return NULL;
551 //Check if the function is set correctly
552 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
554 GEOMImpl_ICylinder aCI (aFunction);
556 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
557 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
559 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
561 aCI.SetPoint(aRefPnt);
562 aCI.SetVector(aRefVec);
566 //Compute the Cylinder value
568 #if OCC_VERSION_LARGE > 0x06010000
571 if (!GetSolver()->ComputeFunction(aFunction)) {
572 SetErrorCode("Cylinder driver failed");
576 catch (Standard_Failure) {
577 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
578 SetErrorCode(aFail->GetMessageString());
582 //Make a Python command
583 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
584 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
591 //=============================================================================
595 //=============================================================================
596 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
601 //Add a new Cone object
602 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
604 //Add a new Cone function with R and H parameters
605 Handle(GEOM_Function) aFunction =
606 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
607 if (aFunction.IsNull()) return NULL;
609 //Check if the function is set correctly
610 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
612 GEOMImpl_ICone aCI (aFunction);
618 //Compute the Cone value
620 #if OCC_VERSION_LARGE > 0x06010000
623 if (!GetSolver()->ComputeFunction(aFunction)) {
624 SetErrorCode("Cone driver failed");
628 catch (Standard_Failure) {
629 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
630 SetErrorCode(aFail->GetMessageString());
634 //Make a Python command
635 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
636 << theR1 << ", " << theR2 << ", " << theH << ")";
643 //=============================================================================
645 * MakeConePntVecR1R2H
647 //=============================================================================
648 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
649 Handle(GEOM_Object) theVec,
650 double theR1, double theR2,
655 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
657 //Add a new Cone object
658 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
660 //Add a new Cone function for creation a cone relatively to point and vector
661 Handle(GEOM_Function) aFunction =
662 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
663 if (aFunction.IsNull()) return NULL;
665 //Check if the function is set correctly
666 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
668 GEOMImpl_ICone aCI (aFunction);
670 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
671 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
673 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
675 aCI.SetPoint(aRefPnt);
676 aCI.SetVector(aRefVec);
681 //Compute the Cone value
683 #if OCC_VERSION_LARGE > 0x06010000
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Cone driver failed");
691 catch (Standard_Failure) {
692 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
693 SetErrorCode(aFail->GetMessageString());
697 //Make a Python command
698 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
699 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
706 //=============================================================================
710 //=============================================================================
711 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
715 //Add a new Sphere object
716 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
718 //Add a new Sphere function with R parameter
719 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
720 if (aFunction.IsNull()) return NULL;
722 //Check if the function is set correctly
723 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
725 GEOMImpl_ISphere aCI (aFunction);
729 //Compute the Sphere value
731 #if OCC_VERSION_LARGE > 0x06010000
734 if (!GetSolver()->ComputeFunction(aFunction)) {
735 SetErrorCode("Sphere driver failed");
739 catch (Standard_Failure) {
740 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
741 SetErrorCode(aFail->GetMessageString());
745 //Make a Python command
746 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
753 //=============================================================================
757 //=============================================================================
758 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
763 if (thePnt.IsNull()) return NULL;
765 //Add a new Point object
766 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
768 //Add a new Sphere function for creation a sphere relatively to point
769 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
770 if (aFunction.IsNull()) return NULL;
772 //Check if the function is set correctly
773 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
775 GEOMImpl_ISphere aCI (aFunction);
777 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
779 if (aRefPnt.IsNull()) return NULL;
781 aCI.SetPoint(aRefPnt);
784 //Compute the Sphere value
786 #if OCC_VERSION_LARGE > 0x06010000
789 if (!GetSolver()->ComputeFunction(aFunction)) {
790 SetErrorCode("Sphere driver failed");
794 catch (Standard_Failure) {
795 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
796 SetErrorCode(aFail->GetMessageString());
800 //Make a Python command
801 GEOM::TPythonDump(aFunction) << aSphere
802 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
809 //=============================================================================
813 //=============================================================================
814 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
815 (double theRMajor, double theRMinor)
819 //Add a new Torus object
820 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
822 //Add a new Torus function
823 Handle(GEOM_Function) aFunction =
824 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
825 if (aFunction.IsNull()) return NULL;
827 //Check if the function is set correctly
828 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
830 GEOMImpl_ITorus aCI (aFunction);
832 aCI.SetRMajor(theRMajor);
833 aCI.SetRMinor(theRMinor);
835 //Compute the Torus value
837 #if OCC_VERSION_LARGE > 0x06010000
840 if (!GetSolver()->ComputeFunction(aFunction)) {
841 SetErrorCode("Torus driver failed");
845 catch (Standard_Failure) {
846 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
847 SetErrorCode(aFail->GetMessageString());
851 //Make a Python command
852 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
853 << theRMajor << ", " << theRMinor << ")";
859 //=============================================================================
863 //=============================================================================
864 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
865 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
866 double theRMajor, double theRMinor)
870 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
872 //Add a new Torus object
873 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
875 //Add a new Torus function
876 Handle(GEOM_Function) aFunction =
877 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
878 if (aFunction.IsNull()) return NULL;
880 //Check if the function is set correctly
881 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
883 GEOMImpl_ITorus aCI (aFunction);
885 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
886 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
888 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
890 aCI.SetCenter(aRefPnt);
891 aCI.SetVector(aRefVec);
892 aCI.SetRMajor(theRMajor);
893 aCI.SetRMinor(theRMinor);
895 //Compute the Torus value
897 #if OCC_VERSION_LARGE > 0x06010000
900 if (!GetSolver()->ComputeFunction(aFunction)) {
901 SetErrorCode("Torus driver failed");
905 catch (Standard_Failure) {
906 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
907 SetErrorCode(aFail->GetMessageString());
911 //Make a Python command
912 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
913 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
920 //=============================================================================
924 //=============================================================================
925 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
926 Handle(GEOM_Object) theVec,
927 double theH, double theScaleFactor)
931 if (theBase.IsNull() || theVec.IsNull()) return NULL;
933 //Add a new Prism object
934 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
936 //Add a new Prism function for creation a Prism relatively to vector
937 Handle(GEOM_Function) aFunction =
938 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
939 if (aFunction.IsNull()) return NULL;
941 //Check if the function is set correctly
942 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
944 GEOMImpl_IPrism aCI (aFunction);
946 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
947 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
949 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
951 aCI.SetBase(aRefBase);
952 aCI.SetVector(aRefVec);
954 aCI.SetScale(theScaleFactor);
956 //Compute the Prism value
958 #if OCC_VERSION_LARGE > 0x06010000
961 if (!GetSolver()->ComputeFunction(aFunction)) {
962 //SetErrorCode("Prism driver failed");
963 SetErrorCode("Extrusion can not be created, check input data");
967 catch (Standard_Failure) {
968 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
969 SetErrorCode(aFail->GetMessageString());
973 //Make a Python command
974 GEOM::TPythonDump pd (aFunction);
975 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
976 if (theScaleFactor > Precision::Confusion())
977 pd << ", " << theScaleFactor << ")";
985 //=============================================================================
989 //=============================================================================
990 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
991 Handle(GEOM_Object) theVec,
996 if (theBase.IsNull() || theVec.IsNull()) return NULL;
998 //Add a new Prism object
999 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1001 //Add a new Prism function for creation a Prism relatively to vector
1002 Handle(GEOM_Function) aFunction =
1003 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1004 if (aFunction.IsNull()) return NULL;
1006 //Check if the function is set correctly
1007 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1009 GEOMImpl_IPrism aCI (aFunction);
1011 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1012 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1014 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1016 aCI.SetBase(aRefBase);
1017 aCI.SetVector(aRefVec);
1020 //Compute the Prism value
1022 #if OCC_VERSION_LARGE > 0x06010000
1025 if (!GetSolver()->ComputeFunction(aFunction)) {
1026 //SetErrorCode("Prism driver failed");
1027 SetErrorCode("Extrusion can not be created, check input data");
1031 catch (Standard_Failure) {
1032 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1033 SetErrorCode(aFail->GetMessageString());
1037 //Make a Python command
1038 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1039 << theBase << ", " << theVec << ", " << theH << ")";
1045 //=============================================================================
1049 //=============================================================================
1050 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1051 (Handle(GEOM_Object) theBase,
1052 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1053 double theScaleFactor)
1057 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1059 //Add a new Prism object
1060 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1062 //Add a new Prism function for creation a Prism relatively to two points
1063 Handle(GEOM_Function) aFunction =
1064 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1065 if (aFunction.IsNull()) return NULL;
1067 //Check if the function is set correctly
1068 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1070 GEOMImpl_IPrism aCI (aFunction);
1072 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1073 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1074 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1076 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1078 aCI.SetBase(aRefBase);
1079 aCI.SetFirstPoint(aRefPnt1);
1080 aCI.SetLastPoint(aRefPnt2);
1081 aCI.SetScale(theScaleFactor);
1083 //Compute the Prism value
1085 #if OCC_VERSION_LARGE > 0x06010000
1088 if (!GetSolver()->ComputeFunction(aFunction)) {
1089 //SetErrorCode("Prism driver failed");
1090 SetErrorCode("Extrusion can not be created, check input data");
1094 catch (Standard_Failure) {
1095 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1096 SetErrorCode(aFail->GetMessageString());
1100 //Make a Python command
1101 GEOM::TPythonDump pd (aFunction);
1102 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1103 if (theScaleFactor > Precision::Confusion())
1104 pd << ", " << theScaleFactor << ")";
1112 //=============================================================================
1114 * MakePrismTwoPnt2Ways
1116 //=============================================================================
1117 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1118 (Handle(GEOM_Object) theBase,
1119 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1123 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1125 //Add a new Prism object
1126 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1128 //Add a new Prism function for creation a Prism relatively to two points
1129 Handle(GEOM_Function) aFunction =
1130 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1131 if (aFunction.IsNull()) return NULL;
1133 //Check if the function is set correctly
1134 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1136 GEOMImpl_IPrism aCI (aFunction);
1138 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1139 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1140 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1142 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1144 aCI.SetBase(aRefBase);
1145 aCI.SetFirstPoint(aRefPnt1);
1146 aCI.SetLastPoint(aRefPnt2);
1148 //Compute the Prism value
1150 #if OCC_VERSION_LARGE > 0x06010000
1153 if (!GetSolver()->ComputeFunction(aFunction)) {
1154 //SetErrorCode("Prism driver failed");
1155 SetErrorCode("Extrusion can not be created, check input data");
1159 catch (Standard_Failure) {
1160 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1161 SetErrorCode(aFail->GetMessageString());
1165 //Make a Python command
1166 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1167 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1173 //=============================================================================
1177 //=============================================================================
1178 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1179 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1180 double theScaleFactor)
1184 if (theBase.IsNull()) return NULL;
1186 //Add a new Prism object
1187 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1189 //Add a new Prism function for creation a Prism by DXDYDZ
1190 Handle(GEOM_Function) aFunction =
1191 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1192 if (aFunction.IsNull()) return NULL;
1194 //Check if the function is set correctly
1195 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1197 GEOMImpl_IPrism aCI (aFunction);
1199 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1201 if (aRefBase.IsNull()) return NULL;
1203 aCI.SetBase(aRefBase);
1207 aCI.SetScale(theScaleFactor);
1209 //Compute the Prism value
1211 #if OCC_VERSION_LARGE > 0x06010000
1214 if (!GetSolver()->ComputeFunction(aFunction)) {
1215 SetErrorCode("Extrusion can not be created, check input data");
1219 catch (Standard_Failure) {
1220 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1221 SetErrorCode(aFail->GetMessageString());
1225 //Make a Python command
1226 GEOM::TPythonDump pd (aFunction);
1227 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1228 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1229 if (theScaleFactor > Precision::Confusion())
1230 pd << ", " << theScaleFactor << ")";
1238 //=============================================================================
1240 * MakePrismDXDYDZ_2WAYS
1242 //=============================================================================
1243 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1244 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1248 if (theBase.IsNull()) return NULL;
1250 //Add a new Prism object
1251 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1253 //Add a new Prism function for creation a Prism by DXDYDZ
1254 Handle(GEOM_Function) aFunction =
1255 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1256 if (aFunction.IsNull()) return NULL;
1258 //Check if the function is set correctly
1259 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1261 GEOMImpl_IPrism aCI (aFunction);
1263 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1265 if (aRefBase.IsNull()) return NULL;
1267 aCI.SetBase(aRefBase);
1272 //Compute the Prism value
1274 #if OCC_VERSION_LARGE > 0x06010000
1277 if (!GetSolver()->ComputeFunction(aFunction)) {
1278 SetErrorCode("Extrusion can not be created, check input data");
1282 catch (Standard_Failure) {
1283 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1284 SetErrorCode(aFail->GetMessageString());
1288 //Make a Python command
1289 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1290 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1296 //=============================================================================
1300 //=============================================================================
1301 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1302 Handle(GEOM_Object) thePath)
1306 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1308 //Add a new Pipe object
1309 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1311 //Add a new Pipe function
1312 Handle(GEOM_Function) aFunction =
1313 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1314 if (aFunction.IsNull()) return NULL;
1316 //Check if the function is set correctly
1317 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1319 GEOMImpl_IPipe aCI (aFunction);
1321 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1322 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1324 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1326 aCI.SetBase(aRefBase);
1327 aCI.SetPath(aRefPath);
1329 //Compute the Pipe value
1331 #if OCC_VERSION_LARGE > 0x06010000
1334 if (!GetSolver()->ComputeFunction(aFunction)) {
1335 SetErrorCode("Pipe driver failed");
1339 catch (Standard_Failure) {
1340 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1341 SetErrorCode(aFail->GetMessageString());
1345 //Make a Python command
1346 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1347 << theBase << ", " << thePath << ")";
1354 //=============================================================================
1356 * MakeRevolutionAxisAngle
1358 //=============================================================================
1359 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1360 Handle(GEOM_Object) theAxis,
1365 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1367 //Add a new Revolution object
1368 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1370 //Add a new Revolution function for creation a revolution relatively to axis
1371 Handle(GEOM_Function) aFunction =
1372 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1373 if (aFunction.IsNull()) return NULL;
1375 //Check if the function is set correctly
1376 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1378 GEOMImpl_IRevolution aCI (aFunction);
1380 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1381 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1383 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1385 aCI.SetBase(aRefBase);
1386 aCI.SetAxis(aRefAxis);
1387 aCI.SetAngle(theAngle);
1389 //Compute the Revolution value
1391 #if OCC_VERSION_LARGE > 0x06010000
1394 if (!GetSolver()->ComputeFunction(aFunction)) {
1395 SetErrorCode("Revolution driver failed");
1399 catch (Standard_Failure) {
1400 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1401 SetErrorCode(aFail->GetMessageString());
1405 //Make a Python command
1406 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1407 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1413 //=============================================================================
1415 * MakeRevolutionAxisAngle2Ways
1417 //=============================================================================
1418 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1419 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1423 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1425 //Add a new Revolution object
1426 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1428 //Add a new Revolution function for creation a revolution relatively to axis
1429 Handle(GEOM_Function) aFunction =
1430 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1431 if (aFunction.IsNull()) return NULL;
1433 //Check if the function is set correctly
1434 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1436 GEOMImpl_IRevolution aCI (aFunction);
1438 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1439 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1441 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1443 aCI.SetBase(aRefBase);
1444 aCI.SetAxis(aRefAxis);
1445 aCI.SetAngle(theAngle);
1447 //Compute the Revolution value
1449 #if OCC_VERSION_LARGE > 0x06010000
1452 if (!GetSolver()->ComputeFunction(aFunction)) {
1453 SetErrorCode("Revolution driver failed");
1457 catch (Standard_Failure) {
1458 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1459 SetErrorCode(aFail->GetMessageString());
1463 //Make a Python command
1464 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1465 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1471 //=============================================================================
1475 //=============================================================================
1476 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1477 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1478 double theTol2D, double theTol3D, int theNbIter,
1479 int theMethod, bool isApprox)
1483 if (theShape.IsNull()) return NULL;
1485 //Add a new Filling object
1486 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1488 //Add a new Filling function for creation a filling from a compound
1489 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1490 if (aFunction.IsNull()) return NULL;
1492 //Check if the function is set correctly
1493 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1495 GEOMImpl_IFilling aFI (aFunction);
1497 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1499 if (aRefShape.IsNull()) return NULL;
1501 aFI.SetShape(aRefShape);
1502 aFI.SetMinDeg(theMinDeg);
1503 aFI.SetMaxDeg(theMaxDeg);
1504 aFI.SetTol2D(theTol2D);
1505 aFI.SetTol3D(theTol3D);
1506 aFI.SetNbIter(theNbIter);
1507 aFI.SetApprox(isApprox);
1508 aFI.SetMethod(theMethod);
1510 //Compute the Solid value
1512 #if OCC_VERSION_LARGE > 0x06010000
1515 if (!GetSolver()->ComputeFunction(aFunction)) {
1516 SetErrorCode("Filling driver failed");
1520 catch (Standard_Failure) {
1521 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1522 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1523 SetErrorCode("B-Spline surface construction failed");
1525 SetErrorCode(aFail->GetMessageString());
1529 //Make a Python command
1530 GEOM::TPythonDump pd (aFunction);
1531 pd << aFilling << " = geompy.MakeFilling("
1532 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1533 << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
1534 if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
1535 else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
1536 else pd << "GEOM.FOM_Default";
1538 pd << ", " << isApprox ;
1545 //=============================================================================
1549 //=============================================================================
1550 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1551 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1556 Handle(GEOM_Object) anObj;
1558 if(theSeqSections.IsNull())
1561 Standard_Integer nbObj = theSeqSections->Length();
1565 //Add a new ThruSections object
1566 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1569 //Add a new ThruSections function
1571 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1572 Handle(GEOM_Function) aFunction =
1573 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1574 if (aFunction.IsNull()) return anObj;
1576 //Check if the function is set correctly
1577 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1579 GEOMImpl_IThruSections aCI (aFunction);
1581 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1583 Standard_Integer i =1;
1584 for( ; i <= nbObj; i++) {
1586 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1590 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1591 if(!aSectObj.IsNull())
1593 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1594 if(!aRefSect.IsNull())
1595 aSeqSections->Append(aRefSect);
1599 if(!aSeqSections->Length())
1602 aCI.SetSections(aSeqSections);
1603 aCI.SetSolidMode(theModeSolid);
1604 aCI.SetPrecision(thePreci);
1606 //Compute the ThruSections value
1608 #if OCC_VERSION_LARGE > 0x06010000
1611 if (!GetSolver()->ComputeFunction(aFunction)) {
1612 SetErrorCode("ThruSections driver failed");
1616 catch (Standard_Failure) {
1617 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1618 SetErrorCode(aFail->GetMessageString());
1622 //Make a Python command
1623 GEOM::TPythonDump pyDump(aFunction);
1624 pyDump << aThruSect << " = geompy.MakeThruSections([";
1626 for(i =1 ; i <= nbObj; i++) {
1628 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1632 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1633 if(!aSectObj.IsNull()) {
1640 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1647 //=============================================================================
1649 * MakePipeWithDifferentSections
1651 //=============================================================================
1652 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1653 const Handle(TColStd_HSequenceOfTransient)& theBases,
1654 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1655 const Handle(GEOM_Object)& thePath,
1656 bool theWithContact,
1657 bool theWithCorrections)
1659 Handle(GEOM_Object) anObj;
1661 if(theBases.IsNull())
1664 Standard_Integer nbBases = theBases->Length();
1669 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1670 //Add a new Pipe object
1671 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1673 //Add a new Pipe function
1675 Handle(GEOM_Function) aFunction =
1676 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1677 if (aFunction.IsNull()) return anObj;
1679 //Check if the function is set correctly
1680 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1682 GEOMImpl_IPipeDiffSect aCI (aFunction);
1684 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1685 if(aRefPath.IsNull())
1688 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1689 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1691 Standard_Integer i =1;
1692 for( ; i <= nbBases; i++) {
1694 Handle(Standard_Transient) anItem = theBases->Value(i);
1698 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1701 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1702 if(aRefBase.IsNull())
1706 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1707 if(anItemLoc.IsNull())
1710 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1713 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1714 if(aRefLoc.IsNull())
1716 aSeqLocs->Append(aRefLoc);
1718 aSeqBases->Append(aRefBase);
1721 if(!aSeqBases->Length())
1724 aCI.SetBases(aSeqBases);
1725 aCI.SetLocations(aSeqLocs);
1726 aCI.SetPath(aRefPath);
1727 aCI.SetWithContactMode(theWithContact);
1728 aCI.SetWithCorrectionMode(theWithCorrections);
1730 //Compute the Pipe value
1732 #if OCC_VERSION_LARGE > 0x06010000
1735 if (!GetSolver()->ComputeFunction(aFunction)) {
1736 SetErrorCode("Pipe with defferent section driver failed");
1740 catch (Standard_Failure) {
1741 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1742 SetErrorCode(aFail->GetMessageString());
1746 //Make a Python command
1747 GEOM::TPythonDump pyDump(aFunction);
1748 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1750 for(i =1 ; i <= nbBases; i++) {
1752 Handle(Standard_Transient) anItem = theBases->Value(i);
1756 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1757 if(!anObj.IsNull()) {
1766 for(i =1 ; i <= nbLocs; i++) {
1768 Handle(Standard_Transient) anItem = theLocations->Value(i);
1772 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1773 if(!anObj.IsNull()) {
1780 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1787 //=============================================================================
1789 * MakePipeWithShellSections
1791 //=============================================================================
1792 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1793 const Handle(TColStd_HSequenceOfTransient)& theBases,
1794 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1795 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1796 const Handle(GEOM_Object)& thePath,
1797 bool theWithContact,
1798 bool theWithCorrections)
1800 Handle(GEOM_Object) anObj;
1802 if(theBases.IsNull())
1805 Standard_Integer nbBases = theBases->Length();
1810 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1812 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1814 //Add a new Pipe object
1815 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1817 //Add a new Pipe function
1819 Handle(GEOM_Function) aFunction =
1820 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1821 if (aFunction.IsNull()) return anObj;
1823 //Check if the function is set correctly
1824 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1826 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1827 GEOMImpl_IPipeShellSect aCI (aFunction);
1829 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1830 if(aRefPath.IsNull())
1833 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1834 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1835 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1837 Standard_Integer i =1;
1838 for( ; i <= nbBases; i++) {
1840 Handle(Standard_Transient) anItem = theBases->Value(i);
1843 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1846 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1847 if(aRefBase.IsNull())
1850 if( nbSubBases >= nbBases ) {
1851 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1852 if(aSubItem.IsNull())
1854 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1855 if(aSubBase.IsNull())
1857 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1858 if(aRefSubBase.IsNull())
1860 aSeqSubBases->Append(aRefSubBase);
1864 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1865 if(anItemLoc.IsNull())
1867 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1870 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1871 if(aRefLoc.IsNull())
1873 aSeqLocs->Append(aRefLoc);
1876 aSeqBases->Append(aRefBase);
1879 if(!aSeqBases->Length())
1882 aCI.SetBases(aSeqBases);
1883 aCI.SetSubBases(aSeqSubBases);
1884 aCI.SetLocations(aSeqLocs);
1885 aCI.SetPath(aRefPath);
1886 aCI.SetWithContactMode(theWithContact);
1887 aCI.SetWithCorrectionMode(theWithCorrections);
1889 //Compute the Pipe value
1891 #if OCC_VERSION_LARGE > 0x06010000
1894 if (!GetSolver()->ComputeFunction(aFunction)) {
1895 SetErrorCode("Pipe with shell sections driver failed");
1899 catch (Standard_Failure) {
1900 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1901 SetErrorCode(aFail->GetMessageString());
1905 //Make a Python command
1906 GEOM::TPythonDump pyDump(aFunction);
1907 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1909 for(i =1 ; i <= nbBases; i++) {
1911 Handle(Standard_Transient) anItem = theBases->Value(i);
1915 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1916 if(!anObj.IsNull()) {
1925 for(i =1 ; i <= nbSubBases; i++) {
1927 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1931 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1932 if(!anObj.IsNull()) {
1941 for(i =1 ; i <= nbLocs; i++) {
1943 Handle(Standard_Transient) anItem = theLocations->Value(i);
1947 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1948 if(!anObj.IsNull()) {
1955 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1963 //=============================================================================
1965 * MakePipeShellsWithoutPath
1967 //=============================================================================
1968 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1969 const Handle(TColStd_HSequenceOfTransient)& theBases,
1970 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1972 Handle(GEOM_Object) anObj;
1974 if(theBases.IsNull())
1977 Standard_Integer nbBases = theBases->Length();
1982 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1984 //Add a new Pipe object
1985 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1987 //Add a new Pipe function
1989 Handle(GEOM_Function) aFunction =
1990 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1991 if (aFunction.IsNull()) return anObj;
1993 //Check if the function is set correctly
1994 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1996 GEOMImpl_IPipeShellSect aCI (aFunction);
1998 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1999 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2001 Standard_Integer i =1;
2002 for( ; i <= nbBases; i++) {
2004 Handle(Standard_Transient) anItem = theBases->Value(i);
2007 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2010 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2011 if(aRefBase.IsNull())
2015 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2016 if(anItemLoc.IsNull())
2018 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2021 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2022 if(aRefLoc.IsNull())
2024 aSeqLocs->Append(aRefLoc);
2027 aSeqBases->Append(aRefBase);
2030 if(!aSeqBases->Length())
2033 aCI.SetBases(aSeqBases);
2034 aCI.SetLocations(aSeqLocs);
2036 //Compute the Pipe value
2038 #if OCC_VERSION_LARGE > 0x06010000
2041 if (!GetSolver()->ComputeFunction(aFunction)) {
2042 SetErrorCode("Pipe with shell sections without path driver failed");
2046 catch (Standard_Failure) {
2047 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2048 SetErrorCode(aFail->GetMessageString());
2052 //Make a Python command
2053 GEOM::TPythonDump pyDump(aFunction);
2054 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2056 for(i =1 ; i <= nbBases; i++) {
2058 Handle(Standard_Transient) anItem = theBases->Value(i);
2062 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2063 if(!anObj.IsNull()) {
2072 for(i =1 ; i <= nbLocs; i++) {
2074 Handle(Standard_Transient) anItem = theLocations->Value(i);
2078 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2079 if(!anObj.IsNull()) {
2094 //=============================================================================
2096 * MakePipeBiNormalAlongVector
2098 //=============================================================================
2099 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2100 Handle(GEOM_Object) thePath,
2101 Handle(GEOM_Object) theVec)
2105 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2107 //Add a new Pipe object
2108 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2110 //Add a new Pipe function
2111 Handle(GEOM_Function) aFunction =
2112 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2113 if (aFunction.IsNull()) return NULL;
2115 //Check if the function is set correctly
2116 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2118 GEOMImpl_IPipeBiNormal aCI (aFunction);
2120 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2121 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2122 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2124 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2126 aCI.SetBase(aRefBase);
2127 aCI.SetPath(aRefPath);
2128 aCI.SetVector(aRefVec);
2130 //Compute the Pipe value
2132 #if OCC_VERSION_LARGE > 0x06010000
2135 if (!GetSolver()->ComputeFunction(aFunction)) {
2136 SetErrorCode("Pipe driver failed");
2140 catch (Standard_Failure) {
2141 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2142 SetErrorCode(aFail->GetMessageString());
2146 //Make a Python command
2147 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2148 << theBase << ", " << thePath << ", " << theVec << ")";