1 // Copyright (C) 2007-2019 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, or (at your option) any later version.
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 <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_Types.hxx>
40 #include <GEOMImpl_BoxDriver.hxx>
41 #include <GEOMImpl_FaceDriver.hxx>
42 #include <GEOMImpl_DiskDriver.hxx>
43 #include <GEOMImpl_CylinderDriver.hxx>
44 #include <GEOMImpl_ConeDriver.hxx>
45 #include <GEOMImpl_SphereDriver.hxx>
46 #include <GEOMImpl_TorusDriver.hxx>
47 #include <GEOMImpl_PrismDriver.hxx>
48 #include <GEOMImpl_PipeDriver.hxx>
49 #include <GEOMImpl_PipePathDriver.hxx>
50 #include <GEOMImpl_RevolutionDriver.hxx>
51 #include <GEOMImpl_ShapeDriver.hxx>
52 #include <GEOMImpl_FillingDriver.hxx>
53 #include <GEOMImpl_ThruSectionsDriver.hxx>
54 #include <GEOMImpl_OffsetDriver.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_IGroupOperations.hxx>
62 #include <GEOMImpl_ISphere.hxx>
63 #include <GEOMImpl_ITorus.hxx>
64 #include <GEOMImpl_IPrism.hxx>
65 #include <GEOMImpl_IPipe.hxx>
66 #include <GEOMImpl_IRevolution.hxx>
67 #include <GEOMImpl_IFilling.hxx>
68 #include <GEOMImpl_IThruSections.hxx>
69 #include <GEOMImpl_IPipeDiffSect.hxx>
70 #include <GEOMImpl_IPipeShellSect.hxx>
71 #include <GEOMImpl_IPipeBiNormal.hxx>
72 #include <GEOMImpl_IOffset.hxx>
73 #include <GEOMImpl_IPipePath.hxx>
75 #include <Precision.hxx>
78 #include <Standard_Failure.hxx>
79 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
81 //=============================================================================
85 //=============================================================================
86 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine)
87 : GEOM_IOperations(theEngine)
89 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
90 myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine());
93 //=============================================================================
97 //=============================================================================
98 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
100 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
101 delete myGroupOperations;
105 //=============================================================================
109 //=============================================================================
110 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
114 //Add a new Box object
115 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GEOM_BOX);
117 //Add a new Box function with DX_DY_DZ parameters
118 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
119 if (aFunction.IsNull()) return NULL;
121 //Check if the function is set correctly
122 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
124 GEOMImpl_IBox aBI (aFunction);
130 //Compute the box value
133 if (!GetSolver()->ComputeFunction(aFunction)) {
134 SetErrorCode("Box driver failed");
138 catch (Standard_Failure& aFail) {
139 SetErrorCode(aFail.GetMessageString());
143 //Make a Python command
144 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
145 << theDX << ", " << theDY << ", " << theDZ << ")";
152 //=============================================================================
156 //=============================================================================
157 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
158 Handle(GEOM_Object) thePnt2)
162 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
164 //Add a new Box object
165 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GEOM_BOX);
167 //Add a new Box function for creation a box relatively to two points
168 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
169 if (aFunction.IsNull()) return NULL;
171 //Check if the function is set correctly
172 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
174 GEOMImpl_IBox aBI (aFunction);
176 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
177 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
179 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
181 aBI.SetRef1(aRefFunction1);
182 aBI.SetRef2(aRefFunction2);
184 //Compute the Box value
187 if (!GetSolver()->ComputeFunction(aFunction)) {
188 SetErrorCode("Box driver failed");
192 catch (Standard_Failure& aFail) {
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(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);
235 if (!GetSolver()->ComputeFunction(aFunction)) {
236 SetErrorCode("Face driver failed");
240 catch (Standard_Failure& aFail) {
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(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);
289 if (!GetSolver()->ComputeFunction(aFunction)) {
290 SetErrorCode("Face driver failed");
294 catch (Standard_Failure& aFail) {
295 SetErrorCode(aFail.GetMessageString());
299 //Make a Python command
300 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
301 << theObj << ", " << theH << ", " << theW << ")";
307 //=============================================================================
311 //=============================================================================
312 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
313 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
317 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
319 //Add a new Disk object
320 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GEOM_FACE);
322 //Add a new Disk function for creation a disk relatively to point and vector
323 Handle(GEOM_Function) aFunction =
324 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
325 if (aFunction.IsNull()) return NULL;
327 //Check if the function is set correctly
328 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
330 GEOMImpl_IDisk aCI (aFunction);
332 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
333 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
335 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
337 aCI.SetCenter(aRefPnt);
338 aCI.SetVector(aRefVec);
341 //Compute the Disk value
344 if (!GetSolver()->ComputeFunction(aFunction)) {
345 SetErrorCode("Disk driver failed");
349 catch (Standard_Failure& aFail) {
350 SetErrorCode(aFail.GetMessageString());
354 //Make a Python command
355 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
356 << thePnt << ", " << theVec << ", " << theR << ")";
362 //=============================================================================
366 //=============================================================================
367 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
368 Handle(GEOM_Object) thePnt2,
369 Handle(GEOM_Object) thePnt3)
373 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
375 //Add a new Disk object
376 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GEOM_FACE);
378 //Add a new Disk function for creation a disk relatively to three points
379 Handle(GEOM_Function) aFunction =
380 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
381 if (aFunction.IsNull()) return NULL;
383 //Check if the function is set correctly
384 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
386 GEOMImpl_IDisk aCI (aFunction);
388 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
389 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
390 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
392 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
394 aCI.SetPoint1(aRefPnt1);
395 aCI.SetPoint2(aRefPnt2);
396 aCI.SetPoint3(aRefPnt3);
398 //Compute the Disk value
401 if (!GetSolver()->ComputeFunction(aFunction)) {
402 SetErrorCode("Disk driver failed");
406 catch (Standard_Failure& aFail) {
407 SetErrorCode(aFail.GetMessageString());
411 //Make a Python command
412 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
413 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
419 //=============================================================================
423 //=============================================================================
424 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
428 if (theR == 0 ) return NULL;
430 //Add a new Disk object
431 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GEOM_FACE);
433 //Add a new Box function for creation a box relatively to two points
434 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
435 if (aFunction.IsNull()) return NULL;
437 //Check if the function is set correctly
438 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
440 GEOMImpl_IDisk aDI (aFunction);
443 aDI.SetOrientation(theOrientation);
448 if (!GetSolver()->ComputeFunction(aFunction)) {
449 SetErrorCode("Disk driver failed");
453 catch (Standard_Failure& aFail) {
454 SetErrorCode(aFail.GetMessageString());
458 //Make a Python command
459 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
460 << theR << ", " << theOrientation << ")";
466 //=============================================================================
470 //=============================================================================
471 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
475 //Add a new Cylinder object
476 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
478 //Add a new Cylinder function with R and H parameters
479 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
480 if (aFunction.IsNull()) return NULL;
482 //Check if the function is set correctly
483 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
485 GEOMImpl_ICylinder aCI (aFunction);
490 //Compute the Cylinder value
493 if (!GetSolver()->ComputeFunction(aFunction)) {
494 SetErrorCode("Cylinder driver failed");
498 catch (Standard_Failure& aFail) {
499 SetErrorCode(aFail.GetMessageString());
503 //Make a Python command
504 GEOM::TPythonDump(aFunction) << aCylinder
505 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
511 //=============================================================================
515 //=============================================================================
516 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
520 //Add a new Cylinder object
521 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
523 //Add a new Cylinder function with R and H parameters
524 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
525 if (aFunction.IsNull()) return NULL;
527 //Check if the function is set correctly
528 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
530 GEOMImpl_ICylinder aCI (aFunction);
536 //Compute the Cylinder value
539 if (!GetSolver()->ComputeFunction(aFunction)) {
540 SetErrorCode("Cylinder driver failed");
544 catch (Standard_Failure& aFail) {
545 SetErrorCode(aFail.GetMessageString());
549 //Make a Python command
550 GEOM::TPythonDump(aFunction) << aCylinder
551 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
557 //=============================================================================
559 * MakeCylinderPntVecRH
561 //=============================================================================
562 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
563 Handle(GEOM_Object) theVec,
564 double theR, double theH)
568 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
570 //Add a new Cylinder object
571 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
573 //Add a new Cylinder function for creation a cylinder relatively to point and vector
574 Handle(GEOM_Function) aFunction =
575 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
576 if (aFunction.IsNull()) return NULL;
578 //Check if the function is set correctly
579 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
581 GEOMImpl_ICylinder aCI (aFunction);
583 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
584 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
586 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
588 aCI.SetPoint(aRefPnt);
589 aCI.SetVector(aRefVec);
593 //Compute the Cylinder value
596 if (!GetSolver()->ComputeFunction(aFunction)) {
597 SetErrorCode("Cylinder driver failed");
601 catch (Standard_Failure& aFail) {
602 SetErrorCode(aFail.GetMessageString());
606 //Make a Python command
607 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
608 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
614 //=============================================================================
616 * MakeCylinderPntVecRHA
618 //=============================================================================
619 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
620 Handle(GEOM_Object) theVec,
621 double theR, double theH, double theA)
625 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
627 //Add a new Cylinder object
628 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
630 //Add a new Cylinder function for creation a cylinder relatively to point and vector
631 Handle(GEOM_Function) aFunction =
632 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
633 if (aFunction.IsNull()) return NULL;
635 //Check if the function is set correctly
636 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
638 GEOMImpl_ICylinder aCI (aFunction);
640 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
641 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
643 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
645 aCI.SetPoint(aRefPnt);
646 aCI.SetVector(aRefVec);
651 //Compute the Cylinder value
654 if (!GetSolver()->ComputeFunction(aFunction)) {
655 SetErrorCode("Cylinder driver failed");
659 catch (Standard_Failure& aFail) {
660 SetErrorCode(aFail.GetMessageString());
664 //Make a Python command
665 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
666 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
673 //=============================================================================
677 //=============================================================================
678 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
683 //Add a new Cone object
684 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GEOM_CONE);
686 //Add a new Cone function with R and H parameters
687 Handle(GEOM_Function) aFunction =
688 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
689 if (aFunction.IsNull()) return NULL;
691 //Check if the function is set correctly
692 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
694 GEOMImpl_ICone aCI (aFunction);
700 //Compute the Cone value
703 if (!GetSolver()->ComputeFunction(aFunction)) {
704 SetErrorCode("Cone driver failed");
708 catch (Standard_Failure& aFail) {
709 SetErrorCode(aFail.GetMessageString());
713 //Make a Python command
714 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
715 << theR1 << ", " << theR2 << ", " << theH << ")";
722 //=============================================================================
724 * MakeConePntVecR1R2H
726 //=============================================================================
727 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
728 Handle(GEOM_Object) theVec,
729 double theR1, double theR2,
734 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
736 //Add a new Cone object
737 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GEOM_CONE);
739 //Add a new Cone function for creation a cone relatively to point and vector
740 Handle(GEOM_Function) aFunction =
741 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
742 if (aFunction.IsNull()) return NULL;
744 //Check if the function is set correctly
745 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
747 GEOMImpl_ICone aCI (aFunction);
749 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
750 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
752 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
754 aCI.SetPoint(aRefPnt);
755 aCI.SetVector(aRefVec);
760 //Compute the Cone value
763 if (!GetSolver()->ComputeFunction(aFunction)) {
764 SetErrorCode("Cone driver failed");
768 catch (Standard_Failure& aFail) {
769 SetErrorCode(aFail.GetMessageString());
773 //Make a Python command
774 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
775 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
782 //=============================================================================
786 //=============================================================================
787 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
791 //Add a new Sphere object
792 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GEOM_SPHERE);
794 //Add a new Sphere function with R parameter
795 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
796 if (aFunction.IsNull()) return NULL;
798 //Check if the function is set correctly
799 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
801 GEOMImpl_ISphere aCI (aFunction);
805 //Compute the Sphere value
808 if (!GetSolver()->ComputeFunction(aFunction)) {
809 SetErrorCode("Sphere driver failed");
813 catch (Standard_Failure& aFail) {
814 SetErrorCode(aFail.GetMessageString());
818 //Make a Python command
819 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
826 //=============================================================================
830 //=============================================================================
831 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
836 if (thePnt.IsNull()) return NULL;
838 //Add a new Point object
839 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GEOM_SPHERE);
841 //Add a new Sphere function for creation a sphere relatively to point
842 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
843 if (aFunction.IsNull()) return NULL;
845 //Check if the function is set correctly
846 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
848 GEOMImpl_ISphere aCI (aFunction);
850 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
852 if (aRefPnt.IsNull()) return NULL;
854 aCI.SetPoint(aRefPnt);
857 //Compute the Sphere value
860 if (!GetSolver()->ComputeFunction(aFunction)) {
861 SetErrorCode("Sphere driver failed");
865 catch (Standard_Failure& aFail) {
866 SetErrorCode(aFail.GetMessageString());
870 //Make a Python command
871 GEOM::TPythonDump(aFunction) << aSphere
872 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
879 //=============================================================================
883 //=============================================================================
884 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
885 (double theRMajor, double theRMinor)
889 //Add a new Torus object
890 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GEOM_TORUS);
892 //Add a new Torus function
893 Handle(GEOM_Function) aFunction =
894 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
895 if (aFunction.IsNull()) return NULL;
897 //Check if the function is set correctly
898 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
900 GEOMImpl_ITorus aCI (aFunction);
902 aCI.SetRMajor(theRMajor);
903 aCI.SetRMinor(theRMinor);
905 //Compute the Torus value
908 if (!GetSolver()->ComputeFunction(aFunction)) {
909 SetErrorCode("Torus driver failed");
913 catch (Standard_Failure& aFail) {
914 SetErrorCode(aFail.GetMessageString());
918 //Make a Python command
919 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
920 << theRMajor << ", " << theRMinor << ")";
926 //=============================================================================
930 //=============================================================================
931 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
932 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
933 double theRMajor, double theRMinor)
937 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
939 //Add a new Torus object
940 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GEOM_TORUS);
942 //Add a new Torus function
943 Handle(GEOM_Function) aFunction =
944 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
945 if (aFunction.IsNull()) return NULL;
947 //Check if the function is set correctly
948 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
950 GEOMImpl_ITorus aCI (aFunction);
952 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
953 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
955 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
957 aCI.SetCenter(aRefPnt);
958 aCI.SetVector(aRefVec);
959 aCI.SetRMajor(theRMajor);
960 aCI.SetRMinor(theRMinor);
962 //Compute the Torus value
965 if (!GetSolver()->ComputeFunction(aFunction)) {
966 SetErrorCode("Torus driver failed");
970 catch (Standard_Failure& aFail) {
971 SetErrorCode(aFail.GetMessageString());
975 //Make a Python command
976 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
977 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
984 //=============================================================================
988 //=============================================================================
989 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
990 Handle(GEOM_Object) theVec,
991 double theH, double theScaleFactor)
995 if (theBase.IsNull() || theVec.IsNull()) return NULL;
997 //Add a new Prism object
998 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1000 //Add a new Prism function for creation a Prism relatively to vector
1001 Handle(GEOM_Function) aFunction =
1002 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1003 if (aFunction.IsNull()) return NULL;
1005 //Check if the function is set correctly
1006 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1008 GEOMImpl_IPrism aCI (aFunction);
1010 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1011 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1013 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1015 aCI.SetBase(aRefBase);
1016 aCI.SetVector(aRefVec);
1018 aCI.SetScale(theScaleFactor);
1020 //Compute the Prism value
1023 if (!GetSolver()->ComputeFunction(aFunction)) {
1024 //SetErrorCode("Prism driver failed");
1025 SetErrorCode("Extrusion can not be created, check input data");
1029 catch (Standard_Failure& aFail) {
1030 SetErrorCode(aFail.GetMessageString());
1034 //Make a Python command
1035 GEOM::TPythonDump pd (aFunction);
1036 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1037 if (theScaleFactor > Precision::Confusion())
1038 pd << ", " << theScaleFactor << ")";
1046 //=============================================================================
1048 * MakePrismVecH2Ways
1050 //=============================================================================
1051 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1052 Handle(GEOM_Object) theVec,
1057 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1059 //Add a new Prism object
1060 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1062 //Add a new Prism function for creation a Prism relatively to vector
1063 Handle(GEOM_Function) aFunction =
1064 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
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) aRefVec = theVec->GetLastFunction();
1075 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1077 aCI.SetBase(aRefBase);
1078 aCI.SetVector(aRefVec);
1081 //Compute the Prism value
1084 if (!GetSolver()->ComputeFunction(aFunction)) {
1085 //SetErrorCode("Prism driver failed");
1086 SetErrorCode("Extrusion can not be created, check input data");
1090 catch (Standard_Failure& aFail) {
1091 SetErrorCode(aFail.GetMessageString());
1095 //Make a Python command
1096 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1097 << theBase << ", " << theVec << ", " << theH << ")";
1103 //=============================================================================
1107 //=============================================================================
1108 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1109 (Handle(GEOM_Object) theBase,
1110 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1111 double theScaleFactor)
1115 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1117 //Add a new Prism object
1118 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1120 //Add a new Prism function for creation a Prism relatively to two points
1121 Handle(GEOM_Function) aFunction =
1122 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1123 if (aFunction.IsNull()) return NULL;
1125 //Check if the function is set correctly
1126 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1128 GEOMImpl_IPrism aCI (aFunction);
1130 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1131 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1132 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1134 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1136 aCI.SetBase(aRefBase);
1137 aCI.SetFirstPoint(aRefPnt1);
1138 aCI.SetLastPoint(aRefPnt2);
1139 aCI.SetScale(theScaleFactor);
1141 //Compute the Prism value
1144 if (!GetSolver()->ComputeFunction(aFunction)) {
1145 //SetErrorCode("Prism driver failed");
1146 SetErrorCode("Extrusion can not be created, check input data");
1150 catch (Standard_Failure& aFail) {
1151 SetErrorCode(aFail.GetMessageString());
1155 //Make a Python command
1156 GEOM::TPythonDump pd (aFunction);
1157 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1158 if (theScaleFactor > Precision::Confusion())
1159 pd << ", " << theScaleFactor << ")";
1167 //=============================================================================
1169 * MakePrismTwoPnt2Ways
1171 //=============================================================================
1172 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1173 (Handle(GEOM_Object) theBase,
1174 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1178 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1180 //Add a new Prism object
1181 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1183 //Add a new Prism function for creation a Prism relatively to two points
1184 Handle(GEOM_Function) aFunction =
1185 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1186 if (aFunction.IsNull()) return NULL;
1188 //Check if the function is set correctly
1189 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1191 GEOMImpl_IPrism aCI (aFunction);
1193 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1194 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1195 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1197 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1199 aCI.SetBase(aRefBase);
1200 aCI.SetFirstPoint(aRefPnt1);
1201 aCI.SetLastPoint(aRefPnt2);
1203 //Compute the Prism value
1206 if (!GetSolver()->ComputeFunction(aFunction)) {
1207 //SetErrorCode("Prism driver failed");
1208 SetErrorCode("Extrusion can not be created, check input data");
1212 catch (Standard_Failure& aFail) {
1213 SetErrorCode(aFail.GetMessageString());
1217 //Make a Python command
1218 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1219 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1225 //=============================================================================
1229 //=============================================================================
1230 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1231 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1232 double theScaleFactor)
1236 if (theBase.IsNull()) return NULL;
1238 //Add a new Prism object
1239 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1241 //Add a new Prism function for creation a Prism by DXDYDZ
1242 Handle(GEOM_Function) aFunction =
1243 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1244 if (aFunction.IsNull()) return NULL;
1246 //Check if the function is set correctly
1247 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1249 GEOMImpl_IPrism aCI (aFunction);
1251 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1253 if (aRefBase.IsNull()) return NULL;
1255 aCI.SetBase(aRefBase);
1259 aCI.SetScale(theScaleFactor);
1261 //Compute the Prism value
1264 if (!GetSolver()->ComputeFunction(aFunction)) {
1265 SetErrorCode("Extrusion can not be created, check input data");
1269 catch (Standard_Failure& aFail) {
1270 SetErrorCode(aFail.GetMessageString());
1274 //Make a Python command
1275 GEOM::TPythonDump pd (aFunction);
1276 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1277 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1278 if (theScaleFactor > Precision::Confusion())
1279 pd << ", " << theScaleFactor << ")";
1287 //=============================================================================
1289 * MakePrismDXDYDZ_2WAYS
1291 //=============================================================================
1292 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1293 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1297 if (theBase.IsNull()) return NULL;
1299 //Add a new Prism object
1300 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1302 //Add a new Prism function for creation a Prism by DXDYDZ
1303 Handle(GEOM_Function) aFunction =
1304 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1305 if (aFunction.IsNull()) return NULL;
1307 //Check if the function is set correctly
1308 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1310 GEOMImpl_IPrism aCI (aFunction);
1312 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1314 if (aRefBase.IsNull()) return NULL;
1316 aCI.SetBase(aRefBase);
1321 //Compute the Prism value
1324 if (!GetSolver()->ComputeFunction(aFunction)) {
1325 SetErrorCode("Extrusion can not be created, check input data");
1329 catch (Standard_Failure& aFail) {
1330 SetErrorCode(aFail.GetMessageString());
1334 //Make a Python command
1335 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1336 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1342 //=============================================================================
1346 //=============================================================================
1347 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1348 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse, bool theInvert)
1352 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1354 Handle(GEOM_Object) aPrism = NULL;
1358 //Add a new Extruded Boss object
1359 aPrism = GetEngine()->AddObject(GEOM_EXTRUDED_BOSS);
1363 //Add a new Extruded Cut object
1364 aPrism = GetEngine()->AddObject(GEOM_EXTRUDED_CUT);
1367 //Add a new Prism function for the creation of a Draft Prism feature
1368 Handle(GEOM_Function) aFunction =
1369 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1370 if (aFunction.IsNull()) return NULL;
1372 //Check if the function is set correctly
1373 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1375 GEOMImpl_IPrism aCI (aFunction);
1377 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1378 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1380 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1383 aCI.SetBase(aRefBase);
1384 aCI.SetInitShape(aRefInit);
1385 aCI.SetH(theHeight);
1386 aCI.SetDraftAngle(theAngle);
1391 aCI.SetInvertFlag(theInvert);
1393 //Compute the Draft Prism Feature value
1396 if (!GetSolver()->ComputeFunction(aFunction)) {
1397 SetErrorCode("Extrusion can not be created, check input data");
1401 catch (Standard_Failure& aFail) {
1402 SetErrorCode(aFail.GetMessageString());
1406 //Make a Python command
1407 GEOM::TPythonDump pd (aFunction);
1410 pd << aPrism << " = geompy.MakeExtrudedBoss(" << theInitShape << ", " << theBase << ", "
1411 << theHeight << ", " << theAngle;
1415 pd << aPrism << " = geompy.MakeExtrudedCut(" << theInitShape << ", " << theBase << ", "
1416 << theHeight << ", " << theAngle;
1419 pd << ", " << theInvert;
1426 //=============================================================================
1430 //=============================================================================
1431 Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
1432 (const Handle(GEOM_Object) &theBase,
1433 const Handle(GEOM_Object) &thePath,
1434 const bool IsGenerateGroups)
1438 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1440 //Add a new Pipe object
1441 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GEOM_PIPE);
1443 //Add a new Pipe function
1444 Handle(GEOM_Function) aFunction =
1445 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1446 if (aFunction.IsNull()) return NULL;
1448 //Check if the function is set correctly
1449 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1451 GEOMImpl_IPipe aCI (aFunction);
1453 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1454 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1456 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1458 aCI.SetBase(aRefBase);
1459 aCI.SetPath(aRefPath);
1460 aCI.SetGenerateGroups(IsGenerateGroups);
1462 //Compute the Pipe value
1465 if (!GetSolver()->ComputeFunction(aFunction)) {
1466 SetErrorCode("Pipe driver failed");
1470 catch (Standard_Failure& aFail) {
1471 SetErrorCode(aFail.GetMessageString());
1475 // Create the sequence of objects.
1476 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1478 aSeq->Append(aPipe);
1479 createGroups(aPipe, &aCI, aSeq);
1481 //Make a Python command
1482 GEOM::TPythonDump pyDump(aFunction);
1484 if (IsGenerateGroups) {
1490 pyDump << " = geompy.MakePipe(" << theBase << ", " << thePath;
1492 if (IsGenerateGroups) {
1503 //=============================================================================
1505 * MakeRevolutionAxisAngle
1507 //=============================================================================
1508 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1509 Handle(GEOM_Object) theAxis,
1514 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1516 //Add a new Revolution object
1517 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GEOM_REVOLUTION);
1519 //Add a new Revolution function for creation a revolution relatively to axis
1520 Handle(GEOM_Function) aFunction =
1521 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1522 if (aFunction.IsNull()) return NULL;
1524 //Check if the function is set correctly
1525 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1527 GEOMImpl_IRevolution aCI (aFunction);
1529 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1530 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1532 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1534 aCI.SetBase(aRefBase);
1535 aCI.SetAxis(aRefAxis);
1536 aCI.SetAngle(theAngle);
1538 //Compute the Revolution value
1541 if (!GetSolver()->ComputeFunction(aFunction)) {
1542 SetErrorCode("Revolution driver failed");
1546 catch (Standard_Failure& aFail) {
1547 SetErrorCode(aFail.GetMessageString());
1551 //Make a Python command
1552 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1553 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1559 //=============================================================================
1561 * MakeRevolutionAxisAngle2Ways
1563 //=============================================================================
1564 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1565 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1569 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1571 //Add a new Revolution object
1572 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GEOM_REVOLUTION);
1574 //Add a new Revolution function for creation a revolution relatively to axis
1575 Handle(GEOM_Function) aFunction =
1576 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1577 if (aFunction.IsNull()) return NULL;
1579 //Check if the function is set correctly
1580 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1582 GEOMImpl_IRevolution aCI (aFunction);
1584 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1585 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1587 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1589 aCI.SetBase(aRefBase);
1590 aCI.SetAxis(aRefAxis);
1591 aCI.SetAngle(theAngle);
1593 //Compute the Revolution value
1596 if (!GetSolver()->ComputeFunction(aFunction)) {
1597 SetErrorCode("Revolution driver failed");
1601 catch (Standard_Failure& aFail) {
1602 SetErrorCode(aFail.GetMessageString());
1606 //Make a Python command
1607 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1608 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1614 //=============================================================================
1618 //=============================================================================
1620 GEOMImpl_I3DPrimOperations::MakeFilling (std::list< Handle(GEOM_Object)> & theContours,
1621 int theMinDeg, int theMaxDeg,
1622 double theTol2D, double theTol3D, int theNbIter,
1623 int theMethod, bool isApprox)
1627 Handle(TColStd_HSequenceOfTransient) contours = GEOM_Object::GetLastFunctions( theContours );
1628 if ( contours.IsNull() || contours->IsEmpty() ) {
1629 SetErrorCode("NULL argument shape");
1632 //Add a new Filling object
1633 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GEOM_FILLING);
1635 //Add a new Filling function for creation a filling from a compound
1636 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1637 if (aFunction.IsNull()) return NULL;
1639 //Check if the function is set correctly
1640 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1642 GEOMImpl_IFilling aFI (aFunction);
1643 aFI.SetShapes(contours);
1644 aFI.SetMinDeg(theMinDeg);
1645 aFI.SetMaxDeg(theMaxDeg);
1646 aFI.SetTol2D(theTol2D);
1647 aFI.SetTol3D(theTol3D);
1648 aFI.SetNbIter(theNbIter);
1649 aFI.SetApprox(isApprox);
1650 aFI.SetMethod(theMethod);
1652 //Compute the Solid value
1655 if (!GetSolver()->ComputeFunction(aFunction)) {
1656 SetErrorCode("Filling driver failed");
1660 catch (Standard_Failure& aFail) {
1661 if (strcmp(aFail.GetMessageString(), "Geom_BSplineSurface") == 0)
1662 SetErrorCode("B-Spline surface construction failed");
1664 SetErrorCode(aFail.GetMessageString());
1668 //Make a Python command
1669 GEOM::TPythonDump pd (aFunction);
1670 pd << aFilling << " = geompy.MakeFilling(" << theContours ;
1671 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1672 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1673 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1674 { pd << ", theTol2D=" << theTol2D ; }
1675 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1676 { pd << ", theTol3D=" << theTol3D ; }
1677 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1678 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1679 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1680 if ( isApprox ) pd << ", isApprox=" << isApprox ;
1687 //=============================================================================
1691 //=============================================================================
1692 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1693 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1698 Handle(GEOM_Object) anObj;
1700 if(theSeqSections.IsNull())
1703 Standard_Integer nbObj = theSeqSections->Length();
1707 //Add a new ThruSections object
1708 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GEOM_THRUSECTIONS);
1711 //Add a new ThruSections function
1713 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1714 Handle(GEOM_Function) aFunction =
1715 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1716 if (aFunction.IsNull()) return anObj;
1718 //Check if the function is set correctly
1719 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1721 GEOMImpl_IThruSections aCI (aFunction);
1723 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1725 Standard_Integer i =1;
1726 for( ; i <= nbObj; i++) {
1728 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1732 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1733 if(!aSectObj.IsNull())
1735 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1736 if(!aRefSect.IsNull())
1737 aSeqSections->Append(aRefSect);
1741 if(!aSeqSections->Length())
1744 aCI.SetSections(aSeqSections);
1745 aCI.SetSolidMode(theModeSolid);
1746 aCI.SetPrecision(thePreci);
1748 //Compute the ThruSections value
1751 if (!GetSolver()->ComputeFunction(aFunction)) {
1752 SetErrorCode("ThruSections driver failed");
1756 catch (Standard_Failure& aFail) {
1757 SetErrorCode(aFail.GetMessageString());
1761 //Make a Python command
1762 GEOM::TPythonDump pyDump(aFunction);
1763 pyDump << aThruSect << " = geompy.MakeThruSections([";
1765 for(i =1 ; i <= nbObj; i++) {
1767 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1771 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1772 if(!aSectObj.IsNull()) {
1779 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1786 //=============================================================================
1788 * MakePipeWithDifferentSections
1790 //=============================================================================
1791 Handle(TColStd_HSequenceOfTransient)
1792 GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections
1793 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1794 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1795 const Handle(GEOM_Object) &thePath,
1796 const bool theWithContact,
1797 const bool theWithCorrections,
1798 const bool IsBySteps,
1799 const bool IsGenerateGroups)
1802 if(theBases.IsNull())
1805 Standard_Integer nbBases = theBases->Length();
1810 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1811 //Add a new Pipe object
1812 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
1814 //Add a new Pipe function
1816 Handle(GEOM_Function) aFunction =
1817 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1818 if (aFunction.IsNull()) return NULL;
1820 //Check if the function is set correctly
1821 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1823 GEOMImpl_IPipeDiffSect aCI (aFunction);
1825 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1826 if(aRefPath.IsNull())
1829 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1830 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1832 Standard_Integer i =1;
1833 for( ; i <= nbBases; i++) {
1835 Handle(Standard_Transient) anItem = theBases->Value(i);
1839 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1842 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1843 if(aRefBase.IsNull())
1847 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1848 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);
1859 aSeqBases->Append(aRefBase);
1862 if(!aSeqBases->Length())
1865 aCI.SetBases(aSeqBases);
1866 aCI.SetLocations(aSeqLocs);
1867 aCI.SetPath(aRefPath);
1870 aCI.SetWithContactMode(theWithContact);
1871 aCI.SetWithCorrectionMode(theWithCorrections);
1874 aCI.SetIsBySteps(IsBySteps);
1875 aCI.SetGenerateGroups(IsGenerateGroups);
1877 //Compute the Pipe value
1880 if (!GetSolver()->ComputeFunction(aFunction)) {
1881 SetErrorCode("Pipe with different section driver failed");
1885 catch (Standard_Failure& aFail) {
1886 SetErrorCode(aFail.GetMessageString());
1890 // Create the sequence of objects.
1891 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1893 aSeq->Append(aPipeDS);
1894 createGroups(aPipeDS, &aCI, aSeq);
1896 //Make a Python command
1897 GEOM::TPythonDump pyDump(aFunction);
1899 if (IsGenerateGroups) {
1906 pyDump << " = geompy.MakePipeWithDifferentSectionsBySteps([";
1908 pyDump << " = geompy.MakePipeWithDifferentSections([";
1911 for(i =1 ; i <= nbBases; i++) {
1913 Handle(Standard_Transient) anItem = theBases->Value(i);
1917 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1918 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;
1944 pyDump<<","<<theWithContact << "," << theWithCorrections;
1947 if (IsGenerateGroups) {
1958 //=============================================================================
1960 * MakePipeWithShellSections
1962 //=============================================================================
1963 Handle(TColStd_HSequenceOfTransient)
1964 GEOMImpl_I3DPrimOperations::MakePipeWithShellSections
1965 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1966 const Handle(TColStd_HSequenceOfTransient) &theSubBases,
1967 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1968 const Handle(GEOM_Object) &thePath,
1969 const bool theWithContact,
1970 const bool theWithCorrections,
1971 const bool IsGenerateGroups)
1974 if(theBases.IsNull())
1977 Standard_Integer nbBases = theBases->Length();
1982 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1984 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1986 //Add a new Pipe object
1987 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
1989 //Add a new Pipe function
1991 Handle(GEOM_Function) aFunction =
1992 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1993 if (aFunction.IsNull()) return NULL;
1995 //Check if the function is set correctly
1996 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1998 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1999 GEOMImpl_IPipeShellSect aCI (aFunction);
2001 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2002 if(aRefPath.IsNull())
2005 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2006 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
2007 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2009 Standard_Integer i =1;
2010 for( ; i <= nbBases; i++) {
2012 Handle(Standard_Transient) anItem = theBases->Value(i);
2015 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2018 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2019 if(aRefBase.IsNull())
2022 if( nbSubBases >= nbBases ) {
2023 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
2024 if(aSubItem.IsNull())
2026 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
2027 if(aSubBase.IsNull())
2029 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
2030 if(aRefSubBase.IsNull())
2032 aSeqSubBases->Append(aRefSubBase);
2036 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2037 if(anItemLoc.IsNull())
2039 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2042 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2043 if(aRefLoc.IsNull())
2045 aSeqLocs->Append(aRefLoc);
2048 aSeqBases->Append(aRefBase);
2051 if(!aSeqBases->Length())
2054 aCI.SetBases(aSeqBases);
2055 aCI.SetSubBases(aSeqSubBases);
2056 aCI.SetLocations(aSeqLocs);
2057 aCI.SetPath(aRefPath);
2058 aCI.SetWithContactMode(theWithContact);
2059 aCI.SetWithCorrectionMode(theWithCorrections);
2060 aCI.SetGenerateGroups(IsGenerateGroups);
2062 //Compute the Pipe value
2065 if (!GetSolver()->ComputeFunction(aFunction)) {
2066 SetErrorCode("Pipe with shell sections driver failed");
2070 catch (Standard_Failure& aFail) {
2071 SetErrorCode(aFail.GetMessageString());
2075 // Create the sequence of objects.
2076 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2078 aSeq->Append(aPipeDS);
2079 createGroups(aPipeDS, &aCI, aSeq);
2081 //Make a Python command
2082 GEOM::TPythonDump pyDump(aFunction);
2084 if (IsGenerateGroups) {
2090 pyDump << " = geompy.MakePipeWithShellSections([";
2092 for(i =1 ; i <= nbBases; i++) {
2094 Handle(Standard_Transient) anItem = theBases->Value(i);
2098 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2099 if(!anObj.IsNull()) {
2108 for(i =1 ; i <= nbSubBases; i++) {
2110 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2114 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2115 if(!anObj.IsNull()) {
2124 for(i =1 ; i <= nbLocs; i++) {
2126 Handle(Standard_Transient) anItem = theLocations->Value(i);
2130 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2131 if(!anObj.IsNull()) {
2138 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections;
2140 if (IsGenerateGroups) {
2152 //=============================================================================
2154 * MakePipeShellsWithoutPath
2156 //=============================================================================
2157 Handle(TColStd_HSequenceOfTransient)
2158 GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath
2159 (const Handle(TColStd_HSequenceOfTransient) &theBases,
2160 const Handle(TColStd_HSequenceOfTransient) &theLocations,
2161 const bool IsGenerateGroups)
2164 if(theBases.IsNull())
2167 Standard_Integer nbBases = theBases->Length();
2172 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2174 //Add a new Pipe object
2175 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
2177 //Add a new Pipe function
2179 Handle(GEOM_Function) aFunction =
2180 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2181 if (aFunction.IsNull()) return NULL;
2183 //Check if the function is set correctly
2184 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2186 GEOMImpl_IPipeShellSect aCI (aFunction);
2188 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2189 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2191 Standard_Integer i =1;
2192 for( ; i <= nbBases; i++) {
2194 Handle(Standard_Transient) anItem = theBases->Value(i);
2197 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2200 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2201 if(aRefBase.IsNull())
2205 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2206 if(anItemLoc.IsNull())
2208 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2211 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2212 if(aRefLoc.IsNull())
2214 aSeqLocs->Append(aRefLoc);
2217 aSeqBases->Append(aRefBase);
2220 if(!aSeqBases->Length())
2223 aCI.SetBases(aSeqBases);
2224 aCI.SetLocations(aSeqLocs);
2225 aCI.SetGenerateGroups(IsGenerateGroups);
2227 //Compute the Pipe value
2230 if (!GetSolver()->ComputeFunction(aFunction)) {
2231 SetErrorCode("Pipe with shell sections without path driver failed");
2235 catch (Standard_Failure& aFail) {
2236 SetErrorCode(aFail.GetMessageString());
2240 // Create the sequence of objects.
2241 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2243 aSeq->Append(aPipeDS);
2244 createGroups(aPipeDS, &aCI, aSeq);
2246 //Make a Python command
2247 GEOM::TPythonDump pyDump(aFunction);
2249 if (IsGenerateGroups) {
2255 pyDump << " = geompy.MakePipeShellsWithoutPath([";
2257 for(i =1 ; i <= nbBases; i++) {
2259 Handle(Standard_Transient) anItem = theBases->Value(i);
2263 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2264 if(!anObj.IsNull()) {
2273 for(i =1 ; i <= nbLocs; i++) {
2275 Handle(Standard_Transient) anItem = theLocations->Value(i);
2279 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2280 if(!anObj.IsNull()) {
2289 if (IsGenerateGroups) {
2300 //=============================================================================
2302 * MakePipeBiNormalAlongVector
2304 //=============================================================================
2305 Handle(TColStd_HSequenceOfTransient)
2306 GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector
2307 (const Handle(GEOM_Object) &theBase,
2308 const Handle(GEOM_Object) &thePath,
2309 const Handle(GEOM_Object) &theVec,
2310 const bool IsGenerateGroups)
2314 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2316 //Add a new Pipe object
2317 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GEOM_PIPE);
2319 //Add a new Pipe function
2320 Handle(GEOM_Function) aFunction =
2321 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2322 if (aFunction.IsNull()) return NULL;
2324 //Check if the function is set correctly
2325 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2327 GEOMImpl_IPipeBiNormal aCI (aFunction);
2329 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2330 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2331 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2333 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2335 aCI.SetBase(aRefBase);
2336 aCI.SetPath(aRefPath);
2337 aCI.SetVector(aRefVec);
2338 aCI.SetGenerateGroups(IsGenerateGroups);
2340 //Compute the Pipe value
2343 if (!GetSolver()->ComputeFunction(aFunction)) {
2344 SetErrorCode("Pipe driver failed");
2348 catch (Standard_Failure& aFail) {
2349 SetErrorCode(aFail.GetMessageString());
2353 // Create the sequence of objects.
2354 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2356 aSeq->Append(aPipe);
2357 createGroups(aPipe, &aCI, aSeq);
2359 //Make a Python command
2360 GEOM::TPythonDump pyDump(aFunction);
2362 if (IsGenerateGroups) {
2368 pyDump << " = geompy.MakePipeBiNormalAlongVector("
2369 << theBase << ", " << thePath << ", " << theVec;
2371 if (IsGenerateGroups) {
2381 //=============================================================================
2385 //=============================================================================
2386 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening
2387 (Handle(GEOM_Object) theObject,
2388 const Handle(TColStd_HArray1OfInteger) &theFacesIDs,
2395 if (theObject.IsNull()) return NULL;
2397 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2398 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2400 //Add a new Offset function
2401 Handle(GEOM_Function) aFunction;
2402 Handle(GEOM_Object) aCopy;
2405 //Add a new Copy object
2406 aCopy = GetEngine()->AddObject(theObject->GetType());
2407 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2410 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2412 if (aFunction.IsNull()) return NULL;
2414 //Check if the function is set correctly
2415 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2417 GEOMImpl_IOffset aTI (aFunction);
2418 aTI.SetShape(anOriginal);
2419 aTI.SetValue(theOffset);
2420 aTI.SetParam(theInside);
2422 if (theFacesIDs.IsNull() == Standard_False) {
2423 aTI.SetFaceIDs(theFacesIDs);
2426 //Compute the offset
2429 if (!GetSolver()->ComputeFunction(aFunction)) {
2430 SetErrorCode("Offset driver failed");
2434 catch (Standard_Failure& aFail) {
2435 SetErrorCode(aFail.GetMessageString());
2439 //Make a Python command
2440 GEOM::TPythonDump pd (aFunction);
2441 Handle(GEOM_Object) aResult;
2444 pd << aCopy << " = geompy.MakeThickSolid("
2445 << theObject << ", " << theOffset;
2448 pd << "geompy.Thicken(" << theObject << ", " << theOffset;
2449 aResult = theObject;
2453 if (theFacesIDs.IsNull() == Standard_False) {
2457 for (i = theFacesIDs->Lower(); i < theFacesIDs->Upper(); ++i) {
2458 pd << theFacesIDs->Value(i) << ", ";
2460 // Dump the last value.
2461 pd << theFacesIDs->Value(i);
2466 pd << ", " << theInside;
2474 //=============================================================================
2478 //=============================================================================
2479 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2480 Handle(GEOM_Object) theBase1,
2481 Handle(GEOM_Object) theBase2)
2485 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2487 // Add a new Path object
2488 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GEOM_PIPE_PATH);
2490 // Add a new Path function
2491 Handle(GEOM_Function) aFunction =
2492 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2493 if (aFunction.IsNull()) return NULL;
2495 // Check if the function is set correctly
2496 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2498 GEOMImpl_IPipePath aCI (aFunction);
2500 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2501 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2502 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2504 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2506 aCI.SetShape(aRefShape);
2507 aCI.SetBase1(aRefBase1);
2508 aCI.SetBase2(aRefBase2);
2510 // Compute the Path value
2513 if (!GetSolver()->ComputeFunction(aFunction)) {
2514 SetErrorCode("PipePath driver failed");
2518 catch (Standard_Failure& aFail) {
2519 SetErrorCode("RestorePath: inappropriate arguments given");
2523 // Make a Python command
2524 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2525 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2531 //=============================================================================
2535 //=============================================================================
2536 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2537 (Handle(GEOM_Object) theShape,
2538 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2539 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2543 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2545 Standard_Integer nbBases1 = theBase1->Length();
2546 Standard_Integer nbBases2 = theBase2->Length();
2548 if (!nbBases1 || !nbBases2)
2551 // Add a new Path object
2552 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GEOM_PIPE_PATH);
2554 // Add a new Path function
2555 Handle(GEOM_Function) aFunction =
2556 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2557 if (aFunction.IsNull()) return NULL;
2559 // Check if the function is set correctly
2560 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2562 GEOMImpl_IPipePath aCI (aFunction);
2564 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2565 if (aRefShape.IsNull()) return NULL;
2567 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2568 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2571 for (i = 1; i <= nbBases1; i++) {
2572 Handle(Standard_Transient) anItem = theBase1->Value(i);
2573 if (!anItem.IsNull()) {
2574 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2575 if (!aBase.IsNull()) {
2576 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2577 if (!aRefBase.IsNull())
2578 aSeqBases1->Append(aRefBase);
2582 for (i = 1; i <= nbBases2; i++) {
2583 Handle(Standard_Transient) anItem = theBase2->Value(i);
2584 if (!anItem.IsNull()) {
2585 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2586 if (!aBase.IsNull()) {
2587 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2588 if (!aRefBase.IsNull())
2589 aSeqBases2->Append(aRefBase);
2593 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2595 aCI.SetShape(aRefShape);
2596 aCI.SetBaseSeq1(aSeqBases1);
2597 aCI.SetBaseSeq2(aSeqBases2);
2599 // Compute the Path value
2602 if (!GetSolver()->ComputeFunction(aFunction)) {
2603 SetErrorCode("PipePath driver failed");
2607 catch (Standard_Failure& aFail) {
2608 SetErrorCode("RestorePath: inappropriate arguments given");
2612 // Make a Python command
2613 GEOM::TPythonDump pyDump (aFunction);
2614 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2615 for (i = 1; i <= nbBases1; i++) {
2616 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2617 if (!anObj.IsNull()) {
2624 for (i = 1; i <= nbBases2; i++) {
2625 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2626 if (!anObj.IsNull()) {
2638 //=============================================================================
2642 //=============================================================================
2643 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
2644 (const Handle(GEOM_Object) &theBaseObject,
2645 const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
2646 const TCollection_AsciiString &theName,
2647 const TopTools_IndexedMapOfShape &theIndices)
2649 if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
2653 // Get the Shape type.
2654 const Standard_Integer anID = theGroupIDs->Value(theGroupIDs->Lower());
2655 const Standard_Integer aNbShapes = theIndices.Extent();
2657 if (anID < 1 || anID > aNbShapes) {
2661 const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
2663 if (aSubShape.IsNull()) {
2668 const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
2669 Handle(GEOM_Object) aGroup =
2670 myGroupOperations->CreateGroup(theBaseObject, aGroupType);
2672 if (aGroup.IsNull() == Standard_False) {
2673 aGroup->GetLastFunction()->SetDescription("");
2674 aGroup->SetName(theName.ToCString());
2676 Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
2679 for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
2680 // Get and check the index.
2681 const Standard_Integer anIndex = theGroupIDs->Value(i);
2683 if (anIndex < 1 || anIndex > aNbShapes) {
2687 // Get and check the sub-shape.
2688 const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
2690 if (aSubShape.IsNull()) {
2694 // Check the shape type.
2695 if (aSubShape.ShapeType() != aGroupType) {
2699 aSeqIDs->Append(anIndex);
2702 myGroupOperations->UnionIDs(aGroup, aSeqIDs);
2703 aGroup->GetLastFunction()->SetDescription("");
2709 //=============================================================================
2713 //=============================================================================
2714 void GEOMImpl_I3DPrimOperations::createGroups
2715 (const Handle(GEOM_Object) &theBaseObject,
2716 GEOMImpl_IPipe *thePipe,
2717 Handle(TColStd_HSequenceOfTransient) &theSequence)
2719 if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
2723 TopoDS_Shape aShape = theBaseObject->GetValue();
2725 if (aShape.IsNull()) {
2729 TopTools_IndexedMapOfShape anIndices;
2730 Handle(TColStd_HArray1OfInteger) aGroupIDs;
2731 TopoDS_Shape aShapeType;
2732 const Standard_Integer aNbGroups = 5;
2733 Handle(GEOM_Object) aGrps[aNbGroups];
2736 TopExp::MapShapes(aShape, anIndices);
2739 aGroupIDs = thePipe->GetGroupDown();
2740 aGrps[0] = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
2741 aGroupIDs = thePipe->GetGroupUp();
2742 aGrps[1] = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
2743 aGroupIDs = thePipe->GetGroupSide1();
2744 aGrps[2] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
2745 aGroupIDs = thePipe->GetGroupSide2();
2746 aGrps[3] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
2747 aGroupIDs = thePipe->GetGroupOther();
2748 aGrps[4] = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
2750 for (i = 0; i < aNbGroups; ++i) {
2751 if (aGrps[i].IsNull() == Standard_False) {
2752 theSequence->Append(aGrps[i]);