1 // Copyright (C) 2007-2012 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.
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
22 #include <Standard_Stream.hxx>
24 #include <Basics_OCCTVersion.hxx>
26 #include <GEOMImpl_I3DPrimOperations.hxx>
28 #include "utilities.h"
30 #include <Utils_ExceptHandlers.hxx>
32 #include <TFunction_DriverTable.hxx>
33 #include <TFunction_Driver.hxx>
34 #include <TFunction_Logbook.hxx>
35 #include <TDF_Tool.hxx>
37 #include <GEOM_Function.hxx>
38 #include <GEOM_PythonDump.hxx>
40 #include <GEOMImpl_Types.hxx>
42 #include <GEOMImpl_BoxDriver.hxx>
43 #include <GEOMImpl_FaceDriver.hxx>
44 #include <GEOMImpl_DiskDriver.hxx>
45 #include <GEOMImpl_CylinderDriver.hxx>
46 #include <GEOMImpl_ConeDriver.hxx>
47 #include <GEOMImpl_SphereDriver.hxx>
48 #include <GEOMImpl_TorusDriver.hxx>
49 #include <GEOMImpl_PrismDriver.hxx>
50 #include <GEOMImpl_PipeDriver.hxx>
51 #include <GEOMImpl_PipePathDriver.hxx>
52 #include <GEOMImpl_RevolutionDriver.hxx>
53 #include <GEOMImpl_ShapeDriver.hxx>
54 #include <GEOMImpl_FillingDriver.hxx>
55 #include <GEOMImpl_ThruSectionsDriver.hxx>
57 #include <GEOMImpl_IBox.hxx>
58 #include <GEOMImpl_IFace.hxx>
59 #include <GEOMImpl_IDisk.hxx>
60 #include <GEOMImpl_ICylinder.hxx>
61 #include <GEOMImpl_ICone.hxx>
62 #include <GEOMImpl_ISphere.hxx>
63 #include <GEOMImpl_ITorus.hxx>
64 #include <GEOMImpl_IPrism.hxx>
65 #include <GEOMImpl_IPipe.hxx>
66 #include <GEOMImpl_IRevolution.hxx>
67 #include <GEOMImpl_IFilling.hxx>
68 #include <GEOMImpl_IThruSections.hxx>
69 #include <GEOMImpl_IPipeDiffSect.hxx>
70 #include <GEOMImpl_IPipeShellSect.hxx>
71 #include <GEOMImpl_IPipeBiNormal.hxx>
72 #include <GEOMImpl_IPipePath.hxx>
74 #include <Precision.hxx>
76 #include <Standard_Failure.hxx>
77 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
79 //=============================================================================
83 //=============================================================================
84 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
85 : GEOM_IOperations(theEngine, theDocID)
87 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
90 //=============================================================================
94 //=============================================================================
95 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
97 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
101 //=============================================================================
105 //=============================================================================
106 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
110 //Add a new Box object
111 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
113 //Add a new Box function with DX_DY_DZ parameters
114 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
115 if (aFunction.IsNull()) return NULL;
117 //Check if the function is set correctly
118 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
120 GEOMImpl_IBox aBI (aFunction);
126 //Compute the box value
128 #if OCC_VERSION_LARGE > 0x06010000
131 if (!GetSolver()->ComputeFunction(aFunction)) {
132 SetErrorCode("Box driver failed");
136 catch (Standard_Failure) {
137 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
138 SetErrorCode(aFail->GetMessageString());
142 //Make a Python command
143 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
144 << theDX << ", " << theDY << ", " << theDZ << ")";
151 //=============================================================================
155 //=============================================================================
156 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
157 Handle(GEOM_Object) thePnt2)
161 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
163 //Add a new Box object
164 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
166 //Add a new Box function for creation a box relatively to two points
167 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
168 if (aFunction.IsNull()) return NULL;
170 //Check if the function is set correctly
171 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
173 GEOMImpl_IBox aBI (aFunction);
175 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
176 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
178 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
180 aBI.SetRef1(aRefFunction1);
181 aBI.SetRef2(aRefFunction2);
183 //Compute the Box value
185 #if OCC_VERSION_LARGE > 0x06010000
188 if (!GetSolver()->ComputeFunction(aFunction)) {
189 SetErrorCode("Box driver failed");
193 catch (Standard_Failure) {
194 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
195 SetErrorCode(aFail->GetMessageString());
199 //Make a Python command
200 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
201 << thePnt1 << ", " << thePnt2 << ")";
207 //=============================================================================
211 //=============================================================================
212 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
216 if (theH == 0 || theW == 0) return NULL;
218 //Add a new Face object
219 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
221 //Add a new Box function for creation a box relatively to two points
222 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
223 if (aFunction.IsNull()) return NULL;
225 //Check if the function is set correctly
226 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
228 GEOMImpl_IFace aFI (aFunction);
232 aFI.SetOrientation(theOrientation);
236 #if OCC_VERSION_LARGE > 0x06010000
239 if (!GetSolver()->ComputeFunction(aFunction)) {
240 SetErrorCode("Face driver failed");
244 catch (Standard_Failure) {
245 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
246 SetErrorCode(aFail->GetMessageString());
250 //Make a Python command
251 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
252 << theH << ", " << theW << ", " << theOrientation << ")";
258 //=============================================================================
262 //=============================================================================
263 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
264 double theH, double theW)
268 if (theObj.IsNull()) return NULL;
270 //Add a new Face object
271 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
273 //Add a new Box function for creation a box relatively to two points
274 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
275 if (aFunction.IsNull()) return NULL;
277 //Check if the function is set correctly
278 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
280 GEOMImpl_IFace aFI (aFunction);
282 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
284 if (aRefFunction1.IsNull())
287 aFI.SetRef1(aRefFunction1);
293 #if OCC_VERSION_LARGE > 0x06010000
296 if (!GetSolver()->ComputeFunction(aFunction)) {
297 SetErrorCode("Face driver failed");
301 catch (Standard_Failure) {
302 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
303 SetErrorCode(aFail->GetMessageString());
307 //Make a Python command
308 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
309 << theObj << ", " << theH << ", " << theW << ")";
315 //=============================================================================
319 //=============================================================================
320 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
321 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
325 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
327 //Add a new Disk object
328 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
330 //Add a new Disk function for creation a disk relatively to point and vector
331 Handle(GEOM_Function) aFunction =
332 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
333 if (aFunction.IsNull()) return NULL;
335 //Check if the function is set correctly
336 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
338 GEOMImpl_IDisk aCI (aFunction);
340 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
341 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
343 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
345 aCI.SetCenter(aRefPnt);
346 aCI.SetVector(aRefVec);
349 //Compute the Disk value
351 #if OCC_VERSION_LARGE > 0x06010000
354 if (!GetSolver()->ComputeFunction(aFunction)) {
355 SetErrorCode("Disk driver failed");
359 catch (Standard_Failure) {
360 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
361 SetErrorCode(aFail->GetMessageString());
365 //Make a Python command
366 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
367 << thePnt << ", " << theVec << ", " << theR << ")";
373 //=============================================================================
377 //=============================================================================
378 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
379 Handle(GEOM_Object) thePnt2,
380 Handle(GEOM_Object) thePnt3)
384 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
386 //Add a new Disk object
387 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
389 //Add a new Disk function for creation a disk relatively to three points
390 Handle(GEOM_Function) aFunction =
391 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
392 if (aFunction.IsNull()) return NULL;
394 //Check if the function is set correctly
395 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
397 GEOMImpl_IDisk aCI (aFunction);
399 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
400 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
401 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
403 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
405 aCI.SetPoint1(aRefPnt1);
406 aCI.SetPoint2(aRefPnt2);
407 aCI.SetPoint3(aRefPnt3);
409 //Compute the Disk value
411 #if OCC_VERSION_LARGE > 0x06010000
414 if (!GetSolver()->ComputeFunction(aFunction)) {
415 SetErrorCode("Disk driver failed");
419 catch (Standard_Failure) {
420 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
421 SetErrorCode(aFail->GetMessageString());
425 //Make a Python command
426 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
427 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
433 //=============================================================================
437 //=============================================================================
438 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
442 if (theR == 0 ) return NULL;
444 //Add a new Disk object
445 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
447 //Add a new Box function for creation a box relatively to two points
448 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
449 if (aFunction.IsNull()) return NULL;
451 //Check if the function is set correctly
452 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
454 GEOMImpl_IDisk aDI (aFunction);
457 aDI.SetOrientation(theOrientation);
461 #if OCC_VERSION_LARGE > 0x06010000
464 if (!GetSolver()->ComputeFunction(aFunction)) {
465 SetErrorCode("Disk driver failed");
469 catch (Standard_Failure) {
470 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
471 SetErrorCode(aFail->GetMessageString());
475 //Make a Python command
476 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
477 << theR << ", " << theOrientation << ")";
483 //=============================================================================
487 //=============================================================================
488 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
492 //Add a new Cylinder object
493 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
495 //Add a new Cylinder function with R and H parameters
496 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
497 if (aFunction.IsNull()) return NULL;
499 //Check if the function is set correctly
500 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
502 GEOMImpl_ICylinder aCI (aFunction);
507 //Compute the Cylinder value
509 #if OCC_VERSION_LARGE > 0x06010000
512 if (!GetSolver()->ComputeFunction(aFunction)) {
513 SetErrorCode("Cylinder driver failed");
517 catch (Standard_Failure) {
518 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
519 SetErrorCode(aFail->GetMessageString());
523 //Make a Python command
524 GEOM::TPythonDump(aFunction) << aCylinder
525 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
532 //=============================================================================
534 * MakeCylinderPntVecRH
536 //=============================================================================
537 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
538 Handle(GEOM_Object) theVec,
539 double theR, double theH)
543 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
545 //Add a new Cylinder object
546 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
548 //Add a new Cylinder function for creation a cylinder relatively to point and vector
549 Handle(GEOM_Function) aFunction =
550 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
551 if (aFunction.IsNull()) return NULL;
553 //Check if the function is set correctly
554 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
556 GEOMImpl_ICylinder aCI (aFunction);
558 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
559 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
561 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
563 aCI.SetPoint(aRefPnt);
564 aCI.SetVector(aRefVec);
568 //Compute the Cylinder value
570 #if OCC_VERSION_LARGE > 0x06010000
573 if (!GetSolver()->ComputeFunction(aFunction)) {
574 SetErrorCode("Cylinder driver failed");
578 catch (Standard_Failure) {
579 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
580 SetErrorCode(aFail->GetMessageString());
584 //Make a Python command
585 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
586 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
593 //=============================================================================
597 //=============================================================================
598 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
603 //Add a new Cone object
604 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
606 //Add a new Cone function with R and H parameters
607 Handle(GEOM_Function) aFunction =
608 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
609 if (aFunction.IsNull()) return NULL;
611 //Check if the function is set correctly
612 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
614 GEOMImpl_ICone aCI (aFunction);
620 //Compute the Cone value
622 #if OCC_VERSION_LARGE > 0x06010000
625 if (!GetSolver()->ComputeFunction(aFunction)) {
626 SetErrorCode("Cone driver failed");
630 catch (Standard_Failure) {
631 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
632 SetErrorCode(aFail->GetMessageString());
636 //Make a Python command
637 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
638 << theR1 << ", " << theR2 << ", " << theH << ")";
645 //=============================================================================
647 * MakeConePntVecR1R2H
649 //=============================================================================
650 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
651 Handle(GEOM_Object) theVec,
652 double theR1, double theR2,
657 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
659 //Add a new Cone object
660 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
662 //Add a new Cone function for creation a cone relatively to point and vector
663 Handle(GEOM_Function) aFunction =
664 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
665 if (aFunction.IsNull()) return NULL;
667 //Check if the function is set correctly
668 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
670 GEOMImpl_ICone aCI (aFunction);
672 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
673 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
675 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
677 aCI.SetPoint(aRefPnt);
678 aCI.SetVector(aRefVec);
683 //Compute the Cone value
685 #if OCC_VERSION_LARGE > 0x06010000
688 if (!GetSolver()->ComputeFunction(aFunction)) {
689 SetErrorCode("Cone driver failed");
693 catch (Standard_Failure) {
694 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
695 SetErrorCode(aFail->GetMessageString());
699 //Make a Python command
700 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
701 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
708 //=============================================================================
712 //=============================================================================
713 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
717 //Add a new Sphere object
718 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
720 //Add a new Sphere function with R parameter
721 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
722 if (aFunction.IsNull()) return NULL;
724 //Check if the function is set correctly
725 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
727 GEOMImpl_ISphere aCI (aFunction);
731 //Compute the Sphere value
733 #if OCC_VERSION_LARGE > 0x06010000
736 if (!GetSolver()->ComputeFunction(aFunction)) {
737 SetErrorCode("Sphere driver failed");
741 catch (Standard_Failure) {
742 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
743 SetErrorCode(aFail->GetMessageString());
747 //Make a Python command
748 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
755 //=============================================================================
759 //=============================================================================
760 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
765 if (thePnt.IsNull()) return NULL;
767 //Add a new Point object
768 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
770 //Add a new Sphere function for creation a sphere relatively to point
771 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
772 if (aFunction.IsNull()) return NULL;
774 //Check if the function is set correctly
775 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
777 GEOMImpl_ISphere aCI (aFunction);
779 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
781 if (aRefPnt.IsNull()) return NULL;
783 aCI.SetPoint(aRefPnt);
786 //Compute the Sphere value
788 #if OCC_VERSION_LARGE > 0x06010000
791 if (!GetSolver()->ComputeFunction(aFunction)) {
792 SetErrorCode("Sphere driver failed");
796 catch (Standard_Failure) {
797 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
798 SetErrorCode(aFail->GetMessageString());
802 //Make a Python command
803 GEOM::TPythonDump(aFunction) << aSphere
804 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
811 //=============================================================================
815 //=============================================================================
816 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
817 (double theRMajor, double theRMinor)
821 //Add a new Torus object
822 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
824 //Add a new Torus function
825 Handle(GEOM_Function) aFunction =
826 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
827 if (aFunction.IsNull()) return NULL;
829 //Check if the function is set correctly
830 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
832 GEOMImpl_ITorus aCI (aFunction);
834 aCI.SetRMajor(theRMajor);
835 aCI.SetRMinor(theRMinor);
837 //Compute the Torus value
839 #if OCC_VERSION_LARGE > 0x06010000
842 if (!GetSolver()->ComputeFunction(aFunction)) {
843 SetErrorCode("Torus driver failed");
847 catch (Standard_Failure) {
848 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
849 SetErrorCode(aFail->GetMessageString());
853 //Make a Python command
854 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
855 << theRMajor << ", " << theRMinor << ")";
861 //=============================================================================
865 //=============================================================================
866 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
867 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
868 double theRMajor, double theRMinor)
872 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
874 //Add a new Torus object
875 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
877 //Add a new Torus function
878 Handle(GEOM_Function) aFunction =
879 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
880 if (aFunction.IsNull()) return NULL;
882 //Check if the function is set correctly
883 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
885 GEOMImpl_ITorus aCI (aFunction);
887 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
888 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
890 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
892 aCI.SetCenter(aRefPnt);
893 aCI.SetVector(aRefVec);
894 aCI.SetRMajor(theRMajor);
895 aCI.SetRMinor(theRMinor);
897 //Compute the Torus value
899 #if OCC_VERSION_LARGE > 0x06010000
902 if (!GetSolver()->ComputeFunction(aFunction)) {
903 SetErrorCode("Torus driver failed");
907 catch (Standard_Failure) {
908 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
909 SetErrorCode(aFail->GetMessageString());
913 //Make a Python command
914 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
915 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
922 //=============================================================================
926 //=============================================================================
927 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
928 Handle(GEOM_Object) theVec,
929 double theH, double theScaleFactor)
933 if (theBase.IsNull() || theVec.IsNull()) return NULL;
935 //Add a new Prism object
936 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
938 //Add a new Prism function for creation a Prism relatively to vector
939 Handle(GEOM_Function) aFunction =
940 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
941 if (aFunction.IsNull()) return NULL;
943 //Check if the function is set correctly
944 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
946 GEOMImpl_IPrism aCI (aFunction);
948 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
949 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
951 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
953 aCI.SetBase(aRefBase);
954 aCI.SetVector(aRefVec);
956 aCI.SetScale(theScaleFactor);
958 //Compute the Prism value
960 #if OCC_VERSION_LARGE > 0x06010000
963 if (!GetSolver()->ComputeFunction(aFunction)) {
964 //SetErrorCode("Prism driver failed");
965 SetErrorCode("Extrusion can not be created, check input data");
969 catch (Standard_Failure) {
970 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
971 SetErrorCode(aFail->GetMessageString());
975 //Make a Python command
976 GEOM::TPythonDump pd (aFunction);
977 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
978 if (theScaleFactor > Precision::Confusion())
979 pd << ", " << theScaleFactor << ")";
987 //=============================================================================
991 //=============================================================================
992 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
993 Handle(GEOM_Object) theVec,
998 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1000 //Add a new Prism object
1001 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1003 //Add a new Prism function for creation a Prism relatively to vector
1004 Handle(GEOM_Function) aFunction =
1005 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1006 if (aFunction.IsNull()) return NULL;
1008 //Check if the function is set correctly
1009 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1011 GEOMImpl_IPrism aCI (aFunction);
1013 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1014 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1016 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1018 aCI.SetBase(aRefBase);
1019 aCI.SetVector(aRefVec);
1022 //Compute the Prism value
1024 #if OCC_VERSION_LARGE > 0x06010000
1027 if (!GetSolver()->ComputeFunction(aFunction)) {
1028 //SetErrorCode("Prism driver failed");
1029 SetErrorCode("Extrusion can not be created, check input data");
1033 catch (Standard_Failure) {
1034 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1035 SetErrorCode(aFail->GetMessageString());
1039 //Make a Python command
1040 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1041 << theBase << ", " << theVec << ", " << theH << ")";
1047 //=============================================================================
1051 //=============================================================================
1052 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1053 (Handle(GEOM_Object) theBase,
1054 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1055 double theScaleFactor)
1059 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1061 //Add a new Prism object
1062 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1064 //Add a new Prism function for creation a Prism relatively to two points
1065 Handle(GEOM_Function) aFunction =
1066 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1067 if (aFunction.IsNull()) return NULL;
1069 //Check if the function is set correctly
1070 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1072 GEOMImpl_IPrism aCI (aFunction);
1074 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1075 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1076 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1078 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1080 aCI.SetBase(aRefBase);
1081 aCI.SetFirstPoint(aRefPnt1);
1082 aCI.SetLastPoint(aRefPnt2);
1083 aCI.SetScale(theScaleFactor);
1085 //Compute the Prism value
1087 #if OCC_VERSION_LARGE > 0x06010000
1090 if (!GetSolver()->ComputeFunction(aFunction)) {
1091 //SetErrorCode("Prism driver failed");
1092 SetErrorCode("Extrusion can not be created, check input data");
1096 catch (Standard_Failure) {
1097 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1098 SetErrorCode(aFail->GetMessageString());
1102 //Make a Python command
1103 GEOM::TPythonDump pd (aFunction);
1104 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1105 if (theScaleFactor > Precision::Confusion())
1106 pd << ", " << theScaleFactor << ")";
1114 //=============================================================================
1116 * MakePrismTwoPnt2Ways
1118 //=============================================================================
1119 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1120 (Handle(GEOM_Object) theBase,
1121 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1125 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1127 //Add a new Prism object
1128 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1130 //Add a new Prism function for creation a Prism relatively to two points
1131 Handle(GEOM_Function) aFunction =
1132 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1133 if (aFunction.IsNull()) return NULL;
1135 //Check if the function is set correctly
1136 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1138 GEOMImpl_IPrism aCI (aFunction);
1140 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1141 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1142 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1144 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1146 aCI.SetBase(aRefBase);
1147 aCI.SetFirstPoint(aRefPnt1);
1148 aCI.SetLastPoint(aRefPnt2);
1150 //Compute the Prism value
1152 #if OCC_VERSION_LARGE > 0x06010000
1155 if (!GetSolver()->ComputeFunction(aFunction)) {
1156 //SetErrorCode("Prism driver failed");
1157 SetErrorCode("Extrusion can not be created, check input data");
1161 catch (Standard_Failure) {
1162 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1163 SetErrorCode(aFail->GetMessageString());
1167 //Make a Python command
1168 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1169 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1175 //=============================================================================
1179 //=============================================================================
1180 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1181 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1182 double theScaleFactor)
1186 if (theBase.IsNull()) return NULL;
1188 //Add a new Prism object
1189 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1191 //Add a new Prism function for creation a Prism by DXDYDZ
1192 Handle(GEOM_Function) aFunction =
1193 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1194 if (aFunction.IsNull()) return NULL;
1196 //Check if the function is set correctly
1197 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1199 GEOMImpl_IPrism aCI (aFunction);
1201 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1203 if (aRefBase.IsNull()) return NULL;
1205 aCI.SetBase(aRefBase);
1209 aCI.SetScale(theScaleFactor);
1211 //Compute the Prism value
1213 #if OCC_VERSION_LARGE > 0x06010000
1216 if (!GetSolver()->ComputeFunction(aFunction)) {
1217 SetErrorCode("Extrusion can not be created, check input data");
1221 catch (Standard_Failure) {
1222 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1223 SetErrorCode(aFail->GetMessageString());
1227 //Make a Python command
1228 GEOM::TPythonDump pd (aFunction);
1229 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1230 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1231 if (theScaleFactor > Precision::Confusion())
1232 pd << ", " << theScaleFactor << ")";
1240 //=============================================================================
1242 * MakePrismDXDYDZ_2WAYS
1244 //=============================================================================
1245 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1246 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1250 if (theBase.IsNull()) return NULL;
1252 //Add a new Prism object
1253 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1255 //Add a new Prism function for creation a Prism by DXDYDZ
1256 Handle(GEOM_Function) aFunction =
1257 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1258 if (aFunction.IsNull()) return NULL;
1260 //Check if the function is set correctly
1261 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1263 GEOMImpl_IPrism aCI (aFunction);
1265 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1267 if (aRefBase.IsNull()) return NULL;
1269 aCI.SetBase(aRefBase);
1274 //Compute the Prism value
1276 #if OCC_VERSION_LARGE > 0x06010000
1279 if (!GetSolver()->ComputeFunction(aFunction)) {
1280 SetErrorCode("Extrusion can not be created, check input data");
1284 catch (Standard_Failure) {
1285 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1286 SetErrorCode(aFail->GetMessageString());
1290 //Make a Python command
1291 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1292 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1298 //=============================================================================
1302 //=============================================================================
1303 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1304 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1308 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1310 Handle(GEOM_Object) aPrism = NULL;
1314 //Add a new Extruded Boss object
1315 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1319 //Add a new Extruded Cut object
1320 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1323 //Add a new Prism function for the creation of a Draft Prism feature
1324 Handle(GEOM_Function) aFunction =
1325 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1326 if (aFunction.IsNull()) return NULL;
1328 //Check if the function is set correctly
1329 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1331 GEOMImpl_IPrism aCI (aFunction);
1333 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1334 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1336 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1339 aCI.SetBase(aRefBase);
1340 aCI.SetInitShape(aRefInit);
1341 aCI.SetH(theHeight);
1342 aCI.SetDraftAngle(theAngle);
1348 //Compute the Draft Prism Feature value
1350 #if OCC_VERSION_LARGE > 0x06010000
1353 if (!GetSolver()->ComputeFunction(aFunction)) {
1354 SetErrorCode("Extrusion can not be created, check input data");
1358 catch (Standard_Failure) {
1359 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1360 SetErrorCode(aFail->GetMessageString());
1364 //Make a Python command
1367 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1368 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1372 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1373 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1380 //=============================================================================
1384 //=============================================================================
1385 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1386 Handle(GEOM_Object) thePath)
1390 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1392 //Add a new Pipe object
1393 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1395 //Add a new Pipe function
1396 Handle(GEOM_Function) aFunction =
1397 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1398 if (aFunction.IsNull()) return NULL;
1400 //Check if the function is set correctly
1401 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1403 GEOMImpl_IPipe aCI (aFunction);
1405 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1406 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1408 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1410 aCI.SetBase(aRefBase);
1411 aCI.SetPath(aRefPath);
1413 //Compute the Pipe value
1415 #if OCC_VERSION_LARGE > 0x06010000
1418 if (!GetSolver()->ComputeFunction(aFunction)) {
1419 SetErrorCode("Pipe driver failed");
1423 catch (Standard_Failure) {
1424 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1425 SetErrorCode(aFail->GetMessageString());
1429 //Make a Python command
1430 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1431 << theBase << ", " << thePath << ")";
1438 //=============================================================================
1440 * MakeRevolutionAxisAngle
1442 //=============================================================================
1443 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1444 Handle(GEOM_Object) theAxis,
1449 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1451 //Add a new Revolution object
1452 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1454 //Add a new Revolution function for creation a revolution relatively to axis
1455 Handle(GEOM_Function) aFunction =
1456 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1457 if (aFunction.IsNull()) return NULL;
1459 //Check if the function is set correctly
1460 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1462 GEOMImpl_IRevolution aCI (aFunction);
1464 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1465 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1467 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1469 aCI.SetBase(aRefBase);
1470 aCI.SetAxis(aRefAxis);
1471 aCI.SetAngle(theAngle);
1473 //Compute the Revolution value
1475 #if OCC_VERSION_LARGE > 0x06010000
1478 if (!GetSolver()->ComputeFunction(aFunction)) {
1479 SetErrorCode("Revolution driver failed");
1483 catch (Standard_Failure) {
1484 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1485 SetErrorCode(aFail->GetMessageString());
1489 //Make a Python command
1490 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1491 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1497 //=============================================================================
1499 * MakeRevolutionAxisAngle2Ways
1501 //=============================================================================
1502 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1503 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1507 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1509 //Add a new Revolution object
1510 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1512 //Add a new Revolution function for creation a revolution relatively to axis
1513 Handle(GEOM_Function) aFunction =
1514 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1515 if (aFunction.IsNull()) return NULL;
1517 //Check if the function is set correctly
1518 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1520 GEOMImpl_IRevolution aCI (aFunction);
1522 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1523 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1525 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1527 aCI.SetBase(aRefBase);
1528 aCI.SetAxis(aRefAxis);
1529 aCI.SetAngle(theAngle);
1531 //Compute the Revolution value
1533 #if OCC_VERSION_LARGE > 0x06010000
1536 if (!GetSolver()->ComputeFunction(aFunction)) {
1537 SetErrorCode("Revolution driver failed");
1541 catch (Standard_Failure) {
1542 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1543 SetErrorCode(aFail->GetMessageString());
1547 //Make a Python command
1548 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1549 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1555 //=============================================================================
1559 //=============================================================================
1560 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1561 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1562 double theTol2D, double theTol3D, int theNbIter,
1563 int theMethod, bool isApprox)
1567 if (theShape.IsNull()) return NULL;
1569 //Add a new Filling object
1570 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1572 //Add a new Filling function for creation a filling from a compound
1573 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1574 if (aFunction.IsNull()) return NULL;
1576 //Check if the function is set correctly
1577 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1579 GEOMImpl_IFilling aFI (aFunction);
1581 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1583 if (aRefShape.IsNull()) return NULL;
1585 aFI.SetShape(aRefShape);
1586 aFI.SetMinDeg(theMinDeg);
1587 aFI.SetMaxDeg(theMaxDeg);
1588 aFI.SetTol2D(theTol2D);
1589 aFI.SetTol3D(theTol3D);
1590 aFI.SetNbIter(theNbIter);
1591 aFI.SetApprox(isApprox);
1592 aFI.SetMethod(theMethod);
1594 //Compute the Solid value
1596 #if OCC_VERSION_LARGE > 0x06010000
1599 if (!GetSolver()->ComputeFunction(aFunction)) {
1600 SetErrorCode("Filling driver failed");
1604 catch (Standard_Failure) {
1605 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1606 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1607 SetErrorCode("B-Spline surface construction failed");
1609 SetErrorCode(aFail->GetMessageString());
1613 //Make a Python command
1614 GEOM::TPythonDump pd (aFunction);
1615 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1616 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1617 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1618 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1619 pd << ", theTol2D=" << theTol2D ;
1620 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1621 pd << ", theTol3D=" << theTol3D ;
1622 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1623 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1624 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1625 if(isApprox) pd << ", isApprox=" << isApprox ;
1632 //=============================================================================
1636 //=============================================================================
1637 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1638 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1643 Handle(GEOM_Object) anObj;
1645 if(theSeqSections.IsNull())
1648 Standard_Integer nbObj = theSeqSections->Length();
1652 //Add a new ThruSections object
1653 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1656 //Add a new ThruSections function
1658 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1659 Handle(GEOM_Function) aFunction =
1660 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1661 if (aFunction.IsNull()) return anObj;
1663 //Check if the function is set correctly
1664 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1666 GEOMImpl_IThruSections aCI (aFunction);
1668 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1670 Standard_Integer i =1;
1671 for( ; i <= nbObj; i++) {
1673 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1677 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1678 if(!aSectObj.IsNull())
1680 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1681 if(!aRefSect.IsNull())
1682 aSeqSections->Append(aRefSect);
1686 if(!aSeqSections->Length())
1689 aCI.SetSections(aSeqSections);
1690 aCI.SetSolidMode(theModeSolid);
1691 aCI.SetPrecision(thePreci);
1693 //Compute the ThruSections value
1695 #if OCC_VERSION_LARGE > 0x06010000
1698 if (!GetSolver()->ComputeFunction(aFunction)) {
1699 SetErrorCode("ThruSections driver failed");
1703 catch (Standard_Failure) {
1704 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1705 SetErrorCode(aFail->GetMessageString());
1709 //Make a Python command
1710 GEOM::TPythonDump pyDump(aFunction);
1711 pyDump << aThruSect << " = geompy.MakeThruSections([";
1713 for(i =1 ; i <= nbObj; i++) {
1715 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1719 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1720 if(!aSectObj.IsNull()) {
1727 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1734 //=============================================================================
1736 * MakePipeWithDifferentSections
1738 //=============================================================================
1739 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1740 const Handle(TColStd_HSequenceOfTransient)& theBases,
1741 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1742 const Handle(GEOM_Object)& thePath,
1743 bool theWithContact,
1744 bool theWithCorrections)
1746 Handle(GEOM_Object) anObj;
1748 if(theBases.IsNull())
1751 Standard_Integer nbBases = theBases->Length();
1756 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1757 //Add a new Pipe object
1758 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1760 //Add a new Pipe function
1762 Handle(GEOM_Function) aFunction =
1763 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1764 if (aFunction.IsNull()) return anObj;
1766 //Check if the function is set correctly
1767 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1769 GEOMImpl_IPipeDiffSect aCI (aFunction);
1771 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1772 if(aRefPath.IsNull())
1775 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1776 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1778 Standard_Integer i =1;
1779 for( ; i <= nbBases; i++) {
1781 Handle(Standard_Transient) anItem = theBases->Value(i);
1785 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1788 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1789 if(aRefBase.IsNull())
1793 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1794 if(anItemLoc.IsNull())
1797 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1800 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1801 if(aRefLoc.IsNull())
1803 aSeqLocs->Append(aRefLoc);
1805 aSeqBases->Append(aRefBase);
1808 if(!aSeqBases->Length())
1811 aCI.SetBases(aSeqBases);
1812 aCI.SetLocations(aSeqLocs);
1813 aCI.SetPath(aRefPath);
1814 aCI.SetWithContactMode(theWithContact);
1815 aCI.SetWithCorrectionMode(theWithCorrections);
1817 //Compute the Pipe value
1819 #if OCC_VERSION_LARGE > 0x06010000
1822 if (!GetSolver()->ComputeFunction(aFunction)) {
1823 SetErrorCode("Pipe with defferent section driver failed");
1827 catch (Standard_Failure) {
1828 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1829 SetErrorCode(aFail->GetMessageString());
1833 //Make a Python command
1834 GEOM::TPythonDump pyDump(aFunction);
1835 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1837 for(i =1 ; i <= nbBases; i++) {
1839 Handle(Standard_Transient) anItem = theBases->Value(i);
1843 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1844 if(!anObj.IsNull()) {
1853 for(i =1 ; i <= nbLocs; i++) {
1855 Handle(Standard_Transient) anItem = theLocations->Value(i);
1859 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1860 if(!anObj.IsNull()) {
1867 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1874 //=============================================================================
1876 * MakePipeWithShellSections
1878 //=============================================================================
1879 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1880 const Handle(TColStd_HSequenceOfTransient)& theBases,
1881 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1882 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1883 const Handle(GEOM_Object)& thePath,
1884 bool theWithContact,
1885 bool theWithCorrections)
1887 Handle(GEOM_Object) anObj;
1889 if(theBases.IsNull())
1892 Standard_Integer nbBases = theBases->Length();
1897 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1899 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1901 //Add a new Pipe object
1902 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1904 //Add a new Pipe function
1906 Handle(GEOM_Function) aFunction =
1907 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1908 if (aFunction.IsNull()) return anObj;
1910 //Check if the function is set correctly
1911 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1913 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1914 GEOMImpl_IPipeShellSect aCI (aFunction);
1916 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1917 if(aRefPath.IsNull())
1920 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1921 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1922 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1924 Standard_Integer i =1;
1925 for( ; i <= nbBases; i++) {
1927 Handle(Standard_Transient) anItem = theBases->Value(i);
1930 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1933 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1934 if(aRefBase.IsNull())
1937 if( nbSubBases >= nbBases ) {
1938 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1939 if(aSubItem.IsNull())
1941 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1942 if(aSubBase.IsNull())
1944 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1945 if(aRefSubBase.IsNull())
1947 aSeqSubBases->Append(aRefSubBase);
1951 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1952 if(anItemLoc.IsNull())
1954 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1957 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1958 if(aRefLoc.IsNull())
1960 aSeqLocs->Append(aRefLoc);
1963 aSeqBases->Append(aRefBase);
1966 if(!aSeqBases->Length())
1969 aCI.SetBases(aSeqBases);
1970 aCI.SetSubBases(aSeqSubBases);
1971 aCI.SetLocations(aSeqLocs);
1972 aCI.SetPath(aRefPath);
1973 aCI.SetWithContactMode(theWithContact);
1974 aCI.SetWithCorrectionMode(theWithCorrections);
1976 //Compute the Pipe value
1978 #if OCC_VERSION_LARGE > 0x06010000
1981 if (!GetSolver()->ComputeFunction(aFunction)) {
1982 SetErrorCode("Pipe with shell sections driver failed");
1986 catch (Standard_Failure) {
1987 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1988 SetErrorCode(aFail->GetMessageString());
1992 //Make a Python command
1993 GEOM::TPythonDump pyDump(aFunction);
1994 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1996 for(i =1 ; i <= nbBases; i++) {
1998 Handle(Standard_Transient) anItem = theBases->Value(i);
2002 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2003 if(!anObj.IsNull()) {
2012 for(i =1 ; i <= nbSubBases; i++) {
2014 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2018 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2019 if(!anObj.IsNull()) {
2028 for(i =1 ; i <= nbLocs; i++) {
2030 Handle(Standard_Transient) anItem = theLocations->Value(i);
2034 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2035 if(!anObj.IsNull()) {
2042 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2050 //=============================================================================
2052 * MakePipeShellsWithoutPath
2054 //=============================================================================
2055 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2056 const Handle(TColStd_HSequenceOfTransient)& theBases,
2057 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2059 Handle(GEOM_Object) anObj;
2061 if(theBases.IsNull())
2064 Standard_Integer nbBases = theBases->Length();
2069 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2071 //Add a new Pipe object
2072 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2074 //Add a new Pipe function
2076 Handle(GEOM_Function) aFunction =
2077 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2078 if (aFunction.IsNull()) return anObj;
2080 //Check if the function is set correctly
2081 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2083 GEOMImpl_IPipeShellSect aCI (aFunction);
2085 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2086 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2088 Standard_Integer i =1;
2089 for( ; i <= nbBases; i++) {
2091 Handle(Standard_Transient) anItem = theBases->Value(i);
2094 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2097 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2098 if(aRefBase.IsNull())
2102 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2103 if(anItemLoc.IsNull())
2105 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2108 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2109 if(aRefLoc.IsNull())
2111 aSeqLocs->Append(aRefLoc);
2114 aSeqBases->Append(aRefBase);
2117 if(!aSeqBases->Length())
2120 aCI.SetBases(aSeqBases);
2121 aCI.SetLocations(aSeqLocs);
2123 //Compute the Pipe value
2125 #if OCC_VERSION_LARGE > 0x06010000
2128 if (!GetSolver()->ComputeFunction(aFunction)) {
2129 SetErrorCode("Pipe with shell sections without path driver failed");
2133 catch (Standard_Failure) {
2134 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2135 SetErrorCode(aFail->GetMessageString());
2139 //Make a Python command
2140 GEOM::TPythonDump pyDump(aFunction);
2141 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2143 for(i =1 ; i <= nbBases; i++) {
2145 Handle(Standard_Transient) anItem = theBases->Value(i);
2149 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2150 if(!anObj.IsNull()) {
2159 for(i =1 ; i <= nbLocs; i++) {
2161 Handle(Standard_Transient) anItem = theLocations->Value(i);
2165 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2166 if(!anObj.IsNull()) {
2180 //=============================================================================
2182 * MakePipeBiNormalAlongVector
2184 //=============================================================================
2185 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2186 Handle(GEOM_Object) thePath,
2187 Handle(GEOM_Object) theVec)
2191 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2193 //Add a new Pipe object
2194 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2196 //Add a new Pipe function
2197 Handle(GEOM_Function) aFunction =
2198 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2199 if (aFunction.IsNull()) return NULL;
2201 //Check if the function is set correctly
2202 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2204 GEOMImpl_IPipeBiNormal aCI (aFunction);
2206 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2207 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2208 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2210 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2212 aCI.SetBase(aRefBase);
2213 aCI.SetPath(aRefPath);
2214 aCI.SetVector(aRefVec);
2216 //Compute the Pipe value
2218 #if OCC_VERSION_LARGE > 0x06010000
2221 if (!GetSolver()->ComputeFunction(aFunction)) {
2222 SetErrorCode("Pipe driver failed");
2226 catch (Standard_Failure) {
2227 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2228 SetErrorCode(aFail->GetMessageString());
2232 //Make a Python command
2233 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2234 << theBase << ", " << thePath << ", " << theVec << ")";
2240 //=============================================================================
2244 //=============================================================================
2245 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2246 Handle(GEOM_Object) theBase1,
2247 Handle(GEOM_Object) theBase2)
2251 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2253 // Add a new Path object
2254 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2256 // Add a new Path function
2257 Handle(GEOM_Function) aFunction =
2258 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2259 if (aFunction.IsNull()) return NULL;
2261 // Check if the function is set correctly
2262 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2264 GEOMImpl_IPipePath aCI (aFunction);
2266 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2267 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2268 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2270 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2272 aCI.SetShape(aRefShape);
2273 aCI.SetBase1(aRefBase1);
2274 aCI.SetBase2(aRefBase2);
2276 // Compute the Path value
2278 #if OCC_VERSION_LARGE > 0x06010000
2281 if (!GetSolver()->ComputeFunction(aFunction)) {
2282 SetErrorCode("PipePath driver failed");
2286 catch (Standard_Failure) {
2287 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2288 SetErrorCode("RestorePath: inappropriate arguments given");
2292 // Make a Python command
2293 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2294 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2300 //=============================================================================
2304 //=============================================================================
2305 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2306 (Handle(GEOM_Object) theShape,
2307 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2308 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2312 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2314 Standard_Integer nbBases1 = theBase1->Length();
2315 Standard_Integer nbBases2 = theBase2->Length();
2317 if (!nbBases1 || !nbBases2)
2320 // Add a new Path object
2321 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2323 // Add a new Path function
2324 Handle(GEOM_Function) aFunction =
2325 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2326 if (aFunction.IsNull()) return NULL;
2328 // Check if the function is set correctly
2329 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2331 GEOMImpl_IPipePath aCI (aFunction);
2333 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2334 if (aRefShape.IsNull()) return NULL;
2336 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2337 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2340 for (i = 1; i <= nbBases1; i++) {
2341 Handle(Standard_Transient) anItem = theBase1->Value(i);
2342 if (!anItem.IsNull()) {
2343 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2344 if (!aBase.IsNull()) {
2345 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2346 if (!aRefBase.IsNull())
2347 aSeqBases1->Append(aRefBase);
2351 for (i = 1; i <= nbBases2; i++) {
2352 Handle(Standard_Transient) anItem = theBase2->Value(i);
2353 if (!anItem.IsNull()) {
2354 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2355 if (!aBase.IsNull()) {
2356 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2357 if (!aRefBase.IsNull())
2358 aSeqBases2->Append(aRefBase);
2362 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2364 aCI.SetShape(aRefShape);
2365 aCI.SetBaseSeq1(aSeqBases1);
2366 aCI.SetBaseSeq2(aSeqBases2);
2368 // Compute the Path value
2370 #if OCC_VERSION_LARGE > 0x06010000
2373 if (!GetSolver()->ComputeFunction(aFunction)) {
2374 SetErrorCode("PipePath driver failed");
2378 catch (Standard_Failure) {
2379 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2380 SetErrorCode("RestorePath: inappropriate arguments given");
2384 // Make a Python command
2385 GEOM::TPythonDump pyDump (aFunction);
2386 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2387 for (i = 1; i <= nbBases1; i++) {
2388 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2389 if (!anObj.IsNull()) {
2396 for (i = 1; i <= nbBases2; i++) {
2397 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2398 if (!anObj.IsNull()) {