1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_I3DPrimOperations.hxx>
24 #include "utilities.h"
26 #include <Utils_ExceptHandlers.hxx>
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
36 #include <GEOMImpl_Types.hxx>
38 #include <GEOMImpl_BoxDriver.hxx>
39 #include <GEOMImpl_FaceDriver.hxx>
40 #include <GEOMImpl_DiskDriver.hxx>
41 #include <GEOMImpl_CylinderDriver.hxx>
42 #include <GEOMImpl_ConeDriver.hxx>
43 #include <GEOMImpl_SphereDriver.hxx>
44 #include <GEOMImpl_TorusDriver.hxx>
45 #include <GEOMImpl_PrismDriver.hxx>
46 #include <GEOMImpl_PipeDriver.hxx>
47 #include <GEOMImpl_RevolutionDriver.hxx>
48 #include <GEOMImpl_ShapeDriver.hxx>
49 #include <GEOMImpl_FillingDriver.hxx>
50 #include <GEOMImpl_ThruSectionsDriver.hxx>
52 #include <GEOMImpl_IBox.hxx>
53 #include <GEOMImpl_IFace.hxx>
54 #include <GEOMImpl_IDisk.hxx>
55 #include <GEOMImpl_ICylinder.hxx>
56 #include <GEOMImpl_ICone.hxx>
57 #include <GEOMImpl_ISphere.hxx>
58 #include <GEOMImpl_ITorus.hxx>
59 #include <GEOMImpl_IPrism.hxx>
60 #include <GEOMImpl_IPipe.hxx>
61 #include <GEOMImpl_IRevolution.hxx>
62 #include <GEOMImpl_IShapes.hxx>
63 #include <GEOMImpl_IFilling.hxx>
64 #include <GEOMImpl_IThruSections.hxx>
65 #include <GEOMImpl_IPipeDiffSect.hxx>
66 #include <GEOMImpl_IPipeShellSect.hxx>
67 #include <GEOMImpl_IPipeBiNormal.hxx>
69 #include <Standard_Failure.hxx>
70 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
72 //=============================================================================
76 //=============================================================================
77 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
78 : GEOM_IOperations(theEngine, theDocID)
80 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
83 //=============================================================================
87 //=============================================================================
88 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
90 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
94 //=============================================================================
98 //=============================================================================
99 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
103 //Add a new Box object
104 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
106 //Add a new Box function with DX_DY_DZ parameters
107 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
108 if (aFunction.IsNull()) return NULL;
110 //Check if the function is set correctly
111 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
113 GEOMImpl_IBox aBI (aFunction);
119 //Compute the box value
121 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
124 if (!GetSolver()->ComputeFunction(aFunction)) {
125 SetErrorCode("Box driver failed");
129 catch (Standard_Failure) {
130 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
131 SetErrorCode(aFail->GetMessageString());
135 //Make a Python command
136 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
137 << theDX << ", " << theDY << ", " << theDZ << ")";
144 //=============================================================================
148 //=============================================================================
149 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
150 Handle(GEOM_Object) thePnt2)
154 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
156 //Add a new Box object
157 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
159 //Add a new Box function for creation a box relatively to two points
160 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
161 if (aFunction.IsNull()) return NULL;
163 //Check if the function is set correctly
164 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
166 GEOMImpl_IBox aBI (aFunction);
168 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
169 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
171 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
173 aBI.SetRef1(aRefFunction1);
174 aBI.SetRef2(aRefFunction2);
176 //Compute the Box value
178 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
181 if (!GetSolver()->ComputeFunction(aFunction)) {
182 SetErrorCode("Box driver failed");
186 catch (Standard_Failure) {
187 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
188 SetErrorCode(aFail->GetMessageString());
192 //Make a Python command
193 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
194 << thePnt1 << ", " << thePnt2 << ")";
200 //=============================================================================
204 //=============================================================================
205 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
209 if (theH == 0 || theW == 0) return NULL;
211 //Add a new Face object
212 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
214 //Add a new Box function for creation a box relatively to two points
215 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
216 if (aFunction.IsNull()) return NULL;
218 //Check if the function is set correctly
219 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
221 GEOMImpl_IFace aFI (aFunction);
225 aFI.SetOrientation(theOrientation);
229 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
232 if (!GetSolver()->ComputeFunction(aFunction)) {
233 SetErrorCode("Face driver failed");
237 catch (Standard_Failure) {
238 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
239 SetErrorCode(aFail->GetMessageString());
243 //Make a Python command
244 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
245 << theH << ", " << theW << ", " << theOrientation << ")";
251 //=============================================================================
255 //=============================================================================
256 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
257 double theH, double theW)
261 if (theObj.IsNull()) return NULL;
263 //Add a new Face object
264 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
266 //Add a new Box function for creation a box relatively to two points
267 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
268 if (aFunction.IsNull()) return NULL;
270 //Check if the function is set correctly
271 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
273 GEOMImpl_IFace aFI (aFunction);
275 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
277 if (aRefFunction1.IsNull())
280 aFI.SetRef1(aRefFunction1);
286 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
289 if (!GetSolver()->ComputeFunction(aFunction)) {
290 SetErrorCode("Face driver failed");
294 catch (Standard_Failure) {
295 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
296 SetErrorCode(aFail->GetMessageString());
300 //Make a Python command
301 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
302 << theObj << ", " << theH << ", " << theW << ")";
308 //=============================================================================
312 //=============================================================================
313 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
314 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
318 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
320 //Add a new Disk object
321 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
323 //Add a new Disk function for creation a disk relatively to point and vector
324 Handle(GEOM_Function) aFunction =
325 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
326 if (aFunction.IsNull()) return NULL;
328 //Check if the function is set correctly
329 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
331 GEOMImpl_IDisk aCI (aFunction);
333 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
334 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
336 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
338 aCI.SetCenter(aRefPnt);
339 aCI.SetVector(aRefVec);
342 //Compute the Disk value
344 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
347 if (!GetSolver()->ComputeFunction(aFunction)) {
348 SetErrorCode("Disk driver failed");
352 catch (Standard_Failure) {
353 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
354 SetErrorCode(aFail->GetMessageString());
358 //Make a Python command
359 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
360 << thePnt << ", " << theVec << ", " << theR << ")";
366 //=============================================================================
370 //=============================================================================
371 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
372 Handle(GEOM_Object) thePnt2,
373 Handle(GEOM_Object) thePnt3)
377 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
379 //Add a new Disk object
380 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
382 //Add a new Disk function for creation a disk relatively to three points
383 Handle(GEOM_Function) aFunction =
384 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
385 if (aFunction.IsNull()) return NULL;
387 //Check if the function is set correctly
388 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
390 GEOMImpl_IDisk aCI (aFunction);
392 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
393 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
394 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
396 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
398 aCI.SetPoint1(aRefPnt1);
399 aCI.SetPoint2(aRefPnt2);
400 aCI.SetPoint3(aRefPnt3);
402 //Compute the Disk value
404 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
407 if (!GetSolver()->ComputeFunction(aFunction)) {
408 SetErrorCode("Disk driver failed");
412 catch (Standard_Failure) {
413 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
414 SetErrorCode(aFail->GetMessageString());
418 //Make a Python command
419 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
420 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
426 //=============================================================================
430 //=============================================================================
431 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
435 if (theR == 0 ) return NULL;
437 //Add a new Disk object
438 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
440 //Add a new Box function for creation a box relatively to two points
441 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
442 if (aFunction.IsNull()) return NULL;
444 //Check if the function is set correctly
445 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
447 GEOMImpl_IDisk aDI (aFunction);
450 aDI.SetOrientation(theOrientation);
454 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
457 if (!GetSolver()->ComputeFunction(aFunction)) {
458 SetErrorCode("Disk driver failed");
462 catch (Standard_Failure) {
463 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
464 SetErrorCode(aFail->GetMessageString());
468 //Make a Python command
469 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
470 << theR << ", " << theOrientation << ")";
476 //=============================================================================
480 //=============================================================================
481 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
485 //Add a new Cylinder object
486 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
488 //Add a new Cylinder function with R and H parameters
489 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
490 if (aFunction.IsNull()) return NULL;
492 //Check if the function is set correctly
493 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
495 GEOMImpl_ICylinder aCI (aFunction);
500 //Compute the Cylinder value
502 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
505 if (!GetSolver()->ComputeFunction(aFunction)) {
506 SetErrorCode("Cylinder driver failed");
510 catch (Standard_Failure) {
511 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
512 SetErrorCode(aFail->GetMessageString());
516 //Make a Python command
517 GEOM::TPythonDump(aFunction) << aCylinder
518 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
525 //=============================================================================
527 * MakeCylinderPntVecRH
529 //=============================================================================
530 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
531 Handle(GEOM_Object) theVec,
532 double theR, double theH)
536 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
538 //Add a new Cylinder object
539 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
541 //Add a new Cylinder function for creation a cylinder relatively to point and vector
542 Handle(GEOM_Function) aFunction =
543 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
544 if (aFunction.IsNull()) return NULL;
546 //Check if the function is set correctly
547 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
549 GEOMImpl_ICylinder aCI (aFunction);
551 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
552 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
554 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
556 aCI.SetPoint(aRefPnt);
557 aCI.SetVector(aRefVec);
561 //Compute the Cylinder value
563 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
566 if (!GetSolver()->ComputeFunction(aFunction)) {
567 SetErrorCode("Cylinder driver failed");
571 catch (Standard_Failure) {
572 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
573 SetErrorCode(aFail->GetMessageString());
577 //Make a Python command
578 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
579 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
586 //=============================================================================
590 //=============================================================================
591 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
596 //Add a new Cone object
597 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
599 //Add a new Cone function with R and H parameters
600 Handle(GEOM_Function) aFunction =
601 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
602 if (aFunction.IsNull()) return NULL;
604 //Check if the function is set correctly
605 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
607 GEOMImpl_ICone aCI (aFunction);
613 //Compute the Cone value
615 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
618 if (!GetSolver()->ComputeFunction(aFunction)) {
619 SetErrorCode("Cone driver failed");
623 catch (Standard_Failure) {
624 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
625 SetErrorCode(aFail->GetMessageString());
629 //Make a Python command
630 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
631 << theR1 << ", " << theR2 << ", " << theH << ")";
638 //=============================================================================
640 * MakeConePntVecR1R2H
642 //=============================================================================
643 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
644 Handle(GEOM_Object) theVec,
645 double theR1, double theR2,
650 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
652 //Add a new Cone object
653 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
655 //Add a new Cone function for creation a cone relatively to point and vector
656 Handle(GEOM_Function) aFunction =
657 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
658 if (aFunction.IsNull()) return NULL;
660 //Check if the function is set correctly
661 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
663 GEOMImpl_ICone aCI (aFunction);
665 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
666 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
668 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
670 aCI.SetPoint(aRefPnt);
671 aCI.SetVector(aRefVec);
676 //Compute the Cone value
678 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
681 if (!GetSolver()->ComputeFunction(aFunction)) {
682 SetErrorCode("Cone driver failed");
686 catch (Standard_Failure) {
687 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
688 SetErrorCode(aFail->GetMessageString());
692 //Make a Python command
693 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
694 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
701 //=============================================================================
705 //=============================================================================
706 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
710 //Add a new Sphere object
711 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
713 //Add a new Sphere function with R parameter
714 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
715 if (aFunction.IsNull()) return NULL;
717 //Check if the function is set correctly
718 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
720 GEOMImpl_ISphere aCI (aFunction);
724 //Compute the Sphere value
726 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
729 if (!GetSolver()->ComputeFunction(aFunction)) {
730 SetErrorCode("Sphere driver failed");
734 catch (Standard_Failure) {
735 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
736 SetErrorCode(aFail->GetMessageString());
740 //Make a Python command
741 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
748 //=============================================================================
752 //=============================================================================
753 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
758 if (thePnt.IsNull()) return NULL;
760 //Add a new Point object
761 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
763 //Add a new Sphere function for creation a sphere relatively to point
764 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
765 if (aFunction.IsNull()) return NULL;
767 //Check if the function is set correctly
768 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
770 GEOMImpl_ISphere aCI (aFunction);
772 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
774 if (aRefPnt.IsNull()) return NULL;
776 aCI.SetPoint(aRefPnt);
779 //Compute the Sphere value
781 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
784 if (!GetSolver()->ComputeFunction(aFunction)) {
785 SetErrorCode("Sphere driver failed");
789 catch (Standard_Failure) {
790 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
791 SetErrorCode(aFail->GetMessageString());
795 //Make a Python command
796 GEOM::TPythonDump(aFunction) << aSphere
797 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
804 //=============================================================================
808 //=============================================================================
809 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
810 (double theRMajor, double theRMinor)
814 //Add a new Torus object
815 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
817 //Add a new Torus function
818 Handle(GEOM_Function) aFunction =
819 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
820 if (aFunction.IsNull()) return NULL;
822 //Check if the function is set correctly
823 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
825 GEOMImpl_ITorus aCI (aFunction);
827 aCI.SetRMajor(theRMajor);
828 aCI.SetRMinor(theRMinor);
830 //Compute the Torus value
832 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
835 if (!GetSolver()->ComputeFunction(aFunction)) {
836 SetErrorCode("Torus driver failed");
840 catch (Standard_Failure) {
841 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
842 SetErrorCode(aFail->GetMessageString());
846 //Make a Python command
847 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
848 << theRMajor << ", " << theRMinor << ")";
854 //=============================================================================
858 //=============================================================================
859 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
860 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
861 double theRMajor, double theRMinor)
865 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
867 //Add a new Torus object
868 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
870 //Add a new Torus function
871 Handle(GEOM_Function) aFunction =
872 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
873 if (aFunction.IsNull()) return NULL;
875 //Check if the function is set correctly
876 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
878 GEOMImpl_ITorus aCI (aFunction);
880 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
881 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
883 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
885 aCI.SetCenter(aRefPnt);
886 aCI.SetVector(aRefVec);
887 aCI.SetRMajor(theRMajor);
888 aCI.SetRMinor(theRMinor);
890 //Compute the Torus value
892 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
895 if (!GetSolver()->ComputeFunction(aFunction)) {
896 SetErrorCode("Torus driver failed");
900 catch (Standard_Failure) {
901 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
902 SetErrorCode(aFail->GetMessageString());
906 //Make a Python command
907 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
908 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
915 //=============================================================================
919 //=============================================================================
920 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
921 Handle(GEOM_Object) theVec,
926 if (theBase.IsNull() || theVec.IsNull()) return NULL;
928 //Add a new Prism object
929 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
931 //Add a new Prism function for creation a Prism relatively to vector
932 Handle(GEOM_Function) aFunction =
933 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
934 if (aFunction.IsNull()) return NULL;
936 //Check if the function is set correctly
937 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
939 GEOMImpl_IPrism aCI (aFunction);
941 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
942 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
944 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
946 aCI.SetBase(aRefBase);
947 aCI.SetVector(aRefVec);
950 //Compute the Prism value
952 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
955 if (!GetSolver()->ComputeFunction(aFunction)) {
956 //SetErrorCode("Prism driver failed");
957 SetErrorCode("Extrusion can not be created, check input data");
961 catch (Standard_Failure) {
962 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
963 SetErrorCode(aFail->GetMessageString());
967 //Make a Python command
968 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
969 << theBase << ", " << theVec << ", " << theH << ")";
975 //=============================================================================
979 //=============================================================================
980 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
981 Handle(GEOM_Object) theVec,
986 if (theBase.IsNull() || theVec.IsNull()) return NULL;
988 //Add a new Prism object
989 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
991 //Add a new Prism function for creation a Prism relatively to vector
992 Handle(GEOM_Function) aFunction =
993 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
994 if (aFunction.IsNull()) return NULL;
996 //Check if the function is set correctly
997 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
999 GEOMImpl_IPrism aCI (aFunction);
1001 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1002 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1004 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1006 aCI.SetBase(aRefBase);
1007 aCI.SetVector(aRefVec);
1010 //Compute the Prism value
1012 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1015 if (!GetSolver()->ComputeFunction(aFunction)) {
1016 //SetErrorCode("Prism driver failed");
1017 SetErrorCode("Extrusion can not be created, check input data");
1021 catch (Standard_Failure) {
1022 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1023 SetErrorCode(aFail->GetMessageString());
1027 //Make a Python command
1028 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1029 << theBase << ", " << theVec << ", " << theH << ")";
1035 //=============================================================================
1039 //=============================================================================
1040 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1041 (Handle(GEOM_Object) theBase,
1042 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1046 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1048 //Add a new Prism object
1049 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1051 //Add a new Prism function for creation a Prism relatively to two points
1052 Handle(GEOM_Function) aFunction =
1053 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1054 if (aFunction.IsNull()) return NULL;
1056 //Check if the function is set correctly
1057 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1059 GEOMImpl_IPrism aCI (aFunction);
1061 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1062 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1063 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1065 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1067 aCI.SetBase(aRefBase);
1068 aCI.SetFirstPoint(aRefPnt1);
1069 aCI.SetLastPoint(aRefPnt2);
1071 //Compute the Prism value
1073 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1076 if (!GetSolver()->ComputeFunction(aFunction)) {
1077 //SetErrorCode("Prism driver failed");
1078 SetErrorCode("Extrusion can not be created, check input data");
1082 catch (Standard_Failure) {
1083 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1084 SetErrorCode(aFail->GetMessageString());
1088 //Make a Python command
1089 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
1090 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1096 //=============================================================================
1098 * MakePrismTwoPnt2Ways
1100 //=============================================================================
1101 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1102 (Handle(GEOM_Object) theBase,
1103 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1107 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1109 //Add a new Prism object
1110 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1112 //Add a new Prism function for creation a Prism relatively to two points
1113 Handle(GEOM_Function) aFunction =
1114 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1115 if (aFunction.IsNull()) return NULL;
1117 //Check if the function is set correctly
1118 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1120 GEOMImpl_IPrism aCI (aFunction);
1122 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1123 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1124 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1126 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1128 aCI.SetBase(aRefBase);
1129 aCI.SetFirstPoint(aRefPnt1);
1130 aCI.SetLastPoint(aRefPnt2);
1132 //Compute the Prism value
1134 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1137 if (!GetSolver()->ComputeFunction(aFunction)) {
1138 //SetErrorCode("Prism driver failed");
1139 SetErrorCode("Extrusion can not be created, check input data");
1143 catch (Standard_Failure) {
1144 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1145 SetErrorCode(aFail->GetMessageString());
1149 //Make a Python command
1150 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1151 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1157 //=============================================================================
1161 //=============================================================================
1162 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1163 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1167 if (theBase.IsNull()) return NULL;
1169 //Add a new Prism object
1170 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1172 //Add a new Prism function for creation a Prism by DXDYDZ
1173 Handle(GEOM_Function) aFunction =
1174 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1175 if (aFunction.IsNull()) return NULL;
1177 //Check if the function is set correctly
1178 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1180 GEOMImpl_IPrism aCI (aFunction);
1182 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1184 if (aRefBase.IsNull()) return NULL;
1186 aCI.SetBase(aRefBase);
1191 //Compute the Prism value
1193 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1196 if (!GetSolver()->ComputeFunction(aFunction)) {
1197 SetErrorCode("Extrusion can not be created, check input data");
1201 catch (Standard_Failure) {
1202 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1203 SetErrorCode(aFail->GetMessageString());
1207 //Make a Python command
1208 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ("
1209 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1215 //=============================================================================
1217 * MakePrismDXDYDZ_2WAYS
1219 //=============================================================================
1220 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1221 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1225 if (theBase.IsNull()) return NULL;
1227 //Add a new Prism object
1228 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1230 //Add a new Prism function for creation a Prism by DXDYDZ
1231 Handle(GEOM_Function) aFunction =
1232 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1233 if (aFunction.IsNull()) return NULL;
1235 //Check if the function is set correctly
1236 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1238 GEOMImpl_IPrism aCI (aFunction);
1240 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1242 if (aRefBase.IsNull()) return NULL;
1244 aCI.SetBase(aRefBase);
1249 //Compute the Prism value
1251 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1254 if (!GetSolver()->ComputeFunction(aFunction)) {
1255 SetErrorCode("Extrusion can not be created, check input data");
1259 catch (Standard_Failure) {
1260 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1261 SetErrorCode(aFail->GetMessageString());
1265 //Make a Python command
1266 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1267 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1273 //=============================================================================
1277 //=============================================================================
1278 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1279 Handle(GEOM_Object) thePath)
1283 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1285 //Add a new Pipe object
1286 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1288 //Add a new Pipe function
1289 Handle(GEOM_Function) aFunction =
1290 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1291 if (aFunction.IsNull()) return NULL;
1293 //Check if the function is set correctly
1294 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1296 GEOMImpl_IPipe aCI (aFunction);
1298 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1299 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1301 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1303 aCI.SetBase(aRefBase);
1304 aCI.SetPath(aRefPath);
1306 //Compute the Pipe value
1308 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1311 if (!GetSolver()->ComputeFunction(aFunction)) {
1312 SetErrorCode("Pipe driver failed");
1316 catch (Standard_Failure) {
1317 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1318 SetErrorCode(aFail->GetMessageString());
1322 //Make a Python command
1323 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1324 << theBase << ", " << thePath << ")";
1331 //=============================================================================
1333 * MakeRevolutionAxisAngle
1335 //=============================================================================
1336 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1337 Handle(GEOM_Object) theAxis,
1342 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1344 //Add a new Revolution object
1345 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1347 //Add a new Revolution function for creation a revolution relatively to axis
1348 Handle(GEOM_Function) aFunction =
1349 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1350 if (aFunction.IsNull()) return NULL;
1352 //Check if the function is set correctly
1353 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1355 GEOMImpl_IRevolution aCI (aFunction);
1357 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1358 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1360 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1362 aCI.SetBase(aRefBase);
1363 aCI.SetAxis(aRefAxis);
1364 aCI.SetAngle(theAngle);
1366 //Compute the Revolution value
1368 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1371 if (!GetSolver()->ComputeFunction(aFunction)) {
1372 SetErrorCode("Revolution driver failed");
1376 catch (Standard_Failure) {
1377 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1378 SetErrorCode(aFail->GetMessageString());
1382 //Make a Python command
1383 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1384 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1390 //=============================================================================
1392 * MakeRevolutionAxisAngle2Ways
1394 //=============================================================================
1395 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1396 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1400 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1402 //Add a new Revolution object
1403 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1405 //Add a new Revolution function for creation a revolution relatively to axis
1406 Handle(GEOM_Function) aFunction =
1407 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1408 if (aFunction.IsNull()) return NULL;
1410 //Check if the function is set correctly
1411 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1413 GEOMImpl_IRevolution aCI (aFunction);
1415 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1416 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1418 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1420 aCI.SetBase(aRefBase);
1421 aCI.SetAxis(aRefAxis);
1422 aCI.SetAngle(theAngle);
1424 //Compute the Revolution value
1426 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1429 if (!GetSolver()->ComputeFunction(aFunction)) {
1430 SetErrorCode("Revolution driver failed");
1434 catch (Standard_Failure) {
1435 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1436 SetErrorCode(aFail->GetMessageString());
1440 //Make a Python command
1441 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1442 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1448 //=============================================================================
1452 //=============================================================================
1453 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
1457 if (theShell.IsNull()) return NULL;
1459 //Add a new Solid object
1460 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
1462 //Add a new Solid function for creation a solid from a shell
1463 Handle(GEOM_Function) aFunction =
1464 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
1465 if (aFunction.IsNull()) return NULL;
1467 //Check if the function is set correctly
1468 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
1470 GEOMImpl_IShapes aCI (aFunction);
1472 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
1474 if (aRefShell.IsNull()) return NULL;
1476 aCI.SetBase(aRefShell);
1478 //Compute the Solid value
1480 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1483 if (!GetSolver()->ComputeFunction(aFunction)) {
1484 SetErrorCode("Solid driver failed");
1488 catch (Standard_Failure) {
1489 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1490 SetErrorCode(aFail->GetMessageString());
1494 //Make a Python command
1495 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
1501 //=============================================================================
1505 //=============================================================================
1506 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1507 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1508 double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1512 if (theShape.IsNull()) return NULL;
1514 //Add a new Filling object
1515 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1517 //Add a new Filling function for creation a filling from a compound
1518 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1519 if (aFunction.IsNull()) return NULL;
1521 //Check if the function is set correctly
1522 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1524 GEOMImpl_IFilling aFI (aFunction);
1526 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1528 if (aRefShape.IsNull()) return NULL;
1530 aFI.SetShape(aRefShape);
1531 aFI.SetMinDeg(theMinDeg);
1532 aFI.SetMaxDeg(theMaxDeg);
1533 aFI.SetTol2D(theTol2D);
1534 aFI.SetTol3D(theTol3D);
1535 aFI.SetNbIter(theNbIter);
1536 aFI.SetApprox(isApprox);
1538 //Compute the Solid value
1540 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1543 if (!GetSolver()->ComputeFunction(aFunction)) {
1544 SetErrorCode("Filling driver failed");
1548 catch (Standard_Failure) {
1549 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1550 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1551 SetErrorCode("B-Spline surface construction failed");
1553 SetErrorCode(aFail->GetMessageString());
1557 //Make a Python command
1558 GEOM::TPythonDump pd (aFunction);
1559 pd << aFilling << " = geompy.MakeFilling("
1560 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1561 << theTol2D << ", " << theTol3D << ", " << theNbIter;
1563 pd << ", " << isApprox;
1570 //=============================================================================
1574 //=============================================================================
1575 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1576 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1581 Handle(GEOM_Object) anObj;
1583 if(theSeqSections.IsNull())
1586 Standard_Integer nbObj = theSeqSections->Length();
1590 //Add a new ThruSections object
1591 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1594 //Add a new ThruSections function
1596 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1597 Handle(GEOM_Function) aFunction =
1598 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1599 if (aFunction.IsNull()) return anObj;
1601 //Check if the function is set correctly
1602 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1604 GEOMImpl_IThruSections aCI (aFunction);
1606 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1608 Standard_Integer i =1;
1609 for( ; i <= nbObj; i++) {
1611 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1615 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1616 if(!aSectObj.IsNull())
1618 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1619 if(!aRefSect.IsNull())
1620 aSeqSections->Append(aRefSect);
1624 if(!aSeqSections->Length())
1627 aCI.SetSections(aSeqSections);
1628 aCI.SetSolidMode(theModeSolid);
1629 aCI.SetPrecision(thePreci);
1631 //Compute the ThruSections value
1633 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1636 if (!GetSolver()->ComputeFunction(aFunction)) {
1637 SetErrorCode("ThruSections driver failed");
1641 catch (Standard_Failure) {
1642 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1643 SetErrorCode(aFail->GetMessageString());
1647 //Make a Python command
1648 GEOM::TPythonDump pyDump(aFunction);
1649 pyDump << aThruSect << " = geompy.MakeThruSections([";
1651 for(i =1 ; i <= nbObj; i++) {
1653 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1657 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1658 if(!aSectObj.IsNull()) {
1665 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1674 //=============================================================================
1676 * MakePipeWithDifferentSections
1678 //=============================================================================
1679 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1680 const Handle(TColStd_HSequenceOfTransient)& theBases,
1681 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1682 const Handle(GEOM_Object)& thePath,
1683 bool theWithContact,
1684 bool theWithCorrections)
1686 Handle(GEOM_Object) anObj;
1688 if(theBases.IsNull())
1691 Standard_Integer nbBases = theBases->Length();
1696 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1697 //Add a new Pipe object
1698 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1700 //Add a new Pipe function
1702 Handle(GEOM_Function) aFunction =
1703 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1704 if (aFunction.IsNull()) return anObj;
1706 //Check if the function is set correctly
1707 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1709 GEOMImpl_IPipeDiffSect aCI (aFunction);
1711 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1712 if(aRefPath.IsNull())
1715 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1716 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1718 Standard_Integer i =1;
1719 for( ; i <= nbBases; i++) {
1721 Handle(Standard_Transient) anItem = theBases->Value(i);
1725 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1728 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1729 if(aRefBase.IsNull())
1733 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1734 if(anItemLoc.IsNull())
1737 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1740 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1741 if(aRefLoc.IsNull())
1743 aSeqLocs->Append(aRefLoc);
1745 aSeqBases->Append(aRefBase);
1748 if(!aSeqBases->Length())
1751 aCI.SetBases(aSeqBases);
1752 aCI.SetLocations(aSeqLocs);
1753 aCI.SetPath(aRefPath);
1754 aCI.SetWithContactMode(theWithContact);
1755 aCI.SetWithCorrectionMode(theWithCorrections);
1757 //Compute the Pipe value
1759 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1762 if (!GetSolver()->ComputeFunction(aFunction)) {
1763 SetErrorCode("Pipe with defferent section driver failed");
1767 catch (Standard_Failure) {
1768 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1769 SetErrorCode(aFail->GetMessageString());
1773 //Make a Python command
1774 GEOM::TPythonDump pyDump(aFunction);
1775 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1777 for(i =1 ; i <= nbBases; i++) {
1779 Handle(Standard_Transient) anItem = theBases->Value(i);
1783 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1784 if(!anObj.IsNull()) {
1794 for(i =1 ; i <= nbLocs; i++) {
1796 Handle(Standard_Transient) anItem = theLocations->Value(i);
1800 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1801 if(!anObj.IsNull()) {
1808 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1817 //=============================================================================
1819 * MakePipeWithShellSections
1821 //=============================================================================
1822 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1823 const Handle(TColStd_HSequenceOfTransient)& theBases,
1824 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1825 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1826 const Handle(GEOM_Object)& thePath,
1827 bool theWithContact,
1828 bool theWithCorrections)
1830 Handle(GEOM_Object) anObj;
1832 if(theBases.IsNull())
1835 Standard_Integer nbBases = theBases->Length();
1840 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1842 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1844 //Add a new Pipe object
1845 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1847 //Add a new Pipe function
1849 Handle(GEOM_Function) aFunction =
1850 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1851 if (aFunction.IsNull()) return anObj;
1853 //Check if the function is set correctly
1854 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1856 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1857 GEOMImpl_IPipeShellSect aCI (aFunction);
1859 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1860 if(aRefPath.IsNull())
1863 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1864 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1865 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1867 Standard_Integer i =1;
1868 for( ; i <= nbBases; i++) {
1870 Handle(Standard_Transient) anItem = theBases->Value(i);
1873 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1876 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1877 if(aRefBase.IsNull())
1880 if( nbSubBases >= nbBases ) {
1881 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1882 if(aSubItem.IsNull())
1884 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1885 if(aSubBase.IsNull())
1887 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1888 if(aRefSubBase.IsNull())
1890 aSeqSubBases->Append(aRefSubBase);
1894 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1895 if(anItemLoc.IsNull())
1897 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1900 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1901 if(aRefLoc.IsNull())
1903 aSeqLocs->Append(aRefLoc);
1906 aSeqBases->Append(aRefBase);
1909 if(!aSeqBases->Length())
1912 aCI.SetBases(aSeqBases);
1913 aCI.SetSubBases(aSeqSubBases);
1914 aCI.SetLocations(aSeqLocs);
1915 aCI.SetPath(aRefPath);
1916 aCI.SetWithContactMode(theWithContact);
1917 aCI.SetWithCorrectionMode(theWithCorrections);
1919 //Compute the Pipe value
1921 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1924 if (!GetSolver()->ComputeFunction(aFunction)) {
1925 SetErrorCode("Pipe with shell sections driver failed");
1929 catch (Standard_Failure) {
1930 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1931 SetErrorCode(aFail->GetMessageString());
1935 //Make a Python command
1936 GEOM::TPythonDump pyDump(aFunction);
1937 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1939 for(i =1 ; i <= nbBases; i++) {
1941 Handle(Standard_Transient) anItem = theBases->Value(i);
1945 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1946 if(!anObj.IsNull()) {
1956 for(i =1 ; i <= nbSubBases; i++) {
1958 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1962 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1963 if(!anObj.IsNull()) {
1973 for(i =1 ; i <= nbLocs; i++) {
1975 Handle(Standard_Transient) anItem = theLocations->Value(i);
1979 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1980 if(!anObj.IsNull()) {
1987 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1995 //=============================================================================
1997 * MakePipeShellsWithoutPath
1999 //=============================================================================
2000 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2001 const Handle(TColStd_HSequenceOfTransient)& theBases,
2002 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2004 Handle(GEOM_Object) anObj;
2006 if(theBases.IsNull())
2009 Standard_Integer nbBases = theBases->Length();
2014 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2016 //Add a new Pipe object
2017 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2019 //Add a new Pipe function
2021 Handle(GEOM_Function) aFunction =
2022 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2023 if (aFunction.IsNull()) return anObj;
2025 //Check if the function is set correctly
2026 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2028 GEOMImpl_IPipeShellSect aCI (aFunction);
2030 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2031 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2033 Standard_Integer i =1;
2034 for( ; i <= nbBases; i++) {
2036 Handle(Standard_Transient) anItem = theBases->Value(i);
2039 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2042 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2043 if(aRefBase.IsNull())
2047 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2048 if(anItemLoc.IsNull())
2050 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2053 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2054 if(aRefLoc.IsNull())
2056 aSeqLocs->Append(aRefLoc);
2059 aSeqBases->Append(aRefBase);
2062 if(!aSeqBases->Length())
2065 aCI.SetBases(aSeqBases);
2066 aCI.SetLocations(aSeqLocs);
2068 //Compute the Pipe value
2070 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2073 if (!GetSolver()->ComputeFunction(aFunction)) {
2074 SetErrorCode("Pipe with shell sections without path driver failed");
2078 catch (Standard_Failure) {
2079 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2080 SetErrorCode(aFail->GetMessageString());
2084 //Make a Python command
2085 GEOM::TPythonDump pyDump(aFunction);
2086 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2088 for(i =1 ; i <= nbBases; i++) {
2090 Handle(Standard_Transient) anItem = theBases->Value(i);
2094 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2095 if(!anObj.IsNull()) {
2105 for(i =1 ; i <= nbLocs; i++) {
2107 Handle(Standard_Transient) anItem = theLocations->Value(i);
2111 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2112 if(!anObj.IsNull()) {
2127 //=============================================================================
2129 * MakePipeBiNormalAlongVector
2131 //=============================================================================
2132 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2133 Handle(GEOM_Object) thePath,
2134 Handle(GEOM_Object) theVec)
2138 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2140 //Add a new Pipe object
2141 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2143 //Add a new Pipe function
2144 Handle(GEOM_Function) aFunction =
2145 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2146 if (aFunction.IsNull()) return NULL;
2148 //Check if the function is set correctly
2149 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2151 GEOMImpl_IPipeBiNormal aCI (aFunction);
2153 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2154 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2155 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2157 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2159 aCI.SetBase(aRefBase);
2160 aCI.SetPath(aRefPath);
2161 aCI.SetVector(aRefVec);
2163 //Compute the Pipe value
2165 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2168 if (!GetSolver()->ComputeFunction(aFunction)) {
2169 SetErrorCode("Pipe driver failed");
2173 catch (Standard_Failure) {
2174 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2175 SetErrorCode(aFail->GetMessageString());
2179 //Make a Python command
2180 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2181 << theBase << ", " << thePath << ", " << theVec << ")";