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, double theA)
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);
511 //Compute the Cylinder value
513 #if OCC_VERSION_LARGE > 0x06010000
516 if (!GetSolver()->ComputeFunction(aFunction)) {
517 SetErrorCode("Cylinder driver failed");
521 catch (Standard_Failure) {
522 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
523 SetErrorCode(aFail->GetMessageString());
527 //Make a Python command
528 GEOM::TPythonDump(aFunction) << aCylinder
529 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ", " << theA << ")";
536 //=============================================================================
538 * MakeCylinderPntVecRH
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
542 Handle(GEOM_Object) theVec,
543 double theR, double theH, double theA)
547 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
549 //Add a new Cylinder object
550 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
552 //Add a new Cylinder function for creation a cylinder relatively to point and vector
553 Handle(GEOM_Function) aFunction =
554 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
555 if (aFunction.IsNull()) return NULL;
557 //Check if the function is set correctly
558 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
560 GEOMImpl_ICylinder aCI (aFunction);
562 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
563 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
565 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
567 aCI.SetPoint(aRefPnt);
568 aCI.SetVector(aRefVec);
573 //Compute the Cylinder value
575 #if OCC_VERSION_LARGE > 0x06010000
578 if (!GetSolver()->ComputeFunction(aFunction)) {
579 SetErrorCode("Cylinder driver failed");
583 catch (Standard_Failure) {
584 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
585 SetErrorCode(aFail->GetMessageString());
589 //Make a Python command
590 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
591 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA << ")";
598 //=============================================================================
602 //=============================================================================
603 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
608 //Add a new Cone object
609 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
611 //Add a new Cone function with R and H parameters
612 Handle(GEOM_Function) aFunction =
613 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
614 if (aFunction.IsNull()) return NULL;
616 //Check if the function is set correctly
617 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
619 GEOMImpl_ICone aCI (aFunction);
625 //Compute the Cone value
627 #if OCC_VERSION_LARGE > 0x06010000
630 if (!GetSolver()->ComputeFunction(aFunction)) {
631 SetErrorCode("Cone driver failed");
635 catch (Standard_Failure) {
636 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
637 SetErrorCode(aFail->GetMessageString());
641 //Make a Python command
642 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
643 << theR1 << ", " << theR2 << ", " << theH << ")";
650 //=============================================================================
652 * MakeConePntVecR1R2H
654 //=============================================================================
655 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
656 Handle(GEOM_Object) theVec,
657 double theR1, double theR2,
662 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
664 //Add a new Cone object
665 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
667 //Add a new Cone function for creation a cone relatively to point and vector
668 Handle(GEOM_Function) aFunction =
669 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
670 if (aFunction.IsNull()) return NULL;
672 //Check if the function is set correctly
673 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
675 GEOMImpl_ICone aCI (aFunction);
677 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
678 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
680 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
682 aCI.SetPoint(aRefPnt);
683 aCI.SetVector(aRefVec);
688 //Compute the Cone value
690 #if OCC_VERSION_LARGE > 0x06010000
693 if (!GetSolver()->ComputeFunction(aFunction)) {
694 SetErrorCode("Cone driver failed");
698 catch (Standard_Failure) {
699 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
700 SetErrorCode(aFail->GetMessageString());
704 //Make a Python command
705 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
706 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
713 //=============================================================================
717 //=============================================================================
718 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
722 //Add a new Sphere object
723 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
725 //Add a new Sphere function with R parameter
726 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
727 if (aFunction.IsNull()) return NULL;
729 //Check if the function is set correctly
730 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
732 GEOMImpl_ISphere aCI (aFunction);
736 //Compute the Sphere value
738 #if OCC_VERSION_LARGE > 0x06010000
741 if (!GetSolver()->ComputeFunction(aFunction)) {
742 SetErrorCode("Sphere driver failed");
746 catch (Standard_Failure) {
747 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
748 SetErrorCode(aFail->GetMessageString());
752 //Make a Python command
753 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
760 //=============================================================================
764 //=============================================================================
765 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
770 if (thePnt.IsNull()) return NULL;
772 //Add a new Point object
773 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
775 //Add a new Sphere function for creation a sphere relatively to point
776 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
777 if (aFunction.IsNull()) return NULL;
779 //Check if the function is set correctly
780 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
782 GEOMImpl_ISphere aCI (aFunction);
784 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
786 if (aRefPnt.IsNull()) return NULL;
788 aCI.SetPoint(aRefPnt);
791 //Compute the Sphere value
793 #if OCC_VERSION_LARGE > 0x06010000
796 if (!GetSolver()->ComputeFunction(aFunction)) {
797 SetErrorCode("Sphere driver failed");
801 catch (Standard_Failure) {
802 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
803 SetErrorCode(aFail->GetMessageString());
807 //Make a Python command
808 GEOM::TPythonDump(aFunction) << aSphere
809 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
816 //=============================================================================
820 //=============================================================================
821 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
822 (double theRMajor, double theRMinor)
826 //Add a new Torus object
827 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
829 //Add a new Torus function
830 Handle(GEOM_Function) aFunction =
831 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
832 if (aFunction.IsNull()) return NULL;
834 //Check if the function is set correctly
835 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
837 GEOMImpl_ITorus aCI (aFunction);
839 aCI.SetRMajor(theRMajor);
840 aCI.SetRMinor(theRMinor);
842 //Compute the Torus value
844 #if OCC_VERSION_LARGE > 0x06010000
847 if (!GetSolver()->ComputeFunction(aFunction)) {
848 SetErrorCode("Torus driver failed");
852 catch (Standard_Failure) {
853 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
854 SetErrorCode(aFail->GetMessageString());
858 //Make a Python command
859 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
860 << theRMajor << ", " << theRMinor << ")";
866 //=============================================================================
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
872 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
873 double theRMajor, double theRMinor)
877 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
879 //Add a new Torus object
880 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
882 //Add a new Torus function
883 Handle(GEOM_Function) aFunction =
884 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
885 if (aFunction.IsNull()) return NULL;
887 //Check if the function is set correctly
888 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
890 GEOMImpl_ITorus aCI (aFunction);
892 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
893 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
895 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
897 aCI.SetCenter(aRefPnt);
898 aCI.SetVector(aRefVec);
899 aCI.SetRMajor(theRMajor);
900 aCI.SetRMinor(theRMinor);
902 //Compute the Torus value
904 #if OCC_VERSION_LARGE > 0x06010000
907 if (!GetSolver()->ComputeFunction(aFunction)) {
908 SetErrorCode("Torus driver failed");
912 catch (Standard_Failure) {
913 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
914 SetErrorCode(aFail->GetMessageString());
918 //Make a Python command
919 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
920 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
927 //=============================================================================
931 //=============================================================================
932 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
933 Handle(GEOM_Object) theVec,
934 double theH, double theScaleFactor)
938 if (theBase.IsNull() || theVec.IsNull()) return NULL;
940 //Add a new Prism object
941 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
943 //Add a new Prism function for creation a Prism relatively to vector
944 Handle(GEOM_Function) aFunction =
945 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
946 if (aFunction.IsNull()) return NULL;
948 //Check if the function is set correctly
949 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
951 GEOMImpl_IPrism aCI (aFunction);
953 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
954 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
956 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
958 aCI.SetBase(aRefBase);
959 aCI.SetVector(aRefVec);
961 aCI.SetScale(theScaleFactor);
963 //Compute the Prism value
965 #if OCC_VERSION_LARGE > 0x06010000
968 if (!GetSolver()->ComputeFunction(aFunction)) {
969 //SetErrorCode("Prism driver failed");
970 SetErrorCode("Extrusion can not be created, check input data");
974 catch (Standard_Failure) {
975 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
976 SetErrorCode(aFail->GetMessageString());
980 //Make a Python command
981 GEOM::TPythonDump pd (aFunction);
982 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
983 if (theScaleFactor > Precision::Confusion())
984 pd << ", " << theScaleFactor << ")";
992 //=============================================================================
996 //=============================================================================
997 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
998 Handle(GEOM_Object) theVec,
1003 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1005 //Add a new Prism object
1006 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1008 //Add a new Prism function for creation a Prism relatively to vector
1009 Handle(GEOM_Function) aFunction =
1010 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1011 if (aFunction.IsNull()) return NULL;
1013 //Check if the function is set correctly
1014 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1016 GEOMImpl_IPrism aCI (aFunction);
1018 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1019 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1021 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1023 aCI.SetBase(aRefBase);
1024 aCI.SetVector(aRefVec);
1027 //Compute the Prism value
1029 #if OCC_VERSION_LARGE > 0x06010000
1032 if (!GetSolver()->ComputeFunction(aFunction)) {
1033 //SetErrorCode("Prism driver failed");
1034 SetErrorCode("Extrusion can not be created, check input data");
1038 catch (Standard_Failure) {
1039 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1040 SetErrorCode(aFail->GetMessageString());
1044 //Make a Python command
1045 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1046 << theBase << ", " << theVec << ", " << theH << ")";
1052 //=============================================================================
1056 //=============================================================================
1057 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1058 (Handle(GEOM_Object) theBase,
1059 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1060 double theScaleFactor)
1064 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1066 //Add a new Prism object
1067 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1069 //Add a new Prism function for creation a Prism relatively to two points
1070 Handle(GEOM_Function) aFunction =
1071 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1072 if (aFunction.IsNull()) return NULL;
1074 //Check if the function is set correctly
1075 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1077 GEOMImpl_IPrism aCI (aFunction);
1079 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1080 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1081 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1083 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1085 aCI.SetBase(aRefBase);
1086 aCI.SetFirstPoint(aRefPnt1);
1087 aCI.SetLastPoint(aRefPnt2);
1088 aCI.SetScale(theScaleFactor);
1090 //Compute the Prism value
1092 #if OCC_VERSION_LARGE > 0x06010000
1095 if (!GetSolver()->ComputeFunction(aFunction)) {
1096 //SetErrorCode("Prism driver failed");
1097 SetErrorCode("Extrusion can not be created, check input data");
1101 catch (Standard_Failure) {
1102 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1103 SetErrorCode(aFail->GetMessageString());
1107 //Make a Python command
1108 GEOM::TPythonDump pd (aFunction);
1109 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1110 if (theScaleFactor > Precision::Confusion())
1111 pd << ", " << theScaleFactor << ")";
1119 //=============================================================================
1121 * MakePrismTwoPnt2Ways
1123 //=============================================================================
1124 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1125 (Handle(GEOM_Object) theBase,
1126 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1130 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1132 //Add a new Prism object
1133 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1135 //Add a new Prism function for creation a Prism relatively to two points
1136 Handle(GEOM_Function) aFunction =
1137 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1138 if (aFunction.IsNull()) return NULL;
1140 //Check if the function is set correctly
1141 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1143 GEOMImpl_IPrism aCI (aFunction);
1145 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1146 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1147 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1149 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1151 aCI.SetBase(aRefBase);
1152 aCI.SetFirstPoint(aRefPnt1);
1153 aCI.SetLastPoint(aRefPnt2);
1155 //Compute the Prism value
1157 #if OCC_VERSION_LARGE > 0x06010000
1160 if (!GetSolver()->ComputeFunction(aFunction)) {
1161 //SetErrorCode("Prism driver failed");
1162 SetErrorCode("Extrusion can not be created, check input data");
1166 catch (Standard_Failure) {
1167 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1168 SetErrorCode(aFail->GetMessageString());
1172 //Make a Python command
1173 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1174 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1180 //=============================================================================
1184 //=============================================================================
1185 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1186 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1187 double theScaleFactor)
1191 if (theBase.IsNull()) return NULL;
1193 //Add a new Prism object
1194 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1196 //Add a new Prism function for creation a Prism by DXDYDZ
1197 Handle(GEOM_Function) aFunction =
1198 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1199 if (aFunction.IsNull()) return NULL;
1201 //Check if the function is set correctly
1202 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1204 GEOMImpl_IPrism aCI (aFunction);
1206 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1208 if (aRefBase.IsNull()) return NULL;
1210 aCI.SetBase(aRefBase);
1214 aCI.SetScale(theScaleFactor);
1216 //Compute the Prism value
1218 #if OCC_VERSION_LARGE > 0x06010000
1221 if (!GetSolver()->ComputeFunction(aFunction)) {
1222 SetErrorCode("Extrusion can not be created, check input data");
1226 catch (Standard_Failure) {
1227 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1228 SetErrorCode(aFail->GetMessageString());
1232 //Make a Python command
1233 GEOM::TPythonDump pd (aFunction);
1234 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1235 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1236 if (theScaleFactor > Precision::Confusion())
1237 pd << ", " << theScaleFactor << ")";
1245 //=============================================================================
1247 * MakePrismDXDYDZ_2WAYS
1249 //=============================================================================
1250 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1251 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1255 if (theBase.IsNull()) return NULL;
1257 //Add a new Prism object
1258 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1260 //Add a new Prism function for creation a Prism by DXDYDZ
1261 Handle(GEOM_Function) aFunction =
1262 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1263 if (aFunction.IsNull()) return NULL;
1265 //Check if the function is set correctly
1266 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1268 GEOMImpl_IPrism aCI (aFunction);
1270 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1272 if (aRefBase.IsNull()) return NULL;
1274 aCI.SetBase(aRefBase);
1279 //Compute the Prism value
1281 #if OCC_VERSION_LARGE > 0x06010000
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(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1297 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1303 //=============================================================================
1307 //=============================================================================
1308 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1309 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1313 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1315 Handle(GEOM_Object) aPrism = NULL;
1319 //Add a new Extruded Boss object
1320 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1324 //Add a new Extruded Cut object
1325 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1328 //Add a new Prism function for the creation of a Draft Prism feature
1329 Handle(GEOM_Function) aFunction =
1330 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1331 if (aFunction.IsNull()) return NULL;
1333 //Check if the function is set correctly
1334 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1336 GEOMImpl_IPrism aCI (aFunction);
1338 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1339 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1341 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1344 aCI.SetBase(aRefBase);
1345 aCI.SetInitShape(aRefInit);
1346 aCI.SetH(theHeight);
1347 aCI.SetDraftAngle(theAngle);
1353 //Compute the Draft Prism Feature value
1355 #if OCC_VERSION_LARGE > 0x06010000
1358 if (!GetSolver()->ComputeFunction(aFunction)) {
1359 SetErrorCode("Extrusion can not be created, check input data");
1363 catch (Standard_Failure) {
1364 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1365 SetErrorCode(aFail->GetMessageString());
1369 //Make a Python command
1372 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1373 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1377 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1378 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1385 //=============================================================================
1389 //=============================================================================
1390 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1391 Handle(GEOM_Object) thePath)
1395 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1397 //Add a new Pipe object
1398 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1400 //Add a new Pipe function
1401 Handle(GEOM_Function) aFunction =
1402 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1403 if (aFunction.IsNull()) return NULL;
1405 //Check if the function is set correctly
1406 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1408 GEOMImpl_IPipe aCI (aFunction);
1410 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1411 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1413 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1415 aCI.SetBase(aRefBase);
1416 aCI.SetPath(aRefPath);
1418 //Compute the Pipe value
1420 #if OCC_VERSION_LARGE > 0x06010000
1423 if (!GetSolver()->ComputeFunction(aFunction)) {
1424 SetErrorCode("Pipe driver failed");
1428 catch (Standard_Failure) {
1429 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1430 SetErrorCode(aFail->GetMessageString());
1434 //Make a Python command
1435 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1436 << theBase << ", " << thePath << ")";
1443 //=============================================================================
1445 * MakeRevolutionAxisAngle
1447 //=============================================================================
1448 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1449 Handle(GEOM_Object) theAxis,
1454 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1456 //Add a new Revolution object
1457 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1459 //Add a new Revolution function for creation a revolution relatively to axis
1460 Handle(GEOM_Function) aFunction =
1461 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1462 if (aFunction.IsNull()) return NULL;
1464 //Check if the function is set correctly
1465 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1467 GEOMImpl_IRevolution aCI (aFunction);
1469 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1470 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1472 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1474 aCI.SetBase(aRefBase);
1475 aCI.SetAxis(aRefAxis);
1476 aCI.SetAngle(theAngle);
1478 //Compute the Revolution value
1480 #if OCC_VERSION_LARGE > 0x06010000
1483 if (!GetSolver()->ComputeFunction(aFunction)) {
1484 SetErrorCode("Revolution driver failed");
1488 catch (Standard_Failure) {
1489 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1490 SetErrorCode(aFail->GetMessageString());
1494 //Make a Python command
1495 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1496 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1502 //=============================================================================
1504 * MakeRevolutionAxisAngle2Ways
1506 //=============================================================================
1507 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1508 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1512 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1514 //Add a new Revolution object
1515 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1517 //Add a new Revolution function for creation a revolution relatively to axis
1518 Handle(GEOM_Function) aFunction =
1519 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1520 if (aFunction.IsNull()) return NULL;
1522 //Check if the function is set correctly
1523 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1525 GEOMImpl_IRevolution aCI (aFunction);
1527 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1528 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1530 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1532 aCI.SetBase(aRefBase);
1533 aCI.SetAxis(aRefAxis);
1534 aCI.SetAngle(theAngle);
1536 //Compute the Revolution value
1538 #if OCC_VERSION_LARGE > 0x06010000
1541 if (!GetSolver()->ComputeFunction(aFunction)) {
1542 SetErrorCode("Revolution driver failed");
1546 catch (Standard_Failure) {
1547 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1548 SetErrorCode(aFail->GetMessageString());
1552 //Make a Python command
1553 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1554 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1560 //=============================================================================
1564 //=============================================================================
1565 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1566 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1567 double theTol2D, double theTol3D, int theNbIter,
1568 int theMethod, bool isApprox)
1572 if (theShape.IsNull()) return NULL;
1574 //Add a new Filling object
1575 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1577 //Add a new Filling function for creation a filling from a compound
1578 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1579 if (aFunction.IsNull()) return NULL;
1581 //Check if the function is set correctly
1582 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1584 GEOMImpl_IFilling aFI (aFunction);
1586 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1588 if (aRefShape.IsNull()) return NULL;
1590 aFI.SetShape(aRefShape);
1591 aFI.SetMinDeg(theMinDeg);
1592 aFI.SetMaxDeg(theMaxDeg);
1593 aFI.SetTol2D(theTol2D);
1594 aFI.SetTol3D(theTol3D);
1595 aFI.SetNbIter(theNbIter);
1596 aFI.SetApprox(isApprox);
1597 aFI.SetMethod(theMethod);
1599 //Compute the Solid value
1601 #if OCC_VERSION_LARGE > 0x06010000
1604 if (!GetSolver()->ComputeFunction(aFunction)) {
1605 SetErrorCode("Filling driver failed");
1609 catch (Standard_Failure) {
1610 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1611 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1612 SetErrorCode("B-Spline surface construction failed");
1614 SetErrorCode(aFail->GetMessageString());
1618 //Make a Python command
1619 GEOM::TPythonDump pd (aFunction);
1620 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1621 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1622 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1623 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1624 pd << ", theTol2D=" << theTol2D ;
1625 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1626 pd << ", theTol3D=" << theTol3D ;
1627 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1628 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1629 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1630 if(isApprox) pd << ", isApprox=" << isApprox ;
1637 //=============================================================================
1641 //=============================================================================
1642 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1643 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1648 Handle(GEOM_Object) anObj;
1650 if(theSeqSections.IsNull())
1653 Standard_Integer nbObj = theSeqSections->Length();
1657 //Add a new ThruSections object
1658 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1661 //Add a new ThruSections function
1663 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1664 Handle(GEOM_Function) aFunction =
1665 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1666 if (aFunction.IsNull()) return anObj;
1668 //Check if the function is set correctly
1669 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1671 GEOMImpl_IThruSections aCI (aFunction);
1673 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1675 Standard_Integer i =1;
1676 for( ; i <= nbObj; i++) {
1678 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1682 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1683 if(!aSectObj.IsNull())
1685 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1686 if(!aRefSect.IsNull())
1687 aSeqSections->Append(aRefSect);
1691 if(!aSeqSections->Length())
1694 aCI.SetSections(aSeqSections);
1695 aCI.SetSolidMode(theModeSolid);
1696 aCI.SetPrecision(thePreci);
1698 //Compute the ThruSections value
1700 #if OCC_VERSION_LARGE > 0x06010000
1703 if (!GetSolver()->ComputeFunction(aFunction)) {
1704 SetErrorCode("ThruSections driver failed");
1708 catch (Standard_Failure) {
1709 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1710 SetErrorCode(aFail->GetMessageString());
1714 //Make a Python command
1715 GEOM::TPythonDump pyDump(aFunction);
1716 pyDump << aThruSect << " = geompy.MakeThruSections([";
1718 for(i =1 ; i <= nbObj; i++) {
1720 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1724 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1725 if(!aSectObj.IsNull()) {
1732 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1739 //=============================================================================
1741 * MakePipeWithDifferentSections
1743 //=============================================================================
1744 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1745 const Handle(TColStd_HSequenceOfTransient)& theBases,
1746 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1747 const Handle(GEOM_Object)& thePath,
1748 bool theWithContact,
1749 bool theWithCorrections)
1751 Handle(GEOM_Object) anObj;
1753 if(theBases.IsNull())
1756 Standard_Integer nbBases = theBases->Length();
1761 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1762 //Add a new Pipe object
1763 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1765 //Add a new Pipe function
1767 Handle(GEOM_Function) aFunction =
1768 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1769 if (aFunction.IsNull()) return anObj;
1771 //Check if the function is set correctly
1772 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1774 GEOMImpl_IPipeDiffSect aCI (aFunction);
1776 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1777 if(aRefPath.IsNull())
1780 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1781 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1783 Standard_Integer i =1;
1784 for( ; i <= nbBases; i++) {
1786 Handle(Standard_Transient) anItem = theBases->Value(i);
1790 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1793 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1794 if(aRefBase.IsNull())
1798 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1799 if(anItemLoc.IsNull())
1802 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1805 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1806 if(aRefLoc.IsNull())
1808 aSeqLocs->Append(aRefLoc);
1810 aSeqBases->Append(aRefBase);
1813 if(!aSeqBases->Length())
1816 aCI.SetBases(aSeqBases);
1817 aCI.SetLocations(aSeqLocs);
1818 aCI.SetPath(aRefPath);
1819 aCI.SetWithContactMode(theWithContact);
1820 aCI.SetWithCorrectionMode(theWithCorrections);
1822 //Compute the Pipe value
1824 #if OCC_VERSION_LARGE > 0x06010000
1827 if (!GetSolver()->ComputeFunction(aFunction)) {
1828 SetErrorCode("Pipe with defferent section driver failed");
1832 catch (Standard_Failure) {
1833 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1834 SetErrorCode(aFail->GetMessageString());
1838 //Make a Python command
1839 GEOM::TPythonDump pyDump(aFunction);
1840 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1842 for(i =1 ; i <= nbBases; i++) {
1844 Handle(Standard_Transient) anItem = theBases->Value(i);
1848 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1849 if(!anObj.IsNull()) {
1858 for(i =1 ; i <= nbLocs; i++) {
1860 Handle(Standard_Transient) anItem = theLocations->Value(i);
1864 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1865 if(!anObj.IsNull()) {
1872 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1879 //=============================================================================
1881 * MakePipeWithShellSections
1883 //=============================================================================
1884 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1885 const Handle(TColStd_HSequenceOfTransient)& theBases,
1886 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1887 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1888 const Handle(GEOM_Object)& thePath,
1889 bool theWithContact,
1890 bool theWithCorrections)
1892 Handle(GEOM_Object) anObj;
1894 if(theBases.IsNull())
1897 Standard_Integer nbBases = theBases->Length();
1902 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1904 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1906 //Add a new Pipe object
1907 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1909 //Add a new Pipe function
1911 Handle(GEOM_Function) aFunction =
1912 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1913 if (aFunction.IsNull()) return anObj;
1915 //Check if the function is set correctly
1916 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1918 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1919 GEOMImpl_IPipeShellSect aCI (aFunction);
1921 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1922 if(aRefPath.IsNull())
1925 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1926 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1927 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1929 Standard_Integer i =1;
1930 for( ; i <= nbBases; i++) {
1932 Handle(Standard_Transient) anItem = theBases->Value(i);
1935 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1938 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1939 if(aRefBase.IsNull())
1942 if( nbSubBases >= nbBases ) {
1943 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1944 if(aSubItem.IsNull())
1946 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1947 if(aSubBase.IsNull())
1949 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1950 if(aRefSubBase.IsNull())
1952 aSeqSubBases->Append(aRefSubBase);
1956 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1957 if(anItemLoc.IsNull())
1959 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1962 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1963 if(aRefLoc.IsNull())
1965 aSeqLocs->Append(aRefLoc);
1968 aSeqBases->Append(aRefBase);
1971 if(!aSeqBases->Length())
1974 aCI.SetBases(aSeqBases);
1975 aCI.SetSubBases(aSeqSubBases);
1976 aCI.SetLocations(aSeqLocs);
1977 aCI.SetPath(aRefPath);
1978 aCI.SetWithContactMode(theWithContact);
1979 aCI.SetWithCorrectionMode(theWithCorrections);
1981 //Compute the Pipe value
1983 #if OCC_VERSION_LARGE > 0x06010000
1986 if (!GetSolver()->ComputeFunction(aFunction)) {
1987 SetErrorCode("Pipe with shell sections driver failed");
1991 catch (Standard_Failure) {
1992 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1993 SetErrorCode(aFail->GetMessageString());
1997 //Make a Python command
1998 GEOM::TPythonDump pyDump(aFunction);
1999 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
2001 for(i =1 ; i <= nbBases; i++) {
2003 Handle(Standard_Transient) anItem = theBases->Value(i);
2007 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2008 if(!anObj.IsNull()) {
2017 for(i =1 ; i <= nbSubBases; i++) {
2019 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2023 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2024 if(!anObj.IsNull()) {
2033 for(i =1 ; i <= nbLocs; i++) {
2035 Handle(Standard_Transient) anItem = theLocations->Value(i);
2039 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2040 if(!anObj.IsNull()) {
2047 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2055 //=============================================================================
2057 * MakePipeShellsWithoutPath
2059 //=============================================================================
2060 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2061 const Handle(TColStd_HSequenceOfTransient)& theBases,
2062 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2064 Handle(GEOM_Object) anObj;
2066 if(theBases.IsNull())
2069 Standard_Integer nbBases = theBases->Length();
2074 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2076 //Add a new Pipe object
2077 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2079 //Add a new Pipe function
2081 Handle(GEOM_Function) aFunction =
2082 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2083 if (aFunction.IsNull()) return anObj;
2085 //Check if the function is set correctly
2086 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2088 GEOMImpl_IPipeShellSect aCI (aFunction);
2090 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2091 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2093 Standard_Integer i =1;
2094 for( ; i <= nbBases; i++) {
2096 Handle(Standard_Transient) anItem = theBases->Value(i);
2099 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2102 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2103 if(aRefBase.IsNull())
2107 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2108 if(anItemLoc.IsNull())
2110 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2113 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2114 if(aRefLoc.IsNull())
2116 aSeqLocs->Append(aRefLoc);
2119 aSeqBases->Append(aRefBase);
2122 if(!aSeqBases->Length())
2125 aCI.SetBases(aSeqBases);
2126 aCI.SetLocations(aSeqLocs);
2128 //Compute the Pipe value
2130 #if OCC_VERSION_LARGE > 0x06010000
2133 if (!GetSolver()->ComputeFunction(aFunction)) {
2134 SetErrorCode("Pipe with shell sections without path driver failed");
2138 catch (Standard_Failure) {
2139 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2140 SetErrorCode(aFail->GetMessageString());
2144 //Make a Python command
2145 GEOM::TPythonDump pyDump(aFunction);
2146 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2148 for(i =1 ; i <= nbBases; i++) {
2150 Handle(Standard_Transient) anItem = theBases->Value(i);
2154 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2155 if(!anObj.IsNull()) {
2164 for(i =1 ; i <= nbLocs; i++) {
2166 Handle(Standard_Transient) anItem = theLocations->Value(i);
2170 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2171 if(!anObj.IsNull()) {
2185 //=============================================================================
2187 * MakePipeBiNormalAlongVector
2189 //=============================================================================
2190 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2191 Handle(GEOM_Object) thePath,
2192 Handle(GEOM_Object) theVec)
2196 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2198 //Add a new Pipe object
2199 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2201 //Add a new Pipe function
2202 Handle(GEOM_Function) aFunction =
2203 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2204 if (aFunction.IsNull()) return NULL;
2206 //Check if the function is set correctly
2207 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2209 GEOMImpl_IPipeBiNormal aCI (aFunction);
2211 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2212 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2213 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2215 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2217 aCI.SetBase(aRefBase);
2218 aCI.SetPath(aRefPath);
2219 aCI.SetVector(aRefVec);
2221 //Compute the Pipe value
2223 #if OCC_VERSION_LARGE > 0x06010000
2226 if (!GetSolver()->ComputeFunction(aFunction)) {
2227 SetErrorCode("Pipe driver failed");
2231 catch (Standard_Failure) {
2232 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2233 SetErrorCode(aFail->GetMessageString());
2237 //Make a Python command
2238 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2239 << theBase << ", " << thePath << ", " << theVec << ")";
2245 //=============================================================================
2249 //=============================================================================
2250 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2256 if (theObject.IsNull()) return NULL;
2258 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2259 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2261 //Add a new Offset function
2262 Handle(GEOM_Function) aFunction;
2263 Handle(GEOM_Object) aCopy;
2266 //Add a new Copy object
2267 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2268 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2271 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2273 if (aFunction.IsNull()) return NULL;
2275 //Check if the function is set correctly
2276 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2278 GEOMImpl_IOffset aTI (aFunction);
2279 aTI.SetShape(anOriginal);
2280 aTI.SetValue(theOffset);
2282 //Compute the offset
2284 #if OCC_VERSION_LARGE > 0x06010000
2287 if (!GetSolver()->ComputeFunction(aFunction)) {
2288 SetErrorCode("Offset driver failed");
2292 catch (Standard_Failure) {
2293 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2294 SetErrorCode(aFail->GetMessageString());
2298 //Make a Python command
2301 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2302 << theObject << ", " << theOffset << ")";
2308 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2309 << theObject << ", " << theOffset << ")";
2315 //=============================================================================
2319 //=============================================================================
2320 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2321 Handle(GEOM_Object) theBase1,
2322 Handle(GEOM_Object) theBase2)
2326 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2328 // Add a new Path object
2329 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2331 // Add a new Path function
2332 Handle(GEOM_Function) aFunction =
2333 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2334 if (aFunction.IsNull()) return NULL;
2336 // Check if the function is set correctly
2337 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2339 GEOMImpl_IPipePath aCI (aFunction);
2341 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2342 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2343 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2345 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2347 aCI.SetShape(aRefShape);
2348 aCI.SetBase1(aRefBase1);
2349 aCI.SetBase2(aRefBase2);
2351 // Compute the Path value
2353 #if OCC_VERSION_LARGE > 0x06010000
2356 if (!GetSolver()->ComputeFunction(aFunction)) {
2357 SetErrorCode("PipePath driver failed");
2361 catch (Standard_Failure) {
2362 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2363 SetErrorCode("RestorePath: inappropriate arguments given");
2367 // Make a Python command
2368 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2369 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2375 //=============================================================================
2379 //=============================================================================
2380 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2381 (Handle(GEOM_Object) theShape,
2382 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2383 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2387 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2389 Standard_Integer nbBases1 = theBase1->Length();
2390 Standard_Integer nbBases2 = theBase2->Length();
2392 if (!nbBases1 || !nbBases2)
2395 // Add a new Path object
2396 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2398 // Add a new Path function
2399 Handle(GEOM_Function) aFunction =
2400 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2401 if (aFunction.IsNull()) return NULL;
2403 // Check if the function is set correctly
2404 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2406 GEOMImpl_IPipePath aCI (aFunction);
2408 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2409 if (aRefShape.IsNull()) return NULL;
2411 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2412 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2415 for (i = 1; i <= nbBases1; i++) {
2416 Handle(Standard_Transient) anItem = theBase1->Value(i);
2417 if (!anItem.IsNull()) {
2418 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2419 if (!aBase.IsNull()) {
2420 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2421 if (!aRefBase.IsNull())
2422 aSeqBases1->Append(aRefBase);
2426 for (i = 1; i <= nbBases2; i++) {
2427 Handle(Standard_Transient) anItem = theBase2->Value(i);
2428 if (!anItem.IsNull()) {
2429 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2430 if (!aBase.IsNull()) {
2431 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2432 if (!aRefBase.IsNull())
2433 aSeqBases2->Append(aRefBase);
2437 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2439 aCI.SetShape(aRefShape);
2440 aCI.SetBaseSeq1(aSeqBases1);
2441 aCI.SetBaseSeq2(aSeqBases2);
2443 // Compute the Path value
2445 #if OCC_VERSION_LARGE > 0x06010000
2448 if (!GetSolver()->ComputeFunction(aFunction)) {
2449 SetErrorCode("PipePath driver failed");
2453 catch (Standard_Failure) {
2454 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2455 SetErrorCode("RestorePath: inappropriate arguments given");
2459 // Make a Python command
2460 GEOM::TPythonDump pyDump (aFunction);
2461 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2462 for (i = 1; i <= nbBases1; i++) {
2463 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2464 if (!anObj.IsNull()) {
2471 for (i = 1; i <= nbBases2; i++) {
2472 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2473 if (!anObj.IsNull()) {