1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include <Basics_OCCTVersion.hxx>
27 #include <GEOMImpl_I3DPrimOperations.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_Types.hxx>
43 #include <GEOMImpl_BoxDriver.hxx>
44 #include <GEOMImpl_FaceDriver.hxx>
45 #include <GEOMImpl_DiskDriver.hxx>
46 #include <GEOMImpl_CylinderDriver.hxx>
47 #include <GEOMImpl_ConeDriver.hxx>
48 #include <GEOMImpl_SphereDriver.hxx>
49 #include <GEOMImpl_TorusDriver.hxx>
50 #include <GEOMImpl_PrismDriver.hxx>
51 #include <GEOMImpl_PipeDriver.hxx>
52 #include <GEOMImpl_PipePathDriver.hxx>
53 #include <GEOMImpl_RevolutionDriver.hxx>
54 #include <GEOMImpl_ShapeDriver.hxx>
55 #include <GEOMImpl_FillingDriver.hxx>
56 #include <GEOMImpl_ThruSectionsDriver.hxx>
57 #include <GEOMImpl_OffsetDriver.hxx>
59 #include <GEOMImpl_IBox.hxx>
60 #include <GEOMImpl_IFace.hxx>
61 #include <GEOMImpl_IDisk.hxx>
62 #include <GEOMImpl_ICylinder.hxx>
63 #include <GEOMImpl_ICone.hxx>
64 #include <GEOMImpl_ISphere.hxx>
65 #include <GEOMImpl_ITorus.hxx>
66 #include <GEOMImpl_IPrism.hxx>
67 #include <GEOMImpl_IPipe.hxx>
68 #include <GEOMImpl_IRevolution.hxx>
69 #include <GEOMImpl_IFilling.hxx>
70 #include <GEOMImpl_IThruSections.hxx>
71 #include <GEOMImpl_IPipeDiffSect.hxx>
72 #include <GEOMImpl_IPipeShellSect.hxx>
73 #include <GEOMImpl_IPipeBiNormal.hxx>
74 #include <GEOMImpl_IOffset.hxx>
75 #include <GEOMImpl_IPipePath.hxx>
77 #include <Precision.hxx>
79 #include <Standard_Failure.hxx>
80 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
82 //=============================================================================
86 //=============================================================================
87 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
88 : GEOM_IOperations(theEngine, theDocID)
90 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
93 //=============================================================================
97 //=============================================================================
98 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
100 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
104 //=============================================================================
108 //=============================================================================
109 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
113 //Add a new Box object
114 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
116 //Add a new Box function with DX_DY_DZ parameters
117 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
118 if (aFunction.IsNull()) return NULL;
120 //Check if the function is set correctly
121 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
123 GEOMImpl_IBox aBI (aFunction);
129 //Compute the box value
131 #if OCC_VERSION_LARGE > 0x06010000
134 if (!GetSolver()->ComputeFunction(aFunction)) {
135 SetErrorCode("Box driver failed");
139 catch (Standard_Failure) {
140 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
141 SetErrorCode(aFail->GetMessageString());
145 //Make a Python command
146 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
147 << theDX << ", " << theDY << ", " << theDZ << ")";
154 //=============================================================================
158 //=============================================================================
159 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
160 Handle(GEOM_Object) thePnt2)
164 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
166 //Add a new Box object
167 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
169 //Add a new Box function for creation a box relatively to two points
170 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
171 if (aFunction.IsNull()) return NULL;
173 //Check if the function is set correctly
174 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
176 GEOMImpl_IBox aBI (aFunction);
178 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
179 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
181 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
183 aBI.SetRef1(aRefFunction1);
184 aBI.SetRef2(aRefFunction2);
186 //Compute the Box value
188 #if OCC_VERSION_LARGE > 0x06010000
191 if (!GetSolver()->ComputeFunction(aFunction)) {
192 SetErrorCode("Box driver failed");
196 catch (Standard_Failure) {
197 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
198 SetErrorCode(aFail->GetMessageString());
202 //Make a Python command
203 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
204 << thePnt1 << ", " << thePnt2 << ")";
210 //=============================================================================
214 //=============================================================================
215 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
219 if (theH == 0 || theW == 0) return NULL;
221 //Add a new Face object
222 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
224 //Add a new Box function for creation a box relatively to two points
225 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
226 if (aFunction.IsNull()) return NULL;
228 //Check if the function is set correctly
229 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
231 GEOMImpl_IFace aFI (aFunction);
235 aFI.SetOrientation(theOrientation);
239 #if OCC_VERSION_LARGE > 0x06010000
242 if (!GetSolver()->ComputeFunction(aFunction)) {
243 SetErrorCode("Face driver failed");
247 catch (Standard_Failure) {
248 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
249 SetErrorCode(aFail->GetMessageString());
253 //Make a Python command
254 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
255 << theH << ", " << theW << ", " << theOrientation << ")";
261 //=============================================================================
265 //=============================================================================
266 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
267 double theH, double theW)
271 if (theObj.IsNull()) return NULL;
273 //Add a new Face object
274 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
276 //Add a new Box function for creation a box relatively to two points
277 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
278 if (aFunction.IsNull()) return NULL;
280 //Check if the function is set correctly
281 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
283 GEOMImpl_IFace aFI (aFunction);
285 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
287 if (aRefFunction1.IsNull())
290 aFI.SetRef1(aRefFunction1);
296 #if OCC_VERSION_LARGE > 0x06010000
299 if (!GetSolver()->ComputeFunction(aFunction)) {
300 SetErrorCode("Face driver failed");
304 catch (Standard_Failure) {
305 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
306 SetErrorCode(aFail->GetMessageString());
310 //Make a Python command
311 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
312 << theObj << ", " << theH << ", " << theW << ")";
318 //=============================================================================
322 //=============================================================================
323 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
324 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
328 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
330 //Add a new Disk object
331 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
333 //Add a new Disk function for creation a disk relatively to point and vector
334 Handle(GEOM_Function) aFunction =
335 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
336 if (aFunction.IsNull()) return NULL;
338 //Check if the function is set correctly
339 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
341 GEOMImpl_IDisk aCI (aFunction);
343 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
344 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
346 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
348 aCI.SetCenter(aRefPnt);
349 aCI.SetVector(aRefVec);
352 //Compute the Disk value
354 #if OCC_VERSION_LARGE > 0x06010000
357 if (!GetSolver()->ComputeFunction(aFunction)) {
358 SetErrorCode("Disk driver failed");
362 catch (Standard_Failure) {
363 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
364 SetErrorCode(aFail->GetMessageString());
368 //Make a Python command
369 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
370 << thePnt << ", " << theVec << ", " << theR << ")";
376 //=============================================================================
380 //=============================================================================
381 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
382 Handle(GEOM_Object) thePnt2,
383 Handle(GEOM_Object) thePnt3)
387 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
389 //Add a new Disk object
390 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
392 //Add a new Disk function for creation a disk relatively to three points
393 Handle(GEOM_Function) aFunction =
394 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
395 if (aFunction.IsNull()) return NULL;
397 //Check if the function is set correctly
398 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
400 GEOMImpl_IDisk aCI (aFunction);
402 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
403 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
404 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
406 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
408 aCI.SetPoint1(aRefPnt1);
409 aCI.SetPoint2(aRefPnt2);
410 aCI.SetPoint3(aRefPnt3);
412 //Compute the Disk value
414 #if OCC_VERSION_LARGE > 0x06010000
417 if (!GetSolver()->ComputeFunction(aFunction)) {
418 SetErrorCode("Disk driver failed");
422 catch (Standard_Failure) {
423 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
424 SetErrorCode(aFail->GetMessageString());
428 //Make a Python command
429 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
430 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
436 //=============================================================================
440 //=============================================================================
441 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
445 if (theR == 0 ) return NULL;
447 //Add a new Disk object
448 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
450 //Add a new Box function for creation a box relatively to two points
451 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
452 if (aFunction.IsNull()) return NULL;
454 //Check if the function is set correctly
455 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
457 GEOMImpl_IDisk aDI (aFunction);
460 aDI.SetOrientation(theOrientation);
464 #if OCC_VERSION_LARGE > 0x06010000
467 if (!GetSolver()->ComputeFunction(aFunction)) {
468 SetErrorCode("Disk driver failed");
472 catch (Standard_Failure) {
473 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
474 SetErrorCode(aFail->GetMessageString());
478 //Make a Python command
479 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
480 << theR << ", " << theOrientation << ")";
486 //=============================================================================
490 //=============================================================================
491 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
495 //Add a new Cylinder object
496 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
498 //Add a new Cylinder function with R and H parameters
499 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
500 if (aFunction.IsNull()) return NULL;
502 //Check if the function is set correctly
503 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
505 GEOMImpl_ICylinder aCI (aFunction);
510 //Compute the Cylinder value
512 #if OCC_VERSION_LARGE > 0x06010000
515 if (!GetSolver()->ComputeFunction(aFunction)) {
516 SetErrorCode("Cylinder driver failed");
520 catch (Standard_Failure) {
521 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
522 SetErrorCode(aFail->GetMessageString());
526 //Make a Python command
527 GEOM::TPythonDump(aFunction) << aCylinder
528 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
534 //=============================================================================
538 //=============================================================================
539 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
543 //Add a new Cylinder object
544 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
546 //Add a new Cylinder function with R and H parameters
547 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
548 if (aFunction.IsNull()) return NULL;
550 //Check if the function is set correctly
551 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
553 GEOMImpl_ICylinder aCI (aFunction);
559 //Compute the Cylinder value
561 #if OCC_VERSION_LARGE > 0x06010000
564 if (!GetSolver()->ComputeFunction(aFunction)) {
565 SetErrorCode("Cylinder driver failed");
569 catch (Standard_Failure) {
570 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
571 SetErrorCode(aFail->GetMessageString());
575 //Make a Python command
576 GEOM::TPythonDump(aFunction) << aCylinder
577 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
583 //=============================================================================
585 * MakeCylinderPntVecRH
587 //=============================================================================
588 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
589 Handle(GEOM_Object) theVec,
590 double theR, double theH)
594 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
596 //Add a new Cylinder object
597 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
599 //Add a new Cylinder function for creation a cylinder relatively to point and vector
600 Handle(GEOM_Function) aFunction =
601 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
602 if (aFunction.IsNull()) return NULL;
604 //Check if the function is set correctly
605 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
607 GEOMImpl_ICylinder aCI (aFunction);
609 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
610 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
612 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
614 aCI.SetPoint(aRefPnt);
615 aCI.SetVector(aRefVec);
619 //Compute the Cylinder value
621 #if OCC_VERSION_LARGE > 0x06010000
624 if (!GetSolver()->ComputeFunction(aFunction)) {
625 SetErrorCode("Cylinder driver failed");
629 catch (Standard_Failure) {
630 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
631 SetErrorCode(aFail->GetMessageString());
635 //Make a Python command
636 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
637 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
643 //=============================================================================
645 * MakeCylinderPntVecRHA
647 //=============================================================================
648 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
649 Handle(GEOM_Object) theVec,
650 double theR, double theH, double theA)
654 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
656 //Add a new Cylinder object
657 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
659 //Add a new Cylinder function for creation a cylinder relatively to point and vector
660 Handle(GEOM_Function) aFunction =
661 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
662 if (aFunction.IsNull()) return NULL;
664 //Check if the function is set correctly
665 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
667 GEOMImpl_ICylinder aCI (aFunction);
669 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
670 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
672 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
674 aCI.SetPoint(aRefPnt);
675 aCI.SetVector(aRefVec);
680 //Compute the Cylinder value
682 #if OCC_VERSION_LARGE > 0x06010000
685 if (!GetSolver()->ComputeFunction(aFunction)) {
686 SetErrorCode("Cylinder driver failed");
690 catch (Standard_Failure) {
691 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
692 SetErrorCode(aFail->GetMessageString());
696 //Make a Python command
697 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
698 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
705 //=============================================================================
709 //=============================================================================
710 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
715 //Add a new Cone object
716 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
718 //Add a new Cone function with R and H parameters
719 Handle(GEOM_Function) aFunction =
720 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
721 if (aFunction.IsNull()) return NULL;
723 //Check if the function is set correctly
724 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
726 GEOMImpl_ICone aCI (aFunction);
732 //Compute the Cone value
734 #if OCC_VERSION_LARGE > 0x06010000
737 if (!GetSolver()->ComputeFunction(aFunction)) {
738 SetErrorCode("Cone driver failed");
742 catch (Standard_Failure) {
743 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
744 SetErrorCode(aFail->GetMessageString());
748 //Make a Python command
749 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
750 << theR1 << ", " << theR2 << ", " << theH << ")";
757 //=============================================================================
759 * MakeConePntVecR1R2H
761 //=============================================================================
762 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
763 Handle(GEOM_Object) theVec,
764 double theR1, double theR2,
769 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
771 //Add a new Cone object
772 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
774 //Add a new Cone function for creation a cone relatively to point and vector
775 Handle(GEOM_Function) aFunction =
776 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
777 if (aFunction.IsNull()) return NULL;
779 //Check if the function is set correctly
780 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
782 GEOMImpl_ICone aCI (aFunction);
784 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
785 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
787 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
789 aCI.SetPoint(aRefPnt);
790 aCI.SetVector(aRefVec);
795 //Compute the Cone value
797 #if OCC_VERSION_LARGE > 0x06010000
800 if (!GetSolver()->ComputeFunction(aFunction)) {
801 SetErrorCode("Cone driver failed");
805 catch (Standard_Failure) {
806 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
807 SetErrorCode(aFail->GetMessageString());
811 //Make a Python command
812 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
813 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
820 //=============================================================================
824 //=============================================================================
825 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
829 //Add a new Sphere object
830 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
832 //Add a new Sphere function with R parameter
833 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
834 if (aFunction.IsNull()) return NULL;
836 //Check if the function is set correctly
837 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
839 GEOMImpl_ISphere aCI (aFunction);
843 //Compute the Sphere value
845 #if OCC_VERSION_LARGE > 0x06010000
848 if (!GetSolver()->ComputeFunction(aFunction)) {
849 SetErrorCode("Sphere driver failed");
853 catch (Standard_Failure) {
854 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
855 SetErrorCode(aFail->GetMessageString());
859 //Make a Python command
860 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
867 //=============================================================================
871 //=============================================================================
872 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
877 if (thePnt.IsNull()) return NULL;
879 //Add a new Point object
880 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
882 //Add a new Sphere function for creation a sphere relatively to point
883 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
884 if (aFunction.IsNull()) return NULL;
886 //Check if the function is set correctly
887 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
889 GEOMImpl_ISphere aCI (aFunction);
891 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
893 if (aRefPnt.IsNull()) return NULL;
895 aCI.SetPoint(aRefPnt);
898 //Compute the Sphere value
900 #if OCC_VERSION_LARGE > 0x06010000
903 if (!GetSolver()->ComputeFunction(aFunction)) {
904 SetErrorCode("Sphere driver failed");
908 catch (Standard_Failure) {
909 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
910 SetErrorCode(aFail->GetMessageString());
914 //Make a Python command
915 GEOM::TPythonDump(aFunction) << aSphere
916 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
923 //=============================================================================
927 //=============================================================================
928 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
929 (double theRMajor, double theRMinor)
933 //Add a new Torus object
934 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
936 //Add a new Torus function
937 Handle(GEOM_Function) aFunction =
938 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
939 if (aFunction.IsNull()) return NULL;
941 //Check if the function is set correctly
942 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
944 GEOMImpl_ITorus aCI (aFunction);
946 aCI.SetRMajor(theRMajor);
947 aCI.SetRMinor(theRMinor);
949 //Compute the Torus value
951 #if OCC_VERSION_LARGE > 0x06010000
954 if (!GetSolver()->ComputeFunction(aFunction)) {
955 SetErrorCode("Torus driver failed");
959 catch (Standard_Failure) {
960 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
961 SetErrorCode(aFail->GetMessageString());
965 //Make a Python command
966 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
967 << theRMajor << ", " << theRMinor << ")";
973 //=============================================================================
977 //=============================================================================
978 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
979 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
980 double theRMajor, double theRMinor)
984 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
986 //Add a new Torus object
987 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
989 //Add a new Torus function
990 Handle(GEOM_Function) aFunction =
991 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
992 if (aFunction.IsNull()) return NULL;
994 //Check if the function is set correctly
995 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
997 GEOMImpl_ITorus aCI (aFunction);
999 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
1000 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1002 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
1004 aCI.SetCenter(aRefPnt);
1005 aCI.SetVector(aRefVec);
1006 aCI.SetRMajor(theRMajor);
1007 aCI.SetRMinor(theRMinor);
1009 //Compute the Torus value
1011 #if OCC_VERSION_LARGE > 0x06010000
1014 if (!GetSolver()->ComputeFunction(aFunction)) {
1015 SetErrorCode("Torus driver failed");
1019 catch (Standard_Failure) {
1020 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1021 SetErrorCode(aFail->GetMessageString());
1025 //Make a Python command
1026 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
1027 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
1034 //=============================================================================
1038 //=============================================================================
1039 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
1040 Handle(GEOM_Object) theVec,
1041 double theH, double theScaleFactor)
1045 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1047 //Add a new Prism object
1048 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1050 //Add a new Prism function for creation a Prism relatively to vector
1051 Handle(GEOM_Function) aFunction =
1052 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1053 if (aFunction.IsNull()) return NULL;
1055 //Check if the function is set correctly
1056 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1058 GEOMImpl_IPrism aCI (aFunction);
1060 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1061 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1063 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1065 aCI.SetBase(aRefBase);
1066 aCI.SetVector(aRefVec);
1068 aCI.SetScale(theScaleFactor);
1070 //Compute the Prism value
1072 #if OCC_VERSION_LARGE > 0x06010000
1075 if (!GetSolver()->ComputeFunction(aFunction)) {
1076 //SetErrorCode("Prism driver failed");
1077 SetErrorCode("Extrusion can not be created, check input data");
1081 catch (Standard_Failure) {
1082 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1083 SetErrorCode(aFail->GetMessageString());
1087 //Make a Python command
1088 GEOM::TPythonDump pd (aFunction);
1089 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1090 if (theScaleFactor > Precision::Confusion())
1091 pd << ", " << theScaleFactor << ")";
1099 //=============================================================================
1101 * MakePrismVecH2Ways
1103 //=============================================================================
1104 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1105 Handle(GEOM_Object) theVec,
1110 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1112 //Add a new Prism object
1113 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1115 //Add a new Prism function for creation a Prism relatively to vector
1116 Handle(GEOM_Function) aFunction =
1117 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1118 if (aFunction.IsNull()) return NULL;
1120 //Check if the function is set correctly
1121 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1123 GEOMImpl_IPrism aCI (aFunction);
1125 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1126 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1128 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1130 aCI.SetBase(aRefBase);
1131 aCI.SetVector(aRefVec);
1134 //Compute the Prism value
1136 #if OCC_VERSION_LARGE > 0x06010000
1139 if (!GetSolver()->ComputeFunction(aFunction)) {
1140 //SetErrorCode("Prism driver failed");
1141 SetErrorCode("Extrusion can not be created, check input data");
1145 catch (Standard_Failure) {
1146 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1147 SetErrorCode(aFail->GetMessageString());
1151 //Make a Python command
1152 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1153 << theBase << ", " << theVec << ", " << theH << ")";
1159 //=============================================================================
1163 //=============================================================================
1164 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1165 (Handle(GEOM_Object) theBase,
1166 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1167 double theScaleFactor)
1171 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1173 //Add a new Prism object
1174 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1176 //Add a new Prism function for creation a Prism relatively to two points
1177 Handle(GEOM_Function) aFunction =
1178 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1179 if (aFunction.IsNull()) return NULL;
1181 //Check if the function is set correctly
1182 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1184 GEOMImpl_IPrism aCI (aFunction);
1186 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1187 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1188 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1190 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1192 aCI.SetBase(aRefBase);
1193 aCI.SetFirstPoint(aRefPnt1);
1194 aCI.SetLastPoint(aRefPnt2);
1195 aCI.SetScale(theScaleFactor);
1197 //Compute the Prism value
1199 #if OCC_VERSION_LARGE > 0x06010000
1202 if (!GetSolver()->ComputeFunction(aFunction)) {
1203 //SetErrorCode("Prism driver failed");
1204 SetErrorCode("Extrusion can not be created, check input data");
1208 catch (Standard_Failure) {
1209 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1210 SetErrorCode(aFail->GetMessageString());
1214 //Make a Python command
1215 GEOM::TPythonDump pd (aFunction);
1216 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1217 if (theScaleFactor > Precision::Confusion())
1218 pd << ", " << theScaleFactor << ")";
1226 //=============================================================================
1228 * MakePrismTwoPnt2Ways
1230 //=============================================================================
1231 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1232 (Handle(GEOM_Object) theBase,
1233 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1237 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1239 //Add a new Prism object
1240 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1242 //Add a new Prism function for creation a Prism relatively to two points
1243 Handle(GEOM_Function) aFunction =
1244 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1245 if (aFunction.IsNull()) return NULL;
1247 //Check if the function is set correctly
1248 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1250 GEOMImpl_IPrism aCI (aFunction);
1252 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1253 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1254 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1256 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1258 aCI.SetBase(aRefBase);
1259 aCI.SetFirstPoint(aRefPnt1);
1260 aCI.SetLastPoint(aRefPnt2);
1262 //Compute the Prism value
1264 #if OCC_VERSION_LARGE > 0x06010000
1267 if (!GetSolver()->ComputeFunction(aFunction)) {
1268 //SetErrorCode("Prism driver failed");
1269 SetErrorCode("Extrusion can not be created, check input data");
1273 catch (Standard_Failure) {
1274 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1275 SetErrorCode(aFail->GetMessageString());
1279 //Make a Python command
1280 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1281 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1287 //=============================================================================
1291 //=============================================================================
1292 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1293 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1294 double theScaleFactor)
1298 if (theBase.IsNull()) return NULL;
1300 //Add a new Prism object
1301 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1303 //Add a new Prism function for creation a Prism by DXDYDZ
1304 Handle(GEOM_Function) aFunction =
1305 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1306 if (aFunction.IsNull()) return NULL;
1308 //Check if the function is set correctly
1309 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1311 GEOMImpl_IPrism aCI (aFunction);
1313 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1315 if (aRefBase.IsNull()) return NULL;
1317 aCI.SetBase(aRefBase);
1321 aCI.SetScale(theScaleFactor);
1323 //Compute the Prism value
1325 #if OCC_VERSION_LARGE > 0x06010000
1328 if (!GetSolver()->ComputeFunction(aFunction)) {
1329 SetErrorCode("Extrusion can not be created, check input data");
1333 catch (Standard_Failure) {
1334 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1335 SetErrorCode(aFail->GetMessageString());
1339 //Make a Python command
1340 GEOM::TPythonDump pd (aFunction);
1341 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1342 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1343 if (theScaleFactor > Precision::Confusion())
1344 pd << ", " << theScaleFactor << ")";
1352 //=============================================================================
1354 * MakePrismDXDYDZ_2WAYS
1356 //=============================================================================
1357 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1358 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1362 if (theBase.IsNull()) return NULL;
1364 //Add a new Prism object
1365 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1367 //Add a new Prism function for creation a Prism by DXDYDZ
1368 Handle(GEOM_Function) aFunction =
1369 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1370 if (aFunction.IsNull()) return NULL;
1372 //Check if the function is set correctly
1373 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1375 GEOMImpl_IPrism aCI (aFunction);
1377 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1379 if (aRefBase.IsNull()) return NULL;
1381 aCI.SetBase(aRefBase);
1386 //Compute the Prism value
1388 #if OCC_VERSION_LARGE > 0x06010000
1391 if (!GetSolver()->ComputeFunction(aFunction)) {
1392 SetErrorCode("Extrusion can not be created, check input data");
1396 catch (Standard_Failure) {
1397 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1398 SetErrorCode(aFail->GetMessageString());
1402 //Make a Python command
1403 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1404 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1410 //=============================================================================
1414 //=============================================================================
1415 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1416 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1420 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1422 Handle(GEOM_Object) aPrism = NULL;
1426 //Add a new Extruded Boss object
1427 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1431 //Add a new Extruded Cut object
1432 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1435 //Add a new Prism function for the creation of a Draft Prism feature
1436 Handle(GEOM_Function) aFunction =
1437 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1438 if (aFunction.IsNull()) return NULL;
1440 //Check if the function is set correctly
1441 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1443 GEOMImpl_IPrism aCI (aFunction);
1445 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1446 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1448 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1451 aCI.SetBase(aRefBase);
1452 aCI.SetInitShape(aRefInit);
1453 aCI.SetH(theHeight);
1454 aCI.SetDraftAngle(theAngle);
1460 //Compute the Draft Prism Feature value
1462 #if OCC_VERSION_LARGE > 0x06010000
1465 if (!GetSolver()->ComputeFunction(aFunction)) {
1466 SetErrorCode("Extrusion can not be created, check input data");
1470 catch (Standard_Failure) {
1471 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1472 SetErrorCode(aFail->GetMessageString());
1476 //Make a Python command
1479 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1480 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1484 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1485 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1492 //=============================================================================
1496 //=============================================================================
1497 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1498 Handle(GEOM_Object) thePath)
1502 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1504 //Add a new Pipe object
1505 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1507 //Add a new Pipe function
1508 Handle(GEOM_Function) aFunction =
1509 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1510 if (aFunction.IsNull()) return NULL;
1512 //Check if the function is set correctly
1513 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1515 GEOMImpl_IPipe aCI (aFunction);
1517 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1518 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1520 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1522 aCI.SetBase(aRefBase);
1523 aCI.SetPath(aRefPath);
1525 //Compute the Pipe value
1527 #if OCC_VERSION_LARGE > 0x06010000
1530 if (!GetSolver()->ComputeFunction(aFunction)) {
1531 SetErrorCode("Pipe driver failed");
1535 catch (Standard_Failure) {
1536 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1537 SetErrorCode(aFail->GetMessageString());
1541 //Make a Python command
1542 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1543 << theBase << ", " << thePath << ")";
1550 //=============================================================================
1552 * MakeRevolutionAxisAngle
1554 //=============================================================================
1555 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1556 Handle(GEOM_Object) theAxis,
1561 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1563 //Add a new Revolution object
1564 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1566 //Add a new Revolution function for creation a revolution relatively to axis
1567 Handle(GEOM_Function) aFunction =
1568 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1569 if (aFunction.IsNull()) return NULL;
1571 //Check if the function is set correctly
1572 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1574 GEOMImpl_IRevolution aCI (aFunction);
1576 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1577 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1579 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1581 aCI.SetBase(aRefBase);
1582 aCI.SetAxis(aRefAxis);
1583 aCI.SetAngle(theAngle);
1585 //Compute the Revolution value
1587 #if OCC_VERSION_LARGE > 0x06010000
1590 if (!GetSolver()->ComputeFunction(aFunction)) {
1591 SetErrorCode("Revolution driver failed");
1595 catch (Standard_Failure) {
1596 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1597 SetErrorCode(aFail->GetMessageString());
1601 //Make a Python command
1602 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1603 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1609 //=============================================================================
1611 * MakeRevolutionAxisAngle2Ways
1613 //=============================================================================
1614 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1615 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1619 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1621 //Add a new Revolution object
1622 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1624 //Add a new Revolution function for creation a revolution relatively to axis
1625 Handle(GEOM_Function) aFunction =
1626 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1627 if (aFunction.IsNull()) return NULL;
1629 //Check if the function is set correctly
1630 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1632 GEOMImpl_IRevolution aCI (aFunction);
1634 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1635 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1637 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1639 aCI.SetBase(aRefBase);
1640 aCI.SetAxis(aRefAxis);
1641 aCI.SetAngle(theAngle);
1643 //Compute the Revolution value
1645 #if OCC_VERSION_LARGE > 0x06010000
1648 if (!GetSolver()->ComputeFunction(aFunction)) {
1649 SetErrorCode("Revolution driver failed");
1653 catch (Standard_Failure) {
1654 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1655 SetErrorCode(aFail->GetMessageString());
1659 //Make a Python command
1660 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1661 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1667 //=============================================================================
1671 //=============================================================================
1672 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1673 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1674 double theTol2D, double theTol3D, int theNbIter,
1675 int theMethod, bool isApprox)
1679 if (theShape.IsNull()) return NULL;
1681 //Add a new Filling object
1682 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1684 //Add a new Filling function for creation a filling from a compound
1685 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1686 if (aFunction.IsNull()) return NULL;
1688 //Check if the function is set correctly
1689 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1691 GEOMImpl_IFilling aFI (aFunction);
1693 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1695 if (aRefShape.IsNull()) return NULL;
1697 aFI.SetShape(aRefShape);
1698 aFI.SetMinDeg(theMinDeg);
1699 aFI.SetMaxDeg(theMaxDeg);
1700 aFI.SetTol2D(theTol2D);
1701 aFI.SetTol3D(theTol3D);
1702 aFI.SetNbIter(theNbIter);
1703 aFI.SetApprox(isApprox);
1704 aFI.SetMethod(theMethod);
1706 //Compute the Solid value
1708 #if OCC_VERSION_LARGE > 0x06010000
1711 if (!GetSolver()->ComputeFunction(aFunction)) {
1712 SetErrorCode("Filling driver failed");
1716 catch (Standard_Failure) {
1717 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1718 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1719 SetErrorCode("B-Spline surface construction failed");
1721 SetErrorCode(aFail->GetMessageString());
1725 //Make a Python command
1726 GEOM::TPythonDump pd (aFunction);
1727 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1728 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1729 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1730 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1731 pd << ", theTol2D=" << theTol2D ;
1732 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1733 pd << ", theTol3D=" << theTol3D ;
1734 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1735 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1736 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1737 if(isApprox) pd << ", isApprox=" << isApprox ;
1744 //=============================================================================
1748 //=============================================================================
1749 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1750 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1755 Handle(GEOM_Object) anObj;
1757 if(theSeqSections.IsNull())
1760 Standard_Integer nbObj = theSeqSections->Length();
1764 //Add a new ThruSections object
1765 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1768 //Add a new ThruSections function
1770 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1771 Handle(GEOM_Function) aFunction =
1772 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1773 if (aFunction.IsNull()) return anObj;
1775 //Check if the function is set correctly
1776 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1778 GEOMImpl_IThruSections aCI (aFunction);
1780 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1782 Standard_Integer i =1;
1783 for( ; i <= nbObj; i++) {
1785 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1789 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1790 if(!aSectObj.IsNull())
1792 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1793 if(!aRefSect.IsNull())
1794 aSeqSections->Append(aRefSect);
1798 if(!aSeqSections->Length())
1801 aCI.SetSections(aSeqSections);
1802 aCI.SetSolidMode(theModeSolid);
1803 aCI.SetPrecision(thePreci);
1805 //Compute the ThruSections value
1807 #if OCC_VERSION_LARGE > 0x06010000
1810 if (!GetSolver()->ComputeFunction(aFunction)) {
1811 SetErrorCode("ThruSections driver failed");
1815 catch (Standard_Failure) {
1816 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1817 SetErrorCode(aFail->GetMessageString());
1821 //Make a Python command
1822 GEOM::TPythonDump pyDump(aFunction);
1823 pyDump << aThruSect << " = geompy.MakeThruSections([";
1825 for(i =1 ; i <= nbObj; i++) {
1827 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1831 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1832 if(!aSectObj.IsNull()) {
1839 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1846 //=============================================================================
1848 * MakePipeWithDifferentSections
1850 //=============================================================================
1851 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1852 const Handle(TColStd_HSequenceOfTransient)& theBases,
1853 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1854 const Handle(GEOM_Object)& thePath,
1855 bool theWithContact,
1856 bool theWithCorrections)
1858 Handle(GEOM_Object) anObj;
1860 if(theBases.IsNull())
1863 Standard_Integer nbBases = theBases->Length();
1868 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1869 //Add a new Pipe object
1870 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1872 //Add a new Pipe function
1874 Handle(GEOM_Function) aFunction =
1875 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1876 if (aFunction.IsNull()) return anObj;
1878 //Check if the function is set correctly
1879 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1881 GEOMImpl_IPipeDiffSect aCI (aFunction);
1883 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1884 if(aRefPath.IsNull())
1887 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1888 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1890 Standard_Integer i =1;
1891 for( ; i <= nbBases; i++) {
1893 Handle(Standard_Transient) anItem = theBases->Value(i);
1897 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1900 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1901 if(aRefBase.IsNull())
1905 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1906 if(anItemLoc.IsNull())
1909 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1912 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1913 if(aRefLoc.IsNull())
1915 aSeqLocs->Append(aRefLoc);
1917 aSeqBases->Append(aRefBase);
1920 if(!aSeqBases->Length())
1923 aCI.SetBases(aSeqBases);
1924 aCI.SetLocations(aSeqLocs);
1925 aCI.SetPath(aRefPath);
1926 aCI.SetWithContactMode(theWithContact);
1927 aCI.SetWithCorrectionMode(theWithCorrections);
1929 //Compute the Pipe value
1931 #if OCC_VERSION_LARGE > 0x06010000
1934 if (!GetSolver()->ComputeFunction(aFunction)) {
1935 SetErrorCode("Pipe with defferent section driver failed");
1939 catch (Standard_Failure) {
1940 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1941 SetErrorCode(aFail->GetMessageString());
1945 //Make a Python command
1946 GEOM::TPythonDump pyDump(aFunction);
1947 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1949 for(i =1 ; i <= nbBases; i++) {
1951 Handle(Standard_Transient) anItem = theBases->Value(i);
1955 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1956 if(!anObj.IsNull()) {
1965 for(i =1 ; i <= nbLocs; i++) {
1967 Handle(Standard_Transient) anItem = theLocations->Value(i);
1971 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1972 if(!anObj.IsNull()) {
1979 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1986 //=============================================================================
1988 * MakePipeWithShellSections
1990 //=============================================================================
1991 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1992 const Handle(TColStd_HSequenceOfTransient)& theBases,
1993 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1994 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1995 const Handle(GEOM_Object)& thePath,
1996 bool theWithContact,
1997 bool theWithCorrections)
1999 Handle(GEOM_Object) anObj;
2001 if(theBases.IsNull())
2004 Standard_Integer nbBases = theBases->Length();
2009 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
2011 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2013 //Add a new Pipe object
2014 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2016 //Add a new Pipe function
2018 Handle(GEOM_Function) aFunction =
2019 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
2020 if (aFunction.IsNull()) return anObj;
2022 //Check if the function is set correctly
2023 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2025 //GEOMImpl_IPipeDiffSect aCI (aFunction);
2026 GEOMImpl_IPipeShellSect aCI (aFunction);
2028 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2029 if(aRefPath.IsNull())
2032 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2033 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
2034 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2036 Standard_Integer i =1;
2037 for( ; i <= nbBases; i++) {
2039 Handle(Standard_Transient) anItem = theBases->Value(i);
2042 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2045 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2046 if(aRefBase.IsNull())
2049 if( nbSubBases >= nbBases ) {
2050 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
2051 if(aSubItem.IsNull())
2053 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
2054 if(aSubBase.IsNull())
2056 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
2057 if(aRefSubBase.IsNull())
2059 aSeqSubBases->Append(aRefSubBase);
2063 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2064 if(anItemLoc.IsNull())
2066 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2069 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2070 if(aRefLoc.IsNull())
2072 aSeqLocs->Append(aRefLoc);
2075 aSeqBases->Append(aRefBase);
2078 if(!aSeqBases->Length())
2081 aCI.SetBases(aSeqBases);
2082 aCI.SetSubBases(aSeqSubBases);
2083 aCI.SetLocations(aSeqLocs);
2084 aCI.SetPath(aRefPath);
2085 aCI.SetWithContactMode(theWithContact);
2086 aCI.SetWithCorrectionMode(theWithCorrections);
2088 //Compute the Pipe value
2090 #if OCC_VERSION_LARGE > 0x06010000
2093 if (!GetSolver()->ComputeFunction(aFunction)) {
2094 SetErrorCode("Pipe with shell sections driver failed");
2098 catch (Standard_Failure) {
2099 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2100 SetErrorCode(aFail->GetMessageString());
2104 //Make a Python command
2105 GEOM::TPythonDump pyDump(aFunction);
2106 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
2108 for(i =1 ; i <= nbBases; i++) {
2110 Handle(Standard_Transient) anItem = theBases->Value(i);
2114 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2115 if(!anObj.IsNull()) {
2124 for(i =1 ; i <= nbSubBases; i++) {
2126 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2130 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2131 if(!anObj.IsNull()) {
2140 for(i =1 ; i <= nbLocs; i++) {
2142 Handle(Standard_Transient) anItem = theLocations->Value(i);
2146 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2147 if(!anObj.IsNull()) {
2154 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2162 //=============================================================================
2164 * MakePipeShellsWithoutPath
2166 //=============================================================================
2167 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2168 const Handle(TColStd_HSequenceOfTransient)& theBases,
2169 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2171 Handle(GEOM_Object) anObj;
2173 if(theBases.IsNull())
2176 Standard_Integer nbBases = theBases->Length();
2181 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2183 //Add a new Pipe object
2184 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2186 //Add a new Pipe function
2188 Handle(GEOM_Function) aFunction =
2189 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2190 if (aFunction.IsNull()) return anObj;
2192 //Check if the function is set correctly
2193 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2195 GEOMImpl_IPipeShellSect aCI (aFunction);
2197 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2198 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2200 Standard_Integer i =1;
2201 for( ; i <= nbBases; i++) {
2203 Handle(Standard_Transient) anItem = theBases->Value(i);
2206 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2209 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2210 if(aRefBase.IsNull())
2214 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2215 if(anItemLoc.IsNull())
2217 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2220 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2221 if(aRefLoc.IsNull())
2223 aSeqLocs->Append(aRefLoc);
2226 aSeqBases->Append(aRefBase);
2229 if(!aSeqBases->Length())
2232 aCI.SetBases(aSeqBases);
2233 aCI.SetLocations(aSeqLocs);
2235 //Compute the Pipe value
2237 #if OCC_VERSION_LARGE > 0x06010000
2240 if (!GetSolver()->ComputeFunction(aFunction)) {
2241 SetErrorCode("Pipe with shell sections without path driver failed");
2245 catch (Standard_Failure) {
2246 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2247 SetErrorCode(aFail->GetMessageString());
2251 //Make a Python command
2252 GEOM::TPythonDump pyDump(aFunction);
2253 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2255 for(i =1 ; i <= nbBases; i++) {
2257 Handle(Standard_Transient) anItem = theBases->Value(i);
2261 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2262 if(!anObj.IsNull()) {
2271 for(i =1 ; i <= nbLocs; i++) {
2273 Handle(Standard_Transient) anItem = theLocations->Value(i);
2277 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2278 if(!anObj.IsNull()) {
2292 //=============================================================================
2294 * MakePipeBiNormalAlongVector
2296 //=============================================================================
2297 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2298 Handle(GEOM_Object) thePath,
2299 Handle(GEOM_Object) theVec)
2303 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2305 //Add a new Pipe object
2306 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2308 //Add a new Pipe function
2309 Handle(GEOM_Function) aFunction =
2310 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2311 if (aFunction.IsNull()) return NULL;
2313 //Check if the function is set correctly
2314 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2316 GEOMImpl_IPipeBiNormal aCI (aFunction);
2318 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2319 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2320 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2322 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2324 aCI.SetBase(aRefBase);
2325 aCI.SetPath(aRefPath);
2326 aCI.SetVector(aRefVec);
2328 //Compute the Pipe value
2330 #if OCC_VERSION_LARGE > 0x06010000
2333 if (!GetSolver()->ComputeFunction(aFunction)) {
2334 SetErrorCode("Pipe driver failed");
2338 catch (Standard_Failure) {
2339 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2340 SetErrorCode(aFail->GetMessageString());
2344 //Make a Python command
2345 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2346 << theBase << ", " << thePath << ", " << theVec << ")";
2352 //=============================================================================
2356 //=============================================================================
2357 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2363 if (theObject.IsNull()) return NULL;
2365 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2366 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2368 //Add a new Offset function
2369 Handle(GEOM_Function) aFunction;
2370 Handle(GEOM_Object) aCopy;
2373 //Add a new Copy object
2374 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2375 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2378 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2380 if (aFunction.IsNull()) return NULL;
2382 //Check if the function is set correctly
2383 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2385 GEOMImpl_IOffset aTI (aFunction);
2386 aTI.SetShape(anOriginal);
2387 aTI.SetValue(theOffset);
2389 //Compute the offset
2391 #if OCC_VERSION_LARGE > 0x06010000
2394 if (!GetSolver()->ComputeFunction(aFunction)) {
2395 SetErrorCode("Offset driver failed");
2399 catch (Standard_Failure) {
2400 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2401 SetErrorCode(aFail->GetMessageString());
2405 //Make a Python command
2408 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2409 << theObject << ", " << theOffset << ")";
2415 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2416 << theObject << ", " << theOffset << ")";
2422 //=============================================================================
2426 //=============================================================================
2427 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2428 Handle(GEOM_Object) theBase1,
2429 Handle(GEOM_Object) theBase2)
2433 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2435 // Add a new Path object
2436 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2438 // Add a new Path function
2439 Handle(GEOM_Function) aFunction =
2440 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2441 if (aFunction.IsNull()) return NULL;
2443 // Check if the function is set correctly
2444 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2446 GEOMImpl_IPipePath aCI (aFunction);
2448 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2449 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2450 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2452 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2454 aCI.SetShape(aRefShape);
2455 aCI.SetBase1(aRefBase1);
2456 aCI.SetBase2(aRefBase2);
2458 // Compute the Path value
2460 #if OCC_VERSION_LARGE > 0x06010000
2463 if (!GetSolver()->ComputeFunction(aFunction)) {
2464 SetErrorCode("PipePath driver failed");
2468 catch (Standard_Failure) {
2469 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2470 SetErrorCode("RestorePath: inappropriate arguments given");
2474 // Make a Python command
2475 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2476 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2482 //=============================================================================
2486 //=============================================================================
2487 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2488 (Handle(GEOM_Object) theShape,
2489 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2490 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2494 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2496 Standard_Integer nbBases1 = theBase1->Length();
2497 Standard_Integer nbBases2 = theBase2->Length();
2499 if (!nbBases1 || !nbBases2)
2502 // Add a new Path object
2503 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2505 // Add a new Path function
2506 Handle(GEOM_Function) aFunction =
2507 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2508 if (aFunction.IsNull()) return NULL;
2510 // Check if the function is set correctly
2511 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2513 GEOMImpl_IPipePath aCI (aFunction);
2515 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2516 if (aRefShape.IsNull()) return NULL;
2518 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2519 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2522 for (i = 1; i <= nbBases1; i++) {
2523 Handle(Standard_Transient) anItem = theBase1->Value(i);
2524 if (!anItem.IsNull()) {
2525 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2526 if (!aBase.IsNull()) {
2527 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2528 if (!aRefBase.IsNull())
2529 aSeqBases1->Append(aRefBase);
2533 for (i = 1; i <= nbBases2; i++) {
2534 Handle(Standard_Transient) anItem = theBase2->Value(i);
2535 if (!anItem.IsNull()) {
2536 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2537 if (!aBase.IsNull()) {
2538 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2539 if (!aRefBase.IsNull())
2540 aSeqBases2->Append(aRefBase);
2544 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2546 aCI.SetShape(aRefShape);
2547 aCI.SetBaseSeq1(aSeqBases1);
2548 aCI.SetBaseSeq2(aSeqBases2);
2550 // Compute the Path value
2552 #if OCC_VERSION_LARGE > 0x06010000
2555 if (!GetSolver()->ComputeFunction(aFunction)) {
2556 SetErrorCode("PipePath driver failed");
2560 catch (Standard_Failure) {
2561 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2562 SetErrorCode("RestorePath: inappropriate arguments given");
2566 // Make a Python command
2567 GEOM::TPythonDump pyDump (aFunction);
2568 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2569 for (i = 1; i <= nbBases1; i++) {
2570 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2571 if (!anObj.IsNull()) {
2578 for (i = 1; i <= nbBases2; i++) {
2579 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2580 if (!anObj.IsNull()) {