1 // Copyright (C) 2007-2015 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 <Basics_OCCTVersion.hxx>
27 #include <GEOMImpl_I3DPrimOperations.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_Types.hxx>
43 #include <GEOMImpl_BoxDriver.hxx>
44 #include <GEOMImpl_FaceDriver.hxx>
45 #include <GEOMImpl_DiskDriver.hxx>
46 #include <GEOMImpl_CylinderDriver.hxx>
47 #include <GEOMImpl_ConeDriver.hxx>
48 #include <GEOMImpl_SphereDriver.hxx>
49 #include <GEOMImpl_TorusDriver.hxx>
50 #include <GEOMImpl_PrismDriver.hxx>
51 #include <GEOMImpl_PipeDriver.hxx>
52 #include <GEOMImpl_PipePathDriver.hxx>
53 #include <GEOMImpl_RevolutionDriver.hxx>
54 #include <GEOMImpl_ShapeDriver.hxx>
55 #include <GEOMImpl_FillingDriver.hxx>
56 #include <GEOMImpl_ThruSectionsDriver.hxx>
57 #include <GEOMImpl_OffsetDriver.hxx>
59 #include <GEOMImpl_IBox.hxx>
60 #include <GEOMImpl_IFace.hxx>
61 #include <GEOMImpl_IDisk.hxx>
62 #include <GEOMImpl_ICylinder.hxx>
63 #include <GEOMImpl_ICone.hxx>
64 #include <GEOMImpl_IGroupOperations.hxx>
65 #include <GEOMImpl_ISphere.hxx>
66 #include <GEOMImpl_ITorus.hxx>
67 #include <GEOMImpl_IPrism.hxx>
68 #include <GEOMImpl_IPipe.hxx>
69 #include <GEOMImpl_IRevolution.hxx>
70 #include <GEOMImpl_IFilling.hxx>
71 #include <GEOMImpl_IThruSections.hxx>
72 #include <GEOMImpl_IPipeDiffSect.hxx>
73 #include <GEOMImpl_IPipeShellSect.hxx>
74 #include <GEOMImpl_IPipeBiNormal.hxx>
75 #include <GEOMImpl_IOffset.hxx>
76 #include <GEOMImpl_IPipePath.hxx>
78 #include <Precision.hxx>
80 #include <TopTools_IndexedMapOfShape.hxx>
82 #include <Standard_Failure.hxx>
83 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
85 //=============================================================================
89 //=============================================================================
90 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
91 : GEOM_IOperations(theEngine, theDocID)
93 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
94 myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
97 //=============================================================================
101 //=============================================================================
102 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
104 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
105 delete myGroupOperations;
109 //=============================================================================
113 //=============================================================================
114 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
118 //Add a new Box object
119 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
121 //Add a new Box function with DX_DY_DZ parameters
122 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
123 if (aFunction.IsNull()) return NULL;
125 //Check if the function is set correctly
126 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
128 GEOMImpl_IBox aBI (aFunction);
134 //Compute the box value
137 if (!GetSolver()->ComputeFunction(aFunction)) {
138 SetErrorCode("Box driver failed");
142 catch (Standard_Failure) {
143 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
144 SetErrorCode(aFail->GetMessageString());
148 //Make a Python command
149 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
150 << theDX << ", " << theDY << ", " << theDZ << ")";
157 //=============================================================================
161 //=============================================================================
162 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
163 Handle(GEOM_Object) thePnt2)
167 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
169 //Add a new Box object
170 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
172 //Add a new Box function for creation a box relatively to two points
173 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
174 if (aFunction.IsNull()) return NULL;
176 //Check if the function is set correctly
177 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
179 GEOMImpl_IBox aBI (aFunction);
181 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
182 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
184 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
186 aBI.SetRef1(aRefFunction1);
187 aBI.SetRef2(aRefFunction2);
189 //Compute the Box value
192 if (!GetSolver()->ComputeFunction(aFunction)) {
193 SetErrorCode("Box driver failed");
197 catch (Standard_Failure) {
198 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
199 SetErrorCode(aFail->GetMessageString());
203 //Make a Python command
204 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
205 << thePnt1 << ", " << thePnt2 << ")";
211 //=============================================================================
215 //=============================================================================
216 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
220 if (theH == 0 || theW == 0) return NULL;
222 //Add a new Face object
223 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
225 //Add a new Box function for creation a box relatively to two points
226 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
227 if (aFunction.IsNull()) return NULL;
229 //Check if the function is set correctly
230 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
232 GEOMImpl_IFace aFI (aFunction);
236 aFI.SetOrientation(theOrientation);
241 if (!GetSolver()->ComputeFunction(aFunction)) {
242 SetErrorCode("Face driver failed");
246 catch (Standard_Failure) {
247 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
248 SetErrorCode(aFail->GetMessageString());
252 //Make a Python command
253 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
254 << theH << ", " << theW << ", " << theOrientation << ")";
260 //=============================================================================
264 //=============================================================================
265 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
266 double theH, double theW)
270 if (theObj.IsNull()) return NULL;
272 //Add a new Face object
273 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
275 //Add a new Box function for creation a box relatively to two points
276 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
277 if (aFunction.IsNull()) return NULL;
279 //Check if the function is set correctly
280 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
282 GEOMImpl_IFace aFI (aFunction);
284 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
286 if (aRefFunction1.IsNull())
289 aFI.SetRef1(aRefFunction1);
296 if (!GetSolver()->ComputeFunction(aFunction)) {
297 SetErrorCode("Face driver failed");
301 catch (Standard_Failure) {
302 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
303 SetErrorCode(aFail->GetMessageString());
307 //Make a Python command
308 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
309 << theObj << ", " << theH << ", " << theW << ")";
315 //=============================================================================
319 //=============================================================================
320 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
321 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
325 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
327 //Add a new Disk object
328 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
330 //Add a new Disk function for creation a disk relatively to point and vector
331 Handle(GEOM_Function) aFunction =
332 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
333 if (aFunction.IsNull()) return NULL;
335 //Check if the function is set correctly
336 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
338 GEOMImpl_IDisk aCI (aFunction);
340 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
341 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
343 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
345 aCI.SetCenter(aRefPnt);
346 aCI.SetVector(aRefVec);
349 //Compute the Disk value
352 if (!GetSolver()->ComputeFunction(aFunction)) {
353 SetErrorCode("Disk driver failed");
357 catch (Standard_Failure) {
358 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
359 SetErrorCode(aFail->GetMessageString());
363 //Make a Python command
364 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
365 << thePnt << ", " << theVec << ", " << theR << ")";
371 //=============================================================================
375 //=============================================================================
376 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
377 Handle(GEOM_Object) thePnt2,
378 Handle(GEOM_Object) thePnt3)
382 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
384 //Add a new Disk object
385 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
387 //Add a new Disk function for creation a disk relatively to three points
388 Handle(GEOM_Function) aFunction =
389 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
390 if (aFunction.IsNull()) return NULL;
392 //Check if the function is set correctly
393 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
395 GEOMImpl_IDisk aCI (aFunction);
397 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
398 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
399 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
401 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
403 aCI.SetPoint1(aRefPnt1);
404 aCI.SetPoint2(aRefPnt2);
405 aCI.SetPoint3(aRefPnt3);
407 //Compute the Disk value
410 if (!GetSolver()->ComputeFunction(aFunction)) {
411 SetErrorCode("Disk driver failed");
415 catch (Standard_Failure) {
416 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
417 SetErrorCode(aFail->GetMessageString());
421 //Make a Python command
422 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
423 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
429 //=============================================================================
433 //=============================================================================
434 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
438 if (theR == 0 ) return NULL;
440 //Add a new Disk object
441 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
443 //Add a new Box function for creation a box relatively to two points
444 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
445 if (aFunction.IsNull()) return NULL;
447 //Check if the function is set correctly
448 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
450 GEOMImpl_IDisk aDI (aFunction);
453 aDI.SetOrientation(theOrientation);
458 if (!GetSolver()->ComputeFunction(aFunction)) {
459 SetErrorCode("Disk driver failed");
463 catch (Standard_Failure) {
464 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
465 SetErrorCode(aFail->GetMessageString());
469 //Make a Python command
470 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
471 << theR << ", " << theOrientation << ")";
477 //=============================================================================
481 //=============================================================================
482 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
486 //Add a new Cylinder object
487 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
489 //Add a new Cylinder function with R and H parameters
490 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
491 if (aFunction.IsNull()) return NULL;
493 //Check if the function is set correctly
494 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
496 GEOMImpl_ICylinder aCI (aFunction);
501 //Compute the Cylinder value
504 if (!GetSolver()->ComputeFunction(aFunction)) {
505 SetErrorCode("Cylinder driver failed");
509 catch (Standard_Failure) {
510 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
511 SetErrorCode(aFail->GetMessageString());
515 //Make a Python command
516 GEOM::TPythonDump(aFunction) << aCylinder
517 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
523 //=============================================================================
527 //=============================================================================
528 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
532 //Add a new Cylinder object
533 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
535 //Add a new Cylinder function with R and H parameters
536 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
537 if (aFunction.IsNull()) return NULL;
539 //Check if the function is set correctly
540 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
542 GEOMImpl_ICylinder aCI (aFunction);
548 //Compute the Cylinder value
551 if (!GetSolver()->ComputeFunction(aFunction)) {
552 SetErrorCode("Cylinder driver failed");
556 catch (Standard_Failure) {
557 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
558 SetErrorCode(aFail->GetMessageString());
562 //Make a Python command
563 GEOM::TPythonDump(aFunction) << aCylinder
564 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
570 //=============================================================================
572 * MakeCylinderPntVecRH
574 //=============================================================================
575 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
576 Handle(GEOM_Object) theVec,
577 double theR, double theH)
581 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
583 //Add a new Cylinder object
584 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
586 //Add a new Cylinder function for creation a cylinder relatively to point and vector
587 Handle(GEOM_Function) aFunction =
588 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
589 if (aFunction.IsNull()) return NULL;
591 //Check if the function is set correctly
592 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
594 GEOMImpl_ICylinder aCI (aFunction);
596 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
597 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
599 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
601 aCI.SetPoint(aRefPnt);
602 aCI.SetVector(aRefVec);
606 //Compute the Cylinder value
609 if (!GetSolver()->ComputeFunction(aFunction)) {
610 SetErrorCode("Cylinder driver failed");
614 catch (Standard_Failure) {
615 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
616 SetErrorCode(aFail->GetMessageString());
620 //Make a Python command
621 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
622 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
628 //=============================================================================
630 * MakeCylinderPntVecRHA
632 //=============================================================================
633 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
634 Handle(GEOM_Object) theVec,
635 double theR, double theH, double theA)
639 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
641 //Add a new Cylinder object
642 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
644 //Add a new Cylinder function for creation a cylinder relatively to point and vector
645 Handle(GEOM_Function) aFunction =
646 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
647 if (aFunction.IsNull()) return NULL;
649 //Check if the function is set correctly
650 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
652 GEOMImpl_ICylinder aCI (aFunction);
654 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
655 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
657 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
659 aCI.SetPoint(aRefPnt);
660 aCI.SetVector(aRefVec);
665 //Compute the Cylinder value
668 if (!GetSolver()->ComputeFunction(aFunction)) {
669 SetErrorCode("Cylinder driver failed");
673 catch (Standard_Failure) {
674 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
675 SetErrorCode(aFail->GetMessageString());
679 //Make a Python command
680 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
681 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
688 //=============================================================================
692 //=============================================================================
693 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
698 //Add a new Cone object
699 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
701 //Add a new Cone function with R and H parameters
702 Handle(GEOM_Function) aFunction =
703 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
704 if (aFunction.IsNull()) return NULL;
706 //Check if the function is set correctly
707 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
709 GEOMImpl_ICone aCI (aFunction);
715 //Compute the Cone value
718 if (!GetSolver()->ComputeFunction(aFunction)) {
719 SetErrorCode("Cone driver failed");
723 catch (Standard_Failure) {
724 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
725 SetErrorCode(aFail->GetMessageString());
729 //Make a Python command
730 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
731 << theR1 << ", " << theR2 << ", " << theH << ")";
738 //=============================================================================
740 * MakeConePntVecR1R2H
742 //=============================================================================
743 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
744 Handle(GEOM_Object) theVec,
745 double theR1, double theR2,
750 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
752 //Add a new Cone object
753 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
755 //Add a new Cone function for creation a cone relatively to point and vector
756 Handle(GEOM_Function) aFunction =
757 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
758 if (aFunction.IsNull()) return NULL;
760 //Check if the function is set correctly
761 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
763 GEOMImpl_ICone aCI (aFunction);
765 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
766 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
768 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
770 aCI.SetPoint(aRefPnt);
771 aCI.SetVector(aRefVec);
776 //Compute the Cone value
779 if (!GetSolver()->ComputeFunction(aFunction)) {
780 SetErrorCode("Cone driver failed");
784 catch (Standard_Failure) {
785 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
786 SetErrorCode(aFail->GetMessageString());
790 //Make a Python command
791 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
792 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
799 //=============================================================================
803 //=============================================================================
804 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
808 //Add a new Sphere object
809 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
811 //Add a new Sphere function with R parameter
812 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
813 if (aFunction.IsNull()) return NULL;
815 //Check if the function is set correctly
816 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
818 GEOMImpl_ISphere aCI (aFunction);
822 //Compute the Sphere value
825 if (!GetSolver()->ComputeFunction(aFunction)) {
826 SetErrorCode("Sphere driver failed");
830 catch (Standard_Failure) {
831 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
832 SetErrorCode(aFail->GetMessageString());
836 //Make a Python command
837 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
844 //=============================================================================
848 //=============================================================================
849 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
854 if (thePnt.IsNull()) return NULL;
856 //Add a new Point object
857 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
859 //Add a new Sphere function for creation a sphere relatively to point
860 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
861 if (aFunction.IsNull()) return NULL;
863 //Check if the function is set correctly
864 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
866 GEOMImpl_ISphere aCI (aFunction);
868 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
870 if (aRefPnt.IsNull()) return NULL;
872 aCI.SetPoint(aRefPnt);
875 //Compute the Sphere value
878 if (!GetSolver()->ComputeFunction(aFunction)) {
879 SetErrorCode("Sphere driver failed");
883 catch (Standard_Failure) {
884 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
885 SetErrorCode(aFail->GetMessageString());
889 //Make a Python command
890 GEOM::TPythonDump(aFunction) << aSphere
891 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
898 //=============================================================================
902 //=============================================================================
903 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
904 (double theRMajor, double theRMinor)
908 //Add a new Torus object
909 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
911 //Add a new Torus function
912 Handle(GEOM_Function) aFunction =
913 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
914 if (aFunction.IsNull()) return NULL;
916 //Check if the function is set correctly
917 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
919 GEOMImpl_ITorus aCI (aFunction);
921 aCI.SetRMajor(theRMajor);
922 aCI.SetRMinor(theRMinor);
924 //Compute the Torus value
927 if (!GetSolver()->ComputeFunction(aFunction)) {
928 SetErrorCode("Torus driver failed");
932 catch (Standard_Failure) {
933 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
934 SetErrorCode(aFail->GetMessageString());
938 //Make a Python command
939 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
940 << theRMajor << ", " << theRMinor << ")";
946 //=============================================================================
950 //=============================================================================
951 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
952 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
953 double theRMajor, double theRMinor)
957 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
959 //Add a new Torus object
960 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
962 //Add a new Torus function
963 Handle(GEOM_Function) aFunction =
964 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
965 if (aFunction.IsNull()) return NULL;
967 //Check if the function is set correctly
968 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
970 GEOMImpl_ITorus aCI (aFunction);
972 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
973 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
975 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
977 aCI.SetCenter(aRefPnt);
978 aCI.SetVector(aRefVec);
979 aCI.SetRMajor(theRMajor);
980 aCI.SetRMinor(theRMinor);
982 //Compute the Torus value
985 if (!GetSolver()->ComputeFunction(aFunction)) {
986 SetErrorCode("Torus driver failed");
990 catch (Standard_Failure) {
991 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
992 SetErrorCode(aFail->GetMessageString());
996 //Make a Python command
997 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
998 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
1005 //=============================================================================
1009 //=============================================================================
1010 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
1011 Handle(GEOM_Object) theVec,
1012 double theH, double theScaleFactor)
1016 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1018 //Add a new Prism object
1019 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1021 //Add a new Prism function for creation a Prism relatively to vector
1022 Handle(GEOM_Function) aFunction =
1023 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1024 if (aFunction.IsNull()) return NULL;
1026 //Check if the function is set correctly
1027 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1029 GEOMImpl_IPrism aCI (aFunction);
1031 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1032 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1034 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1036 aCI.SetBase(aRefBase);
1037 aCI.SetVector(aRefVec);
1039 aCI.SetScale(theScaleFactor);
1041 //Compute the Prism value
1044 if (!GetSolver()->ComputeFunction(aFunction)) {
1045 //SetErrorCode("Prism driver failed");
1046 SetErrorCode("Extrusion can not be created, check input data");
1050 catch (Standard_Failure) {
1051 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1052 SetErrorCode(aFail->GetMessageString());
1056 //Make a Python command
1057 GEOM::TPythonDump pd (aFunction);
1058 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1059 if (theScaleFactor > Precision::Confusion())
1060 pd << ", " << theScaleFactor << ")";
1068 //=============================================================================
1070 * MakePrismVecH2Ways
1072 //=============================================================================
1073 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1074 Handle(GEOM_Object) theVec,
1079 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1081 //Add a new Prism object
1082 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1084 //Add a new Prism function for creation a Prism relatively to vector
1085 Handle(GEOM_Function) aFunction =
1086 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1087 if (aFunction.IsNull()) return NULL;
1089 //Check if the function is set correctly
1090 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1092 GEOMImpl_IPrism aCI (aFunction);
1094 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1095 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1097 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1099 aCI.SetBase(aRefBase);
1100 aCI.SetVector(aRefVec);
1103 //Compute the Prism value
1106 if (!GetSolver()->ComputeFunction(aFunction)) {
1107 //SetErrorCode("Prism driver failed");
1108 SetErrorCode("Extrusion can not be created, check input data");
1112 catch (Standard_Failure) {
1113 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1114 SetErrorCode(aFail->GetMessageString());
1118 //Make a Python command
1119 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1120 << theBase << ", " << theVec << ", " << theH << ")";
1126 //=============================================================================
1130 //=============================================================================
1131 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1132 (Handle(GEOM_Object) theBase,
1133 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1134 double theScaleFactor)
1138 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1140 //Add a new Prism object
1141 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1143 //Add a new Prism function for creation a Prism relatively to two points
1144 Handle(GEOM_Function) aFunction =
1145 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1146 if (aFunction.IsNull()) return NULL;
1148 //Check if the function is set correctly
1149 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1151 GEOMImpl_IPrism aCI (aFunction);
1153 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1154 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1155 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1157 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1159 aCI.SetBase(aRefBase);
1160 aCI.SetFirstPoint(aRefPnt1);
1161 aCI.SetLastPoint(aRefPnt2);
1162 aCI.SetScale(theScaleFactor);
1164 //Compute the Prism value
1167 if (!GetSolver()->ComputeFunction(aFunction)) {
1168 //SetErrorCode("Prism driver failed");
1169 SetErrorCode("Extrusion can not be created, check input data");
1173 catch (Standard_Failure) {
1174 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1175 SetErrorCode(aFail->GetMessageString());
1179 //Make a Python command
1180 GEOM::TPythonDump pd (aFunction);
1181 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1182 if (theScaleFactor > Precision::Confusion())
1183 pd << ", " << theScaleFactor << ")";
1191 //=============================================================================
1193 * MakePrismTwoPnt2Ways
1195 //=============================================================================
1196 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1197 (Handle(GEOM_Object) theBase,
1198 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1202 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1204 //Add a new Prism object
1205 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1207 //Add a new Prism function for creation a Prism relatively to two points
1208 Handle(GEOM_Function) aFunction =
1209 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1210 if (aFunction.IsNull()) return NULL;
1212 //Check if the function is set correctly
1213 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1215 GEOMImpl_IPrism aCI (aFunction);
1217 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1218 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1219 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1221 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1223 aCI.SetBase(aRefBase);
1224 aCI.SetFirstPoint(aRefPnt1);
1225 aCI.SetLastPoint(aRefPnt2);
1227 //Compute the Prism value
1230 if (!GetSolver()->ComputeFunction(aFunction)) {
1231 //SetErrorCode("Prism driver failed");
1232 SetErrorCode("Extrusion can not be created, check input data");
1236 catch (Standard_Failure) {
1237 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1238 SetErrorCode(aFail->GetMessageString());
1242 //Make a Python command
1243 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1244 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1250 //=============================================================================
1254 //=============================================================================
1255 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1256 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1257 double theScaleFactor)
1261 if (theBase.IsNull()) return NULL;
1263 //Add a new Prism object
1264 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1266 //Add a new Prism function for creation a Prism by DXDYDZ
1267 Handle(GEOM_Function) aFunction =
1268 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1269 if (aFunction.IsNull()) return NULL;
1271 //Check if the function is set correctly
1272 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1274 GEOMImpl_IPrism aCI (aFunction);
1276 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1278 if (aRefBase.IsNull()) return NULL;
1280 aCI.SetBase(aRefBase);
1284 aCI.SetScale(theScaleFactor);
1286 //Compute the Prism value
1289 if (!GetSolver()->ComputeFunction(aFunction)) {
1290 SetErrorCode("Extrusion can not be created, check input data");
1294 catch (Standard_Failure) {
1295 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1296 SetErrorCode(aFail->GetMessageString());
1300 //Make a Python command
1301 GEOM::TPythonDump pd (aFunction);
1302 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1303 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1304 if (theScaleFactor > Precision::Confusion())
1305 pd << ", " << theScaleFactor << ")";
1313 //=============================================================================
1315 * MakePrismDXDYDZ_2WAYS
1317 //=============================================================================
1318 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1319 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1323 if (theBase.IsNull()) return NULL;
1325 //Add a new Prism object
1326 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1328 //Add a new Prism function for creation a Prism by DXDYDZ
1329 Handle(GEOM_Function) aFunction =
1330 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1331 if (aFunction.IsNull()) return NULL;
1333 //Check if the function is set correctly
1334 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1336 GEOMImpl_IPrism aCI (aFunction);
1338 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1340 if (aRefBase.IsNull()) return NULL;
1342 aCI.SetBase(aRefBase);
1347 //Compute the Prism value
1350 if (!GetSolver()->ComputeFunction(aFunction)) {
1351 SetErrorCode("Extrusion can not be created, check input data");
1355 catch (Standard_Failure) {
1356 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1357 SetErrorCode(aFail->GetMessageString());
1361 //Make a Python command
1362 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1363 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1369 //=============================================================================
1373 //=============================================================================
1374 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1375 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse, bool theInvert)
1379 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1381 Handle(GEOM_Object) aPrism = NULL;
1385 //Add a new Extruded Boss object
1386 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1390 //Add a new Extruded Cut object
1391 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1394 //Add a new Prism function for the creation of a Draft Prism feature
1395 Handle(GEOM_Function) aFunction =
1396 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1397 if (aFunction.IsNull()) return NULL;
1399 //Check if the function is set correctly
1400 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1402 GEOMImpl_IPrism aCI (aFunction);
1404 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1405 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1407 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1410 aCI.SetBase(aRefBase);
1411 aCI.SetInitShape(aRefInit);
1412 aCI.SetH(theHeight);
1413 aCI.SetDraftAngle(theAngle);
1418 aCI.SetInvertFlag(theInvert);
1420 //Compute the Draft Prism Feature value
1423 if (!GetSolver()->ComputeFunction(aFunction)) {
1424 SetErrorCode("Extrusion can not be created, check input data");
1428 catch (Standard_Failure) {
1429 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1430 SetErrorCode(aFail->GetMessageString());
1434 //Make a Python command
1435 GEOM::TPythonDump pd (aFunction);
1438 pd << aPrism << " = geompy.MakeExtrudedBoss(" << theInitShape << ", " << theBase << ", "
1439 << theHeight << ", " << theAngle;
1443 pd << aPrism << " = geompy.MakeExtrudedCut(" << theInitShape << ", " << theBase << ", "
1444 << theHeight << ", " << theAngle;
1447 pd << ", " << theInvert;
1454 //=============================================================================
1458 //=============================================================================
1459 Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
1460 (const Handle(GEOM_Object) &theBase,
1461 const Handle(GEOM_Object) &thePath,
1462 const bool IsGenerateGroups)
1466 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1468 //Add a new Pipe object
1469 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1471 //Add a new Pipe function
1472 Handle(GEOM_Function) aFunction =
1473 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1474 if (aFunction.IsNull()) return NULL;
1476 //Check if the function is set correctly
1477 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1479 GEOMImpl_IPipe aCI (aFunction);
1481 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1482 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1484 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1486 aCI.SetBase(aRefBase);
1487 aCI.SetPath(aRefPath);
1488 aCI.SetGenerateGroups(IsGenerateGroups);
1490 //Compute the Pipe value
1493 if (!GetSolver()->ComputeFunction(aFunction)) {
1494 SetErrorCode("Pipe driver failed");
1498 catch (Standard_Failure) {
1499 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1500 SetErrorCode(aFail->GetMessageString());
1504 // Create the sequence of objects.
1505 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1507 aSeq->Append(aPipe);
1508 createGroups(aPipe, &aCI, aSeq);
1510 //Make a Python command
1511 GEOM::TPythonDump pyDump(aFunction);
1513 if (IsGenerateGroups) {
1519 pyDump << " = geompy.MakePipe(" << theBase << ", " << thePath;
1521 if (IsGenerateGroups) {
1532 //=============================================================================
1534 * MakeRevolutionAxisAngle
1536 //=============================================================================
1537 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1538 Handle(GEOM_Object) theAxis,
1543 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1545 //Add a new Revolution object
1546 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1548 //Add a new Revolution function for creation a revolution relatively to axis
1549 Handle(GEOM_Function) aFunction =
1550 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1551 if (aFunction.IsNull()) return NULL;
1553 //Check if the function is set correctly
1554 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1556 GEOMImpl_IRevolution aCI (aFunction);
1558 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1559 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1561 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1563 aCI.SetBase(aRefBase);
1564 aCI.SetAxis(aRefAxis);
1565 aCI.SetAngle(theAngle);
1567 //Compute the Revolution value
1570 if (!GetSolver()->ComputeFunction(aFunction)) {
1571 SetErrorCode("Revolution driver failed");
1575 catch (Standard_Failure) {
1576 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1577 SetErrorCode(aFail->GetMessageString());
1581 //Make a Python command
1582 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1583 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1589 //=============================================================================
1591 * MakeRevolutionAxisAngle2Ways
1593 //=============================================================================
1594 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1595 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1599 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1601 //Add a new Revolution object
1602 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1604 //Add a new Revolution function for creation a revolution relatively to axis
1605 Handle(GEOM_Function) aFunction =
1606 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1607 if (aFunction.IsNull()) return NULL;
1609 //Check if the function is set correctly
1610 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1612 GEOMImpl_IRevolution aCI (aFunction);
1614 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1615 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1617 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1619 aCI.SetBase(aRefBase);
1620 aCI.SetAxis(aRefAxis);
1621 aCI.SetAngle(theAngle);
1623 //Compute the Revolution value
1626 if (!GetSolver()->ComputeFunction(aFunction)) {
1627 SetErrorCode("Revolution driver failed");
1631 catch (Standard_Failure) {
1632 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1633 SetErrorCode(aFail->GetMessageString());
1637 //Make a Python command
1638 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1639 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1645 //=============================================================================
1649 //=============================================================================
1651 GEOMImpl_I3DPrimOperations::MakeFilling (std::list< Handle(GEOM_Object)> & theContours,
1652 int theMinDeg, int theMaxDeg,
1653 double theTol2D, double theTol3D, int theNbIter,
1654 int theMethod, bool isApprox)
1658 Handle(TColStd_HSequenceOfTransient) contours = GEOM_Object::GetLastFunctions( theContours );
1659 if ( contours.IsNull() || contours->IsEmpty() ) {
1660 SetErrorCode("NULL argument shape");
1663 //Add a new Filling object
1664 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1666 //Add a new Filling function for creation a filling from a compound
1667 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1668 if (aFunction.IsNull()) return NULL;
1670 //Check if the function is set correctly
1671 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1673 GEOMImpl_IFilling aFI (aFunction);
1674 aFI.SetShapes(contours);
1675 aFI.SetMinDeg(theMinDeg);
1676 aFI.SetMaxDeg(theMaxDeg);
1677 aFI.SetTol2D(theTol2D);
1678 aFI.SetTol3D(theTol3D);
1679 aFI.SetNbIter(theNbIter);
1680 aFI.SetApprox(isApprox);
1681 aFI.SetMethod(theMethod);
1683 //Compute the Solid value
1686 if (!GetSolver()->ComputeFunction(aFunction)) {
1687 SetErrorCode("Filling driver failed");
1691 catch (Standard_Failure) {
1692 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1693 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1694 SetErrorCode("B-Spline surface construction failed");
1696 SetErrorCode(aFail->GetMessageString());
1700 //Make a Python command
1701 GEOM::TPythonDump pd (aFunction);
1702 pd << aFilling << " = geompy.MakeFilling(" << theContours ;
1703 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1704 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1705 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1706 { pd << ", theTol2D=" << theTol2D ; }
1707 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1708 { pd << ", theTol3D=" << theTol3D ; }
1709 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1710 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1711 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1712 if ( isApprox ) pd << ", isApprox=" << isApprox ;
1719 //=============================================================================
1723 //=============================================================================
1724 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1725 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1730 Handle(GEOM_Object) anObj;
1732 if(theSeqSections.IsNull())
1735 Standard_Integer nbObj = theSeqSections->Length();
1739 //Add a new ThruSections object
1740 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1743 //Add a new ThruSections function
1745 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1746 Handle(GEOM_Function) aFunction =
1747 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1748 if (aFunction.IsNull()) return anObj;
1750 //Check if the function is set correctly
1751 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1753 GEOMImpl_IThruSections aCI (aFunction);
1755 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1757 Standard_Integer i =1;
1758 for( ; i <= nbObj; i++) {
1760 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1764 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1765 if(!aSectObj.IsNull())
1767 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1768 if(!aRefSect.IsNull())
1769 aSeqSections->Append(aRefSect);
1773 if(!aSeqSections->Length())
1776 aCI.SetSections(aSeqSections);
1777 aCI.SetSolidMode(theModeSolid);
1778 aCI.SetPrecision(thePreci);
1780 //Compute the ThruSections value
1783 if (!GetSolver()->ComputeFunction(aFunction)) {
1784 SetErrorCode("ThruSections driver failed");
1788 catch (Standard_Failure) {
1789 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1790 SetErrorCode(aFail->GetMessageString());
1794 //Make a Python command
1795 GEOM::TPythonDump pyDump(aFunction);
1796 pyDump << aThruSect << " = geompy.MakeThruSections([";
1798 for(i =1 ; i <= nbObj; i++) {
1800 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1804 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1805 if(!aSectObj.IsNull()) {
1812 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1819 //=============================================================================
1821 * MakePipeWithDifferentSections
1823 //=============================================================================
1824 Handle(TColStd_HSequenceOfTransient)
1825 GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections
1826 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1827 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1828 const Handle(GEOM_Object) &thePath,
1829 const bool theWithContact,
1830 const bool theWithCorrections,
1831 const bool IsGenerateGroups)
1834 if(theBases.IsNull())
1837 Standard_Integer nbBases = theBases->Length();
1842 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1843 //Add a new Pipe object
1844 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1846 //Add a new Pipe function
1848 Handle(GEOM_Function) aFunction =
1849 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1850 if (aFunction.IsNull()) return NULL;
1852 //Check if the function is set correctly
1853 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1855 GEOMImpl_IPipeDiffSect aCI (aFunction);
1857 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1858 if(aRefPath.IsNull())
1861 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1862 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1864 Standard_Integer i =1;
1865 for( ; i <= nbBases; i++) {
1867 Handle(Standard_Transient) anItem = theBases->Value(i);
1871 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1874 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1875 if(aRefBase.IsNull())
1879 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1880 if(anItemLoc.IsNull())
1883 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1886 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1887 if(aRefLoc.IsNull())
1889 aSeqLocs->Append(aRefLoc);
1891 aSeqBases->Append(aRefBase);
1894 if(!aSeqBases->Length())
1897 aCI.SetBases(aSeqBases);
1898 aCI.SetLocations(aSeqLocs);
1899 aCI.SetPath(aRefPath);
1900 aCI.SetWithContactMode(theWithContact);
1901 aCI.SetWithCorrectionMode(theWithCorrections);
1902 aCI.SetGenerateGroups(IsGenerateGroups);
1904 //Compute the Pipe value
1907 if (!GetSolver()->ComputeFunction(aFunction)) {
1908 SetErrorCode("Pipe with defferent section driver failed");
1912 catch (Standard_Failure) {
1913 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1914 SetErrorCode(aFail->GetMessageString());
1918 // Create the sequence of objects.
1919 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1921 aSeq->Append(aPipeDS);
1922 createGroups(aPipeDS, &aCI, aSeq);
1924 //Make a Python command
1925 GEOM::TPythonDump pyDump(aFunction);
1927 if (IsGenerateGroups) {
1933 pyDump << " = geompy.MakePipeWithDifferentSections([";
1935 for(i =1 ; i <= nbBases; i++) {
1937 Handle(Standard_Transient) anItem = theBases->Value(i);
1941 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1942 if(!anObj.IsNull()) {
1951 for(i =1 ; i <= nbLocs; i++) {
1953 Handle(Standard_Transient) anItem = theLocations->Value(i);
1957 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1958 if(!anObj.IsNull()) {
1965 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections;
1967 if (IsGenerateGroups) {
1978 //=============================================================================
1980 * MakePipeWithShellSections
1982 //=============================================================================
1983 Handle(TColStd_HSequenceOfTransient)
1984 GEOMImpl_I3DPrimOperations::MakePipeWithShellSections
1985 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1986 const Handle(TColStd_HSequenceOfTransient) &theSubBases,
1987 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1988 const Handle(GEOM_Object) &thePath,
1989 const bool theWithContact,
1990 const bool theWithCorrections,
1991 const bool IsGenerateGroups)
1994 if(theBases.IsNull())
1997 Standard_Integer nbBases = theBases->Length();
2002 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
2004 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2006 //Add a new Pipe object
2007 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2009 //Add a new Pipe function
2011 Handle(GEOM_Function) aFunction =
2012 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
2013 if (aFunction.IsNull()) return NULL;
2015 //Check if the function is set correctly
2016 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2018 //GEOMImpl_IPipeDiffSect aCI (aFunction);
2019 GEOMImpl_IPipeShellSect aCI (aFunction);
2021 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2022 if(aRefPath.IsNull())
2025 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2026 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
2027 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2029 Standard_Integer i =1;
2030 for( ; i <= nbBases; i++) {
2032 Handle(Standard_Transient) anItem = theBases->Value(i);
2035 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2038 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2039 if(aRefBase.IsNull())
2042 if( nbSubBases >= nbBases ) {
2043 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
2044 if(aSubItem.IsNull())
2046 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
2047 if(aSubBase.IsNull())
2049 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
2050 if(aRefSubBase.IsNull())
2052 aSeqSubBases->Append(aRefSubBase);
2056 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2057 if(anItemLoc.IsNull())
2059 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2062 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2063 if(aRefLoc.IsNull())
2065 aSeqLocs->Append(aRefLoc);
2068 aSeqBases->Append(aRefBase);
2071 if(!aSeqBases->Length())
2074 aCI.SetBases(aSeqBases);
2075 aCI.SetSubBases(aSeqSubBases);
2076 aCI.SetLocations(aSeqLocs);
2077 aCI.SetPath(aRefPath);
2078 aCI.SetWithContactMode(theWithContact);
2079 aCI.SetWithCorrectionMode(theWithCorrections);
2080 aCI.SetGenerateGroups(IsGenerateGroups);
2082 //Compute the Pipe value
2085 if (!GetSolver()->ComputeFunction(aFunction)) {
2086 SetErrorCode("Pipe with shell sections driver failed");
2090 catch (Standard_Failure) {
2091 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2092 SetErrorCode(aFail->GetMessageString());
2096 // Create the sequence of objects.
2097 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2099 aSeq->Append(aPipeDS);
2100 createGroups(aPipeDS, &aCI, aSeq);
2102 //Make a Python command
2103 GEOM::TPythonDump pyDump(aFunction);
2105 if (IsGenerateGroups) {
2111 pyDump << " = geompy.MakePipeWithShellSections([";
2113 for(i =1 ; i <= nbBases; i++) {
2115 Handle(Standard_Transient) anItem = theBases->Value(i);
2119 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2120 if(!anObj.IsNull()) {
2129 for(i =1 ; i <= nbSubBases; i++) {
2131 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2135 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2136 if(!anObj.IsNull()) {
2145 for(i =1 ; i <= nbLocs; i++) {
2147 Handle(Standard_Transient) anItem = theLocations->Value(i);
2151 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2152 if(!anObj.IsNull()) {
2159 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections;
2161 if (IsGenerateGroups) {
2173 //=============================================================================
2175 * MakePipeShellsWithoutPath
2177 //=============================================================================
2178 Handle(TColStd_HSequenceOfTransient)
2179 GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath
2180 (const Handle(TColStd_HSequenceOfTransient) &theBases,
2181 const Handle(TColStd_HSequenceOfTransient) &theLocations,
2182 const bool IsGenerateGroups)
2185 if(theBases.IsNull())
2188 Standard_Integer nbBases = theBases->Length();
2193 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2195 //Add a new Pipe object
2196 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2198 //Add a new Pipe function
2200 Handle(GEOM_Function) aFunction =
2201 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2202 if (aFunction.IsNull()) return NULL;
2204 //Check if the function is set correctly
2205 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2207 GEOMImpl_IPipeShellSect aCI (aFunction);
2209 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2210 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2212 Standard_Integer i =1;
2213 for( ; i <= nbBases; i++) {
2215 Handle(Standard_Transient) anItem = theBases->Value(i);
2218 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2221 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2222 if(aRefBase.IsNull())
2226 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2227 if(anItemLoc.IsNull())
2229 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2232 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2233 if(aRefLoc.IsNull())
2235 aSeqLocs->Append(aRefLoc);
2238 aSeqBases->Append(aRefBase);
2241 if(!aSeqBases->Length())
2244 aCI.SetBases(aSeqBases);
2245 aCI.SetLocations(aSeqLocs);
2246 aCI.SetGenerateGroups(IsGenerateGroups);
2248 //Compute the Pipe value
2251 if (!GetSolver()->ComputeFunction(aFunction)) {
2252 SetErrorCode("Pipe with shell sections without path driver failed");
2256 catch (Standard_Failure) {
2257 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2258 SetErrorCode(aFail->GetMessageString());
2262 // Create the sequence of objects.
2263 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2265 aSeq->Append(aPipeDS);
2266 createGroups(aPipeDS, &aCI, aSeq);
2268 //Make a Python command
2269 GEOM::TPythonDump pyDump(aFunction);
2271 if (IsGenerateGroups) {
2277 pyDump << " = geompy.MakePipeShellsWithoutPath([";
2279 for(i =1 ; i <= nbBases; i++) {
2281 Handle(Standard_Transient) anItem = theBases->Value(i);
2285 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2286 if(!anObj.IsNull()) {
2295 for(i =1 ; i <= nbLocs; i++) {
2297 Handle(Standard_Transient) anItem = theLocations->Value(i);
2301 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2302 if(!anObj.IsNull()) {
2311 if (IsGenerateGroups) {
2322 //=============================================================================
2324 * MakePipeBiNormalAlongVector
2326 //=============================================================================
2327 Handle(TColStd_HSequenceOfTransient)
2328 GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector
2329 (const Handle(GEOM_Object) &theBase,
2330 const Handle(GEOM_Object) &thePath,
2331 const Handle(GEOM_Object) &theVec,
2332 const bool IsGenerateGroups)
2336 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2338 //Add a new Pipe object
2339 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2341 //Add a new Pipe function
2342 Handle(GEOM_Function) aFunction =
2343 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2344 if (aFunction.IsNull()) return NULL;
2346 //Check if the function is set correctly
2347 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2349 GEOMImpl_IPipeBiNormal aCI (aFunction);
2351 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2352 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2353 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2355 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2357 aCI.SetBase(aRefBase);
2358 aCI.SetPath(aRefPath);
2359 aCI.SetVector(aRefVec);
2360 aCI.SetGenerateGroups(IsGenerateGroups);
2362 //Compute the Pipe value
2365 if (!GetSolver()->ComputeFunction(aFunction)) {
2366 SetErrorCode("Pipe driver failed");
2370 catch (Standard_Failure) {
2371 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2372 SetErrorCode(aFail->GetMessageString());
2376 // Create the sequence of objects.
2377 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2379 aSeq->Append(aPipe);
2380 createGroups(aPipe, &aCI, aSeq);
2382 //Make a Python command
2383 GEOM::TPythonDump pyDump(aFunction);
2385 if (IsGenerateGroups) {
2391 pyDump << " = geompy.MakePipeBiNormalAlongVector("
2392 << theBase << ", " << thePath << ", " << theVec;
2394 if (IsGenerateGroups) {
2404 //=============================================================================
2408 //=============================================================================
2409 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening
2410 (Handle(GEOM_Object) theObject,
2411 const Handle(TColStd_HArray1OfInteger) &theFacesIDs,
2418 if (theObject.IsNull()) return NULL;
2420 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2421 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2423 //Add a new Offset function
2424 Handle(GEOM_Function) aFunction;
2425 Handle(GEOM_Object) aCopy;
2428 //Add a new Copy object
2429 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2430 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2433 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2435 if (aFunction.IsNull()) return NULL;
2437 //Check if the function is set correctly
2438 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2440 GEOMImpl_IOffset aTI (aFunction);
2441 aTI.SetShape(anOriginal);
2442 aTI.SetValue(theOffset);
2443 aTI.SetParam(theInside);
2445 if (theFacesIDs.IsNull() == Standard_False) {
2446 aTI.SetFaceIDs(theFacesIDs);
2449 //Compute the offset
2452 if (!GetSolver()->ComputeFunction(aFunction)) {
2453 SetErrorCode("Offset driver failed");
2457 catch (Standard_Failure) {
2458 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2459 SetErrorCode(aFail->GetMessageString());
2463 //Make a Python command
2464 GEOM::TPythonDump pd (aFunction);
2465 Handle(GEOM_Object) aResult;
2468 pd << aCopy << " = geompy.MakeThickSolid("
2469 << theObject << ", " << theOffset;
2472 pd << "geompy.Thicken(" << theObject << ", " << theOffset;
2473 aResult = theObject;
2477 if (theFacesIDs.IsNull() == Standard_False) {
2481 for (i = theFacesIDs->Lower(); i < theFacesIDs->Upper(); ++i) {
2482 pd << theFacesIDs->Value(i) << ", ";
2484 // Dump the last value.
2485 pd << theFacesIDs->Value(i);
2490 pd << ", " << theInside;
2498 //=============================================================================
2502 //=============================================================================
2503 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2504 Handle(GEOM_Object) theBase1,
2505 Handle(GEOM_Object) theBase2)
2509 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2511 // Add a new Path object
2512 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2514 // Add a new Path function
2515 Handle(GEOM_Function) aFunction =
2516 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2517 if (aFunction.IsNull()) return NULL;
2519 // Check if the function is set correctly
2520 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2522 GEOMImpl_IPipePath aCI (aFunction);
2524 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2525 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2526 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2528 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2530 aCI.SetShape(aRefShape);
2531 aCI.SetBase1(aRefBase1);
2532 aCI.SetBase2(aRefBase2);
2534 // Compute the Path value
2537 if (!GetSolver()->ComputeFunction(aFunction)) {
2538 SetErrorCode("PipePath driver failed");
2542 catch (Standard_Failure) {
2543 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2544 SetErrorCode("RestorePath: inappropriate arguments given");
2548 // Make a Python command
2549 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2550 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2556 //=============================================================================
2560 //=============================================================================
2561 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2562 (Handle(GEOM_Object) theShape,
2563 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2564 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2568 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2570 Standard_Integer nbBases1 = theBase1->Length();
2571 Standard_Integer nbBases2 = theBase2->Length();
2573 if (!nbBases1 || !nbBases2)
2576 // Add a new Path object
2577 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2579 // Add a new Path function
2580 Handle(GEOM_Function) aFunction =
2581 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2582 if (aFunction.IsNull()) return NULL;
2584 // Check if the function is set correctly
2585 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2587 GEOMImpl_IPipePath aCI (aFunction);
2589 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2590 if (aRefShape.IsNull()) return NULL;
2592 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2593 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2596 for (i = 1; i <= nbBases1; i++) {
2597 Handle(Standard_Transient) anItem = theBase1->Value(i);
2598 if (!anItem.IsNull()) {
2599 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2600 if (!aBase.IsNull()) {
2601 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2602 if (!aRefBase.IsNull())
2603 aSeqBases1->Append(aRefBase);
2607 for (i = 1; i <= nbBases2; i++) {
2608 Handle(Standard_Transient) anItem = theBase2->Value(i);
2609 if (!anItem.IsNull()) {
2610 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2611 if (!aBase.IsNull()) {
2612 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2613 if (!aRefBase.IsNull())
2614 aSeqBases2->Append(aRefBase);
2618 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2620 aCI.SetShape(aRefShape);
2621 aCI.SetBaseSeq1(aSeqBases1);
2622 aCI.SetBaseSeq2(aSeqBases2);
2624 // Compute the Path value
2627 if (!GetSolver()->ComputeFunction(aFunction)) {
2628 SetErrorCode("PipePath driver failed");
2632 catch (Standard_Failure) {
2633 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2634 SetErrorCode("RestorePath: inappropriate arguments given");
2638 // Make a Python command
2639 GEOM::TPythonDump pyDump (aFunction);
2640 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2641 for (i = 1; i <= nbBases1; i++) {
2642 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2643 if (!anObj.IsNull()) {
2650 for (i = 1; i <= nbBases2; i++) {
2651 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2652 if (!anObj.IsNull()) {
2664 //=============================================================================
2668 //=============================================================================
2669 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
2670 (const Handle(GEOM_Object) &theBaseObject,
2671 const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
2672 const TCollection_AsciiString &theName,
2673 const TopTools_IndexedMapOfShape &theIndices)
2675 if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
2679 // Get the Shape type.
2680 const Standard_Integer anID = theGroupIDs->Value(theGroupIDs->Lower());
2681 const Standard_Integer aNbShapes = theIndices.Extent();
2683 if (anID < 1 || anID > aNbShapes) {
2687 const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
2689 if (aSubShape.IsNull()) {
2694 const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
2695 Handle(GEOM_Object) aGroup =
2696 myGroupOperations->CreateGroup(theBaseObject, aGroupType);
2698 if (aGroup.IsNull() == Standard_False) {
2699 aGroup->GetLastFunction()->SetDescription("");
2700 aGroup->SetName(theName.ToCString());
2702 Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
2705 for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
2706 // Get and check the index.
2707 const Standard_Integer anIndex = theGroupIDs->Value(i);
2709 if (anIndex < 1 || anIndex > aNbShapes) {
2713 // Get and check the sub-shape.
2714 const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
2716 if (aSubShape.IsNull()) {
2720 // Check the shape type.
2721 if (aSubShape.ShapeType() != aGroupType) {
2725 aSeqIDs->Append(anIndex);
2728 myGroupOperations->UnionIDs(aGroup, aSeqIDs);
2729 aGroup->GetLastFunction()->SetDescription("");
2735 //=============================================================================
2739 //=============================================================================
2740 void GEOMImpl_I3DPrimOperations::createGroups
2741 (const Handle(GEOM_Object) &theBaseObject,
2742 GEOMImpl_IPipe *thePipe,
2743 Handle(TColStd_HSequenceOfTransient) &theSequence)
2745 if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
2749 TopoDS_Shape aShape = theBaseObject->GetValue();
2751 if (aShape.IsNull()) {
2755 TopTools_IndexedMapOfShape anIndices;
2756 Handle(TColStd_HArray1OfInteger) aGroupIDs;
2757 TopoDS_Shape aShapeType;
2758 const Standard_Integer aNbGroups = 5;
2759 Handle(GEOM_Object) aGrps[aNbGroups];
2762 TopExp::MapShapes(aShape, anIndices);
2765 aGroupIDs = thePipe->GetGroupDown();
2766 aGrps[0] = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
2767 aGroupIDs = thePipe->GetGroupUp();
2768 aGrps[1] = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
2769 aGroupIDs = thePipe->GetGroupSide1();
2770 aGrps[2] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
2771 aGroupIDs = thePipe->GetGroupSide2();
2772 aGrps[3] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
2773 aGroupIDs = thePipe->GetGroupOther();
2774 aGrps[4] = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
2776 for (i = 0; i < aNbGroups; ++i) {
2777 if (aGrps[i].IsNull() == Standard_False) {
2778 theSequence->Append(aGrps[i]);