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
131 #if OCC_VERSION_LARGE > 0x06010000
134 if (!GetSolver()->ComputeFunction(aFunction)) {
135 SetErrorCode("Box driver failed");
139 catch (Standard_Failure) {
140 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
141 SetErrorCode(aFail->GetMessageString());
145 //Make a Python command
146 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
147 << theDX << ", " << theDY << ", " << theDZ << ")";
154 //=============================================================================
158 //=============================================================================
159 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
160 Handle(GEOM_Object) thePnt2)
164 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
166 //Add a new Box object
167 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
169 //Add a new Box function for creation a box relatively to two points
170 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
171 if (aFunction.IsNull()) return NULL;
173 //Check if the function is set correctly
174 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
176 GEOMImpl_IBox aBI (aFunction);
178 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
179 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
181 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
183 aBI.SetRef1(aRefFunction1);
184 aBI.SetRef2(aRefFunction2);
186 //Compute the Box value
188 #if OCC_VERSION_LARGE > 0x06010000
191 if (!GetSolver()->ComputeFunction(aFunction)) {
192 SetErrorCode("Box driver failed");
196 catch (Standard_Failure) {
197 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
198 SetErrorCode(aFail->GetMessageString());
202 //Make a Python command
203 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
204 << thePnt1 << ", " << thePnt2 << ")";
210 //=============================================================================
214 //=============================================================================
215 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
219 if (theH == 0 || theW == 0) return NULL;
221 //Add a new Face object
222 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
224 //Add a new Box function for creation a box relatively to two points
225 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
226 if (aFunction.IsNull()) return NULL;
228 //Check if the function is set correctly
229 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
231 GEOMImpl_IFace aFI (aFunction);
235 aFI.SetOrientation(theOrientation);
239 #if OCC_VERSION_LARGE > 0x06010000
242 if (!GetSolver()->ComputeFunction(aFunction)) {
243 SetErrorCode("Face driver failed");
247 catch (Standard_Failure) {
248 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
249 SetErrorCode(aFail->GetMessageString());
253 //Make a Python command
254 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
255 << theH << ", " << theW << ", " << theOrientation << ")";
261 //=============================================================================
265 //=============================================================================
266 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
267 double theH, double theW)
271 if (theObj.IsNull()) return NULL;
273 //Add a new Face object
274 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
276 //Add a new Box function for creation a box relatively to two points
277 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
278 if (aFunction.IsNull()) return NULL;
280 //Check if the function is set correctly
281 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
283 GEOMImpl_IFace aFI (aFunction);
285 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
287 if (aRefFunction1.IsNull())
290 aFI.SetRef1(aRefFunction1);
296 #if OCC_VERSION_LARGE > 0x06010000
299 if (!GetSolver()->ComputeFunction(aFunction)) {
300 SetErrorCode("Face driver failed");
304 catch (Standard_Failure) {
305 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
306 SetErrorCode(aFail->GetMessageString());
310 //Make a Python command
311 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
312 << theObj << ", " << theH << ", " << theW << ")";
318 //=============================================================================
322 //=============================================================================
323 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
324 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
328 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
330 //Add a new Disk object
331 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
333 //Add a new Disk function for creation a disk relatively to point and vector
334 Handle(GEOM_Function) aFunction =
335 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
336 if (aFunction.IsNull()) return NULL;
338 //Check if the function is set correctly
339 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
341 GEOMImpl_IDisk aCI (aFunction);
343 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
344 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
346 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
348 aCI.SetCenter(aRefPnt);
349 aCI.SetVector(aRefVec);
352 //Compute the Disk value
354 #if OCC_VERSION_LARGE > 0x06010000
357 if (!GetSolver()->ComputeFunction(aFunction)) {
358 SetErrorCode("Disk driver failed");
362 catch (Standard_Failure) {
363 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
364 SetErrorCode(aFail->GetMessageString());
368 //Make a Python command
369 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
370 << thePnt << ", " << theVec << ", " << theR << ")";
376 //=============================================================================
380 //=============================================================================
381 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
382 Handle(GEOM_Object) thePnt2,
383 Handle(GEOM_Object) thePnt3)
387 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
389 //Add a new Disk object
390 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
392 //Add a new Disk function for creation a disk relatively to three points
393 Handle(GEOM_Function) aFunction =
394 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
395 if (aFunction.IsNull()) return NULL;
397 //Check if the function is set correctly
398 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
400 GEOMImpl_IDisk aCI (aFunction);
402 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
403 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
404 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
406 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
408 aCI.SetPoint1(aRefPnt1);
409 aCI.SetPoint2(aRefPnt2);
410 aCI.SetPoint3(aRefPnt3);
412 //Compute the Disk value
414 #if OCC_VERSION_LARGE > 0x06010000
417 if (!GetSolver()->ComputeFunction(aFunction)) {
418 SetErrorCode("Disk driver failed");
422 catch (Standard_Failure) {
423 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
424 SetErrorCode(aFail->GetMessageString());
428 //Make a Python command
429 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
430 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
436 //=============================================================================
440 //=============================================================================
441 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
445 if (theR == 0 ) return NULL;
447 //Add a new Disk object
448 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
450 //Add a new Box function for creation a box relatively to two points
451 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
452 if (aFunction.IsNull()) return NULL;
454 //Check if the function is set correctly
455 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
457 GEOMImpl_IDisk aDI (aFunction);
460 aDI.SetOrientation(theOrientation);
464 #if OCC_VERSION_LARGE > 0x06010000
467 if (!GetSolver()->ComputeFunction(aFunction)) {
468 SetErrorCode("Disk driver failed");
472 catch (Standard_Failure) {
473 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
474 SetErrorCode(aFail->GetMessageString());
478 //Make a Python command
479 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
480 << theR << ", " << theOrientation << ")";
486 //=============================================================================
490 //=============================================================================
491 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
495 //Add a new Cylinder object
496 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
498 //Add a new Cylinder function with R and H parameters
499 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
500 if (aFunction.IsNull()) return NULL;
502 //Check if the function is set correctly
503 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
505 GEOMImpl_ICylinder aCI (aFunction);
510 //Compute the Cylinder value
512 #if OCC_VERSION_LARGE > 0x06010000
515 if (!GetSolver()->ComputeFunction(aFunction)) {
516 SetErrorCode("Cylinder driver failed");
520 catch (Standard_Failure) {
521 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
522 SetErrorCode(aFail->GetMessageString());
526 //Make a Python command
527 GEOM::TPythonDump(aFunction) << aCylinder
528 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
535 //=============================================================================
537 * MakeCylinderPntVecRH
539 //=============================================================================
540 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
541 Handle(GEOM_Object) theVec,
542 double theR, double theH)
546 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
548 //Add a new Cylinder object
549 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
551 //Add a new Cylinder function for creation a cylinder relatively to point and vector
552 Handle(GEOM_Function) aFunction =
553 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
554 if (aFunction.IsNull()) return NULL;
556 //Check if the function is set correctly
557 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
559 GEOMImpl_ICylinder aCI (aFunction);
561 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
562 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
564 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
566 aCI.SetPoint(aRefPnt);
567 aCI.SetVector(aRefVec);
571 //Compute the Cylinder value
573 #if OCC_VERSION_LARGE > 0x06010000
576 if (!GetSolver()->ComputeFunction(aFunction)) {
577 SetErrorCode("Cylinder driver failed");
581 catch (Standard_Failure) {
582 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
583 SetErrorCode(aFail->GetMessageString());
587 //Make a Python command
588 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
589 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
596 //=============================================================================
600 //=============================================================================
601 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
606 //Add a new Cone object
607 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
609 //Add a new Cone function with R and H parameters
610 Handle(GEOM_Function) aFunction =
611 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
612 if (aFunction.IsNull()) return NULL;
614 //Check if the function is set correctly
615 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
617 GEOMImpl_ICone aCI (aFunction);
623 //Compute the Cone value
625 #if OCC_VERSION_LARGE > 0x06010000
628 if (!GetSolver()->ComputeFunction(aFunction)) {
629 SetErrorCode("Cone driver failed");
633 catch (Standard_Failure) {
634 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
635 SetErrorCode(aFail->GetMessageString());
639 //Make a Python command
640 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
641 << theR1 << ", " << theR2 << ", " << theH << ")";
648 //=============================================================================
650 * MakeConePntVecR1R2H
652 //=============================================================================
653 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
654 Handle(GEOM_Object) theVec,
655 double theR1, double theR2,
660 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
662 //Add a new Cone object
663 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
665 //Add a new Cone function for creation a cone relatively to point and vector
666 Handle(GEOM_Function) aFunction =
667 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
668 if (aFunction.IsNull()) return NULL;
670 //Check if the function is set correctly
671 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
673 GEOMImpl_ICone aCI (aFunction);
675 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
676 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
678 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
680 aCI.SetPoint(aRefPnt);
681 aCI.SetVector(aRefVec);
686 //Compute the Cone value
688 #if OCC_VERSION_LARGE > 0x06010000
691 if (!GetSolver()->ComputeFunction(aFunction)) {
692 SetErrorCode("Cone driver failed");
696 catch (Standard_Failure) {
697 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
698 SetErrorCode(aFail->GetMessageString());
702 //Make a Python command
703 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
704 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
711 //=============================================================================
715 //=============================================================================
716 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
720 //Add a new Sphere object
721 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
723 //Add a new Sphere function with R parameter
724 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
725 if (aFunction.IsNull()) return NULL;
727 //Check if the function is set correctly
728 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
730 GEOMImpl_ISphere aCI (aFunction);
734 //Compute the Sphere value
736 #if OCC_VERSION_LARGE > 0x06010000
739 if (!GetSolver()->ComputeFunction(aFunction)) {
740 SetErrorCode("Sphere driver failed");
744 catch (Standard_Failure) {
745 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
746 SetErrorCode(aFail->GetMessageString());
750 //Make a Python command
751 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
758 //=============================================================================
762 //=============================================================================
763 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
768 if (thePnt.IsNull()) return NULL;
770 //Add a new Point object
771 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
773 //Add a new Sphere function for creation a sphere relatively to point
774 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
775 if (aFunction.IsNull()) return NULL;
777 //Check if the function is set correctly
778 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
780 GEOMImpl_ISphere aCI (aFunction);
782 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
784 if (aRefPnt.IsNull()) return NULL;
786 aCI.SetPoint(aRefPnt);
789 //Compute the Sphere value
791 #if OCC_VERSION_LARGE > 0x06010000
794 if (!GetSolver()->ComputeFunction(aFunction)) {
795 SetErrorCode("Sphere driver failed");
799 catch (Standard_Failure) {
800 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
801 SetErrorCode(aFail->GetMessageString());
805 //Make a Python command
806 GEOM::TPythonDump(aFunction) << aSphere
807 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
814 //=============================================================================
818 //=============================================================================
819 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
820 (double theRMajor, double theRMinor)
824 //Add a new Torus object
825 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
827 //Add a new Torus function
828 Handle(GEOM_Function) aFunction =
829 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
830 if (aFunction.IsNull()) return NULL;
832 //Check if the function is set correctly
833 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
835 GEOMImpl_ITorus aCI (aFunction);
837 aCI.SetRMajor(theRMajor);
838 aCI.SetRMinor(theRMinor);
840 //Compute the Torus value
842 #if OCC_VERSION_LARGE > 0x06010000
845 if (!GetSolver()->ComputeFunction(aFunction)) {
846 SetErrorCode("Torus driver failed");
850 catch (Standard_Failure) {
851 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
852 SetErrorCode(aFail->GetMessageString());
856 //Make a Python command
857 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
858 << theRMajor << ", " << theRMinor << ")";
864 //=============================================================================
868 //=============================================================================
869 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
870 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
871 double theRMajor, double theRMinor)
875 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
877 //Add a new Torus object
878 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
880 //Add a new Torus function
881 Handle(GEOM_Function) aFunction =
882 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
883 if (aFunction.IsNull()) return NULL;
885 //Check if the function is set correctly
886 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
888 GEOMImpl_ITorus aCI (aFunction);
890 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
891 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
893 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
895 aCI.SetCenter(aRefPnt);
896 aCI.SetVector(aRefVec);
897 aCI.SetRMajor(theRMajor);
898 aCI.SetRMinor(theRMinor);
900 //Compute the Torus value
902 #if OCC_VERSION_LARGE > 0x06010000
905 if (!GetSolver()->ComputeFunction(aFunction)) {
906 SetErrorCode("Torus driver failed");
910 catch (Standard_Failure) {
911 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
912 SetErrorCode(aFail->GetMessageString());
916 //Make a Python command
917 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
918 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
925 //=============================================================================
929 //=============================================================================
930 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
931 Handle(GEOM_Object) theVec,
932 double theH, double theScaleFactor)
936 if (theBase.IsNull() || theVec.IsNull()) return NULL;
938 //Add a new Prism object
939 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
941 //Add a new Prism function for creation a Prism relatively to vector
942 Handle(GEOM_Function) aFunction =
943 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
944 if (aFunction.IsNull()) return NULL;
946 //Check if the function is set correctly
947 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
949 GEOMImpl_IPrism aCI (aFunction);
951 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
952 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
954 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
956 aCI.SetBase(aRefBase);
957 aCI.SetVector(aRefVec);
959 aCI.SetScale(theScaleFactor);
961 //Compute the Prism value
963 #if OCC_VERSION_LARGE > 0x06010000
966 if (!GetSolver()->ComputeFunction(aFunction)) {
967 //SetErrorCode("Prism driver failed");
968 SetErrorCode("Extrusion can not be created, check input data");
972 catch (Standard_Failure) {
973 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
974 SetErrorCode(aFail->GetMessageString());
978 //Make a Python command
979 GEOM::TPythonDump pd (aFunction);
980 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
981 if (theScaleFactor > Precision::Confusion())
982 pd << ", " << theScaleFactor << ")";
990 //=============================================================================
994 //=============================================================================
995 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
996 Handle(GEOM_Object) theVec,
1001 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1003 //Add a new Prism object
1004 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1006 //Add a new Prism function for creation a Prism relatively to vector
1007 Handle(GEOM_Function) aFunction =
1008 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1009 if (aFunction.IsNull()) return NULL;
1011 //Check if the function is set correctly
1012 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1014 GEOMImpl_IPrism aCI (aFunction);
1016 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1017 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1019 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1021 aCI.SetBase(aRefBase);
1022 aCI.SetVector(aRefVec);
1025 //Compute the Prism value
1027 #if OCC_VERSION_LARGE > 0x06010000
1030 if (!GetSolver()->ComputeFunction(aFunction)) {
1031 //SetErrorCode("Prism driver failed");
1032 SetErrorCode("Extrusion can not be created, check input data");
1036 catch (Standard_Failure) {
1037 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1038 SetErrorCode(aFail->GetMessageString());
1042 //Make a Python command
1043 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1044 << theBase << ", " << theVec << ", " << theH << ")";
1050 //=============================================================================
1054 //=============================================================================
1055 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1056 (Handle(GEOM_Object) theBase,
1057 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1058 double theScaleFactor)
1062 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1064 //Add a new Prism object
1065 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1067 //Add a new Prism function for creation a Prism relatively to two points
1068 Handle(GEOM_Function) aFunction =
1069 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1070 if (aFunction.IsNull()) return NULL;
1072 //Check if the function is set correctly
1073 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1075 GEOMImpl_IPrism aCI (aFunction);
1077 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1078 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1079 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1081 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1083 aCI.SetBase(aRefBase);
1084 aCI.SetFirstPoint(aRefPnt1);
1085 aCI.SetLastPoint(aRefPnt2);
1086 aCI.SetScale(theScaleFactor);
1088 //Compute the Prism value
1090 #if OCC_VERSION_LARGE > 0x06010000
1093 if (!GetSolver()->ComputeFunction(aFunction)) {
1094 //SetErrorCode("Prism driver failed");
1095 SetErrorCode("Extrusion can not be created, check input data");
1099 catch (Standard_Failure) {
1100 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1101 SetErrorCode(aFail->GetMessageString());
1105 //Make a Python command
1106 GEOM::TPythonDump pd (aFunction);
1107 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1108 if (theScaleFactor > Precision::Confusion())
1109 pd << ", " << theScaleFactor << ")";
1117 //=============================================================================
1119 * MakePrismTwoPnt2Ways
1121 //=============================================================================
1122 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1123 (Handle(GEOM_Object) theBase,
1124 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1128 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1130 //Add a new Prism object
1131 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1133 //Add a new Prism function for creation a Prism relatively to two points
1134 Handle(GEOM_Function) aFunction =
1135 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1136 if (aFunction.IsNull()) return NULL;
1138 //Check if the function is set correctly
1139 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1141 GEOMImpl_IPrism aCI (aFunction);
1143 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1144 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1145 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1147 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1149 aCI.SetBase(aRefBase);
1150 aCI.SetFirstPoint(aRefPnt1);
1151 aCI.SetLastPoint(aRefPnt2);
1153 //Compute the Prism value
1155 #if OCC_VERSION_LARGE > 0x06010000
1158 if (!GetSolver()->ComputeFunction(aFunction)) {
1159 //SetErrorCode("Prism driver failed");
1160 SetErrorCode("Extrusion can not be created, check input data");
1164 catch (Standard_Failure) {
1165 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1166 SetErrorCode(aFail->GetMessageString());
1170 //Make a Python command
1171 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1172 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1178 //=============================================================================
1182 //=============================================================================
1183 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1184 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1185 double theScaleFactor)
1189 if (theBase.IsNull()) return NULL;
1191 //Add a new Prism object
1192 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1194 //Add a new Prism function for creation a Prism by DXDYDZ
1195 Handle(GEOM_Function) aFunction =
1196 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1197 if (aFunction.IsNull()) return NULL;
1199 //Check if the function is set correctly
1200 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1202 GEOMImpl_IPrism aCI (aFunction);
1204 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1206 if (aRefBase.IsNull()) return NULL;
1208 aCI.SetBase(aRefBase);
1212 aCI.SetScale(theScaleFactor);
1214 //Compute the Prism value
1216 #if OCC_VERSION_LARGE > 0x06010000
1219 if (!GetSolver()->ComputeFunction(aFunction)) {
1220 SetErrorCode("Extrusion can not be created, check input data");
1224 catch (Standard_Failure) {
1225 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1226 SetErrorCode(aFail->GetMessageString());
1230 //Make a Python command
1231 GEOM::TPythonDump pd (aFunction);
1232 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1233 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1234 if (theScaleFactor > Precision::Confusion())
1235 pd << ", " << theScaleFactor << ")";
1243 //=============================================================================
1245 * MakePrismDXDYDZ_2WAYS
1247 //=============================================================================
1248 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1249 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1253 if (theBase.IsNull()) return NULL;
1255 //Add a new Prism object
1256 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1258 //Add a new Prism function for creation a Prism by DXDYDZ
1259 Handle(GEOM_Function) aFunction =
1260 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1261 if (aFunction.IsNull()) return NULL;
1263 //Check if the function is set correctly
1264 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1266 GEOMImpl_IPrism aCI (aFunction);
1268 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1270 if (aRefBase.IsNull()) return NULL;
1272 aCI.SetBase(aRefBase);
1277 //Compute the Prism value
1279 #if OCC_VERSION_LARGE > 0x06010000
1282 if (!GetSolver()->ComputeFunction(aFunction)) {
1283 SetErrorCode("Extrusion can not be created, check input data");
1287 catch (Standard_Failure) {
1288 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1289 SetErrorCode(aFail->GetMessageString());
1293 //Make a Python command
1294 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1295 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1301 //=============================================================================
1305 //=============================================================================
1306 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1307 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1311 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1313 Handle(GEOM_Object) aPrism = NULL;
1317 //Add a new Extruded Boss object
1318 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1322 //Add a new Extruded Cut object
1323 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1326 //Add a new Prism function for the creation of a Draft Prism feature
1327 Handle(GEOM_Function) aFunction =
1328 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1329 if (aFunction.IsNull()) return NULL;
1331 //Check if the function is set correctly
1332 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1334 GEOMImpl_IPrism aCI (aFunction);
1336 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1337 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1339 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1342 aCI.SetBase(aRefBase);
1343 aCI.SetInitShape(aRefInit);
1344 aCI.SetH(theHeight);
1345 aCI.SetDraftAngle(theAngle);
1351 //Compute the Draft Prism Feature value
1353 #if OCC_VERSION_LARGE > 0x06010000
1356 if (!GetSolver()->ComputeFunction(aFunction)) {
1357 SetErrorCode("Extrusion can not be created, check input data");
1361 catch (Standard_Failure) {
1362 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1363 SetErrorCode(aFail->GetMessageString());
1367 //Make a Python command
1370 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1371 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1375 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1376 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1383 //=============================================================================
1387 //=============================================================================
1388 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1389 Handle(GEOM_Object) thePath)
1393 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1395 //Add a new Pipe object
1396 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1398 //Add a new Pipe function
1399 Handle(GEOM_Function) aFunction =
1400 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1401 if (aFunction.IsNull()) return NULL;
1403 //Check if the function is set correctly
1404 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1406 GEOMImpl_IPipe aCI (aFunction);
1408 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1409 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1411 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1413 aCI.SetBase(aRefBase);
1414 aCI.SetPath(aRefPath);
1416 //Compute the Pipe value
1418 #if OCC_VERSION_LARGE > 0x06010000
1421 if (!GetSolver()->ComputeFunction(aFunction)) {
1422 SetErrorCode("Pipe driver failed");
1426 catch (Standard_Failure) {
1427 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1428 SetErrorCode(aFail->GetMessageString());
1432 //Make a Python command
1433 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1434 << theBase << ", " << thePath << ")";
1441 //=============================================================================
1443 * MakeRevolutionAxisAngle
1445 //=============================================================================
1446 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1447 Handle(GEOM_Object) theAxis,
1452 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1454 //Add a new Revolution object
1455 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1457 //Add a new Revolution function for creation a revolution relatively to axis
1458 Handle(GEOM_Function) aFunction =
1459 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1460 if (aFunction.IsNull()) return NULL;
1462 //Check if the function is set correctly
1463 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1465 GEOMImpl_IRevolution aCI (aFunction);
1467 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1468 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1470 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1472 aCI.SetBase(aRefBase);
1473 aCI.SetAxis(aRefAxis);
1474 aCI.SetAngle(theAngle);
1476 //Compute the Revolution value
1478 #if OCC_VERSION_LARGE > 0x06010000
1481 if (!GetSolver()->ComputeFunction(aFunction)) {
1482 SetErrorCode("Revolution driver failed");
1486 catch (Standard_Failure) {
1487 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1488 SetErrorCode(aFail->GetMessageString());
1492 //Make a Python command
1493 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1494 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1500 //=============================================================================
1502 * MakeRevolutionAxisAngle2Ways
1504 //=============================================================================
1505 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1506 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1510 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1512 //Add a new Revolution object
1513 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1515 //Add a new Revolution function for creation a revolution relatively to axis
1516 Handle(GEOM_Function) aFunction =
1517 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1518 if (aFunction.IsNull()) return NULL;
1520 //Check if the function is set correctly
1521 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1523 GEOMImpl_IRevolution aCI (aFunction);
1525 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1526 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1528 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1530 aCI.SetBase(aRefBase);
1531 aCI.SetAxis(aRefAxis);
1532 aCI.SetAngle(theAngle);
1534 //Compute the Revolution value
1536 #if OCC_VERSION_LARGE > 0x06010000
1539 if (!GetSolver()->ComputeFunction(aFunction)) {
1540 SetErrorCode("Revolution driver failed");
1544 catch (Standard_Failure) {
1545 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1546 SetErrorCode(aFail->GetMessageString());
1550 //Make a Python command
1551 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1552 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1558 //=============================================================================
1562 //=============================================================================
1563 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1564 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1565 double theTol2D, double theTol3D, int theNbIter,
1566 int theMethod, bool isApprox)
1570 if (theShape.IsNull()) return NULL;
1572 //Add a new Filling object
1573 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1575 //Add a new Filling function for creation a filling from a compound
1576 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1577 if (aFunction.IsNull()) return NULL;
1579 //Check if the function is set correctly
1580 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1582 GEOMImpl_IFilling aFI (aFunction);
1584 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1586 if (aRefShape.IsNull()) return NULL;
1588 aFI.SetShape(aRefShape);
1589 aFI.SetMinDeg(theMinDeg);
1590 aFI.SetMaxDeg(theMaxDeg);
1591 aFI.SetTol2D(theTol2D);
1592 aFI.SetTol3D(theTol3D);
1593 aFI.SetNbIter(theNbIter);
1594 aFI.SetApprox(isApprox);
1595 aFI.SetMethod(theMethod);
1597 //Compute the Solid value
1599 #if OCC_VERSION_LARGE > 0x06010000
1602 if (!GetSolver()->ComputeFunction(aFunction)) {
1603 SetErrorCode("Filling driver failed");
1607 catch (Standard_Failure) {
1608 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1609 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1610 SetErrorCode("B-Spline surface construction failed");
1612 SetErrorCode(aFail->GetMessageString());
1616 //Make a Python command
1617 GEOM::TPythonDump pd (aFunction);
1618 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1619 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1620 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1621 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1622 pd << ", theTol2D=" << theTol2D ;
1623 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1624 pd << ", theTol3D=" << theTol3D ;
1625 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1626 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1627 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1628 if(isApprox) pd << ", isApprox=" << isApprox ;
1635 //=============================================================================
1639 //=============================================================================
1640 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1641 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1646 Handle(GEOM_Object) anObj;
1648 if(theSeqSections.IsNull())
1651 Standard_Integer nbObj = theSeqSections->Length();
1655 //Add a new ThruSections object
1656 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1659 //Add a new ThruSections function
1661 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1662 Handle(GEOM_Function) aFunction =
1663 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1664 if (aFunction.IsNull()) return anObj;
1666 //Check if the function is set correctly
1667 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1669 GEOMImpl_IThruSections aCI (aFunction);
1671 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1673 Standard_Integer i =1;
1674 for( ; i <= nbObj; i++) {
1676 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1680 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1681 if(!aSectObj.IsNull())
1683 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1684 if(!aRefSect.IsNull())
1685 aSeqSections->Append(aRefSect);
1689 if(!aSeqSections->Length())
1692 aCI.SetSections(aSeqSections);
1693 aCI.SetSolidMode(theModeSolid);
1694 aCI.SetPrecision(thePreci);
1696 //Compute the ThruSections value
1698 #if OCC_VERSION_LARGE > 0x06010000
1701 if (!GetSolver()->ComputeFunction(aFunction)) {
1702 SetErrorCode("ThruSections driver failed");
1706 catch (Standard_Failure) {
1707 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1708 SetErrorCode(aFail->GetMessageString());
1712 //Make a Python command
1713 GEOM::TPythonDump pyDump(aFunction);
1714 pyDump << aThruSect << " = geompy.MakeThruSections([";
1716 for(i =1 ; i <= nbObj; i++) {
1718 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1722 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1723 if(!aSectObj.IsNull()) {
1730 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1737 //=============================================================================
1739 * MakePipeWithDifferentSections
1741 //=============================================================================
1742 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1743 const Handle(TColStd_HSequenceOfTransient)& theBases,
1744 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1745 const Handle(GEOM_Object)& thePath,
1746 bool theWithContact,
1747 bool theWithCorrections)
1749 Handle(GEOM_Object) anObj;
1751 if(theBases.IsNull())
1754 Standard_Integer nbBases = theBases->Length();
1759 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1760 //Add a new Pipe object
1761 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1763 //Add a new Pipe function
1765 Handle(GEOM_Function) aFunction =
1766 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1767 if (aFunction.IsNull()) return anObj;
1769 //Check if the function is set correctly
1770 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1772 GEOMImpl_IPipeDiffSect aCI (aFunction);
1774 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1775 if(aRefPath.IsNull())
1778 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1779 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1781 Standard_Integer i =1;
1782 for( ; i <= nbBases; i++) {
1784 Handle(Standard_Transient) anItem = theBases->Value(i);
1788 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1791 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1792 if(aRefBase.IsNull())
1796 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1797 if(anItemLoc.IsNull())
1800 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1803 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1804 if(aRefLoc.IsNull())
1806 aSeqLocs->Append(aRefLoc);
1808 aSeqBases->Append(aRefBase);
1811 if(!aSeqBases->Length())
1814 aCI.SetBases(aSeqBases);
1815 aCI.SetLocations(aSeqLocs);
1816 aCI.SetPath(aRefPath);
1817 aCI.SetWithContactMode(theWithContact);
1818 aCI.SetWithCorrectionMode(theWithCorrections);
1820 //Compute the Pipe value
1822 #if OCC_VERSION_LARGE > 0x06010000
1825 if (!GetSolver()->ComputeFunction(aFunction)) {
1826 SetErrorCode("Pipe with defferent section driver failed");
1830 catch (Standard_Failure) {
1831 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1832 SetErrorCode(aFail->GetMessageString());
1836 //Make a Python command
1837 GEOM::TPythonDump pyDump(aFunction);
1838 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1840 for(i =1 ; i <= nbBases; i++) {
1842 Handle(Standard_Transient) anItem = theBases->Value(i);
1846 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1847 if(!anObj.IsNull()) {
1856 for(i =1 ; i <= nbLocs; i++) {
1858 Handle(Standard_Transient) anItem = theLocations->Value(i);
1862 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1863 if(!anObj.IsNull()) {
1870 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1877 //=============================================================================
1879 * MakePipeWithShellSections
1881 //=============================================================================
1882 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1883 const Handle(TColStd_HSequenceOfTransient)& theBases,
1884 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1885 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1886 const Handle(GEOM_Object)& thePath,
1887 bool theWithContact,
1888 bool theWithCorrections)
1890 Handle(GEOM_Object) anObj;
1892 if(theBases.IsNull())
1895 Standard_Integer nbBases = theBases->Length();
1900 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1902 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1904 //Add a new Pipe object
1905 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1907 //Add a new Pipe function
1909 Handle(GEOM_Function) aFunction =
1910 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1911 if (aFunction.IsNull()) return anObj;
1913 //Check if the function is set correctly
1914 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1916 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1917 GEOMImpl_IPipeShellSect aCI (aFunction);
1919 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1920 if(aRefPath.IsNull())
1923 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1924 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1925 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1927 Standard_Integer i =1;
1928 for( ; i <= nbBases; i++) {
1930 Handle(Standard_Transient) anItem = theBases->Value(i);
1933 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1936 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1937 if(aRefBase.IsNull())
1940 if( nbSubBases >= nbBases ) {
1941 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1942 if(aSubItem.IsNull())
1944 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1945 if(aSubBase.IsNull())
1947 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1948 if(aRefSubBase.IsNull())
1950 aSeqSubBases->Append(aRefSubBase);
1954 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1955 if(anItemLoc.IsNull())
1957 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1960 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1961 if(aRefLoc.IsNull())
1963 aSeqLocs->Append(aRefLoc);
1966 aSeqBases->Append(aRefBase);
1969 if(!aSeqBases->Length())
1972 aCI.SetBases(aSeqBases);
1973 aCI.SetSubBases(aSeqSubBases);
1974 aCI.SetLocations(aSeqLocs);
1975 aCI.SetPath(aRefPath);
1976 aCI.SetWithContactMode(theWithContact);
1977 aCI.SetWithCorrectionMode(theWithCorrections);
1979 //Compute the Pipe value
1981 #if OCC_VERSION_LARGE > 0x06010000
1984 if (!GetSolver()->ComputeFunction(aFunction)) {
1985 SetErrorCode("Pipe with shell sections driver failed");
1989 catch (Standard_Failure) {
1990 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1991 SetErrorCode(aFail->GetMessageString());
1995 //Make a Python command
1996 GEOM::TPythonDump pyDump(aFunction);
1997 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1999 for(i =1 ; i <= nbBases; i++) {
2001 Handle(Standard_Transient) anItem = theBases->Value(i);
2005 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2006 if(!anObj.IsNull()) {
2015 for(i =1 ; i <= nbSubBases; i++) {
2017 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2021 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2022 if(!anObj.IsNull()) {
2031 for(i =1 ; i <= nbLocs; i++) {
2033 Handle(Standard_Transient) anItem = theLocations->Value(i);
2037 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2038 if(!anObj.IsNull()) {
2045 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2053 //=============================================================================
2055 * MakePipeShellsWithoutPath
2057 //=============================================================================
2058 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2059 const Handle(TColStd_HSequenceOfTransient)& theBases,
2060 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2062 Handle(GEOM_Object) anObj;
2064 if(theBases.IsNull())
2067 Standard_Integer nbBases = theBases->Length();
2072 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2074 //Add a new Pipe object
2075 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2077 //Add a new Pipe function
2079 Handle(GEOM_Function) aFunction =
2080 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2081 if (aFunction.IsNull()) return anObj;
2083 //Check if the function is set correctly
2084 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2086 GEOMImpl_IPipeShellSect aCI (aFunction);
2088 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2089 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2091 Standard_Integer i =1;
2092 for( ; i <= nbBases; i++) {
2094 Handle(Standard_Transient) anItem = theBases->Value(i);
2097 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2100 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2101 if(aRefBase.IsNull())
2105 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2106 if(anItemLoc.IsNull())
2108 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2111 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2112 if(aRefLoc.IsNull())
2114 aSeqLocs->Append(aRefLoc);
2117 aSeqBases->Append(aRefBase);
2120 if(!aSeqBases->Length())
2123 aCI.SetBases(aSeqBases);
2124 aCI.SetLocations(aSeqLocs);
2126 //Compute the Pipe value
2128 #if OCC_VERSION_LARGE > 0x06010000
2131 if (!GetSolver()->ComputeFunction(aFunction)) {
2132 SetErrorCode("Pipe with shell sections without path driver failed");
2136 catch (Standard_Failure) {
2137 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2138 SetErrorCode(aFail->GetMessageString());
2142 //Make a Python command
2143 GEOM::TPythonDump pyDump(aFunction);
2144 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2146 for(i =1 ; i <= nbBases; i++) {
2148 Handle(Standard_Transient) anItem = theBases->Value(i);
2152 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2153 if(!anObj.IsNull()) {
2162 for(i =1 ; i <= nbLocs; i++) {
2164 Handle(Standard_Transient) anItem = theLocations->Value(i);
2168 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2169 if(!anObj.IsNull()) {
2183 //=============================================================================
2185 * MakePipeBiNormalAlongVector
2187 //=============================================================================
2188 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2189 Handle(GEOM_Object) thePath,
2190 Handle(GEOM_Object) theVec)
2194 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2196 //Add a new Pipe object
2197 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2199 //Add a new Pipe function
2200 Handle(GEOM_Function) aFunction =
2201 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2202 if (aFunction.IsNull()) return NULL;
2204 //Check if the function is set correctly
2205 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2207 GEOMImpl_IPipeBiNormal aCI (aFunction);
2209 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2210 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2211 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2213 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2215 aCI.SetBase(aRefBase);
2216 aCI.SetPath(aRefPath);
2217 aCI.SetVector(aRefVec);
2219 //Compute the Pipe value
2221 #if OCC_VERSION_LARGE > 0x06010000
2224 if (!GetSolver()->ComputeFunction(aFunction)) {
2225 SetErrorCode("Pipe driver failed");
2229 catch (Standard_Failure) {
2230 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2231 SetErrorCode(aFail->GetMessageString());
2235 //Make a Python command
2236 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2237 << theBase << ", " << thePath << ", " << theVec << ")";
2243 //=============================================================================
2247 //=============================================================================
2248 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2254 if (theObject.IsNull()) return NULL;
2256 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2257 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2259 //Add a new Offset function
2260 Handle(GEOM_Function) aFunction;
2261 Handle(GEOM_Object) aCopy;
2264 //Add a new Copy object
2265 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2266 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2269 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2271 if (aFunction.IsNull()) return NULL;
2273 //Check if the function is set correctly
2274 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2276 GEOMImpl_IOffset aTI (aFunction);
2277 aTI.SetShape(anOriginal);
2278 aTI.SetValue(theOffset);
2280 //Compute the offset
2282 #if OCC_VERSION_LARGE > 0x06010000
2285 if (!GetSolver()->ComputeFunction(aFunction)) {
2286 SetErrorCode("Offset driver failed");
2290 catch (Standard_Failure) {
2291 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2292 SetErrorCode(aFail->GetMessageString());
2296 //Make a Python command
2299 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2300 << theObject << ", " << theOffset << ")";
2306 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2307 << theObject << ", " << theOffset << ")";
2313 //=============================================================================
2317 //=============================================================================
2318 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2319 Handle(GEOM_Object) theBase1,
2320 Handle(GEOM_Object) theBase2)
2324 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2326 // Add a new Path object
2327 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2329 // Add a new Path function
2330 Handle(GEOM_Function) aFunction =
2331 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2332 if (aFunction.IsNull()) return NULL;
2334 // Check if the function is set correctly
2335 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2337 GEOMImpl_IPipePath aCI (aFunction);
2339 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2340 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2341 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2343 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2345 aCI.SetShape(aRefShape);
2346 aCI.SetBase1(aRefBase1);
2347 aCI.SetBase2(aRefBase2);
2349 // Compute the Path value
2351 #if OCC_VERSION_LARGE > 0x06010000
2354 if (!GetSolver()->ComputeFunction(aFunction)) {
2355 SetErrorCode("PipePath driver failed");
2359 catch (Standard_Failure) {
2360 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2361 SetErrorCode("RestorePath: inappropriate arguments given");
2365 // Make a Python command
2366 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2367 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2373 //=============================================================================
2377 //=============================================================================
2378 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2379 (Handle(GEOM_Object) theShape,
2380 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2381 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2385 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2387 Standard_Integer nbBases1 = theBase1->Length();
2388 Standard_Integer nbBases2 = theBase2->Length();
2390 if (!nbBases1 || !nbBases2)
2393 // Add a new Path object
2394 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2396 // Add a new Path function
2397 Handle(GEOM_Function) aFunction =
2398 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2399 if (aFunction.IsNull()) return NULL;
2401 // Check if the function is set correctly
2402 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2404 GEOMImpl_IPipePath aCI (aFunction);
2406 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2407 if (aRefShape.IsNull()) return NULL;
2409 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2410 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2413 for (i = 1; i <= nbBases1; i++) {
2414 Handle(Standard_Transient) anItem = theBase1->Value(i);
2415 if (!anItem.IsNull()) {
2416 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2417 if (!aBase.IsNull()) {
2418 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2419 if (!aRefBase.IsNull())
2420 aSeqBases1->Append(aRefBase);
2424 for (i = 1; i <= nbBases2; i++) {
2425 Handle(Standard_Transient) anItem = theBase2->Value(i);
2426 if (!anItem.IsNull()) {
2427 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2428 if (!aBase.IsNull()) {
2429 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2430 if (!aRefBase.IsNull())
2431 aSeqBases2->Append(aRefBase);
2435 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2437 aCI.SetShape(aRefShape);
2438 aCI.SetBaseSeq1(aSeqBases1);
2439 aCI.SetBaseSeq2(aSeqBases2);
2441 // Compute the Path value
2443 #if OCC_VERSION_LARGE > 0x06010000
2446 if (!GetSolver()->ComputeFunction(aFunction)) {
2447 SetErrorCode("PipePath driver failed");
2451 catch (Standard_Failure) {
2452 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2453 SetErrorCode("RestorePath: inappropriate arguments given");
2457 // Make a Python command
2458 GEOM::TPythonDump pyDump (aFunction);
2459 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2460 for (i = 1; i <= nbBases1; i++) {
2461 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2462 if (!anObj.IsNull()) {
2469 for (i = 1; i <= nbBases2; i++) {
2470 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2471 if (!anObj.IsNull()) {