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>
56 #include <GEOMImpl_OffsetDriver.hxx>
58 #include <GEOMImpl_IBox.hxx>
59 #include <GEOMImpl_IFace.hxx>
60 #include <GEOMImpl_IDisk.hxx>
61 #include <GEOMImpl_ICylinder.hxx>
62 #include <GEOMImpl_ICone.hxx>
63 #include <GEOMImpl_ISphere.hxx>
64 #include <GEOMImpl_ITorus.hxx>
65 #include <GEOMImpl_IPrism.hxx>
66 #include <GEOMImpl_IPipe.hxx>
67 #include <GEOMImpl_IRevolution.hxx>
68 #include <GEOMImpl_IFilling.hxx>
69 #include <GEOMImpl_IThruSections.hxx>
70 #include <GEOMImpl_IPipeDiffSect.hxx>
71 #include <GEOMImpl_IPipeShellSect.hxx>
72 #include <GEOMImpl_IPipeBiNormal.hxx>
73 #include <GEOMImpl_IOffset.hxx>
74 #include <GEOMImpl_IPipePath.hxx>
76 #include <Precision.hxx>
78 #include <Standard_Failure.hxx>
79 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
81 //=============================================================================
85 //=============================================================================
86 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
87 : GEOM_IOperations(theEngine, theDocID)
89 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
92 //=============================================================================
96 //=============================================================================
97 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
99 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
103 //=============================================================================
107 //=============================================================================
108 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
112 //Add a new Box object
113 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
115 //Add a new Box function with DX_DY_DZ parameters
116 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
117 if (aFunction.IsNull()) return NULL;
119 //Check if the function is set correctly
120 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
122 GEOMImpl_IBox aBI (aFunction);
128 //Compute the box value
130 #if OCC_VERSION_LARGE > 0x06010000
133 if (!GetSolver()->ComputeFunction(aFunction)) {
134 SetErrorCode("Box driver failed");
138 catch (Standard_Failure) {
139 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
140 SetErrorCode(aFail->GetMessageString());
144 //Make a Python command
145 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
146 << theDX << ", " << theDY << ", " << theDZ << ")";
153 //=============================================================================
157 //=============================================================================
158 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
159 Handle(GEOM_Object) thePnt2)
163 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
165 //Add a new Box object
166 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
168 //Add a new Box function for creation a box relatively to two points
169 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
170 if (aFunction.IsNull()) return NULL;
172 //Check if the function is set correctly
173 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
175 GEOMImpl_IBox aBI (aFunction);
177 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
178 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
180 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
182 aBI.SetRef1(aRefFunction1);
183 aBI.SetRef2(aRefFunction2);
185 //Compute the Box value
187 #if OCC_VERSION_LARGE > 0x06010000
190 if (!GetSolver()->ComputeFunction(aFunction)) {
191 SetErrorCode("Box driver failed");
195 catch (Standard_Failure) {
196 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
197 SetErrorCode(aFail->GetMessageString());
201 //Make a Python command
202 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
203 << thePnt1 << ", " << thePnt2 << ")";
209 //=============================================================================
213 //=============================================================================
214 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
218 if (theH == 0 || theW == 0) return NULL;
220 //Add a new Face object
221 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
223 //Add a new Box function for creation a box relatively to two points
224 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
225 if (aFunction.IsNull()) return NULL;
227 //Check if the function is set correctly
228 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
230 GEOMImpl_IFace aFI (aFunction);
234 aFI.SetOrientation(theOrientation);
238 #if OCC_VERSION_LARGE > 0x06010000
241 if (!GetSolver()->ComputeFunction(aFunction)) {
242 SetErrorCode("Face driver failed");
246 catch (Standard_Failure) {
247 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
248 SetErrorCode(aFail->GetMessageString());
252 //Make a Python command
253 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
254 << theH << ", " << theW << ", " << theOrientation << ")";
260 //=============================================================================
264 //=============================================================================
265 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
266 double theH, double theW)
270 if (theObj.IsNull()) return NULL;
272 //Add a new Face object
273 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
275 //Add a new Box function for creation a box relatively to two points
276 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
277 if (aFunction.IsNull()) return NULL;
279 //Check if the function is set correctly
280 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
282 GEOMImpl_IFace aFI (aFunction);
284 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
286 if (aRefFunction1.IsNull())
289 aFI.SetRef1(aRefFunction1);
295 #if OCC_VERSION_LARGE > 0x06010000
298 if (!GetSolver()->ComputeFunction(aFunction)) {
299 SetErrorCode("Face driver failed");
303 catch (Standard_Failure) {
304 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
305 SetErrorCode(aFail->GetMessageString());
309 //Make a Python command
310 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
311 << theObj << ", " << theH << ", " << theW << ")";
317 //=============================================================================
321 //=============================================================================
322 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
323 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
327 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
329 //Add a new Disk object
330 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
332 //Add a new Disk function for creation a disk relatively to point and vector
333 Handle(GEOM_Function) aFunction =
334 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
335 if (aFunction.IsNull()) return NULL;
337 //Check if the function is set correctly
338 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
340 GEOMImpl_IDisk aCI (aFunction);
342 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
343 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
345 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
347 aCI.SetCenter(aRefPnt);
348 aCI.SetVector(aRefVec);
351 //Compute the Disk value
353 #if OCC_VERSION_LARGE > 0x06010000
356 if (!GetSolver()->ComputeFunction(aFunction)) {
357 SetErrorCode("Disk driver failed");
361 catch (Standard_Failure) {
362 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
363 SetErrorCode(aFail->GetMessageString());
367 //Make a Python command
368 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
369 << thePnt << ", " << theVec << ", " << theR << ")";
375 //=============================================================================
379 //=============================================================================
380 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
381 Handle(GEOM_Object) thePnt2,
382 Handle(GEOM_Object) thePnt3)
386 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
388 //Add a new Disk object
389 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
391 //Add a new Disk function for creation a disk relatively to three points
392 Handle(GEOM_Function) aFunction =
393 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
394 if (aFunction.IsNull()) return NULL;
396 //Check if the function is set correctly
397 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
399 GEOMImpl_IDisk aCI (aFunction);
401 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
402 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
403 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
405 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
407 aCI.SetPoint1(aRefPnt1);
408 aCI.SetPoint2(aRefPnt2);
409 aCI.SetPoint3(aRefPnt3);
411 //Compute the Disk value
413 #if OCC_VERSION_LARGE > 0x06010000
416 if (!GetSolver()->ComputeFunction(aFunction)) {
417 SetErrorCode("Disk driver failed");
421 catch (Standard_Failure) {
422 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
423 SetErrorCode(aFail->GetMessageString());
427 //Make a Python command
428 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
429 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
435 //=============================================================================
439 //=============================================================================
440 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
444 if (theR == 0 ) return NULL;
446 //Add a new Disk object
447 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
449 //Add a new Box function for creation a box relatively to two points
450 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
451 if (aFunction.IsNull()) return NULL;
453 //Check if the function is set correctly
454 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
456 GEOMImpl_IDisk aDI (aFunction);
459 aDI.SetOrientation(theOrientation);
463 #if OCC_VERSION_LARGE > 0x06010000
466 if (!GetSolver()->ComputeFunction(aFunction)) {
467 SetErrorCode("Disk driver failed");
471 catch (Standard_Failure) {
472 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
473 SetErrorCode(aFail->GetMessageString());
477 //Make a Python command
478 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
479 << theR << ", " << theOrientation << ")";
485 //=============================================================================
489 //=============================================================================
490 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
494 //Add a new Cylinder object
495 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
497 //Add a new Cylinder function with R and H parameters
498 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
499 if (aFunction.IsNull()) return NULL;
501 //Check if the function is set correctly
502 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
504 GEOMImpl_ICylinder aCI (aFunction);
509 //Compute the Cylinder value
511 #if OCC_VERSION_LARGE > 0x06010000
514 if (!GetSolver()->ComputeFunction(aFunction)) {
515 SetErrorCode("Cylinder driver failed");
519 catch (Standard_Failure) {
520 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
521 SetErrorCode(aFail->GetMessageString());
525 //Make a Python command
526 GEOM::TPythonDump(aFunction) << aCylinder
527 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
534 //=============================================================================
536 * MakeCylinderPntVecRH
538 //=============================================================================
539 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
540 Handle(GEOM_Object) theVec,
541 double theR, double theH)
545 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
547 //Add a new Cylinder object
548 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
550 //Add a new Cylinder function for creation a cylinder relatively to point and vector
551 Handle(GEOM_Function) aFunction =
552 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
553 if (aFunction.IsNull()) return NULL;
555 //Check if the function is set correctly
556 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
558 GEOMImpl_ICylinder aCI (aFunction);
560 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
561 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
563 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
565 aCI.SetPoint(aRefPnt);
566 aCI.SetVector(aRefVec);
570 //Compute the Cylinder value
572 #if OCC_VERSION_LARGE > 0x06010000
575 if (!GetSolver()->ComputeFunction(aFunction)) {
576 SetErrorCode("Cylinder driver failed");
580 catch (Standard_Failure) {
581 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
582 SetErrorCode(aFail->GetMessageString());
586 //Make a Python command
587 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
588 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
595 //=============================================================================
599 //=============================================================================
600 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
605 //Add a new Cone object
606 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
608 //Add a new Cone function with R and H parameters
609 Handle(GEOM_Function) aFunction =
610 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
611 if (aFunction.IsNull()) return NULL;
613 //Check if the function is set correctly
614 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
616 GEOMImpl_ICone aCI (aFunction);
622 //Compute the Cone value
624 #if OCC_VERSION_LARGE > 0x06010000
627 if (!GetSolver()->ComputeFunction(aFunction)) {
628 SetErrorCode("Cone driver failed");
632 catch (Standard_Failure) {
633 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
634 SetErrorCode(aFail->GetMessageString());
638 //Make a Python command
639 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
640 << theR1 << ", " << theR2 << ", " << theH << ")";
647 //=============================================================================
649 * MakeConePntVecR1R2H
651 //=============================================================================
652 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
653 Handle(GEOM_Object) theVec,
654 double theR1, double theR2,
659 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
661 //Add a new Cone object
662 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
664 //Add a new Cone function for creation a cone relatively to point and vector
665 Handle(GEOM_Function) aFunction =
666 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
667 if (aFunction.IsNull()) return NULL;
669 //Check if the function is set correctly
670 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
672 GEOMImpl_ICone aCI (aFunction);
674 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
675 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
677 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
679 aCI.SetPoint(aRefPnt);
680 aCI.SetVector(aRefVec);
685 //Compute the Cone value
687 #if OCC_VERSION_LARGE > 0x06010000
690 if (!GetSolver()->ComputeFunction(aFunction)) {
691 SetErrorCode("Cone driver failed");
695 catch (Standard_Failure) {
696 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
697 SetErrorCode(aFail->GetMessageString());
701 //Make a Python command
702 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
703 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
710 //=============================================================================
714 //=============================================================================
715 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
719 //Add a new Sphere object
720 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
722 //Add a new Sphere function with R parameter
723 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
724 if (aFunction.IsNull()) return NULL;
726 //Check if the function is set correctly
727 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
729 GEOMImpl_ISphere aCI (aFunction);
733 //Compute the Sphere value
735 #if OCC_VERSION_LARGE > 0x06010000
738 if (!GetSolver()->ComputeFunction(aFunction)) {
739 SetErrorCode("Sphere driver failed");
743 catch (Standard_Failure) {
744 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
745 SetErrorCode(aFail->GetMessageString());
749 //Make a Python command
750 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
757 //=============================================================================
761 //=============================================================================
762 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
767 if (thePnt.IsNull()) return NULL;
769 //Add a new Point object
770 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
772 //Add a new Sphere function for creation a sphere relatively to point
773 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
774 if (aFunction.IsNull()) return NULL;
776 //Check if the function is set correctly
777 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
779 GEOMImpl_ISphere aCI (aFunction);
781 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
783 if (aRefPnt.IsNull()) return NULL;
785 aCI.SetPoint(aRefPnt);
788 //Compute the Sphere value
790 #if OCC_VERSION_LARGE > 0x06010000
793 if (!GetSolver()->ComputeFunction(aFunction)) {
794 SetErrorCode("Sphere driver failed");
798 catch (Standard_Failure) {
799 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
800 SetErrorCode(aFail->GetMessageString());
804 //Make a Python command
805 GEOM::TPythonDump(aFunction) << aSphere
806 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
813 //=============================================================================
817 //=============================================================================
818 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
819 (double theRMajor, double theRMinor)
823 //Add a new Torus object
824 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
826 //Add a new Torus function
827 Handle(GEOM_Function) aFunction =
828 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
829 if (aFunction.IsNull()) return NULL;
831 //Check if the function is set correctly
832 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
834 GEOMImpl_ITorus aCI (aFunction);
836 aCI.SetRMajor(theRMajor);
837 aCI.SetRMinor(theRMinor);
839 //Compute the Torus value
841 #if OCC_VERSION_LARGE > 0x06010000
844 if (!GetSolver()->ComputeFunction(aFunction)) {
845 SetErrorCode("Torus driver failed");
849 catch (Standard_Failure) {
850 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
851 SetErrorCode(aFail->GetMessageString());
855 //Make a Python command
856 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
857 << theRMajor << ", " << theRMinor << ")";
863 //=============================================================================
867 //=============================================================================
868 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
869 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
870 double theRMajor, double theRMinor)
874 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
876 //Add a new Torus object
877 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
879 //Add a new Torus function
880 Handle(GEOM_Function) aFunction =
881 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
882 if (aFunction.IsNull()) return NULL;
884 //Check if the function is set correctly
885 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
887 GEOMImpl_ITorus aCI (aFunction);
889 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
890 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
892 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
894 aCI.SetCenter(aRefPnt);
895 aCI.SetVector(aRefVec);
896 aCI.SetRMajor(theRMajor);
897 aCI.SetRMinor(theRMinor);
899 //Compute the Torus value
901 #if OCC_VERSION_LARGE > 0x06010000
904 if (!GetSolver()->ComputeFunction(aFunction)) {
905 SetErrorCode("Torus driver failed");
909 catch (Standard_Failure) {
910 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
911 SetErrorCode(aFail->GetMessageString());
915 //Make a Python command
916 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
917 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
924 //=============================================================================
928 //=============================================================================
929 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
930 Handle(GEOM_Object) theVec,
931 double theH, double theScaleFactor)
935 if (theBase.IsNull() || theVec.IsNull()) return NULL;
937 //Add a new Prism object
938 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
940 //Add a new Prism function for creation a Prism relatively to vector
941 Handle(GEOM_Function) aFunction =
942 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
943 if (aFunction.IsNull()) return NULL;
945 //Check if the function is set correctly
946 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
948 GEOMImpl_IPrism aCI (aFunction);
950 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
951 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
953 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
955 aCI.SetBase(aRefBase);
956 aCI.SetVector(aRefVec);
958 aCI.SetScale(theScaleFactor);
960 //Compute the Prism value
962 #if OCC_VERSION_LARGE > 0x06010000
965 if (!GetSolver()->ComputeFunction(aFunction)) {
966 //SetErrorCode("Prism driver failed");
967 SetErrorCode("Extrusion can not be created, check input data");
971 catch (Standard_Failure) {
972 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
973 SetErrorCode(aFail->GetMessageString());
977 //Make a Python command
978 GEOM::TPythonDump pd (aFunction);
979 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
980 if (theScaleFactor > Precision::Confusion())
981 pd << ", " << theScaleFactor << ")";
989 //=============================================================================
993 //=============================================================================
994 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
995 Handle(GEOM_Object) theVec,
1000 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1002 //Add a new Prism object
1003 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1005 //Add a new Prism function for creation a Prism relatively to vector
1006 Handle(GEOM_Function) aFunction =
1007 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1008 if (aFunction.IsNull()) return NULL;
1010 //Check if the function is set correctly
1011 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1013 GEOMImpl_IPrism aCI (aFunction);
1015 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1016 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1018 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1020 aCI.SetBase(aRefBase);
1021 aCI.SetVector(aRefVec);
1024 //Compute the Prism value
1026 #if OCC_VERSION_LARGE > 0x06010000
1029 if (!GetSolver()->ComputeFunction(aFunction)) {
1030 //SetErrorCode("Prism driver failed");
1031 SetErrorCode("Extrusion can not be created, check input data");
1035 catch (Standard_Failure) {
1036 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1037 SetErrorCode(aFail->GetMessageString());
1041 //Make a Python command
1042 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1043 << theBase << ", " << theVec << ", " << theH << ")";
1049 //=============================================================================
1053 //=============================================================================
1054 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1055 (Handle(GEOM_Object) theBase,
1056 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1057 double theScaleFactor)
1061 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1063 //Add a new Prism object
1064 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1066 //Add a new Prism function for creation a Prism relatively to two points
1067 Handle(GEOM_Function) aFunction =
1068 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1069 if (aFunction.IsNull()) return NULL;
1071 //Check if the function is set correctly
1072 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1074 GEOMImpl_IPrism aCI (aFunction);
1076 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1077 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1078 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1080 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1082 aCI.SetBase(aRefBase);
1083 aCI.SetFirstPoint(aRefPnt1);
1084 aCI.SetLastPoint(aRefPnt2);
1085 aCI.SetScale(theScaleFactor);
1087 //Compute the Prism value
1089 #if OCC_VERSION_LARGE > 0x06010000
1092 if (!GetSolver()->ComputeFunction(aFunction)) {
1093 //SetErrorCode("Prism driver failed");
1094 SetErrorCode("Extrusion can not be created, check input data");
1098 catch (Standard_Failure) {
1099 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1100 SetErrorCode(aFail->GetMessageString());
1104 //Make a Python command
1105 GEOM::TPythonDump pd (aFunction);
1106 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1107 if (theScaleFactor > Precision::Confusion())
1108 pd << ", " << theScaleFactor << ")";
1116 //=============================================================================
1118 * MakePrismTwoPnt2Ways
1120 //=============================================================================
1121 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1122 (Handle(GEOM_Object) theBase,
1123 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1127 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1129 //Add a new Prism object
1130 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1132 //Add a new Prism function for creation a Prism relatively to two points
1133 Handle(GEOM_Function) aFunction =
1134 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1135 if (aFunction.IsNull()) return NULL;
1137 //Check if the function is set correctly
1138 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1140 GEOMImpl_IPrism aCI (aFunction);
1142 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1143 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1144 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1146 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1148 aCI.SetBase(aRefBase);
1149 aCI.SetFirstPoint(aRefPnt1);
1150 aCI.SetLastPoint(aRefPnt2);
1152 //Compute the Prism value
1154 #if OCC_VERSION_LARGE > 0x06010000
1157 if (!GetSolver()->ComputeFunction(aFunction)) {
1158 //SetErrorCode("Prism driver failed");
1159 SetErrorCode("Extrusion can not be created, check input data");
1163 catch (Standard_Failure) {
1164 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1165 SetErrorCode(aFail->GetMessageString());
1169 //Make a Python command
1170 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1171 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1177 //=============================================================================
1181 //=============================================================================
1182 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1183 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1184 double theScaleFactor)
1188 if (theBase.IsNull()) return NULL;
1190 //Add a new Prism object
1191 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1193 //Add a new Prism function for creation a Prism by DXDYDZ
1194 Handle(GEOM_Function) aFunction =
1195 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1196 if (aFunction.IsNull()) return NULL;
1198 //Check if the function is set correctly
1199 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1201 GEOMImpl_IPrism aCI (aFunction);
1203 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1205 if (aRefBase.IsNull()) return NULL;
1207 aCI.SetBase(aRefBase);
1211 aCI.SetScale(theScaleFactor);
1213 //Compute the Prism value
1215 #if OCC_VERSION_LARGE > 0x06010000
1218 if (!GetSolver()->ComputeFunction(aFunction)) {
1219 SetErrorCode("Extrusion can not be created, check input data");
1223 catch (Standard_Failure) {
1224 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1225 SetErrorCode(aFail->GetMessageString());
1229 //Make a Python command
1230 GEOM::TPythonDump pd (aFunction);
1231 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1232 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1233 if (theScaleFactor > Precision::Confusion())
1234 pd << ", " << theScaleFactor << ")";
1242 //=============================================================================
1244 * MakePrismDXDYDZ_2WAYS
1246 //=============================================================================
1247 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1248 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1252 if (theBase.IsNull()) return NULL;
1254 //Add a new Prism object
1255 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1257 //Add a new Prism function for creation a Prism by DXDYDZ
1258 Handle(GEOM_Function) aFunction =
1259 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1260 if (aFunction.IsNull()) return NULL;
1262 //Check if the function is set correctly
1263 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1265 GEOMImpl_IPrism aCI (aFunction);
1267 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1269 if (aRefBase.IsNull()) return NULL;
1271 aCI.SetBase(aRefBase);
1276 //Compute the Prism value
1278 #if OCC_VERSION_LARGE > 0x06010000
1281 if (!GetSolver()->ComputeFunction(aFunction)) {
1282 SetErrorCode("Extrusion can not be created, check input data");
1286 catch (Standard_Failure) {
1287 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1288 SetErrorCode(aFail->GetMessageString());
1292 //Make a Python command
1293 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1294 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1300 //=============================================================================
1304 //=============================================================================
1305 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1306 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1310 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1312 Handle(GEOM_Object) aPrism = NULL;
1316 //Add a new Extruded Boss object
1317 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1321 //Add a new Extruded Cut object
1322 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1325 //Add a new Prism function for the creation of a Draft Prism feature
1326 Handle(GEOM_Function) aFunction =
1327 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1328 if (aFunction.IsNull()) return NULL;
1330 //Check if the function is set correctly
1331 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1333 GEOMImpl_IPrism aCI (aFunction);
1335 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1336 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1338 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1341 aCI.SetBase(aRefBase);
1342 aCI.SetInitShape(aRefInit);
1343 aCI.SetH(theHeight);
1344 aCI.SetDraftAngle(theAngle);
1350 //Compute the Draft Prism Feature value
1352 #if OCC_VERSION_LARGE > 0x06010000
1355 if (!GetSolver()->ComputeFunction(aFunction)) {
1356 SetErrorCode("Extrusion can not be created, check input data");
1360 catch (Standard_Failure) {
1361 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1362 SetErrorCode(aFail->GetMessageString());
1366 //Make a Python command
1369 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1370 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1374 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1375 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1382 //=============================================================================
1386 //=============================================================================
1387 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1388 Handle(GEOM_Object) thePath)
1392 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1394 //Add a new Pipe object
1395 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1397 //Add a new Pipe function
1398 Handle(GEOM_Function) aFunction =
1399 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1400 if (aFunction.IsNull()) return NULL;
1402 //Check if the function is set correctly
1403 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1405 GEOMImpl_IPipe aCI (aFunction);
1407 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1408 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1410 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1412 aCI.SetBase(aRefBase);
1413 aCI.SetPath(aRefPath);
1415 //Compute the Pipe value
1417 #if OCC_VERSION_LARGE > 0x06010000
1420 if (!GetSolver()->ComputeFunction(aFunction)) {
1421 SetErrorCode("Pipe driver failed");
1425 catch (Standard_Failure) {
1426 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1427 SetErrorCode(aFail->GetMessageString());
1431 //Make a Python command
1432 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1433 << theBase << ", " << thePath << ")";
1440 //=============================================================================
1442 * MakeRevolutionAxisAngle
1444 //=============================================================================
1445 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1446 Handle(GEOM_Object) theAxis,
1451 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1453 //Add a new Revolution object
1454 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1456 //Add a new Revolution function for creation a revolution relatively to axis
1457 Handle(GEOM_Function) aFunction =
1458 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1459 if (aFunction.IsNull()) return NULL;
1461 //Check if the function is set correctly
1462 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1464 GEOMImpl_IRevolution aCI (aFunction);
1466 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1467 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1469 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1471 aCI.SetBase(aRefBase);
1472 aCI.SetAxis(aRefAxis);
1473 aCI.SetAngle(theAngle);
1475 //Compute the Revolution value
1477 #if OCC_VERSION_LARGE > 0x06010000
1480 if (!GetSolver()->ComputeFunction(aFunction)) {
1481 SetErrorCode("Revolution driver failed");
1485 catch (Standard_Failure) {
1486 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1487 SetErrorCode(aFail->GetMessageString());
1491 //Make a Python command
1492 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1493 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1499 //=============================================================================
1501 * MakeRevolutionAxisAngle2Ways
1503 //=============================================================================
1504 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1505 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1509 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1511 //Add a new Revolution object
1512 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1514 //Add a new Revolution function for creation a revolution relatively to axis
1515 Handle(GEOM_Function) aFunction =
1516 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1517 if (aFunction.IsNull()) return NULL;
1519 //Check if the function is set correctly
1520 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1522 GEOMImpl_IRevolution aCI (aFunction);
1524 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1525 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1527 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1529 aCI.SetBase(aRefBase);
1530 aCI.SetAxis(aRefAxis);
1531 aCI.SetAngle(theAngle);
1533 //Compute the Revolution value
1535 #if OCC_VERSION_LARGE > 0x06010000
1538 if (!GetSolver()->ComputeFunction(aFunction)) {
1539 SetErrorCode("Revolution driver failed");
1543 catch (Standard_Failure) {
1544 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1545 SetErrorCode(aFail->GetMessageString());
1549 //Make a Python command
1550 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1551 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1557 //=============================================================================
1561 //=============================================================================
1562 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1563 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1564 double theTol2D, double theTol3D, int theNbIter,
1565 int theMethod, bool isApprox)
1569 if (theShape.IsNull()) return NULL;
1571 //Add a new Filling object
1572 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1574 //Add a new Filling function for creation a filling from a compound
1575 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1576 if (aFunction.IsNull()) return NULL;
1578 //Check if the function is set correctly
1579 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1581 GEOMImpl_IFilling aFI (aFunction);
1583 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1585 if (aRefShape.IsNull()) return NULL;
1587 aFI.SetShape(aRefShape);
1588 aFI.SetMinDeg(theMinDeg);
1589 aFI.SetMaxDeg(theMaxDeg);
1590 aFI.SetTol2D(theTol2D);
1591 aFI.SetTol3D(theTol3D);
1592 aFI.SetNbIter(theNbIter);
1593 aFI.SetApprox(isApprox);
1594 aFI.SetMethod(theMethod);
1596 //Compute the Solid value
1598 #if OCC_VERSION_LARGE > 0x06010000
1601 if (!GetSolver()->ComputeFunction(aFunction)) {
1602 SetErrorCode("Filling driver failed");
1606 catch (Standard_Failure) {
1607 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1608 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1609 SetErrorCode("B-Spline surface construction failed");
1611 SetErrorCode(aFail->GetMessageString());
1615 //Make a Python command
1616 GEOM::TPythonDump pd (aFunction);
1617 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1618 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1619 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1620 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1621 pd << ", theTol2D=" << theTol2D ;
1622 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1623 pd << ", theTol3D=" << theTol3D ;
1624 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1625 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1626 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1627 if(isApprox) pd << ", isApprox=" << isApprox ;
1634 //=============================================================================
1638 //=============================================================================
1639 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1640 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1645 Handle(GEOM_Object) anObj;
1647 if(theSeqSections.IsNull())
1650 Standard_Integer nbObj = theSeqSections->Length();
1654 //Add a new ThruSections object
1655 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1658 //Add a new ThruSections function
1660 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1661 Handle(GEOM_Function) aFunction =
1662 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1663 if (aFunction.IsNull()) return anObj;
1665 //Check if the function is set correctly
1666 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1668 GEOMImpl_IThruSections aCI (aFunction);
1670 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1672 Standard_Integer i =1;
1673 for( ; i <= nbObj; i++) {
1675 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1679 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1680 if(!aSectObj.IsNull())
1682 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1683 if(!aRefSect.IsNull())
1684 aSeqSections->Append(aRefSect);
1688 if(!aSeqSections->Length())
1691 aCI.SetSections(aSeqSections);
1692 aCI.SetSolidMode(theModeSolid);
1693 aCI.SetPrecision(thePreci);
1695 //Compute the ThruSections value
1697 #if OCC_VERSION_LARGE > 0x06010000
1700 if (!GetSolver()->ComputeFunction(aFunction)) {
1701 SetErrorCode("ThruSections driver failed");
1705 catch (Standard_Failure) {
1706 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1707 SetErrorCode(aFail->GetMessageString());
1711 //Make a Python command
1712 GEOM::TPythonDump pyDump(aFunction);
1713 pyDump << aThruSect << " = geompy.MakeThruSections([";
1715 for(i =1 ; i <= nbObj; i++) {
1717 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1721 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1722 if(!aSectObj.IsNull()) {
1729 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1736 //=============================================================================
1738 * MakePipeWithDifferentSections
1740 //=============================================================================
1741 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1742 const Handle(TColStd_HSequenceOfTransient)& theBases,
1743 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1744 const Handle(GEOM_Object)& thePath,
1745 bool theWithContact,
1746 bool theWithCorrections)
1748 Handle(GEOM_Object) anObj;
1750 if(theBases.IsNull())
1753 Standard_Integer nbBases = theBases->Length();
1758 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1759 //Add a new Pipe object
1760 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1762 //Add a new Pipe function
1764 Handle(GEOM_Function) aFunction =
1765 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1766 if (aFunction.IsNull()) return anObj;
1768 //Check if the function is set correctly
1769 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1771 GEOMImpl_IPipeDiffSect aCI (aFunction);
1773 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1774 if(aRefPath.IsNull())
1777 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1778 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1780 Standard_Integer i =1;
1781 for( ; i <= nbBases; i++) {
1783 Handle(Standard_Transient) anItem = theBases->Value(i);
1787 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1790 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1791 if(aRefBase.IsNull())
1795 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1796 if(anItemLoc.IsNull())
1799 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1802 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1803 if(aRefLoc.IsNull())
1805 aSeqLocs->Append(aRefLoc);
1807 aSeqBases->Append(aRefBase);
1810 if(!aSeqBases->Length())
1813 aCI.SetBases(aSeqBases);
1814 aCI.SetLocations(aSeqLocs);
1815 aCI.SetPath(aRefPath);
1816 aCI.SetWithContactMode(theWithContact);
1817 aCI.SetWithCorrectionMode(theWithCorrections);
1819 //Compute the Pipe value
1821 #if OCC_VERSION_LARGE > 0x06010000
1824 if (!GetSolver()->ComputeFunction(aFunction)) {
1825 SetErrorCode("Pipe with defferent section driver failed");
1829 catch (Standard_Failure) {
1830 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1831 SetErrorCode(aFail->GetMessageString());
1835 //Make a Python command
1836 GEOM::TPythonDump pyDump(aFunction);
1837 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1839 for(i =1 ; i <= nbBases; i++) {
1841 Handle(Standard_Transient) anItem = theBases->Value(i);
1845 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1846 if(!anObj.IsNull()) {
1855 for(i =1 ; i <= nbLocs; i++) {
1857 Handle(Standard_Transient) anItem = theLocations->Value(i);
1861 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1862 if(!anObj.IsNull()) {
1869 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1876 //=============================================================================
1878 * MakePipeWithShellSections
1880 //=============================================================================
1881 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1882 const Handle(TColStd_HSequenceOfTransient)& theBases,
1883 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1884 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1885 const Handle(GEOM_Object)& thePath,
1886 bool theWithContact,
1887 bool theWithCorrections)
1889 Handle(GEOM_Object) anObj;
1891 if(theBases.IsNull())
1894 Standard_Integer nbBases = theBases->Length();
1899 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1901 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1903 //Add a new Pipe object
1904 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1906 //Add a new Pipe function
1908 Handle(GEOM_Function) aFunction =
1909 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1910 if (aFunction.IsNull()) return anObj;
1912 //Check if the function is set correctly
1913 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1915 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1916 GEOMImpl_IPipeShellSect aCI (aFunction);
1918 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1919 if(aRefPath.IsNull())
1922 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1923 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1924 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1926 Standard_Integer i =1;
1927 for( ; i <= nbBases; i++) {
1929 Handle(Standard_Transient) anItem = theBases->Value(i);
1932 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1935 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1936 if(aRefBase.IsNull())
1939 if( nbSubBases >= nbBases ) {
1940 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1941 if(aSubItem.IsNull())
1943 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1944 if(aSubBase.IsNull())
1946 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1947 if(aRefSubBase.IsNull())
1949 aSeqSubBases->Append(aRefSubBase);
1953 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1954 if(anItemLoc.IsNull())
1956 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1959 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1960 if(aRefLoc.IsNull())
1962 aSeqLocs->Append(aRefLoc);
1965 aSeqBases->Append(aRefBase);
1968 if(!aSeqBases->Length())
1971 aCI.SetBases(aSeqBases);
1972 aCI.SetSubBases(aSeqSubBases);
1973 aCI.SetLocations(aSeqLocs);
1974 aCI.SetPath(aRefPath);
1975 aCI.SetWithContactMode(theWithContact);
1976 aCI.SetWithCorrectionMode(theWithCorrections);
1978 //Compute the Pipe value
1980 #if OCC_VERSION_LARGE > 0x06010000
1983 if (!GetSolver()->ComputeFunction(aFunction)) {
1984 SetErrorCode("Pipe with shell sections driver failed");
1988 catch (Standard_Failure) {
1989 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1990 SetErrorCode(aFail->GetMessageString());
1994 //Make a Python command
1995 GEOM::TPythonDump pyDump(aFunction);
1996 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1998 for(i =1 ; i <= nbBases; i++) {
2000 Handle(Standard_Transient) anItem = theBases->Value(i);
2004 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2005 if(!anObj.IsNull()) {
2014 for(i =1 ; i <= nbSubBases; i++) {
2016 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2020 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2021 if(!anObj.IsNull()) {
2030 for(i =1 ; i <= nbLocs; i++) {
2032 Handle(Standard_Transient) anItem = theLocations->Value(i);
2036 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2037 if(!anObj.IsNull()) {
2044 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2052 //=============================================================================
2054 * MakePipeShellsWithoutPath
2056 //=============================================================================
2057 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2058 const Handle(TColStd_HSequenceOfTransient)& theBases,
2059 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2061 Handle(GEOM_Object) anObj;
2063 if(theBases.IsNull())
2066 Standard_Integer nbBases = theBases->Length();
2071 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2073 //Add a new Pipe object
2074 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2076 //Add a new Pipe function
2078 Handle(GEOM_Function) aFunction =
2079 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2080 if (aFunction.IsNull()) return anObj;
2082 //Check if the function is set correctly
2083 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2085 GEOMImpl_IPipeShellSect aCI (aFunction);
2087 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2088 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2090 Standard_Integer i =1;
2091 for( ; i <= nbBases; i++) {
2093 Handle(Standard_Transient) anItem = theBases->Value(i);
2096 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2099 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2100 if(aRefBase.IsNull())
2104 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2105 if(anItemLoc.IsNull())
2107 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2110 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2111 if(aRefLoc.IsNull())
2113 aSeqLocs->Append(aRefLoc);
2116 aSeqBases->Append(aRefBase);
2119 if(!aSeqBases->Length())
2122 aCI.SetBases(aSeqBases);
2123 aCI.SetLocations(aSeqLocs);
2125 //Compute the Pipe value
2127 #if OCC_VERSION_LARGE > 0x06010000
2130 if (!GetSolver()->ComputeFunction(aFunction)) {
2131 SetErrorCode("Pipe with shell sections without path driver failed");
2135 catch (Standard_Failure) {
2136 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2137 SetErrorCode(aFail->GetMessageString());
2141 //Make a Python command
2142 GEOM::TPythonDump pyDump(aFunction);
2143 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2145 for(i =1 ; i <= nbBases; i++) {
2147 Handle(Standard_Transient) anItem = theBases->Value(i);
2151 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2152 if(!anObj.IsNull()) {
2161 for(i =1 ; i <= nbLocs; i++) {
2163 Handle(Standard_Transient) anItem = theLocations->Value(i);
2167 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2168 if(!anObj.IsNull()) {
2182 //=============================================================================
2184 * MakePipeBiNormalAlongVector
2186 //=============================================================================
2187 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2188 Handle(GEOM_Object) thePath,
2189 Handle(GEOM_Object) theVec)
2193 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2195 //Add a new Pipe object
2196 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2198 //Add a new Pipe function
2199 Handle(GEOM_Function) aFunction =
2200 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2201 if (aFunction.IsNull()) return NULL;
2203 //Check if the function is set correctly
2204 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2206 GEOMImpl_IPipeBiNormal aCI (aFunction);
2208 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2209 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2210 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2212 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2214 aCI.SetBase(aRefBase);
2215 aCI.SetPath(aRefPath);
2216 aCI.SetVector(aRefVec);
2218 //Compute the Pipe value
2220 #if OCC_VERSION_LARGE > 0x06010000
2223 if (!GetSolver()->ComputeFunction(aFunction)) {
2224 SetErrorCode("Pipe driver failed");
2228 catch (Standard_Failure) {
2229 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2230 SetErrorCode(aFail->GetMessageString());
2234 //Make a Python command
2235 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2236 << theBase << ", " << thePath << ", " << theVec << ")";
2242 //=============================================================================
2246 //=============================================================================
2247 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2253 if (theObject.IsNull()) return NULL;
2255 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2256 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2258 //Add a new Offset function
2259 Handle(GEOM_Function) aFunction;
2260 Handle(GEOM_Object) aCopy;
2263 //Add a new Copy object
2264 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2265 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2268 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2270 if (aFunction.IsNull()) return NULL;
2272 //Check if the function is set correctly
2273 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2275 GEOMImpl_IOffset aTI (aFunction);
2276 aTI.SetShape(anOriginal);
2277 aTI.SetValue(theOffset);
2279 //Compute the offset
2281 #if OCC_VERSION_LARGE > 0x06010000
2284 if (!GetSolver()->ComputeFunction(aFunction)) {
2285 SetErrorCode("Offset driver failed");
2289 catch (Standard_Failure) {
2290 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2291 SetErrorCode(aFail->GetMessageString());
2295 //Make a Python command
2298 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2299 << theObject << ", " << theOffset << ")";
2305 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2306 << theObject << ", " << theOffset << ")";
2312 //=============================================================================
2316 //=============================================================================
2317 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2318 Handle(GEOM_Object) theBase1,
2319 Handle(GEOM_Object) theBase2)
2323 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2325 // Add a new Path object
2326 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2328 // Add a new Path function
2329 Handle(GEOM_Function) aFunction =
2330 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2331 if (aFunction.IsNull()) return NULL;
2333 // Check if the function is set correctly
2334 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2336 GEOMImpl_IPipePath aCI (aFunction);
2338 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2339 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2340 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2342 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2344 aCI.SetShape(aRefShape);
2345 aCI.SetBase1(aRefBase1);
2346 aCI.SetBase2(aRefBase2);
2348 // Compute the Path value
2350 #if OCC_VERSION_LARGE > 0x06010000
2353 if (!GetSolver()->ComputeFunction(aFunction)) {
2354 SetErrorCode("PipePath driver failed");
2358 catch (Standard_Failure) {
2359 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2360 SetErrorCode("RestorePath: inappropriate arguments given");
2364 // Make a Python command
2365 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2366 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2372 //=============================================================================
2376 //=============================================================================
2377 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2378 (Handle(GEOM_Object) theShape,
2379 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2380 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2384 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2386 Standard_Integer nbBases1 = theBase1->Length();
2387 Standard_Integer nbBases2 = theBase2->Length();
2389 if (!nbBases1 || !nbBases2)
2392 // Add a new Path object
2393 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2395 // Add a new Path function
2396 Handle(GEOM_Function) aFunction =
2397 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2398 if (aFunction.IsNull()) return NULL;
2400 // Check if the function is set correctly
2401 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2403 GEOMImpl_IPipePath aCI (aFunction);
2405 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2406 if (aRefShape.IsNull()) return NULL;
2408 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2409 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2412 for (i = 1; i <= nbBases1; i++) {
2413 Handle(Standard_Transient) anItem = theBase1->Value(i);
2414 if (!anItem.IsNull()) {
2415 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2416 if (!aBase.IsNull()) {
2417 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2418 if (!aRefBase.IsNull())
2419 aSeqBases1->Append(aRefBase);
2423 for (i = 1; i <= nbBases2; i++) {
2424 Handle(Standard_Transient) anItem = theBase2->Value(i);
2425 if (!anItem.IsNull()) {
2426 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2427 if (!aBase.IsNull()) {
2428 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2429 if (!aRefBase.IsNull())
2430 aSeqBases2->Append(aRefBase);
2434 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2436 aCI.SetShape(aRefShape);
2437 aCI.SetBaseSeq1(aSeqBases1);
2438 aCI.SetBaseSeq2(aSeqBases2);
2440 // Compute the Path value
2442 #if OCC_VERSION_LARGE > 0x06010000
2445 if (!GetSolver()->ComputeFunction(aFunction)) {
2446 SetErrorCode("PipePath driver failed");
2450 catch (Standard_Failure) {
2451 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2452 SetErrorCode("RestorePath: inappropriate arguments given");
2456 // Make a Python command
2457 GEOM::TPythonDump pyDump (aFunction);
2458 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2459 for (i = 1; i <= nbBases1; i++) {
2460 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2461 if (!anObj.IsNull()) {
2468 for (i = 1; i <= nbBases2; i++) {
2469 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2470 if (!anObj.IsNull()) {