1 // Copyright (C) 2007-2014 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_ISphere.hxx>
65 #include <GEOMImpl_ITorus.hxx>
66 #include <GEOMImpl_IPrism.hxx>
67 #include <GEOMImpl_IPipe.hxx>
68 #include <GEOMImpl_IRevolution.hxx>
69 #include <GEOMImpl_IFilling.hxx>
70 #include <GEOMImpl_IThruSections.hxx>
71 #include <GEOMImpl_IPipeDiffSect.hxx>
72 #include <GEOMImpl_IPipeShellSect.hxx>
73 #include <GEOMImpl_IPipeBiNormal.hxx>
74 #include <GEOMImpl_IOffset.hxx>
75 #include <GEOMImpl_IPipePath.hxx>
77 #include <Precision.hxx>
79 #include <Standard_Failure.hxx>
80 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
82 //=============================================================================
86 //=============================================================================
87 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
88 : GEOM_IOperations(theEngine, theDocID)
90 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
93 //=============================================================================
97 //=============================================================================
98 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
100 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
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(GetDocID(), 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) {
138 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
139 SetErrorCode(aFail->GetMessageString());
143 //Make a Python command
144 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
145 << theDX << ", " << theDY << ", " << theDZ << ")";
152 //=============================================================================
156 //=============================================================================
157 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
158 Handle(GEOM_Object) thePnt2)
162 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
164 //Add a new Box object
165 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
167 //Add a new Box function for creation a box relatively to two points
168 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
169 if (aFunction.IsNull()) return NULL;
171 //Check if the function is set correctly
172 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
174 GEOMImpl_IBox aBI (aFunction);
176 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
177 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
179 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
181 aBI.SetRef1(aRefFunction1);
182 aBI.SetRef2(aRefFunction2);
184 //Compute the Box value
187 if (!GetSolver()->ComputeFunction(aFunction)) {
188 SetErrorCode("Box driver failed");
192 catch (Standard_Failure) {
193 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
194 SetErrorCode(aFail->GetMessageString());
198 //Make a Python command
199 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
200 << thePnt1 << ", " << thePnt2 << ")";
206 //=============================================================================
210 //=============================================================================
211 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
215 if (theH == 0 || theW == 0) return NULL;
217 //Add a new Face object
218 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
220 //Add a new Box function for creation a box relatively to two points
221 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
222 if (aFunction.IsNull()) return NULL;
224 //Check if the function is set correctly
225 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
227 GEOMImpl_IFace aFI (aFunction);
231 aFI.SetOrientation(theOrientation);
236 if (!GetSolver()->ComputeFunction(aFunction)) {
237 SetErrorCode("Face driver failed");
241 catch (Standard_Failure) {
242 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
243 SetErrorCode(aFail->GetMessageString());
247 //Make a Python command
248 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
249 << theH << ", " << theW << ", " << theOrientation << ")";
255 //=============================================================================
259 //=============================================================================
260 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
261 double theH, double theW)
265 if (theObj.IsNull()) return NULL;
267 //Add a new Face object
268 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
270 //Add a new Box function for creation a box relatively to two points
271 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
272 if (aFunction.IsNull()) return NULL;
274 //Check if the function is set correctly
275 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
277 GEOMImpl_IFace aFI (aFunction);
279 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
281 if (aRefFunction1.IsNull())
284 aFI.SetRef1(aRefFunction1);
291 if (!GetSolver()->ComputeFunction(aFunction)) {
292 SetErrorCode("Face driver failed");
296 catch (Standard_Failure) {
297 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
298 SetErrorCode(aFail->GetMessageString());
302 //Make a Python command
303 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
304 << theObj << ", " << theH << ", " << theW << ")";
310 //=============================================================================
314 //=============================================================================
315 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
316 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
320 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
322 //Add a new Disk object
323 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
325 //Add a new Disk function for creation a disk relatively to point and vector
326 Handle(GEOM_Function) aFunction =
327 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
328 if (aFunction.IsNull()) return NULL;
330 //Check if the function is set correctly
331 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
333 GEOMImpl_IDisk aCI (aFunction);
335 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
336 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
338 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
340 aCI.SetCenter(aRefPnt);
341 aCI.SetVector(aRefVec);
344 //Compute the Disk value
347 if (!GetSolver()->ComputeFunction(aFunction)) {
348 SetErrorCode("Disk driver failed");
352 catch (Standard_Failure) {
353 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
354 SetErrorCode(aFail->GetMessageString());
358 //Make a Python command
359 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
360 << thePnt << ", " << theVec << ", " << theR << ")";
366 //=============================================================================
370 //=============================================================================
371 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
372 Handle(GEOM_Object) thePnt2,
373 Handle(GEOM_Object) thePnt3)
377 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
379 //Add a new Disk object
380 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
382 //Add a new Disk function for creation a disk relatively to three points
383 Handle(GEOM_Function) aFunction =
384 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
385 if (aFunction.IsNull()) return NULL;
387 //Check if the function is set correctly
388 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
390 GEOMImpl_IDisk aCI (aFunction);
392 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
393 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
394 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
396 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
398 aCI.SetPoint1(aRefPnt1);
399 aCI.SetPoint2(aRefPnt2);
400 aCI.SetPoint3(aRefPnt3);
402 //Compute the Disk value
405 if (!GetSolver()->ComputeFunction(aFunction)) {
406 SetErrorCode("Disk driver failed");
410 catch (Standard_Failure) {
411 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
412 SetErrorCode(aFail->GetMessageString());
416 //Make a Python command
417 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
418 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
424 //=============================================================================
428 //=============================================================================
429 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
433 if (theR == 0 ) return NULL;
435 //Add a new Disk object
436 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
438 //Add a new Box function for creation a box relatively to two points
439 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
440 if (aFunction.IsNull()) return NULL;
442 //Check if the function is set correctly
443 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
445 GEOMImpl_IDisk aDI (aFunction);
448 aDI.SetOrientation(theOrientation);
453 if (!GetSolver()->ComputeFunction(aFunction)) {
454 SetErrorCode("Disk driver failed");
458 catch (Standard_Failure) {
459 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
460 SetErrorCode(aFail->GetMessageString());
464 //Make a Python command
465 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
466 << theR << ", " << theOrientation << ")";
472 //=============================================================================
476 //=============================================================================
477 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
481 //Add a new Cylinder object
482 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
484 //Add a new Cylinder function with R and H parameters
485 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
486 if (aFunction.IsNull()) return NULL;
488 //Check if the function is set correctly
489 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
491 GEOMImpl_ICylinder aCI (aFunction);
496 //Compute the Cylinder value
499 if (!GetSolver()->ComputeFunction(aFunction)) {
500 SetErrorCode("Cylinder driver failed");
504 catch (Standard_Failure) {
505 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
506 SetErrorCode(aFail->GetMessageString());
510 //Make a Python command
511 GEOM::TPythonDump(aFunction) << aCylinder
512 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
518 //=============================================================================
522 //=============================================================================
523 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
527 //Add a new Cylinder object
528 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
530 //Add a new Cylinder function with R and H parameters
531 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
532 if (aFunction.IsNull()) return NULL;
534 //Check if the function is set correctly
535 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
537 GEOMImpl_ICylinder aCI (aFunction);
543 //Compute the Cylinder value
546 if (!GetSolver()->ComputeFunction(aFunction)) {
547 SetErrorCode("Cylinder driver failed");
551 catch (Standard_Failure) {
552 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
553 SetErrorCode(aFail->GetMessageString());
557 //Make a Python command
558 GEOM::TPythonDump(aFunction) << aCylinder
559 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
565 //=============================================================================
567 * MakeCylinderPntVecRH
569 //=============================================================================
570 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
571 Handle(GEOM_Object) theVec,
572 double theR, double theH)
576 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
578 //Add a new Cylinder object
579 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
581 //Add a new Cylinder function for creation a cylinder relatively to point and vector
582 Handle(GEOM_Function) aFunction =
583 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
584 if (aFunction.IsNull()) return NULL;
586 //Check if the function is set correctly
587 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
589 GEOMImpl_ICylinder aCI (aFunction);
591 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
592 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
594 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
596 aCI.SetPoint(aRefPnt);
597 aCI.SetVector(aRefVec);
601 //Compute the Cylinder value
604 if (!GetSolver()->ComputeFunction(aFunction)) {
605 SetErrorCode("Cylinder driver failed");
609 catch (Standard_Failure) {
610 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
611 SetErrorCode(aFail->GetMessageString());
615 //Make a Python command
616 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
617 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
623 //=============================================================================
625 * MakeCylinderPntVecRHA
627 //=============================================================================
628 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
629 Handle(GEOM_Object) theVec,
630 double theR, double theH, double theA)
634 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
636 //Add a new Cylinder object
637 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
639 //Add a new Cylinder function for creation a cylinder relatively to point and vector
640 Handle(GEOM_Function) aFunction =
641 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
642 if (aFunction.IsNull()) return NULL;
644 //Check if the function is set correctly
645 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
647 GEOMImpl_ICylinder aCI (aFunction);
649 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
650 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
652 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
654 aCI.SetPoint(aRefPnt);
655 aCI.SetVector(aRefVec);
660 //Compute the Cylinder value
663 if (!GetSolver()->ComputeFunction(aFunction)) {
664 SetErrorCode("Cylinder driver failed");
668 catch (Standard_Failure) {
669 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
670 SetErrorCode(aFail->GetMessageString());
674 //Make a Python command
675 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
676 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
683 //=============================================================================
687 //=============================================================================
688 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
693 //Add a new Cone object
694 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
696 //Add a new Cone function with R and H parameters
697 Handle(GEOM_Function) aFunction =
698 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
699 if (aFunction.IsNull()) return NULL;
701 //Check if the function is set correctly
702 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
704 GEOMImpl_ICone aCI (aFunction);
710 //Compute the Cone value
713 if (!GetSolver()->ComputeFunction(aFunction)) {
714 SetErrorCode("Cone driver failed");
718 catch (Standard_Failure) {
719 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
720 SetErrorCode(aFail->GetMessageString());
724 //Make a Python command
725 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
726 << theR1 << ", " << theR2 << ", " << theH << ")";
733 //=============================================================================
735 * MakeConePntVecR1R2H
737 //=============================================================================
738 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
739 Handle(GEOM_Object) theVec,
740 double theR1, double theR2,
745 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
747 //Add a new Cone object
748 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
750 //Add a new Cone function for creation a cone relatively to point and vector
751 Handle(GEOM_Function) aFunction =
752 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
753 if (aFunction.IsNull()) return NULL;
755 //Check if the function is set correctly
756 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
758 GEOMImpl_ICone aCI (aFunction);
760 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
761 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
763 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
765 aCI.SetPoint(aRefPnt);
766 aCI.SetVector(aRefVec);
771 //Compute the Cone value
774 if (!GetSolver()->ComputeFunction(aFunction)) {
775 SetErrorCode("Cone driver failed");
779 catch (Standard_Failure) {
780 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
781 SetErrorCode(aFail->GetMessageString());
785 //Make a Python command
786 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
787 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
794 //=============================================================================
798 //=============================================================================
799 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
803 //Add a new Sphere object
804 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
806 //Add a new Sphere function with R parameter
807 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
808 if (aFunction.IsNull()) return NULL;
810 //Check if the function is set correctly
811 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
813 GEOMImpl_ISphere aCI (aFunction);
817 //Compute the Sphere value
820 if (!GetSolver()->ComputeFunction(aFunction)) {
821 SetErrorCode("Sphere driver failed");
825 catch (Standard_Failure) {
826 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
827 SetErrorCode(aFail->GetMessageString());
831 //Make a Python command
832 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
839 //=============================================================================
843 //=============================================================================
844 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
849 if (thePnt.IsNull()) return NULL;
851 //Add a new Point object
852 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
854 //Add a new Sphere function for creation a sphere relatively to point
855 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
856 if (aFunction.IsNull()) return NULL;
858 //Check if the function is set correctly
859 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
861 GEOMImpl_ISphere aCI (aFunction);
863 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
865 if (aRefPnt.IsNull()) return NULL;
867 aCI.SetPoint(aRefPnt);
870 //Compute the Sphere value
873 if (!GetSolver()->ComputeFunction(aFunction)) {
874 SetErrorCode("Sphere driver failed");
878 catch (Standard_Failure) {
879 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
880 SetErrorCode(aFail->GetMessageString());
884 //Make a Python command
885 GEOM::TPythonDump(aFunction) << aSphere
886 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
893 //=============================================================================
897 //=============================================================================
898 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
899 (double theRMajor, double theRMinor)
903 //Add a new Torus object
904 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
906 //Add a new Torus function
907 Handle(GEOM_Function) aFunction =
908 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
909 if (aFunction.IsNull()) return NULL;
911 //Check if the function is set correctly
912 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
914 GEOMImpl_ITorus aCI (aFunction);
916 aCI.SetRMajor(theRMajor);
917 aCI.SetRMinor(theRMinor);
919 //Compute the Torus value
922 if (!GetSolver()->ComputeFunction(aFunction)) {
923 SetErrorCode("Torus driver failed");
927 catch (Standard_Failure) {
928 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
929 SetErrorCode(aFail->GetMessageString());
933 //Make a Python command
934 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
935 << theRMajor << ", " << theRMinor << ")";
941 //=============================================================================
945 //=============================================================================
946 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
947 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
948 double theRMajor, double theRMinor)
952 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
954 //Add a new Torus object
955 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
957 //Add a new Torus function
958 Handle(GEOM_Function) aFunction =
959 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
960 if (aFunction.IsNull()) return NULL;
962 //Check if the function is set correctly
963 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
965 GEOMImpl_ITorus aCI (aFunction);
967 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
968 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
970 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
972 aCI.SetCenter(aRefPnt);
973 aCI.SetVector(aRefVec);
974 aCI.SetRMajor(theRMajor);
975 aCI.SetRMinor(theRMinor);
977 //Compute the Torus value
980 if (!GetSolver()->ComputeFunction(aFunction)) {
981 SetErrorCode("Torus driver failed");
985 catch (Standard_Failure) {
986 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
987 SetErrorCode(aFail->GetMessageString());
991 //Make a Python command
992 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
993 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
1000 //=============================================================================
1004 //=============================================================================
1005 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
1006 Handle(GEOM_Object) theVec,
1007 double theH, double theScaleFactor)
1011 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1013 //Add a new Prism object
1014 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1016 //Add a new Prism function for creation a Prism relatively to vector
1017 Handle(GEOM_Function) aFunction =
1018 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1019 if (aFunction.IsNull()) return NULL;
1021 //Check if the function is set correctly
1022 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1024 GEOMImpl_IPrism aCI (aFunction);
1026 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1027 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1029 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1031 aCI.SetBase(aRefBase);
1032 aCI.SetVector(aRefVec);
1034 aCI.SetScale(theScaleFactor);
1036 //Compute the Prism value
1039 if (!GetSolver()->ComputeFunction(aFunction)) {
1040 //SetErrorCode("Prism driver failed");
1041 SetErrorCode("Extrusion can not be created, check input data");
1045 catch (Standard_Failure) {
1046 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1047 SetErrorCode(aFail->GetMessageString());
1051 //Make a Python command
1052 GEOM::TPythonDump pd (aFunction);
1053 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1054 if (theScaleFactor > Precision::Confusion())
1055 pd << ", " << theScaleFactor << ")";
1063 //=============================================================================
1065 * MakePrismVecH2Ways
1067 //=============================================================================
1068 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1069 Handle(GEOM_Object) theVec,
1074 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1076 //Add a new Prism object
1077 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1079 //Add a new Prism function for creation a Prism relatively to vector
1080 Handle(GEOM_Function) aFunction =
1081 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1082 if (aFunction.IsNull()) return NULL;
1084 //Check if the function is set correctly
1085 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1087 GEOMImpl_IPrism aCI (aFunction);
1089 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1090 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1092 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1094 aCI.SetBase(aRefBase);
1095 aCI.SetVector(aRefVec);
1098 //Compute the Prism value
1101 if (!GetSolver()->ComputeFunction(aFunction)) {
1102 //SetErrorCode("Prism driver failed");
1103 SetErrorCode("Extrusion can not be created, check input data");
1107 catch (Standard_Failure) {
1108 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1109 SetErrorCode(aFail->GetMessageString());
1113 //Make a Python command
1114 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1115 << theBase << ", " << theVec << ", " << theH << ")";
1121 //=============================================================================
1125 //=============================================================================
1126 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1127 (Handle(GEOM_Object) theBase,
1128 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1129 double theScaleFactor)
1133 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1135 //Add a new Prism object
1136 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1138 //Add a new Prism function for creation a Prism relatively to two points
1139 Handle(GEOM_Function) aFunction =
1140 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1141 if (aFunction.IsNull()) return NULL;
1143 //Check if the function is set correctly
1144 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1146 GEOMImpl_IPrism aCI (aFunction);
1148 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1149 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1150 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1152 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1154 aCI.SetBase(aRefBase);
1155 aCI.SetFirstPoint(aRefPnt1);
1156 aCI.SetLastPoint(aRefPnt2);
1157 aCI.SetScale(theScaleFactor);
1159 //Compute the Prism value
1162 if (!GetSolver()->ComputeFunction(aFunction)) {
1163 //SetErrorCode("Prism driver failed");
1164 SetErrorCode("Extrusion can not be created, check input data");
1168 catch (Standard_Failure) {
1169 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1170 SetErrorCode(aFail->GetMessageString());
1174 //Make a Python command
1175 GEOM::TPythonDump pd (aFunction);
1176 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1177 if (theScaleFactor > Precision::Confusion())
1178 pd << ", " << theScaleFactor << ")";
1186 //=============================================================================
1188 * MakePrismTwoPnt2Ways
1190 //=============================================================================
1191 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1192 (Handle(GEOM_Object) theBase,
1193 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1197 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1199 //Add a new Prism object
1200 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1202 //Add a new Prism function for creation a Prism relatively to two points
1203 Handle(GEOM_Function) aFunction =
1204 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1205 if (aFunction.IsNull()) return NULL;
1207 //Check if the function is set correctly
1208 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1210 GEOMImpl_IPrism aCI (aFunction);
1212 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1213 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1214 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1216 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1218 aCI.SetBase(aRefBase);
1219 aCI.SetFirstPoint(aRefPnt1);
1220 aCI.SetLastPoint(aRefPnt2);
1222 //Compute the Prism value
1225 if (!GetSolver()->ComputeFunction(aFunction)) {
1226 //SetErrorCode("Prism driver failed");
1227 SetErrorCode("Extrusion can not be created, check input data");
1231 catch (Standard_Failure) {
1232 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1233 SetErrorCode(aFail->GetMessageString());
1237 //Make a Python command
1238 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1239 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1245 //=============================================================================
1249 //=============================================================================
1250 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1251 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1252 double theScaleFactor)
1256 if (theBase.IsNull()) return NULL;
1258 //Add a new Prism object
1259 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1261 //Add a new Prism function for creation a Prism by DXDYDZ
1262 Handle(GEOM_Function) aFunction =
1263 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1264 if (aFunction.IsNull()) return NULL;
1266 //Check if the function is set correctly
1267 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1269 GEOMImpl_IPrism aCI (aFunction);
1271 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1273 if (aRefBase.IsNull()) return NULL;
1275 aCI.SetBase(aRefBase);
1279 aCI.SetScale(theScaleFactor);
1281 //Compute the Prism value
1284 if (!GetSolver()->ComputeFunction(aFunction)) {
1285 SetErrorCode("Extrusion can not be created, check input data");
1289 catch (Standard_Failure) {
1290 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1291 SetErrorCode(aFail->GetMessageString());
1295 //Make a Python command
1296 GEOM::TPythonDump pd (aFunction);
1297 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1298 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1299 if (theScaleFactor > Precision::Confusion())
1300 pd << ", " << theScaleFactor << ")";
1308 //=============================================================================
1310 * MakePrismDXDYDZ_2WAYS
1312 //=============================================================================
1313 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1314 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1318 if (theBase.IsNull()) return NULL;
1320 //Add a new Prism object
1321 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1323 //Add a new Prism function for creation a Prism by DXDYDZ
1324 Handle(GEOM_Function) aFunction =
1325 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1326 if (aFunction.IsNull()) return NULL;
1328 //Check if the function is set correctly
1329 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1331 GEOMImpl_IPrism aCI (aFunction);
1333 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1335 if (aRefBase.IsNull()) return NULL;
1337 aCI.SetBase(aRefBase);
1342 //Compute the Prism value
1345 if (!GetSolver()->ComputeFunction(aFunction)) {
1346 SetErrorCode("Extrusion can not be created, check input data");
1350 catch (Standard_Failure) {
1351 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1352 SetErrorCode(aFail->GetMessageString());
1356 //Make a Python command
1357 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1358 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1364 //=============================================================================
1368 //=============================================================================
1369 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1370 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1374 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1376 Handle(GEOM_Object) aPrism = NULL;
1380 //Add a new Extruded Boss object
1381 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1385 //Add a new Extruded Cut object
1386 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1389 //Add a new Prism function for the creation of a Draft Prism feature
1390 Handle(GEOM_Function) aFunction =
1391 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1392 if (aFunction.IsNull()) return NULL;
1394 //Check if the function is set correctly
1395 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1397 GEOMImpl_IPrism aCI (aFunction);
1399 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1400 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1402 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1405 aCI.SetBase(aRefBase);
1406 aCI.SetInitShape(aRefInit);
1407 aCI.SetH(theHeight);
1408 aCI.SetDraftAngle(theAngle);
1414 //Compute the Draft Prism Feature value
1417 if (!GetSolver()->ComputeFunction(aFunction)) {
1418 SetErrorCode("Extrusion can not be created, check input data");
1422 catch (Standard_Failure) {
1423 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1424 SetErrorCode(aFail->GetMessageString());
1428 //Make a Python command
1431 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1432 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1436 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1437 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1444 //=============================================================================
1448 //=============================================================================
1449 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1450 Handle(GEOM_Object) thePath)
1454 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1456 //Add a new Pipe object
1457 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1459 //Add a new Pipe function
1460 Handle(GEOM_Function) aFunction =
1461 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1462 if (aFunction.IsNull()) return NULL;
1464 //Check if the function is set correctly
1465 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1467 GEOMImpl_IPipe aCI (aFunction);
1469 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1470 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1472 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1474 aCI.SetBase(aRefBase);
1475 aCI.SetPath(aRefPath);
1477 //Compute the Pipe value
1480 if (!GetSolver()->ComputeFunction(aFunction)) {
1481 SetErrorCode("Pipe driver failed");
1485 catch (Standard_Failure) {
1486 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1487 SetErrorCode(aFail->GetMessageString());
1491 //Make a Python command
1492 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1493 << theBase << ", " << thePath << ")";
1500 //=============================================================================
1502 * MakeRevolutionAxisAngle
1504 //=============================================================================
1505 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1506 Handle(GEOM_Object) theAxis,
1511 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1513 //Add a new Revolution object
1514 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1516 //Add a new Revolution function for creation a revolution relatively to axis
1517 Handle(GEOM_Function) aFunction =
1518 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1519 if (aFunction.IsNull()) return NULL;
1521 //Check if the function is set correctly
1522 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1524 GEOMImpl_IRevolution aCI (aFunction);
1526 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1527 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1529 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1531 aCI.SetBase(aRefBase);
1532 aCI.SetAxis(aRefAxis);
1533 aCI.SetAngle(theAngle);
1535 //Compute the Revolution value
1538 if (!GetSolver()->ComputeFunction(aFunction)) {
1539 SetErrorCode("Revolution driver failed");
1543 catch (Standard_Failure) {
1544 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1545 SetErrorCode(aFail->GetMessageString());
1549 //Make a Python command
1550 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1551 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1557 //=============================================================================
1559 * MakeRevolutionAxisAngle2Ways
1561 //=============================================================================
1562 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1563 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1567 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1569 //Add a new Revolution object
1570 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1572 //Add a new Revolution function for creation a revolution relatively to axis
1573 Handle(GEOM_Function) aFunction =
1574 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1575 if (aFunction.IsNull()) return NULL;
1577 //Check if the function is set correctly
1578 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1580 GEOMImpl_IRevolution aCI (aFunction);
1582 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1583 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1585 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1587 aCI.SetBase(aRefBase);
1588 aCI.SetAxis(aRefAxis);
1589 aCI.SetAngle(theAngle);
1591 //Compute the Revolution value
1594 if (!GetSolver()->ComputeFunction(aFunction)) {
1595 SetErrorCode("Revolution driver failed");
1599 catch (Standard_Failure) {
1600 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
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(GetDocID(), 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) {
1660 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1661 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1662 SetErrorCode("B-Spline surface construction failed");
1664 SetErrorCode(aFail->GetMessageString());
1668 //Make a Python command
1669 GEOM::TPythonDump pd (aFunction);
1670 pd << aFilling << " = geompy.MakeFilling(" << theContours ;
1671 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1672 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1673 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1674 { pd << ", theTol2D=" << theTol2D ; }
1675 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1676 { pd << ", theTol3D=" << theTol3D ; }
1677 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1678 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1679 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1680 if ( isApprox ) pd << ", isApprox=" << isApprox ;
1687 //=============================================================================
1691 //=============================================================================
1692 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1693 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1698 Handle(GEOM_Object) anObj;
1700 if(theSeqSections.IsNull())
1703 Standard_Integer nbObj = theSeqSections->Length();
1707 //Add a new ThruSections object
1708 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1711 //Add a new ThruSections function
1713 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1714 Handle(GEOM_Function) aFunction =
1715 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1716 if (aFunction.IsNull()) return anObj;
1718 //Check if the function is set correctly
1719 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1721 GEOMImpl_IThruSections aCI (aFunction);
1723 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1725 Standard_Integer i =1;
1726 for( ; i <= nbObj; i++) {
1728 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1732 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1733 if(!aSectObj.IsNull())
1735 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1736 if(!aRefSect.IsNull())
1737 aSeqSections->Append(aRefSect);
1741 if(!aSeqSections->Length())
1744 aCI.SetSections(aSeqSections);
1745 aCI.SetSolidMode(theModeSolid);
1746 aCI.SetPrecision(thePreci);
1748 //Compute the ThruSections value
1751 if (!GetSolver()->ComputeFunction(aFunction)) {
1752 SetErrorCode("ThruSections driver failed");
1756 catch (Standard_Failure) {
1757 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1758 SetErrorCode(aFail->GetMessageString());
1762 //Make a Python command
1763 GEOM::TPythonDump pyDump(aFunction);
1764 pyDump << aThruSect << " = geompy.MakeThruSections([";
1766 for(i =1 ; i <= nbObj; i++) {
1768 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1772 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1773 if(!aSectObj.IsNull()) {
1780 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1787 //=============================================================================
1789 * MakePipeWithDifferentSections
1791 //=============================================================================
1792 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1793 const Handle(TColStd_HSequenceOfTransient)& theBases,
1794 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1795 const Handle(GEOM_Object)& thePath,
1796 bool theWithContact,
1797 bool theWithCorrections)
1799 Handle(GEOM_Object) anObj;
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(GetDocID(), 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 anObj;
1819 //Check if the function is set correctly
1820 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
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);
1867 aCI.SetWithContactMode(theWithContact);
1868 aCI.SetWithCorrectionMode(theWithCorrections);
1870 //Compute the Pipe value
1873 if (!GetSolver()->ComputeFunction(aFunction)) {
1874 SetErrorCode("Pipe with defferent section driver failed");
1878 catch (Standard_Failure) {
1879 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1880 SetErrorCode(aFail->GetMessageString());
1884 //Make a Python command
1885 GEOM::TPythonDump pyDump(aFunction);
1886 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1888 for(i =1 ; i <= nbBases; i++) {
1890 Handle(Standard_Transient) anItem = theBases->Value(i);
1894 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1895 if(!anObj.IsNull()) {
1904 for(i =1 ; i <= nbLocs; i++) {
1906 Handle(Standard_Transient) anItem = theLocations->Value(i);
1910 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1911 if(!anObj.IsNull()) {
1918 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1925 //=============================================================================
1927 * MakePipeWithShellSections
1929 //=============================================================================
1930 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1931 const Handle(TColStd_HSequenceOfTransient)& theBases,
1932 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1933 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1934 const Handle(GEOM_Object)& thePath,
1935 bool theWithContact,
1936 bool theWithCorrections)
1938 Handle(GEOM_Object) anObj;
1940 if(theBases.IsNull())
1943 Standard_Integer nbBases = theBases->Length();
1948 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1950 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1952 //Add a new Pipe object
1953 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1955 //Add a new Pipe function
1957 Handle(GEOM_Function) aFunction =
1958 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1959 if (aFunction.IsNull()) return anObj;
1961 //Check if the function is set correctly
1962 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1964 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1965 GEOMImpl_IPipeShellSect aCI (aFunction);
1967 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1968 if(aRefPath.IsNull())
1971 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1972 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1973 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1975 Standard_Integer i =1;
1976 for( ; i <= nbBases; i++) {
1978 Handle(Standard_Transient) anItem = theBases->Value(i);
1981 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1984 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1985 if(aRefBase.IsNull())
1988 if( nbSubBases >= nbBases ) {
1989 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1990 if(aSubItem.IsNull())
1992 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1993 if(aSubBase.IsNull())
1995 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1996 if(aRefSubBase.IsNull())
1998 aSeqSubBases->Append(aRefSubBase);
2002 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2003 if(anItemLoc.IsNull())
2005 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2008 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2009 if(aRefLoc.IsNull())
2011 aSeqLocs->Append(aRefLoc);
2014 aSeqBases->Append(aRefBase);
2017 if(!aSeqBases->Length())
2020 aCI.SetBases(aSeqBases);
2021 aCI.SetSubBases(aSeqSubBases);
2022 aCI.SetLocations(aSeqLocs);
2023 aCI.SetPath(aRefPath);
2024 aCI.SetWithContactMode(theWithContact);
2025 aCI.SetWithCorrectionMode(theWithCorrections);
2027 //Compute the Pipe value
2030 if (!GetSolver()->ComputeFunction(aFunction)) {
2031 SetErrorCode("Pipe with shell sections driver failed");
2035 catch (Standard_Failure) {
2036 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2037 SetErrorCode(aFail->GetMessageString());
2041 //Make a Python command
2042 GEOM::TPythonDump pyDump(aFunction);
2043 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
2045 for(i =1 ; i <= nbBases; i++) {
2047 Handle(Standard_Transient) anItem = theBases->Value(i);
2051 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2052 if(!anObj.IsNull()) {
2061 for(i =1 ; i <= nbSubBases; i++) {
2063 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2067 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2068 if(!anObj.IsNull()) {
2077 for(i =1 ; i <= nbLocs; i++) {
2079 Handle(Standard_Transient) anItem = theLocations->Value(i);
2083 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2084 if(!anObj.IsNull()) {
2091 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2099 //=============================================================================
2101 * MakePipeShellsWithoutPath
2103 //=============================================================================
2104 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2105 const Handle(TColStd_HSequenceOfTransient)& theBases,
2106 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2108 Handle(GEOM_Object) anObj;
2110 if(theBases.IsNull())
2113 Standard_Integer nbBases = theBases->Length();
2118 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2120 //Add a new Pipe object
2121 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2123 //Add a new Pipe function
2125 Handle(GEOM_Function) aFunction =
2126 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2127 if (aFunction.IsNull()) return anObj;
2129 //Check if the function is set correctly
2130 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2132 GEOMImpl_IPipeShellSect aCI (aFunction);
2134 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2135 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2137 Standard_Integer i =1;
2138 for( ; i <= nbBases; i++) {
2140 Handle(Standard_Transient) anItem = theBases->Value(i);
2143 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2146 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2147 if(aRefBase.IsNull())
2151 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2152 if(anItemLoc.IsNull())
2154 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2157 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2158 if(aRefLoc.IsNull())
2160 aSeqLocs->Append(aRefLoc);
2163 aSeqBases->Append(aRefBase);
2166 if(!aSeqBases->Length())
2169 aCI.SetBases(aSeqBases);
2170 aCI.SetLocations(aSeqLocs);
2172 //Compute the Pipe value
2175 if (!GetSolver()->ComputeFunction(aFunction)) {
2176 SetErrorCode("Pipe with shell sections without path driver failed");
2180 catch (Standard_Failure) {
2181 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2182 SetErrorCode(aFail->GetMessageString());
2186 //Make a Python command
2187 GEOM::TPythonDump pyDump(aFunction);
2188 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2190 for(i =1 ; i <= nbBases; i++) {
2192 Handle(Standard_Transient) anItem = theBases->Value(i);
2196 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2197 if(!anObj.IsNull()) {
2206 for(i =1 ; i <= nbLocs; i++) {
2208 Handle(Standard_Transient) anItem = theLocations->Value(i);
2212 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2213 if(!anObj.IsNull()) {
2227 //=============================================================================
2229 * MakePipeBiNormalAlongVector
2231 //=============================================================================
2232 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2233 Handle(GEOM_Object) thePath,
2234 Handle(GEOM_Object) theVec)
2238 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2240 //Add a new Pipe object
2241 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2243 //Add a new Pipe function
2244 Handle(GEOM_Function) aFunction =
2245 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2246 if (aFunction.IsNull()) return NULL;
2248 //Check if the function is set correctly
2249 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2251 GEOMImpl_IPipeBiNormal aCI (aFunction);
2253 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2254 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2255 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2257 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2259 aCI.SetBase(aRefBase);
2260 aCI.SetPath(aRefPath);
2261 aCI.SetVector(aRefVec);
2263 //Compute the Pipe value
2266 if (!GetSolver()->ComputeFunction(aFunction)) {
2267 SetErrorCode("Pipe driver failed");
2271 catch (Standard_Failure) {
2272 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2273 SetErrorCode(aFail->GetMessageString());
2277 //Make a Python command
2278 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2279 << theBase << ", " << thePath << ", " << theVec << ")";
2285 //=============================================================================
2289 //=============================================================================
2290 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2296 if (theObject.IsNull()) return NULL;
2298 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2299 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2301 //Add a new Offset function
2302 Handle(GEOM_Function) aFunction;
2303 Handle(GEOM_Object) aCopy;
2306 //Add a new Copy object
2307 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2308 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2311 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2313 if (aFunction.IsNull()) return NULL;
2315 //Check if the function is set correctly
2316 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2318 GEOMImpl_IOffset aTI (aFunction);
2319 aTI.SetShape(anOriginal);
2320 aTI.SetValue(theOffset);
2322 //Compute the offset
2325 if (!GetSolver()->ComputeFunction(aFunction)) {
2326 SetErrorCode("Offset driver failed");
2330 catch (Standard_Failure) {
2331 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2332 SetErrorCode(aFail->GetMessageString());
2336 //Make a Python command
2339 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2340 << theObject << ", " << theOffset << ")";
2346 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2347 << theObject << ", " << theOffset << ")";
2353 //=============================================================================
2357 //=============================================================================
2358 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2359 Handle(GEOM_Object) theBase1,
2360 Handle(GEOM_Object) theBase2)
2364 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2366 // Add a new Path object
2367 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2369 // Add a new Path function
2370 Handle(GEOM_Function) aFunction =
2371 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2372 if (aFunction.IsNull()) return NULL;
2374 // Check if the function is set correctly
2375 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2377 GEOMImpl_IPipePath aCI (aFunction);
2379 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2380 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2381 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2383 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2385 aCI.SetShape(aRefShape);
2386 aCI.SetBase1(aRefBase1);
2387 aCI.SetBase2(aRefBase2);
2389 // Compute the Path value
2392 if (!GetSolver()->ComputeFunction(aFunction)) {
2393 SetErrorCode("PipePath driver failed");
2397 catch (Standard_Failure) {
2398 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2399 SetErrorCode("RestorePath: inappropriate arguments given");
2403 // Make a Python command
2404 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2405 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2411 //=============================================================================
2415 //=============================================================================
2416 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2417 (Handle(GEOM_Object) theShape,
2418 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2419 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2423 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2425 Standard_Integer nbBases1 = theBase1->Length();
2426 Standard_Integer nbBases2 = theBase2->Length();
2428 if (!nbBases1 || !nbBases2)
2431 // Add a new Path object
2432 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2434 // Add a new Path function
2435 Handle(GEOM_Function) aFunction =
2436 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2437 if (aFunction.IsNull()) return NULL;
2439 // Check if the function is set correctly
2440 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2442 GEOMImpl_IPipePath aCI (aFunction);
2444 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2445 if (aRefShape.IsNull()) return NULL;
2447 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2448 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2451 for (i = 1; i <= nbBases1; i++) {
2452 Handle(Standard_Transient) anItem = theBase1->Value(i);
2453 if (!anItem.IsNull()) {
2454 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2455 if (!aBase.IsNull()) {
2456 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2457 if (!aRefBase.IsNull())
2458 aSeqBases1->Append(aRefBase);
2462 for (i = 1; i <= nbBases2; i++) {
2463 Handle(Standard_Transient) anItem = theBase2->Value(i);
2464 if (!anItem.IsNull()) {
2465 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2466 if (!aBase.IsNull()) {
2467 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2468 if (!aRefBase.IsNull())
2469 aSeqBases2->Append(aRefBase);
2473 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2475 aCI.SetShape(aRefShape);
2476 aCI.SetBaseSeq1(aSeqBases1);
2477 aCI.SetBaseSeq2(aSeqBases2);
2479 // Compute the Path value
2482 if (!GetSolver()->ComputeFunction(aFunction)) {
2483 SetErrorCode("PipePath driver failed");
2487 catch (Standard_Failure) {
2488 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2489 SetErrorCode("RestorePath: inappropriate arguments given");
2493 // Make a Python command
2494 GEOM::TPythonDump pyDump (aFunction);
2495 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2496 for (i = 1; i <= nbBases1; i++) {
2497 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2498 if (!anObj.IsNull()) {
2505 for (i = 1; i <= nbBases2; i++) {
2506 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2507 if (!anObj.IsNull()) {