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 //=============================================================================
1618 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1619 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1620 double theTol2D, double theTol3D, int theNbIter,
1621 int theMethod, bool isApprox)
1625 if (theShape.IsNull()) return NULL;
1627 //Add a new Filling object
1628 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1630 //Add a new Filling function for creation a filling from a compound
1631 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1632 if (aFunction.IsNull()) return NULL;
1634 //Check if the function is set correctly
1635 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1637 GEOMImpl_IFilling aFI (aFunction);
1639 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1641 if (aRefShape.IsNull()) return NULL;
1643 aFI.SetShape(aRefShape);
1644 aFI.SetMinDeg(theMinDeg);
1645 aFI.SetMaxDeg(theMaxDeg);
1646 aFI.SetTol2D(theTol2D);
1647 aFI.SetTol3D(theTol3D);
1648 aFI.SetNbIter(theNbIter);
1649 aFI.SetApprox(isApprox);
1650 aFI.SetMethod(theMethod);
1652 //Compute the Solid value
1655 if (!GetSolver()->ComputeFunction(aFunction)) {
1656 SetErrorCode("Filling driver failed");
1660 catch (Standard_Failure) {
1661 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1662 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1663 SetErrorCode("B-Spline surface construction failed");
1665 SetErrorCode(aFail->GetMessageString());
1669 //Make a Python command
1670 GEOM::TPythonDump pd (aFunction);
1671 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1672 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1673 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1674 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1675 pd << ", theTol2D=" << theTol2D ;
1676 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1677 pd << ", theTol3D=" << theTol3D ;
1678 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1679 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1680 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1681 if(isApprox) pd << ", isApprox=" << isApprox ;
1688 //=============================================================================
1692 //=============================================================================
1693 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1694 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1699 Handle(GEOM_Object) anObj;
1701 if(theSeqSections.IsNull())
1704 Standard_Integer nbObj = theSeqSections->Length();
1708 //Add a new ThruSections object
1709 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1712 //Add a new ThruSections function
1714 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1715 Handle(GEOM_Function) aFunction =
1716 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1717 if (aFunction.IsNull()) return anObj;
1719 //Check if the function is set correctly
1720 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1722 GEOMImpl_IThruSections aCI (aFunction);
1724 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1726 Standard_Integer i =1;
1727 for( ; i <= nbObj; i++) {
1729 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1733 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1734 if(!aSectObj.IsNull())
1736 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1737 if(!aRefSect.IsNull())
1738 aSeqSections->Append(aRefSect);
1742 if(!aSeqSections->Length())
1745 aCI.SetSections(aSeqSections);
1746 aCI.SetSolidMode(theModeSolid);
1747 aCI.SetPrecision(thePreci);
1749 //Compute the ThruSections value
1752 if (!GetSolver()->ComputeFunction(aFunction)) {
1753 SetErrorCode("ThruSections driver failed");
1757 catch (Standard_Failure) {
1758 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1759 SetErrorCode(aFail->GetMessageString());
1763 //Make a Python command
1764 GEOM::TPythonDump pyDump(aFunction);
1765 pyDump << aThruSect << " = geompy.MakeThruSections([";
1767 for(i =1 ; i <= nbObj; i++) {
1769 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1773 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1774 if(!aSectObj.IsNull()) {
1781 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1788 //=============================================================================
1790 * MakePipeWithDifferentSections
1792 //=============================================================================
1793 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1794 const Handle(TColStd_HSequenceOfTransient)& theBases,
1795 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1796 const Handle(GEOM_Object)& thePath,
1797 bool theWithContact,
1798 bool theWithCorrections)
1800 Handle(GEOM_Object) anObj;
1802 if(theBases.IsNull())
1805 Standard_Integer nbBases = theBases->Length();
1810 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1811 //Add a new Pipe object
1812 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1814 //Add a new Pipe function
1816 Handle(GEOM_Function) aFunction =
1817 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1818 if (aFunction.IsNull()) return anObj;
1820 //Check if the function is set correctly
1821 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1823 GEOMImpl_IPipeDiffSect aCI (aFunction);
1825 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1826 if(aRefPath.IsNull())
1829 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1830 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1832 Standard_Integer i =1;
1833 for( ; i <= nbBases; i++) {
1835 Handle(Standard_Transient) anItem = theBases->Value(i);
1839 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1842 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1843 if(aRefBase.IsNull())
1847 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1848 if(anItemLoc.IsNull())
1851 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1854 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1855 if(aRefLoc.IsNull())
1857 aSeqLocs->Append(aRefLoc);
1859 aSeqBases->Append(aRefBase);
1862 if(!aSeqBases->Length())
1865 aCI.SetBases(aSeqBases);
1866 aCI.SetLocations(aSeqLocs);
1867 aCI.SetPath(aRefPath);
1868 aCI.SetWithContactMode(theWithContact);
1869 aCI.SetWithCorrectionMode(theWithCorrections);
1871 //Compute the Pipe value
1874 if (!GetSolver()->ComputeFunction(aFunction)) {
1875 SetErrorCode("Pipe with defferent section driver failed");
1879 catch (Standard_Failure) {
1880 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1881 SetErrorCode(aFail->GetMessageString());
1885 //Make a Python command
1886 GEOM::TPythonDump pyDump(aFunction);
1887 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1889 for(i =1 ; i <= nbBases; i++) {
1891 Handle(Standard_Transient) anItem = theBases->Value(i);
1895 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1896 if(!anObj.IsNull()) {
1905 for(i =1 ; i <= nbLocs; i++) {
1907 Handle(Standard_Transient) anItem = theLocations->Value(i);
1911 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1912 if(!anObj.IsNull()) {
1919 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1926 //=============================================================================
1928 * MakePipeWithShellSections
1930 //=============================================================================
1931 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1932 const Handle(TColStd_HSequenceOfTransient)& theBases,
1933 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1934 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1935 const Handle(GEOM_Object)& thePath,
1936 bool theWithContact,
1937 bool theWithCorrections)
1939 Handle(GEOM_Object) anObj;
1941 if(theBases.IsNull())
1944 Standard_Integer nbBases = theBases->Length();
1949 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1951 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1953 //Add a new Pipe object
1954 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1956 //Add a new Pipe function
1958 Handle(GEOM_Function) aFunction =
1959 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1960 if (aFunction.IsNull()) return anObj;
1962 //Check if the function is set correctly
1963 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1965 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1966 GEOMImpl_IPipeShellSect aCI (aFunction);
1968 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1969 if(aRefPath.IsNull())
1972 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1973 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1974 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1976 Standard_Integer i =1;
1977 for( ; i <= nbBases; i++) {
1979 Handle(Standard_Transient) anItem = theBases->Value(i);
1982 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1985 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1986 if(aRefBase.IsNull())
1989 if( nbSubBases >= nbBases ) {
1990 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1991 if(aSubItem.IsNull())
1993 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1994 if(aSubBase.IsNull())
1996 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1997 if(aRefSubBase.IsNull())
1999 aSeqSubBases->Append(aRefSubBase);
2003 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2004 if(anItemLoc.IsNull())
2006 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2009 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2010 if(aRefLoc.IsNull())
2012 aSeqLocs->Append(aRefLoc);
2015 aSeqBases->Append(aRefBase);
2018 if(!aSeqBases->Length())
2021 aCI.SetBases(aSeqBases);
2022 aCI.SetSubBases(aSeqSubBases);
2023 aCI.SetLocations(aSeqLocs);
2024 aCI.SetPath(aRefPath);
2025 aCI.SetWithContactMode(theWithContact);
2026 aCI.SetWithCorrectionMode(theWithCorrections);
2028 //Compute the Pipe value
2031 if (!GetSolver()->ComputeFunction(aFunction)) {
2032 SetErrorCode("Pipe with shell sections driver failed");
2036 catch (Standard_Failure) {
2037 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2038 SetErrorCode(aFail->GetMessageString());
2042 //Make a Python command
2043 GEOM::TPythonDump pyDump(aFunction);
2044 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
2046 for(i =1 ; i <= nbBases; i++) {
2048 Handle(Standard_Transient) anItem = theBases->Value(i);
2052 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2053 if(!anObj.IsNull()) {
2062 for(i =1 ; i <= nbSubBases; i++) {
2064 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2068 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2069 if(!anObj.IsNull()) {
2078 for(i =1 ; i <= nbLocs; i++) {
2080 Handle(Standard_Transient) anItem = theLocations->Value(i);
2084 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2085 if(!anObj.IsNull()) {
2092 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2100 //=============================================================================
2102 * MakePipeShellsWithoutPath
2104 //=============================================================================
2105 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2106 const Handle(TColStd_HSequenceOfTransient)& theBases,
2107 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2109 Handle(GEOM_Object) anObj;
2111 if(theBases.IsNull())
2114 Standard_Integer nbBases = theBases->Length();
2119 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2121 //Add a new Pipe object
2122 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2124 //Add a new Pipe function
2126 Handle(GEOM_Function) aFunction =
2127 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2128 if (aFunction.IsNull()) return anObj;
2130 //Check if the function is set correctly
2131 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2133 GEOMImpl_IPipeShellSect aCI (aFunction);
2135 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2136 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2138 Standard_Integer i =1;
2139 for( ; i <= nbBases; i++) {
2141 Handle(Standard_Transient) anItem = theBases->Value(i);
2144 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2147 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2148 if(aRefBase.IsNull())
2152 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2153 if(anItemLoc.IsNull())
2155 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2158 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2159 if(aRefLoc.IsNull())
2161 aSeqLocs->Append(aRefLoc);
2164 aSeqBases->Append(aRefBase);
2167 if(!aSeqBases->Length())
2170 aCI.SetBases(aSeqBases);
2171 aCI.SetLocations(aSeqLocs);
2173 //Compute the Pipe value
2176 if (!GetSolver()->ComputeFunction(aFunction)) {
2177 SetErrorCode("Pipe with shell sections without path driver failed");
2181 catch (Standard_Failure) {
2182 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2183 SetErrorCode(aFail->GetMessageString());
2187 //Make a Python command
2188 GEOM::TPythonDump pyDump(aFunction);
2189 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2191 for(i =1 ; i <= nbBases; i++) {
2193 Handle(Standard_Transient) anItem = theBases->Value(i);
2197 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2198 if(!anObj.IsNull()) {
2207 for(i =1 ; i <= nbLocs; i++) {
2209 Handle(Standard_Transient) anItem = theLocations->Value(i);
2213 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2214 if(!anObj.IsNull()) {
2228 //=============================================================================
2230 * MakePipeBiNormalAlongVector
2232 //=============================================================================
2233 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2234 Handle(GEOM_Object) thePath,
2235 Handle(GEOM_Object) theVec)
2239 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2241 //Add a new Pipe object
2242 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2244 //Add a new Pipe function
2245 Handle(GEOM_Function) aFunction =
2246 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2247 if (aFunction.IsNull()) return NULL;
2249 //Check if the function is set correctly
2250 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2252 GEOMImpl_IPipeBiNormal aCI (aFunction);
2254 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2255 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2256 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2258 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2260 aCI.SetBase(aRefBase);
2261 aCI.SetPath(aRefPath);
2262 aCI.SetVector(aRefVec);
2264 //Compute the Pipe value
2267 if (!GetSolver()->ComputeFunction(aFunction)) {
2268 SetErrorCode("Pipe driver failed");
2272 catch (Standard_Failure) {
2273 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2274 SetErrorCode(aFail->GetMessageString());
2278 //Make a Python command
2279 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2280 << theBase << ", " << thePath << ", " << theVec << ")";
2286 //=============================================================================
2290 //=============================================================================
2291 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2297 if (theObject.IsNull()) return NULL;
2299 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2300 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2302 //Add a new Offset function
2303 Handle(GEOM_Function) aFunction;
2304 Handle(GEOM_Object) aCopy;
2307 //Add a new Copy object
2308 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2309 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2312 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2314 if (aFunction.IsNull()) return NULL;
2316 //Check if the function is set correctly
2317 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2319 GEOMImpl_IOffset aTI (aFunction);
2320 aTI.SetShape(anOriginal);
2321 aTI.SetValue(theOffset);
2323 //Compute the offset
2326 if (!GetSolver()->ComputeFunction(aFunction)) {
2327 SetErrorCode("Offset driver failed");
2331 catch (Standard_Failure) {
2332 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2333 SetErrorCode(aFail->GetMessageString());
2337 //Make a Python command
2340 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2341 << theObject << ", " << theOffset << ")";
2347 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2348 << theObject << ", " << theOffset << ")";
2354 //=============================================================================
2358 //=============================================================================
2359 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2360 Handle(GEOM_Object) theBase1,
2361 Handle(GEOM_Object) theBase2)
2365 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2367 // Add a new Path object
2368 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2370 // Add a new Path function
2371 Handle(GEOM_Function) aFunction =
2372 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2373 if (aFunction.IsNull()) return NULL;
2375 // Check if the function is set correctly
2376 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2378 GEOMImpl_IPipePath aCI (aFunction);
2380 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2381 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2382 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2384 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2386 aCI.SetShape(aRefShape);
2387 aCI.SetBase1(aRefBase1);
2388 aCI.SetBase2(aRefBase2);
2390 // Compute the Path value
2393 if (!GetSolver()->ComputeFunction(aFunction)) {
2394 SetErrorCode("PipePath driver failed");
2398 catch (Standard_Failure) {
2399 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2400 SetErrorCode("RestorePath: inappropriate arguments given");
2404 // Make a Python command
2405 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2406 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2412 //=============================================================================
2416 //=============================================================================
2417 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2418 (Handle(GEOM_Object) theShape,
2419 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2420 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2424 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2426 Standard_Integer nbBases1 = theBase1->Length();
2427 Standard_Integer nbBases2 = theBase2->Length();
2429 if (!nbBases1 || !nbBases2)
2432 // Add a new Path object
2433 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2435 // Add a new Path function
2436 Handle(GEOM_Function) aFunction =
2437 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2438 if (aFunction.IsNull()) return NULL;
2440 // Check if the function is set correctly
2441 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2443 GEOMImpl_IPipePath aCI (aFunction);
2445 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2446 if (aRefShape.IsNull()) return NULL;
2448 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2449 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2452 for (i = 1; i <= nbBases1; i++) {
2453 Handle(Standard_Transient) anItem = theBase1->Value(i);
2454 if (!anItem.IsNull()) {
2455 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2456 if (!aBase.IsNull()) {
2457 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2458 if (!aRefBase.IsNull())
2459 aSeqBases1->Append(aRefBase);
2463 for (i = 1; i <= nbBases2; i++) {
2464 Handle(Standard_Transient) anItem = theBase2->Value(i);
2465 if (!anItem.IsNull()) {
2466 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2467 if (!aBase.IsNull()) {
2468 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2469 if (!aRefBase.IsNull())
2470 aSeqBases2->Append(aRefBase);
2474 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2476 aCI.SetShape(aRefShape);
2477 aCI.SetBaseSeq1(aSeqBases1);
2478 aCI.SetBaseSeq2(aSeqBases2);
2480 // Compute the Path value
2483 if (!GetSolver()->ComputeFunction(aFunction)) {
2484 SetErrorCode("PipePath driver failed");
2488 catch (Standard_Failure) {
2489 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2490 SetErrorCode("RestorePath: inappropriate arguments given");
2494 // Make a Python command
2495 GEOM::TPythonDump pyDump (aFunction);
2496 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2497 for (i = 1; i <= nbBases1; i++) {
2498 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2499 if (!anObj.IsNull()) {
2506 for (i = 1; i <= nbBases2; i++) {
2507 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2508 if (!anObj.IsNull()) {