1 // Copyright (C) 2007-2024 CEA, EDF, 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"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TDF_Tool.hxx>
34 #include <GEOM_Function.hxx>
35 #include <GEOM_PythonDump.hxx>
37 #include <GEOMImpl_Types.hxx>
39 #include <GEOMImpl_BoxDriver.hxx>
40 #include <GEOMImpl_FaceDriver.hxx>
41 #include <GEOMImpl_DiskDriver.hxx>
42 #include <GEOMImpl_CylinderDriver.hxx>
43 #include <GEOMImpl_ConeDriver.hxx>
44 #include <GEOMImpl_SphereDriver.hxx>
45 #include <GEOMImpl_TorusDriver.hxx>
46 #include <GEOMImpl_PrismDriver.hxx>
47 #include <GEOMImpl_PipeDriver.hxx>
48 #include <GEOMImpl_PipePathDriver.hxx>
49 #include <GEOMImpl_RevolutionDriver.hxx>
50 #include <GEOMImpl_ShapeDriver.hxx>
51 #include <GEOMImpl_FillingDriver.hxx>
52 #include <GEOMImpl_ThruSectionsDriver.hxx>
53 #include <GEOMImpl_OffsetDriver.hxx>
55 #include <GEOMImpl_IBox.hxx>
56 #include <GEOMImpl_IFace.hxx>
57 #include <GEOMImpl_IDisk.hxx>
58 #include <GEOMImpl_ICylinder.hxx>
59 #include <GEOMImpl_ICone.hxx>
60 #include <GEOMImpl_IGroupOperations.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>
71 #include <GEOMImpl_IOffset.hxx>
72 #include <GEOMImpl_IPipePath.hxx>
74 #include <Precision.hxx>
77 #include <Standard_Failure.hxx>
78 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
80 //=============================================================================
84 //=============================================================================
85 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine)
86 : GEOM_IOperations(theEngine)
88 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
89 myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine());
92 //=============================================================================
96 //=============================================================================
97 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
99 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
100 delete myGroupOperations;
104 //=============================================================================
108 //=============================================================================
109 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
113 //Add a new Box object
114 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GEOM_BOX);
116 //Add a new Box function with DX_DY_DZ parameters
117 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
118 if (aFunction.IsNull()) return NULL;
120 //Check if the function is set correctly
121 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
123 GEOMImpl_IBox aBI (aFunction);
129 //Compute the box value
132 if (!GetSolver()->ComputeFunction(aFunction)) {
133 SetErrorCode("Box driver failed");
137 catch (Standard_Failure& aFail) {
138 SetErrorCode(aFail.GetMessageString());
142 //Make a Python command
143 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
144 << theDX << ", " << theDY << ", " << theDZ << ")";
151 //=============================================================================
155 //=============================================================================
156 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
157 Handle(GEOM_Object) thePnt2)
161 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
163 //Add a new Box object
164 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GEOM_BOX);
166 //Add a new Box function for creation a box relatively to two points
167 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
168 if (aFunction.IsNull()) return NULL;
170 //Check if the function is set correctly
171 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
173 GEOMImpl_IBox aBI (aFunction);
175 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
176 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
178 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
180 aBI.SetRef1(aRefFunction1);
181 aBI.SetRef2(aRefFunction2);
183 //Compute the Box value
186 if (!GetSolver()->ComputeFunction(aFunction)) {
187 SetErrorCode("Box driver failed");
191 catch (Standard_Failure& aFail) {
192 SetErrorCode(aFail.GetMessageString());
196 //Make a Python command
197 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
198 << thePnt1 << ", " << thePnt2 << ")";
204 //=============================================================================
208 //=============================================================================
209 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
213 if (theH == 0 || theW == 0) return NULL;
215 //Add a new Face object
216 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GEOM_FACE);
218 //Add a new Box function for creation a box relatively to two points
219 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
220 if (aFunction.IsNull()) return NULL;
222 //Check if the function is set correctly
223 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
225 GEOMImpl_IFace aFI (aFunction);
229 aFI.SetOrientation(theOrientation);
234 if (!GetSolver()->ComputeFunction(aFunction)) {
235 SetErrorCode("Face driver failed");
239 catch (Standard_Failure& aFail) {
240 SetErrorCode(aFail.GetMessageString());
244 //Make a Python command
245 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
246 << theH << ", " << theW << ", " << theOrientation << ")";
252 //=============================================================================
256 //=============================================================================
257 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
258 double theH, double theW)
262 if (theObj.IsNull()) return NULL;
264 //Add a new Face object
265 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GEOM_FACE);
267 //Add a new Box function for creation a box relatively to two points
268 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
269 if (aFunction.IsNull()) return NULL;
271 //Check if the function is set correctly
272 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
274 GEOMImpl_IFace aFI (aFunction);
276 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
278 if (aRefFunction1.IsNull())
281 aFI.SetRef1(aRefFunction1);
288 if (!GetSolver()->ComputeFunction(aFunction)) {
289 SetErrorCode("Face driver failed");
293 catch (Standard_Failure& aFail) {
294 SetErrorCode(aFail.GetMessageString());
298 //Make a Python command
299 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
300 << theObj << ", " << theH << ", " << theW << ")";
306 //=============================================================================
310 //=============================================================================
311 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
312 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
316 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
318 //Add a new Disk object
319 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GEOM_FACE);
321 //Add a new Disk function for creation a disk relatively to point and vector
322 Handle(GEOM_Function) aFunction =
323 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
324 if (aFunction.IsNull()) return NULL;
326 //Check if the function is set correctly
327 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
329 GEOMImpl_IDisk aCI (aFunction);
331 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
332 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
334 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
336 aCI.SetCenter(aRefPnt);
337 aCI.SetVector(aRefVec);
340 //Compute the Disk value
343 if (!GetSolver()->ComputeFunction(aFunction)) {
344 SetErrorCode("Disk driver failed");
348 catch (Standard_Failure& aFail) {
349 SetErrorCode(aFail.GetMessageString());
353 //Make a Python command
354 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
355 << thePnt << ", " << theVec << ", " << theR << ")";
361 //=============================================================================
365 //=============================================================================
366 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
367 Handle(GEOM_Object) thePnt2,
368 Handle(GEOM_Object) thePnt3)
372 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
374 //Add a new Disk object
375 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GEOM_FACE);
377 //Add a new Disk function for creation a disk relatively to three points
378 Handle(GEOM_Function) aFunction =
379 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
380 if (aFunction.IsNull()) return NULL;
382 //Check if the function is set correctly
383 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
385 GEOMImpl_IDisk aCI (aFunction);
387 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
388 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
389 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
391 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
393 aCI.SetPoint1(aRefPnt1);
394 aCI.SetPoint2(aRefPnt2);
395 aCI.SetPoint3(aRefPnt3);
397 //Compute the Disk value
400 if (!GetSolver()->ComputeFunction(aFunction)) {
401 SetErrorCode("Disk driver failed");
405 catch (Standard_Failure& aFail) {
406 SetErrorCode(aFail.GetMessageString());
410 //Make a Python command
411 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
412 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
418 //=============================================================================
422 //=============================================================================
423 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
427 if (theR == 0 ) return NULL;
429 //Add a new Disk object
430 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GEOM_FACE);
432 //Add a new Box function for creation a box relatively to two points
433 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
434 if (aFunction.IsNull()) return NULL;
436 //Check if the function is set correctly
437 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
439 GEOMImpl_IDisk aDI (aFunction);
442 aDI.SetOrientation(theOrientation);
447 if (!GetSolver()->ComputeFunction(aFunction)) {
448 SetErrorCode("Disk driver failed");
452 catch (Standard_Failure& aFail) {
453 SetErrorCode(aFail.GetMessageString());
457 //Make a Python command
458 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
459 << theR << ", " << theOrientation << ")";
465 //=============================================================================
469 //=============================================================================
470 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
474 //Add a new Cylinder object
475 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
477 //Add a new Cylinder function with R and H parameters
478 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
479 if (aFunction.IsNull()) return NULL;
481 //Check if the function is set correctly
482 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
484 GEOMImpl_ICylinder aCI (aFunction);
489 //Compute the Cylinder value
492 if (!GetSolver()->ComputeFunction(aFunction)) {
493 SetErrorCode("Cylinder driver failed");
497 catch (Standard_Failure& aFail) {
498 SetErrorCode(aFail.GetMessageString());
502 //Make a Python command
503 GEOM::TPythonDump(aFunction) << aCylinder
504 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
510 //=============================================================================
514 //=============================================================================
515 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
519 //Add a new Cylinder object
520 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
522 //Add a new Cylinder function with R and H parameters
523 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
524 if (aFunction.IsNull()) return NULL;
526 //Check if the function is set correctly
527 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
529 GEOMImpl_ICylinder aCI (aFunction);
535 //Compute the Cylinder value
538 if (!GetSolver()->ComputeFunction(aFunction)) {
539 SetErrorCode("Cylinder driver failed");
543 catch (Standard_Failure& aFail) {
544 SetErrorCode(aFail.GetMessageString());
548 //Make a Python command
549 GEOM::TPythonDump(aFunction) << aCylinder
550 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
556 //=============================================================================
558 * MakeCylinderPntVecRH
560 //=============================================================================
561 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
562 Handle(GEOM_Object) theVec,
563 double theR, double theH)
567 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
569 //Add a new Cylinder object
570 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
572 //Add a new Cylinder function for creation a cylinder relatively to point and vector
573 Handle(GEOM_Function) aFunction =
574 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
575 if (aFunction.IsNull()) return NULL;
577 //Check if the function is set correctly
578 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
580 GEOMImpl_ICylinder aCI (aFunction);
582 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
583 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
585 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
587 aCI.SetPoint(aRefPnt);
588 aCI.SetVector(aRefVec);
592 //Compute the Cylinder value
595 if (!GetSolver()->ComputeFunction(aFunction)) {
596 SetErrorCode("Cylinder driver failed");
600 catch (Standard_Failure& aFail) {
601 SetErrorCode(aFail.GetMessageString());
605 //Make a Python command
606 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
607 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
613 //=============================================================================
615 * MakeCylinderPntVecRHA
617 //=============================================================================
618 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
619 Handle(GEOM_Object) theVec,
620 double theR, double theH, double theA)
624 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
626 //Add a new Cylinder object
627 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GEOM_CYLINDER);
629 //Add a new Cylinder function for creation a cylinder relatively to point and vector
630 Handle(GEOM_Function) aFunction =
631 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
632 if (aFunction.IsNull()) return NULL;
634 //Check if the function is set correctly
635 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
637 GEOMImpl_ICylinder aCI (aFunction);
639 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
640 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
642 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
644 aCI.SetPoint(aRefPnt);
645 aCI.SetVector(aRefVec);
650 //Compute the Cylinder value
653 if (!GetSolver()->ComputeFunction(aFunction)) {
654 SetErrorCode("Cylinder driver failed");
658 catch (Standard_Failure& aFail) {
659 SetErrorCode(aFail.GetMessageString());
663 //Make a Python command
664 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
665 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
672 //=============================================================================
676 //=============================================================================
677 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
682 //Add a new Cone object
683 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GEOM_CONE);
685 //Add a new Cone function with R and H parameters
686 Handle(GEOM_Function) aFunction =
687 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
688 if (aFunction.IsNull()) return NULL;
690 //Check if the function is set correctly
691 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
693 GEOMImpl_ICone aCI (aFunction);
699 //Compute the Cone value
702 if (!GetSolver()->ComputeFunction(aFunction)) {
703 SetErrorCode("Cone driver failed");
707 catch (Standard_Failure& aFail) {
708 SetErrorCode(aFail.GetMessageString());
712 //Make a Python command
713 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
714 << theR1 << ", " << theR2 << ", " << theH << ")";
721 //=============================================================================
723 * MakeConePntVecR1R2H
725 //=============================================================================
726 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
727 Handle(GEOM_Object) theVec,
728 double theR1, double theR2,
733 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
735 //Add a new Cone object
736 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GEOM_CONE);
738 //Add a new Cone function for creation a cone relatively to point and vector
739 Handle(GEOM_Function) aFunction =
740 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
741 if (aFunction.IsNull()) return NULL;
743 //Check if the function is set correctly
744 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
746 GEOMImpl_ICone aCI (aFunction);
748 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
749 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
751 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
753 aCI.SetPoint(aRefPnt);
754 aCI.SetVector(aRefVec);
759 //Compute the Cone value
762 if (!GetSolver()->ComputeFunction(aFunction)) {
763 SetErrorCode("Cone driver failed");
767 catch (Standard_Failure& aFail) {
768 SetErrorCode(aFail.GetMessageString());
772 //Make a Python command
773 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
774 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
781 //=============================================================================
785 //=============================================================================
786 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
790 //Add a new Sphere object
791 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GEOM_SPHERE);
793 //Add a new Sphere function with R parameter
794 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
795 if (aFunction.IsNull()) return NULL;
797 //Check if the function is set correctly
798 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
800 GEOMImpl_ISphere aCI (aFunction);
804 //Compute the Sphere value
807 if (!GetSolver()->ComputeFunction(aFunction)) {
808 SetErrorCode("Sphere driver failed");
812 catch (Standard_Failure& aFail) {
813 SetErrorCode(aFail.GetMessageString());
817 //Make a Python command
818 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
825 //=============================================================================
829 //=============================================================================
830 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
835 if (thePnt.IsNull()) return NULL;
837 //Add a new Point object
838 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GEOM_SPHERE);
840 //Add a new Sphere function for creation a sphere relatively to point
841 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
842 if (aFunction.IsNull()) return NULL;
844 //Check if the function is set correctly
845 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
847 GEOMImpl_ISphere aCI (aFunction);
849 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
851 if (aRefPnt.IsNull()) return NULL;
853 aCI.SetPoint(aRefPnt);
856 //Compute the Sphere value
859 if (!GetSolver()->ComputeFunction(aFunction)) {
860 SetErrorCode("Sphere driver failed");
864 catch (Standard_Failure& aFail) {
865 SetErrorCode(aFail.GetMessageString());
869 //Make a Python command
870 GEOM::TPythonDump(aFunction) << aSphere
871 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
878 //=============================================================================
882 //=============================================================================
883 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
884 (double theRMajor, double theRMinor)
888 //Add a new Torus object
889 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GEOM_TORUS);
891 //Add a new Torus function
892 Handle(GEOM_Function) aFunction =
893 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
894 if (aFunction.IsNull()) return NULL;
896 //Check if the function is set correctly
897 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
899 GEOMImpl_ITorus aCI (aFunction);
901 aCI.SetRMajor(theRMajor);
902 aCI.SetRMinor(theRMinor);
904 //Compute the Torus value
907 if (!GetSolver()->ComputeFunction(aFunction)) {
908 SetErrorCode("Torus driver failed");
912 catch (Standard_Failure& aFail) {
913 SetErrorCode(aFail.GetMessageString());
917 //Make a Python command
918 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
919 << theRMajor << ", " << theRMinor << ")";
925 //=============================================================================
929 //=============================================================================
930 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
931 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
932 double theRMajor, double theRMinor)
936 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
938 //Add a new Torus object
939 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GEOM_TORUS);
941 //Add a new Torus function
942 Handle(GEOM_Function) aFunction =
943 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
944 if (aFunction.IsNull()) return NULL;
946 //Check if the function is set correctly
947 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
949 GEOMImpl_ITorus aCI (aFunction);
951 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
952 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
954 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
956 aCI.SetCenter(aRefPnt);
957 aCI.SetVector(aRefVec);
958 aCI.SetRMajor(theRMajor);
959 aCI.SetRMinor(theRMinor);
961 //Compute the Torus value
964 if (!GetSolver()->ComputeFunction(aFunction)) {
965 SetErrorCode("Torus driver failed");
969 catch (Standard_Failure& aFail) {
970 SetErrorCode(aFail.GetMessageString());
974 //Make a Python command
975 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
976 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
983 //=============================================================================
987 //=============================================================================
988 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
989 Handle(GEOM_Object) theVec,
990 double theH, double theScaleFactor)
994 if (theBase.IsNull() || theVec.IsNull()) return NULL;
996 //Add a new Prism object
997 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
999 //Add a new Prism function for creation a Prism relatively to vector
1000 Handle(GEOM_Function) aFunction =
1001 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1002 if (aFunction.IsNull()) return NULL;
1004 //Check if the function is set correctly
1005 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1007 GEOMImpl_IPrism aCI (aFunction);
1009 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1010 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1012 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1014 aCI.SetBase(aRefBase);
1015 aCI.SetVector(aRefVec);
1017 aCI.SetScale(theScaleFactor);
1019 //Compute the Prism value
1022 if (!GetSolver()->ComputeFunction(aFunction)) {
1023 //SetErrorCode("Prism driver failed");
1024 SetErrorCode("Extrusion can not be created, check input data");
1028 catch (Standard_Failure& aFail) {
1029 SetErrorCode(aFail.GetMessageString());
1033 //Make a Python command
1034 GEOM::TPythonDump pd (aFunction);
1035 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1036 if (theScaleFactor > Precision::Confusion())
1037 pd << ", " << theScaleFactor << ")";
1045 //=============================================================================
1047 * MakePrismVecH2Ways
1049 //=============================================================================
1050 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1051 Handle(GEOM_Object) theVec,
1056 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1058 //Add a new Prism object
1059 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1061 //Add a new Prism function for creation a Prism relatively to vector
1062 Handle(GEOM_Function) aFunction =
1063 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1064 if (aFunction.IsNull()) return NULL;
1066 //Check if the function is set correctly
1067 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1069 GEOMImpl_IPrism aCI (aFunction);
1071 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1072 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1074 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1076 aCI.SetBase(aRefBase);
1077 aCI.SetVector(aRefVec);
1080 //Compute the Prism value
1083 if (!GetSolver()->ComputeFunction(aFunction)) {
1084 //SetErrorCode("Prism driver failed");
1085 SetErrorCode("Extrusion can not be created, check input data");
1089 catch (Standard_Failure& aFail) {
1090 SetErrorCode(aFail.GetMessageString());
1094 //Make a Python command
1095 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1096 << theBase << ", " << theVec << ", " << theH << ")";
1102 //=============================================================================
1106 //=============================================================================
1107 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1108 (Handle(GEOM_Object) theBase,
1109 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1110 double theScaleFactor)
1114 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1116 //Add a new Prism object
1117 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1119 //Add a new Prism function for creation a Prism relatively to two points
1120 Handle(GEOM_Function) aFunction =
1121 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1122 if (aFunction.IsNull()) return NULL;
1124 //Check if the function is set correctly
1125 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1127 GEOMImpl_IPrism aCI (aFunction);
1129 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1130 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1131 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1133 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1135 aCI.SetBase(aRefBase);
1136 aCI.SetFirstPoint(aRefPnt1);
1137 aCI.SetLastPoint(aRefPnt2);
1138 aCI.SetScale(theScaleFactor);
1140 //Compute the Prism value
1143 if (!GetSolver()->ComputeFunction(aFunction)) {
1144 //SetErrorCode("Prism driver failed");
1145 SetErrorCode("Extrusion can not be created, check input data");
1149 catch (Standard_Failure& aFail) {
1150 SetErrorCode(aFail.GetMessageString());
1154 //Make a Python command
1155 GEOM::TPythonDump pd (aFunction);
1156 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1157 if (theScaleFactor > Precision::Confusion())
1158 pd << ", " << theScaleFactor << ")";
1166 //=============================================================================
1168 * MakePrismTwoPnt2Ways
1170 //=============================================================================
1171 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1172 (Handle(GEOM_Object) theBase,
1173 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1177 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1179 //Add a new Prism object
1180 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1182 //Add a new Prism function for creation a Prism relatively to two points
1183 Handle(GEOM_Function) aFunction =
1184 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1185 if (aFunction.IsNull()) return NULL;
1187 //Check if the function is set correctly
1188 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1190 GEOMImpl_IPrism aCI (aFunction);
1192 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1193 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1194 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1196 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1198 aCI.SetBase(aRefBase);
1199 aCI.SetFirstPoint(aRefPnt1);
1200 aCI.SetLastPoint(aRefPnt2);
1202 //Compute the Prism value
1205 if (!GetSolver()->ComputeFunction(aFunction)) {
1206 //SetErrorCode("Prism driver failed");
1207 SetErrorCode("Extrusion can not be created, check input data");
1211 catch (Standard_Failure& aFail) {
1212 SetErrorCode(aFail.GetMessageString());
1216 //Make a Python command
1217 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1218 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1224 //=============================================================================
1228 //=============================================================================
1229 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1230 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1231 double theScaleFactor)
1235 if (theBase.IsNull()) return NULL;
1237 //Add a new Prism object
1238 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1240 //Add a new Prism function for creation a Prism by DXDYDZ
1241 Handle(GEOM_Function) aFunction =
1242 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1243 if (aFunction.IsNull()) return NULL;
1245 //Check if the function is set correctly
1246 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1248 GEOMImpl_IPrism aCI (aFunction);
1250 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1252 if (aRefBase.IsNull()) return NULL;
1254 aCI.SetBase(aRefBase);
1258 aCI.SetScale(theScaleFactor);
1260 //Compute the Prism value
1263 if (!GetSolver()->ComputeFunction(aFunction)) {
1264 SetErrorCode("Extrusion can not be created, check input data");
1268 catch (Standard_Failure& aFail) {
1269 SetErrorCode(aFail.GetMessageString());
1273 //Make a Python command
1274 GEOM::TPythonDump pd (aFunction);
1275 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1276 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1277 if (theScaleFactor > Precision::Confusion())
1278 pd << ", " << theScaleFactor << ")";
1286 //=============================================================================
1288 * MakePrismDXDYDZ_2WAYS
1290 //=============================================================================
1291 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1292 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1296 if (theBase.IsNull()) return NULL;
1298 //Add a new Prism object
1299 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GEOM_PRISM);
1301 //Add a new Prism function for creation a Prism by DXDYDZ
1302 Handle(GEOM_Function) aFunction =
1303 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1304 if (aFunction.IsNull()) return NULL;
1306 //Check if the function is set correctly
1307 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1309 GEOMImpl_IPrism aCI (aFunction);
1311 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1313 if (aRefBase.IsNull()) return NULL;
1315 aCI.SetBase(aRefBase);
1320 //Compute the Prism value
1323 if (!GetSolver()->ComputeFunction(aFunction)) {
1324 SetErrorCode("Extrusion can not be created, check input data");
1328 catch (Standard_Failure& aFail) {
1329 SetErrorCode(aFail.GetMessageString());
1333 //Make a Python command
1334 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1335 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1341 //=============================================================================
1345 //=============================================================================
1346 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1347 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse, bool theInvert)
1351 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1353 Handle(GEOM_Object) aPrism = NULL;
1357 //Add a new Extruded Boss object
1358 aPrism = GetEngine()->AddObject(GEOM_EXTRUDED_BOSS);
1362 //Add a new Extruded Cut object
1363 aPrism = GetEngine()->AddObject(GEOM_EXTRUDED_CUT);
1366 //Add a new Prism function for the creation of a Draft Prism feature
1367 Handle(GEOM_Function) aFunction =
1368 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1369 if (aFunction.IsNull()) return NULL;
1371 //Check if the function is set correctly
1372 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1374 GEOMImpl_IPrism aCI (aFunction);
1376 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1377 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1379 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1382 aCI.SetBase(aRefBase);
1383 aCI.SetInitShape(aRefInit);
1384 aCI.SetH(theHeight);
1385 aCI.SetDraftAngle(theAngle);
1390 aCI.SetInvertFlag(theInvert);
1392 //Compute the Draft Prism Feature value
1395 if (!GetSolver()->ComputeFunction(aFunction)) {
1396 SetErrorCode("Extrusion can not be created, check input data");
1400 catch (Standard_Failure& aFail) {
1401 SetErrorCode(aFail.GetMessageString());
1405 //Make a Python command
1406 GEOM::TPythonDump pd (aFunction);
1409 pd << aPrism << " = geompy.MakeExtrudedBoss(" << theInitShape << ", " << theBase << ", "
1410 << theHeight << ", " << theAngle;
1414 pd << aPrism << " = geompy.MakeExtrudedCut(" << theInitShape << ", " << theBase << ", "
1415 << theHeight << ", " << theAngle;
1418 pd << ", " << theInvert;
1425 //=============================================================================
1429 //=============================================================================
1430 Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
1431 (const Handle(GEOM_Object) &theBase,
1432 const Handle(GEOM_Object) &thePath,
1433 const bool IsGenerateGroups)
1437 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1439 //Add a new Pipe object
1440 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GEOM_PIPE);
1442 //Add a new Pipe function
1443 Handle(GEOM_Function) aFunction =
1444 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1445 if (aFunction.IsNull()) return NULL;
1447 //Check if the function is set correctly
1448 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1450 GEOMImpl_IPipe aCI (aFunction);
1452 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1453 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1455 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1457 aCI.SetBase(aRefBase);
1458 aCI.SetPath(aRefPath);
1459 aCI.SetGenerateGroups(IsGenerateGroups);
1461 //Compute the Pipe value
1464 if (!GetSolver()->ComputeFunction(aFunction)) {
1465 SetErrorCode("Pipe driver failed");
1469 catch (Standard_Failure& aFail) {
1470 SetErrorCode(aFail.GetMessageString());
1474 // Create the sequence of objects.
1475 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1477 aSeq->Append(aPipe);
1478 createGroups(aPipe, &aCI, aSeq);
1480 //Make a Python command
1481 GEOM::TPythonDump pyDump(aFunction);
1483 if (IsGenerateGroups) {
1489 pyDump << " = geompy.MakePipe(" << theBase << ", " << thePath;
1491 if (IsGenerateGroups) {
1502 //=============================================================================
1504 * MakeRevolutionAxisAngle
1506 //=============================================================================
1507 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1508 Handle(GEOM_Object) theAxis,
1513 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1515 //Add a new Revolution object
1516 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GEOM_REVOLUTION);
1518 //Add a new Revolution function for creation a revolution relatively to axis
1519 Handle(GEOM_Function) aFunction =
1520 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1521 if (aFunction.IsNull()) return NULL;
1523 //Check if the function is set correctly
1524 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1526 GEOMImpl_IRevolution aCI (aFunction);
1528 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1529 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1531 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1533 aCI.SetBase(aRefBase);
1534 aCI.SetAxis(aRefAxis);
1535 aCI.SetAngle(theAngle);
1537 //Compute the Revolution value
1540 if (!GetSolver()->ComputeFunction(aFunction)) {
1541 SetErrorCode("Revolution driver failed");
1545 catch (Standard_Failure& aFail) {
1546 SetErrorCode(aFail.GetMessageString());
1550 //Make a Python command
1551 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1552 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1558 //=============================================================================
1560 * MakeRevolutionAxisAngle2Ways
1562 //=============================================================================
1563 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1564 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1568 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1570 //Add a new Revolution object
1571 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GEOM_REVOLUTION);
1573 //Add a new Revolution function for creation a revolution relatively to axis
1574 Handle(GEOM_Function) aFunction =
1575 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1576 if (aFunction.IsNull()) return NULL;
1578 //Check if the function is set correctly
1579 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1581 GEOMImpl_IRevolution aCI (aFunction);
1583 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1584 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1586 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1588 aCI.SetBase(aRefBase);
1589 aCI.SetAxis(aRefAxis);
1590 aCI.SetAngle(theAngle);
1592 //Compute the Revolution value
1595 if (!GetSolver()->ComputeFunction(aFunction)) {
1596 SetErrorCode("Revolution driver failed");
1600 catch (Standard_Failure& aFail) {
1601 SetErrorCode(aFail.GetMessageString());
1605 //Make a Python command
1606 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1607 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1613 //=============================================================================
1617 //=============================================================================
1619 GEOMImpl_I3DPrimOperations::MakeFilling (std::list< Handle(GEOM_Object)> & theContours,
1620 int theMinDeg, int theMaxDeg,
1621 double theTol2D, double theTol3D, int theNbIter,
1622 int theMethod, bool isApprox)
1626 Handle(TColStd_HSequenceOfTransient) contours = GEOM_Object::GetLastFunctions( theContours );
1627 if ( contours.IsNull() || contours->IsEmpty() ) {
1628 SetErrorCode("NULL argument shape");
1631 //Add a new Filling object
1632 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GEOM_FILLING);
1634 //Add a new Filling function for creation a filling from a compound
1635 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1636 if (aFunction.IsNull()) return NULL;
1638 //Check if the function is set correctly
1639 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1641 GEOMImpl_IFilling aFI (aFunction);
1642 aFI.SetShapes(contours);
1643 aFI.SetMinDeg(theMinDeg);
1644 aFI.SetMaxDeg(theMaxDeg);
1645 aFI.SetTol2D(theTol2D);
1646 aFI.SetTol3D(theTol3D);
1647 aFI.SetNbIter(theNbIter);
1648 aFI.SetApprox(isApprox);
1649 aFI.SetMethod(theMethod);
1651 //Compute the Solid value
1654 if (!GetSolver()->ComputeFunction(aFunction)) {
1655 SetErrorCode("Filling driver failed");
1659 catch (Standard_Failure& aFail) {
1660 if (strcmp(aFail.GetMessageString(), "Geom_BSplineSurface") == 0)
1661 SetErrorCode("B-Spline surface construction failed");
1663 SetErrorCode(aFail.GetMessageString());
1667 //Make a Python command
1668 GEOM::TPythonDump pd (aFunction);
1669 pd << aFilling << " = geompy.MakeFilling(" << theContours ;
1670 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1671 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1672 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1673 { pd << ", theTol2D=" << theTol2D ; }
1674 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1675 { pd << ", theTol3D=" << theTol3D ; }
1676 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1677 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1678 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1679 if ( isApprox ) pd << ", isApprox=" << isApprox ;
1686 //=============================================================================
1690 //=============================================================================
1691 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1692 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1697 Handle(GEOM_Object) anObj;
1699 if(theSeqSections.IsNull())
1702 Standard_Integer nbObj = theSeqSections->Length();
1706 //Add a new ThruSections object
1707 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GEOM_THRUSECTIONS);
1710 //Add a new ThruSections function
1712 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1713 Handle(GEOM_Function) aFunction =
1714 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1715 if (aFunction.IsNull()) return anObj;
1717 //Check if the function is set correctly
1718 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1720 GEOMImpl_IThruSections aCI (aFunction);
1722 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1724 Standard_Integer i =1;
1725 for( ; i <= nbObj; i++) {
1727 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1731 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1732 if(!aSectObj.IsNull())
1734 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1735 if(!aRefSect.IsNull())
1736 aSeqSections->Append(aRefSect);
1740 if(!aSeqSections->Length())
1743 aCI.SetSections(aSeqSections);
1744 aCI.SetSolidMode(theModeSolid);
1745 aCI.SetPrecision(thePreci);
1747 //Compute the ThruSections value
1750 if (!GetSolver()->ComputeFunction(aFunction)) {
1751 SetErrorCode("ThruSections driver failed");
1755 catch (Standard_Failure& aFail) {
1756 SetErrorCode(aFail.GetMessageString());
1760 //Make a Python command
1761 GEOM::TPythonDump pyDump(aFunction);
1762 pyDump << aThruSect << " = geompy.MakeThruSections([";
1764 for(i =1 ; i <= nbObj; i++) {
1766 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1770 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1771 if(!aSectObj.IsNull()) {
1778 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1785 //=============================================================================
1787 * MakePipeWithDifferentSections
1789 //=============================================================================
1790 Handle(TColStd_HSequenceOfTransient)
1791 GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections
1792 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1793 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1794 const Handle(GEOM_Object) &thePath,
1795 const bool theWithContact,
1796 const bool theWithCorrections,
1797 const bool IsBySteps,
1798 const bool IsGenerateGroups)
1801 if(theBases.IsNull())
1804 Standard_Integer nbBases = theBases->Length();
1809 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1810 //Add a new Pipe object
1811 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
1813 //Add a new Pipe function
1815 Handle(GEOM_Function) aFunction =
1816 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1817 if (aFunction.IsNull()) return NULL;
1819 //Check if the function is set correctly
1820 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1822 GEOMImpl_IPipeDiffSect aCI (aFunction);
1824 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1825 if(aRefPath.IsNull())
1828 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1829 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1831 Standard_Integer i =1;
1832 for( ; i <= nbBases; i++) {
1834 Handle(Standard_Transient) anItem = theBases->Value(i);
1838 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1841 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1842 if(aRefBase.IsNull())
1846 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1847 if(anItemLoc.IsNull())
1850 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1853 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1854 if(aRefLoc.IsNull())
1856 aSeqLocs->Append(aRefLoc);
1858 aSeqBases->Append(aRefBase);
1861 if(!aSeqBases->Length())
1864 aCI.SetBases(aSeqBases);
1865 aCI.SetLocations(aSeqLocs);
1866 aCI.SetPath(aRefPath);
1869 aCI.SetWithContactMode(theWithContact);
1870 aCI.SetWithCorrectionMode(theWithCorrections);
1873 aCI.SetIsBySteps(IsBySteps);
1874 aCI.SetGenerateGroups(IsGenerateGroups);
1876 //Compute the Pipe value
1879 if (!GetSolver()->ComputeFunction(aFunction)) {
1880 SetErrorCode("Pipe with different section driver failed");
1884 catch (Standard_Failure& aFail) {
1885 SetErrorCode(aFail.GetMessageString());
1889 // Create the sequence of objects.
1890 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1892 aSeq->Append(aPipeDS);
1893 createGroups(aPipeDS, &aCI, aSeq);
1895 //Make a Python command
1896 GEOM::TPythonDump pyDump(aFunction);
1898 if (IsGenerateGroups) {
1905 pyDump << " = geompy.MakePipeWithDifferentSectionsBySteps([";
1907 pyDump << " = geompy.MakePipeWithDifferentSections([";
1910 for(i =1 ; i <= nbBases; i++) {
1912 Handle(Standard_Transient) anItem = theBases->Value(i);
1916 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1917 if(!anObj.IsNull()) {
1926 for(i =1 ; i <= nbLocs; i++) {
1928 Handle(Standard_Transient) anItem = theLocations->Value(i);
1932 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1933 if(!anObj.IsNull()) {
1940 pyDump<< "], "<<thePath;
1943 pyDump<<","<<theWithContact << "," << theWithCorrections;
1946 if (IsGenerateGroups) {
1957 //=============================================================================
1959 * MakePipeWithShellSections
1961 //=============================================================================
1962 Handle(TColStd_HSequenceOfTransient)
1963 GEOMImpl_I3DPrimOperations::MakePipeWithShellSections
1964 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1965 const Handle(TColStd_HSequenceOfTransient) &theSubBases,
1966 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1967 const Handle(GEOM_Object) &thePath,
1968 const bool theWithContact,
1969 const bool theWithCorrections,
1970 const bool IsGenerateGroups)
1973 if(theBases.IsNull())
1976 Standard_Integer nbBases = theBases->Length();
1981 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1983 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1985 //Add a new Pipe object
1986 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
1988 //Add a new Pipe function
1990 Handle(GEOM_Function) aFunction =
1991 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1992 if (aFunction.IsNull()) return NULL;
1994 //Check if the function is set correctly
1995 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1997 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1998 GEOMImpl_IPipeShellSect aCI (aFunction);
2000 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2001 if(aRefPath.IsNull())
2004 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2005 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
2006 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2008 Standard_Integer i =1;
2009 for( ; i <= nbBases; i++) {
2011 Handle(Standard_Transient) anItem = theBases->Value(i);
2014 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2017 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2018 if(aRefBase.IsNull())
2021 if( nbSubBases >= nbBases ) {
2022 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
2023 if(aSubItem.IsNull())
2025 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
2026 if(aSubBase.IsNull())
2028 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
2029 if(aRefSubBase.IsNull())
2031 aSeqSubBases->Append(aRefSubBase);
2035 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2036 if(anItemLoc.IsNull())
2038 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2041 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2042 if(aRefLoc.IsNull())
2044 aSeqLocs->Append(aRefLoc);
2047 aSeqBases->Append(aRefBase);
2050 if(!aSeqBases->Length())
2053 aCI.SetBases(aSeqBases);
2054 aCI.SetSubBases(aSeqSubBases);
2055 aCI.SetLocations(aSeqLocs);
2056 aCI.SetPath(aRefPath);
2057 aCI.SetWithContactMode(theWithContact);
2058 aCI.SetWithCorrectionMode(theWithCorrections);
2059 aCI.SetGenerateGroups(IsGenerateGroups);
2061 //Compute the Pipe value
2064 if (!GetSolver()->ComputeFunction(aFunction)) {
2065 SetErrorCode("Pipe with shell sections driver failed");
2069 catch (Standard_Failure& aFail) {
2070 SetErrorCode(aFail.GetMessageString());
2074 // Create the sequence of objects.
2075 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2077 aSeq->Append(aPipeDS);
2078 createGroups(aPipeDS, &aCI, aSeq);
2080 //Make a Python command
2081 GEOM::TPythonDump pyDump(aFunction);
2083 if (IsGenerateGroups) {
2089 pyDump << " = geompy.MakePipeWithShellSections([";
2091 for(i =1 ; i <= nbBases; i++) {
2093 Handle(Standard_Transient) anItem = theBases->Value(i);
2097 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2098 if(!anObj.IsNull()) {
2107 for(i =1 ; i <= nbSubBases; i++) {
2109 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2113 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2114 if(!anObj.IsNull()) {
2123 for(i =1 ; i <= nbLocs; i++) {
2125 Handle(Standard_Transient) anItem = theLocations->Value(i);
2129 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2130 if(!anObj.IsNull()) {
2137 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections;
2139 if (IsGenerateGroups) {
2151 //=============================================================================
2153 * MakePipeShellsWithoutPath
2155 //=============================================================================
2156 Handle(TColStd_HSequenceOfTransient)
2157 GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath
2158 (const Handle(TColStd_HSequenceOfTransient) &theBases,
2159 const Handle(TColStd_HSequenceOfTransient) &theLocations,
2160 const bool IsGenerateGroups)
2163 if(theBases.IsNull())
2166 Standard_Integer nbBases = theBases->Length();
2171 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2173 //Add a new Pipe object
2174 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
2176 //Add a new Pipe function
2178 Handle(GEOM_Function) aFunction =
2179 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2180 if (aFunction.IsNull()) return NULL;
2182 //Check if the function is set correctly
2183 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2185 GEOMImpl_IPipeShellSect aCI (aFunction);
2187 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2188 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2190 Standard_Integer i =1;
2191 for( ; i <= nbBases; i++) {
2193 Handle(Standard_Transient) anItem = theBases->Value(i);
2196 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2199 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2200 if(aRefBase.IsNull())
2204 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2205 if(anItemLoc.IsNull())
2207 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2210 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2211 if(aRefLoc.IsNull())
2213 aSeqLocs->Append(aRefLoc);
2216 aSeqBases->Append(aRefBase);
2219 if(!aSeqBases->Length())
2222 aCI.SetBases(aSeqBases);
2223 aCI.SetLocations(aSeqLocs);
2224 aCI.SetGenerateGroups(IsGenerateGroups);
2226 //Compute the Pipe value
2229 if (!GetSolver()->ComputeFunction(aFunction)) {
2230 SetErrorCode("Pipe with shell sections without path driver failed");
2234 catch (Standard_Failure& aFail) {
2235 SetErrorCode(aFail.GetMessageString());
2239 // Create the sequence of objects.
2240 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2242 aSeq->Append(aPipeDS);
2243 createGroups(aPipeDS, &aCI, aSeq);
2245 //Make a Python command
2246 GEOM::TPythonDump pyDump(aFunction);
2248 if (IsGenerateGroups) {
2254 pyDump << " = geompy.MakePipeShellsWithoutPath([";
2256 for(i =1 ; i <= nbBases; i++) {
2258 Handle(Standard_Transient) anItem = theBases->Value(i);
2262 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2263 if(!anObj.IsNull()) {
2272 for(i =1 ; i <= nbLocs; i++) {
2274 Handle(Standard_Transient) anItem = theLocations->Value(i);
2278 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2279 if(!anObj.IsNull()) {
2288 if (IsGenerateGroups) {
2299 //=============================================================================
2301 * MakePipeBiNormalAlongVector
2303 //=============================================================================
2304 Handle(TColStd_HSequenceOfTransient)
2305 GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector
2306 (const Handle(GEOM_Object) &theBase,
2307 const Handle(GEOM_Object) &thePath,
2308 const Handle(GEOM_Object) &theVec,
2309 const bool IsGenerateGroups)
2313 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2315 //Add a new Pipe object
2316 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GEOM_PIPE);
2318 //Add a new Pipe function
2319 Handle(GEOM_Function) aFunction =
2320 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2321 if (aFunction.IsNull()) return NULL;
2323 //Check if the function is set correctly
2324 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2326 GEOMImpl_IPipeBiNormal aCI (aFunction);
2328 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2329 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2330 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2332 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2334 aCI.SetBase(aRefBase);
2335 aCI.SetPath(aRefPath);
2336 aCI.SetVector(aRefVec);
2337 aCI.SetGenerateGroups(IsGenerateGroups);
2339 //Compute the Pipe value
2342 if (!GetSolver()->ComputeFunction(aFunction)) {
2343 SetErrorCode("Pipe driver failed");
2347 catch (Standard_Failure& aFail) {
2348 SetErrorCode(aFail.GetMessageString());
2352 // Create the sequence of objects.
2353 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2355 aSeq->Append(aPipe);
2356 createGroups(aPipe, &aCI, aSeq);
2358 //Make a Python command
2359 GEOM::TPythonDump pyDump(aFunction);
2361 if (IsGenerateGroups) {
2367 pyDump << " = geompy.MakePipeBiNormalAlongVector("
2368 << theBase << ", " << thePath << ", " << theVec;
2370 if (IsGenerateGroups) {
2380 //=============================================================================
2384 //=============================================================================
2385 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening
2386 (Handle(GEOM_Object) theObject,
2387 const Handle(TColStd_HArray1OfInteger) &theFacesIDs,
2394 if (theObject.IsNull()) return NULL;
2396 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2397 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2399 //Add a new Offset function
2400 Handle(GEOM_Function) aFunction;
2401 Handle(GEOM_Object) aCopy;
2404 //Add a new Copy object
2405 aCopy = GetEngine()->AddObject(theObject->GetType());
2406 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2409 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2411 if (aFunction.IsNull()) return NULL;
2413 //Check if the function is set correctly
2414 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2416 GEOMImpl_IOffset aTI (aFunction);
2417 aTI.SetShape(anOriginal);
2418 aTI.SetValue(theOffset);
2419 aTI.SetParam(theInside);
2421 if (theFacesIDs.IsNull() == Standard_False) {
2422 aTI.SetFaceIDs(theFacesIDs);
2425 //Compute the offset
2428 if (!GetSolver()->ComputeFunction(aFunction)) {
2429 SetErrorCode("Offset driver failed");
2433 catch (Standard_Failure& aFail) {
2434 SetErrorCode(aFail.GetMessageString());
2438 //Make a Python command
2439 GEOM::TPythonDump pd (aFunction);
2440 Handle(GEOM_Object) aResult;
2443 pd << aCopy << " = geompy.MakeThickSolid("
2444 << theObject << ", " << theOffset;
2447 pd << "geompy.Thicken(" << theObject << ", " << theOffset;
2448 aResult = theObject;
2452 if (theFacesIDs.IsNull() == Standard_False) {
2456 for (i = theFacesIDs->Lower(); i < theFacesIDs->Upper(); ++i) {
2457 pd << theFacesIDs->Value(i) << ", ";
2459 // Dump the last value.
2460 pd << theFacesIDs->Value(i);
2465 pd << ", " << theInside;
2473 //=============================================================================
2477 //=============================================================================
2478 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2479 Handle(GEOM_Object) theBase1,
2480 Handle(GEOM_Object) theBase2)
2484 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2486 // Add a new Path object
2487 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GEOM_PIPE_PATH);
2489 // Add a new Path function
2490 Handle(GEOM_Function) aFunction =
2491 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2492 if (aFunction.IsNull()) return NULL;
2494 // Check if the function is set correctly
2495 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2497 GEOMImpl_IPipePath aCI (aFunction);
2499 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2500 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2501 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2503 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2505 aCI.SetShape(aRefShape);
2506 aCI.SetBase1(aRefBase1);
2507 aCI.SetBase2(aRefBase2);
2509 // Compute the Path value
2512 if (!GetSolver()->ComputeFunction(aFunction)) {
2513 SetErrorCode("PipePath driver failed");
2517 catch (Standard_Failure& aFail) {
2518 SetErrorCode("RestorePath: inappropriate arguments given");
2522 // Make a Python command
2523 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2524 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2530 //=============================================================================
2534 //=============================================================================
2535 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2536 (Handle(GEOM_Object) theShape,
2537 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2538 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2542 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2544 Standard_Integer nbBases1 = theBase1->Length();
2545 Standard_Integer nbBases2 = theBase2->Length();
2547 if (!nbBases1 || !nbBases2)
2550 // Add a new Path object
2551 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GEOM_PIPE_PATH);
2553 // Add a new Path function
2554 Handle(GEOM_Function) aFunction =
2555 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2556 if (aFunction.IsNull()) return NULL;
2558 // Check if the function is set correctly
2559 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2561 GEOMImpl_IPipePath aCI (aFunction);
2563 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2564 if (aRefShape.IsNull()) return NULL;
2566 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2567 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2570 for (i = 1; i <= nbBases1; i++) {
2571 Handle(Standard_Transient) anItem = theBase1->Value(i);
2572 if (!anItem.IsNull()) {
2573 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2574 if (!aBase.IsNull()) {
2575 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2576 if (!aRefBase.IsNull())
2577 aSeqBases1->Append(aRefBase);
2581 for (i = 1; i <= nbBases2; i++) {
2582 Handle(Standard_Transient) anItem = theBase2->Value(i);
2583 if (!anItem.IsNull()) {
2584 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2585 if (!aBase.IsNull()) {
2586 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2587 if (!aRefBase.IsNull())
2588 aSeqBases2->Append(aRefBase);
2592 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2594 aCI.SetShape(aRefShape);
2595 aCI.SetBaseSeq1(aSeqBases1);
2596 aCI.SetBaseSeq2(aSeqBases2);
2598 // Compute the Path value
2601 if (!GetSolver()->ComputeFunction(aFunction)) {
2602 SetErrorCode("PipePath driver failed");
2606 catch (Standard_Failure& aFail) {
2607 SetErrorCode("RestorePath: inappropriate arguments given");
2611 // Make a Python command
2612 GEOM::TPythonDump pyDump (aFunction);
2613 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2614 for (i = 1; i <= nbBases1; i++) {
2615 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2616 if (!anObj.IsNull()) {
2623 for (i = 1; i <= nbBases2; i++) {
2624 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2625 if (!anObj.IsNull()) {
2637 //=============================================================================
2641 //=============================================================================
2642 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
2643 (const Handle(GEOM_Object) &theBaseObject,
2644 const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
2645 const TCollection_AsciiString &theName,
2646 const TopTools_IndexedMapOfShape &theIndices)
2648 if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
2652 // Get the Shape type.
2653 const Standard_Integer anID = theGroupIDs->Value(theGroupIDs->Lower());
2654 const Standard_Integer aNbShapes = theIndices.Extent();
2656 if (anID < 1 || anID > aNbShapes) {
2660 const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
2662 if (aSubShape.IsNull()) {
2667 const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
2668 Handle(GEOM_Object) aGroup =
2669 myGroupOperations->CreateGroup(theBaseObject, aGroupType);
2671 if (aGroup.IsNull() == Standard_False) {
2672 aGroup->GetLastFunction()->SetDescription("");
2673 aGroup->SetName(theName.ToCString());
2675 Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
2678 for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
2679 // Get and check the index.
2680 const Standard_Integer anIndex = theGroupIDs->Value(i);
2682 if (anIndex < 1 || anIndex > aNbShapes) {
2686 // Get and check the sub-shape.
2687 const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
2689 if (aSubShape.IsNull()) {
2693 // Check the shape type.
2694 if (aSubShape.ShapeType() != aGroupType) {
2698 aSeqIDs->Append(anIndex);
2701 myGroupOperations->UnionIDs(aGroup, aSeqIDs);
2702 aGroup->GetLastFunction()->SetDescription("");
2708 //=============================================================================
2712 //=============================================================================
2713 void GEOMImpl_I3DPrimOperations::createGroups
2714 (const Handle(GEOM_Object) &theBaseObject,
2715 GEOMImpl_IPipe *thePipe,
2716 Handle(TColStd_HSequenceOfTransient) &theSequence)
2718 if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
2722 TopoDS_Shape aShape = theBaseObject->GetValue();
2724 if (aShape.IsNull()) {
2728 TopTools_IndexedMapOfShape anIndices;
2729 Handle(TColStd_HArray1OfInteger) aGroupIDs;
2730 TopoDS_Shape aShapeType;
2731 const Standard_Integer aNbGroups = 5;
2732 Handle(GEOM_Object) aGrps[aNbGroups];
2735 TopExp::MapShapes(aShape, anIndices);
2738 aGroupIDs = thePipe->GetGroupDown();
2739 aGrps[0] = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
2740 aGroupIDs = thePipe->GetGroupUp();
2741 aGrps[1] = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
2742 aGroupIDs = thePipe->GetGroupSide1();
2743 aGrps[2] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
2744 aGroupIDs = thePipe->GetGroupSide2();
2745 aGrps[3] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
2746 aGroupIDs = thePipe->GetGroupOther();
2747 aGrps[4] = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
2749 for (i = 0; i < aNbGroups; ++i) {
2750 if (aGrps[i].IsNull() == Standard_False) {
2751 theSequence->Append(aGrps[i]);