1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_I3DPrimOperations.hxx>
26 #include "utilities.h"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TFunction_Logbook.hxx>
33 #include <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_Types.hxx>
40 #include <GEOMImpl_BoxDriver.hxx>
41 #include <GEOMImpl_FaceDriver.hxx>
42 #include <GEOMImpl_DiskDriver.hxx>
43 #include <GEOMImpl_CylinderDriver.hxx>
44 #include <GEOMImpl_ConeDriver.hxx>
45 #include <GEOMImpl_SphereDriver.hxx>
46 #include <GEOMImpl_TorusDriver.hxx>
47 #include <GEOMImpl_PrismDriver.hxx>
48 #include <GEOMImpl_PipeDriver.hxx>
49 #include <GEOMImpl_RevolutionDriver.hxx>
50 #include <GEOMImpl_ShapeDriver.hxx>
51 #include <GEOMImpl_FillingDriver.hxx>
52 #include <GEOMImpl_ThruSectionsDriver.hxx>
54 #include <GEOMImpl_IBox.hxx>
55 #include <GEOMImpl_IFace.hxx>
56 #include <GEOMImpl_IDisk.hxx>
57 #include <GEOMImpl_ICylinder.hxx>
58 #include <GEOMImpl_ICone.hxx>
59 #include <GEOMImpl_ISphere.hxx>
60 #include <GEOMImpl_ITorus.hxx>
61 #include <GEOMImpl_IPrism.hxx>
62 #include <GEOMImpl_IPipe.hxx>
63 #include <GEOMImpl_IRevolution.hxx>
64 #include <GEOMImpl_IFilling.hxx>
65 #include <GEOMImpl_IThruSections.hxx>
66 #include <GEOMImpl_IPipeDiffSect.hxx>
67 #include <GEOMImpl_IPipeShellSect.hxx>
68 #include <GEOMImpl_IPipeBiNormal.hxx>
70 #include <Standard_Failure.hxx>
71 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
73 //=============================================================================
77 //=============================================================================
78 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
79 : GEOM_IOperations(theEngine, theDocID)
81 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
84 //=============================================================================
88 //=============================================================================
89 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
91 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
95 //=============================================================================
99 //=============================================================================
100 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
104 //Add a new Box object
105 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
107 //Add a new Box function with DX_DY_DZ parameters
108 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
109 if (aFunction.IsNull()) return NULL;
111 //Check if the function is set correctly
112 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
114 GEOMImpl_IBox aBI (aFunction);
120 //Compute the box value
122 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
125 if (!GetSolver()->ComputeFunction(aFunction)) {
126 SetErrorCode("Box driver failed");
130 catch (Standard_Failure) {
131 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
132 SetErrorCode(aFail->GetMessageString());
136 //Make a Python command
137 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
138 << theDX << ", " << theDY << ", " << theDZ << ")";
145 //=============================================================================
149 //=============================================================================
150 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
151 Handle(GEOM_Object) thePnt2)
155 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
157 //Add a new Box object
158 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
160 //Add a new Box function for creation a box relatively to two points
161 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
162 if (aFunction.IsNull()) return NULL;
164 //Check if the function is set correctly
165 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
167 GEOMImpl_IBox aBI (aFunction);
169 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
170 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
172 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
174 aBI.SetRef1(aRefFunction1);
175 aBI.SetRef2(aRefFunction2);
177 //Compute the Box value
179 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
182 if (!GetSolver()->ComputeFunction(aFunction)) {
183 SetErrorCode("Box driver failed");
187 catch (Standard_Failure) {
188 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
189 SetErrorCode(aFail->GetMessageString());
193 //Make a Python command
194 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
195 << thePnt1 << ", " << thePnt2 << ")";
201 //=============================================================================
205 //=============================================================================
206 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
210 if (theH == 0 || theW == 0) return NULL;
212 //Add a new Face object
213 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
215 //Add a new Box function for creation a box relatively to two points
216 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
217 if (aFunction.IsNull()) return NULL;
219 //Check if the function is set correctly
220 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
222 GEOMImpl_IFace aFI (aFunction);
226 aFI.SetOrientation(theOrientation);
230 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
233 if (!GetSolver()->ComputeFunction(aFunction)) {
234 SetErrorCode("Face driver failed");
238 catch (Standard_Failure) {
239 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
240 SetErrorCode(aFail->GetMessageString());
244 //Make a Python command
245 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
246 << theH << ", " << theW << ", " << theOrientation << ")";
252 //=============================================================================
256 //=============================================================================
257 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
258 double theH, double theW)
262 if (theObj.IsNull()) return NULL;
264 //Add a new Face object
265 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
267 //Add a new Box function for creation a box relatively to two points
268 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
269 if (aFunction.IsNull()) return NULL;
271 //Check if the function is set correctly
272 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
274 GEOMImpl_IFace aFI (aFunction);
276 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
278 if (aRefFunction1.IsNull())
281 aFI.SetRef1(aRefFunction1);
287 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
290 if (!GetSolver()->ComputeFunction(aFunction)) {
291 SetErrorCode("Face driver failed");
295 catch (Standard_Failure) {
296 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
297 SetErrorCode(aFail->GetMessageString());
301 //Make a Python command
302 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
303 << theObj << ", " << theH << ", " << theW << ")";
309 //=============================================================================
313 //=============================================================================
314 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
315 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
319 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
321 //Add a new Disk object
322 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
324 //Add a new Disk function for creation a disk relatively to point and vector
325 Handle(GEOM_Function) aFunction =
326 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
327 if (aFunction.IsNull()) return NULL;
329 //Check if the function is set correctly
330 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
332 GEOMImpl_IDisk aCI (aFunction);
334 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
335 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
337 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
339 aCI.SetCenter(aRefPnt);
340 aCI.SetVector(aRefVec);
343 //Compute the Disk value
345 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
348 if (!GetSolver()->ComputeFunction(aFunction)) {
349 SetErrorCode("Disk driver failed");
353 catch (Standard_Failure) {
354 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
355 SetErrorCode(aFail->GetMessageString());
359 //Make a Python command
360 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
361 << thePnt << ", " << theVec << ", " << theR << ")";
367 //=============================================================================
371 //=============================================================================
372 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
373 Handle(GEOM_Object) thePnt2,
374 Handle(GEOM_Object) thePnt3)
378 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
380 //Add a new Disk object
381 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
383 //Add a new Disk function for creation a disk relatively to three points
384 Handle(GEOM_Function) aFunction =
385 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
386 if (aFunction.IsNull()) return NULL;
388 //Check if the function is set correctly
389 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
391 GEOMImpl_IDisk aCI (aFunction);
393 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
394 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
395 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
397 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
399 aCI.SetPoint1(aRefPnt1);
400 aCI.SetPoint2(aRefPnt2);
401 aCI.SetPoint3(aRefPnt3);
403 //Compute the Disk value
405 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
408 if (!GetSolver()->ComputeFunction(aFunction)) {
409 SetErrorCode("Disk driver failed");
413 catch (Standard_Failure) {
414 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
415 SetErrorCode(aFail->GetMessageString());
419 //Make a Python command
420 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
421 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
427 //=============================================================================
431 //=============================================================================
432 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
436 if (theR == 0 ) return NULL;
438 //Add a new Disk object
439 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
441 //Add a new Box function for creation a box relatively to two points
442 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
443 if (aFunction.IsNull()) return NULL;
445 //Check if the function is set correctly
446 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
448 GEOMImpl_IDisk aDI (aFunction);
451 aDI.SetOrientation(theOrientation);
455 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
458 if (!GetSolver()->ComputeFunction(aFunction)) {
459 SetErrorCode("Disk driver failed");
463 catch (Standard_Failure) {
464 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
465 SetErrorCode(aFail->GetMessageString());
469 //Make a Python command
470 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
471 << theR << ", " << theOrientation << ")";
477 //=============================================================================
481 //=============================================================================
482 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
486 //Add a new Cylinder object
487 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
489 //Add a new Cylinder function with R and H parameters
490 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
491 if (aFunction.IsNull()) return NULL;
493 //Check if the function is set correctly
494 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
496 GEOMImpl_ICylinder aCI (aFunction);
501 //Compute the Cylinder value
503 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
506 if (!GetSolver()->ComputeFunction(aFunction)) {
507 SetErrorCode("Cylinder driver failed");
511 catch (Standard_Failure) {
512 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
513 SetErrorCode(aFail->GetMessageString());
517 //Make a Python command
518 GEOM::TPythonDump(aFunction) << aCylinder
519 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
526 //=============================================================================
528 * MakeCylinderPntVecRH
530 //=============================================================================
531 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
532 Handle(GEOM_Object) theVec,
533 double theR, double theH)
537 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
539 //Add a new Cylinder object
540 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
542 //Add a new Cylinder function for creation a cylinder relatively to point and vector
543 Handle(GEOM_Function) aFunction =
544 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
545 if (aFunction.IsNull()) return NULL;
547 //Check if the function is set correctly
548 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
550 GEOMImpl_ICylinder aCI (aFunction);
552 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
553 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
555 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
557 aCI.SetPoint(aRefPnt);
558 aCI.SetVector(aRefVec);
562 //Compute the Cylinder value
564 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
567 if (!GetSolver()->ComputeFunction(aFunction)) {
568 SetErrorCode("Cylinder driver failed");
572 catch (Standard_Failure) {
573 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
574 SetErrorCode(aFail->GetMessageString());
578 //Make a Python command
579 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
580 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
587 //=============================================================================
591 //=============================================================================
592 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
597 //Add a new Cone object
598 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
600 //Add a new Cone function with R and H parameters
601 Handle(GEOM_Function) aFunction =
602 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
603 if (aFunction.IsNull()) return NULL;
605 //Check if the function is set correctly
606 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
608 GEOMImpl_ICone aCI (aFunction);
614 //Compute the Cone value
616 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
619 if (!GetSolver()->ComputeFunction(aFunction)) {
620 SetErrorCode("Cone driver failed");
624 catch (Standard_Failure) {
625 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
626 SetErrorCode(aFail->GetMessageString());
630 //Make a Python command
631 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
632 << theR1 << ", " << theR2 << ", " << theH << ")";
639 //=============================================================================
641 * MakeConePntVecR1R2H
643 //=============================================================================
644 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
645 Handle(GEOM_Object) theVec,
646 double theR1, double theR2,
651 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
653 //Add a new Cone object
654 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
656 //Add a new Cone function for creation a cone relatively to point and vector
657 Handle(GEOM_Function) aFunction =
658 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
659 if (aFunction.IsNull()) return NULL;
661 //Check if the function is set correctly
662 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
664 GEOMImpl_ICone aCI (aFunction);
666 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
667 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
669 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
671 aCI.SetPoint(aRefPnt);
672 aCI.SetVector(aRefVec);
677 //Compute the Cone value
679 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
682 if (!GetSolver()->ComputeFunction(aFunction)) {
683 SetErrorCode("Cone driver failed");
687 catch (Standard_Failure) {
688 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
689 SetErrorCode(aFail->GetMessageString());
693 //Make a Python command
694 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
695 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
702 //=============================================================================
706 //=============================================================================
707 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
711 //Add a new Sphere object
712 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
714 //Add a new Sphere function with R parameter
715 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
716 if (aFunction.IsNull()) return NULL;
718 //Check if the function is set correctly
719 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
721 GEOMImpl_ISphere aCI (aFunction);
725 //Compute the Sphere value
727 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
730 if (!GetSolver()->ComputeFunction(aFunction)) {
731 SetErrorCode("Sphere driver failed");
735 catch (Standard_Failure) {
736 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
737 SetErrorCode(aFail->GetMessageString());
741 //Make a Python command
742 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
749 //=============================================================================
753 //=============================================================================
754 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
759 if (thePnt.IsNull()) return NULL;
761 //Add a new Point object
762 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
764 //Add a new Sphere function for creation a sphere relatively to point
765 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
766 if (aFunction.IsNull()) return NULL;
768 //Check if the function is set correctly
769 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
771 GEOMImpl_ISphere aCI (aFunction);
773 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
775 if (aRefPnt.IsNull()) return NULL;
777 aCI.SetPoint(aRefPnt);
780 //Compute the Sphere value
782 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
785 if (!GetSolver()->ComputeFunction(aFunction)) {
786 SetErrorCode("Sphere driver failed");
790 catch (Standard_Failure) {
791 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
792 SetErrorCode(aFail->GetMessageString());
796 //Make a Python command
797 GEOM::TPythonDump(aFunction) << aSphere
798 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
805 //=============================================================================
809 //=============================================================================
810 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
811 (double theRMajor, double theRMinor)
815 //Add a new Torus object
816 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
818 //Add a new Torus function
819 Handle(GEOM_Function) aFunction =
820 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
821 if (aFunction.IsNull()) return NULL;
823 //Check if the function is set correctly
824 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
826 GEOMImpl_ITorus aCI (aFunction);
828 aCI.SetRMajor(theRMajor);
829 aCI.SetRMinor(theRMinor);
831 //Compute the Torus value
833 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
836 if (!GetSolver()->ComputeFunction(aFunction)) {
837 SetErrorCode("Torus driver failed");
841 catch (Standard_Failure) {
842 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
843 SetErrorCode(aFail->GetMessageString());
847 //Make a Python command
848 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
849 << theRMajor << ", " << theRMinor << ")";
855 //=============================================================================
859 //=============================================================================
860 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
861 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
862 double theRMajor, double theRMinor)
866 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
868 //Add a new Torus object
869 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
871 //Add a new Torus function
872 Handle(GEOM_Function) aFunction =
873 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
874 if (aFunction.IsNull()) return NULL;
876 //Check if the function is set correctly
877 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
879 GEOMImpl_ITorus aCI (aFunction);
881 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
882 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
884 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
886 aCI.SetCenter(aRefPnt);
887 aCI.SetVector(aRefVec);
888 aCI.SetRMajor(theRMajor);
889 aCI.SetRMinor(theRMinor);
891 //Compute the Torus value
893 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
896 if (!GetSolver()->ComputeFunction(aFunction)) {
897 SetErrorCode("Torus driver failed");
901 catch (Standard_Failure) {
902 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
903 SetErrorCode(aFail->GetMessageString());
907 //Make a Python command
908 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
909 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
916 //=============================================================================
920 //=============================================================================
921 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
922 Handle(GEOM_Object) theVec,
927 if (theBase.IsNull() || theVec.IsNull()) return NULL;
929 //Add a new Prism object
930 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
932 //Add a new Prism function for creation a Prism relatively to vector
933 Handle(GEOM_Function) aFunction =
934 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
935 if (aFunction.IsNull()) return NULL;
937 //Check if the function is set correctly
938 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
940 GEOMImpl_IPrism aCI (aFunction);
942 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
943 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
945 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
947 aCI.SetBase(aRefBase);
948 aCI.SetVector(aRefVec);
951 //Compute the Prism value
953 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
956 if (!GetSolver()->ComputeFunction(aFunction)) {
957 //SetErrorCode("Prism driver failed");
958 SetErrorCode("Extrusion can not be created, check input data");
962 catch (Standard_Failure) {
963 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
964 SetErrorCode(aFail->GetMessageString());
968 //Make a Python command
969 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
970 << theBase << ", " << theVec << ", " << theH << ")";
976 //=============================================================================
980 //=============================================================================
981 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
982 Handle(GEOM_Object) theVec,
987 if (theBase.IsNull() || theVec.IsNull()) return NULL;
989 //Add a new Prism object
990 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
992 //Add a new Prism function for creation a Prism relatively to vector
993 Handle(GEOM_Function) aFunction =
994 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
995 if (aFunction.IsNull()) return NULL;
997 //Check if the function is set correctly
998 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1000 GEOMImpl_IPrism aCI (aFunction);
1002 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1003 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1005 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1007 aCI.SetBase(aRefBase);
1008 aCI.SetVector(aRefVec);
1011 //Compute the Prism value
1013 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1016 if (!GetSolver()->ComputeFunction(aFunction)) {
1017 //SetErrorCode("Prism driver failed");
1018 SetErrorCode("Extrusion can not be created, check input data");
1022 catch (Standard_Failure) {
1023 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1024 SetErrorCode(aFail->GetMessageString());
1028 //Make a Python command
1029 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1030 << theBase << ", " << theVec << ", " << theH << ")";
1036 //=============================================================================
1040 //=============================================================================
1041 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1042 (Handle(GEOM_Object) theBase,
1043 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1047 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1049 //Add a new Prism object
1050 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1052 //Add a new Prism function for creation a Prism relatively to two points
1053 Handle(GEOM_Function) aFunction =
1054 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1055 if (aFunction.IsNull()) return NULL;
1057 //Check if the function is set correctly
1058 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1060 GEOMImpl_IPrism aCI (aFunction);
1062 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1063 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1064 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1066 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1068 aCI.SetBase(aRefBase);
1069 aCI.SetFirstPoint(aRefPnt1);
1070 aCI.SetLastPoint(aRefPnt2);
1072 //Compute the Prism value
1074 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1077 if (!GetSolver()->ComputeFunction(aFunction)) {
1078 //SetErrorCode("Prism driver failed");
1079 SetErrorCode("Extrusion can not be created, check input data");
1083 catch (Standard_Failure) {
1084 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1085 SetErrorCode(aFail->GetMessageString());
1089 //Make a Python command
1090 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
1091 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1097 //=============================================================================
1099 * MakePrismTwoPnt2Ways
1101 //=============================================================================
1102 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1103 (Handle(GEOM_Object) theBase,
1104 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1108 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1110 //Add a new Prism object
1111 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1113 //Add a new Prism function for creation a Prism relatively to two points
1114 Handle(GEOM_Function) aFunction =
1115 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1116 if (aFunction.IsNull()) return NULL;
1118 //Check if the function is set correctly
1119 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1121 GEOMImpl_IPrism aCI (aFunction);
1123 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1124 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1125 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1127 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1129 aCI.SetBase(aRefBase);
1130 aCI.SetFirstPoint(aRefPnt1);
1131 aCI.SetLastPoint(aRefPnt2);
1133 //Compute the Prism value
1135 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1138 if (!GetSolver()->ComputeFunction(aFunction)) {
1139 //SetErrorCode("Prism driver failed");
1140 SetErrorCode("Extrusion can not be created, check input data");
1144 catch (Standard_Failure) {
1145 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1146 SetErrorCode(aFail->GetMessageString());
1150 //Make a Python command
1151 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1152 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1158 //=============================================================================
1162 //=============================================================================
1163 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1164 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1168 if (theBase.IsNull()) return NULL;
1170 //Add a new Prism object
1171 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1173 //Add a new Prism function for creation a Prism by DXDYDZ
1174 Handle(GEOM_Function) aFunction =
1175 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1176 if (aFunction.IsNull()) return NULL;
1178 //Check if the function is set correctly
1179 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1181 GEOMImpl_IPrism aCI (aFunction);
1183 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1185 if (aRefBase.IsNull()) return NULL;
1187 aCI.SetBase(aRefBase);
1192 //Compute the Prism value
1194 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1197 if (!GetSolver()->ComputeFunction(aFunction)) {
1198 SetErrorCode("Extrusion can not be created, check input data");
1202 catch (Standard_Failure) {
1203 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1204 SetErrorCode(aFail->GetMessageString());
1208 //Make a Python command
1209 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ("
1210 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1216 //=============================================================================
1218 * MakePrismDXDYDZ_2WAYS
1220 //=============================================================================
1221 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1222 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1226 if (theBase.IsNull()) return NULL;
1228 //Add a new Prism object
1229 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1231 //Add a new Prism function for creation a Prism by DXDYDZ
1232 Handle(GEOM_Function) aFunction =
1233 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1234 if (aFunction.IsNull()) return NULL;
1236 //Check if the function is set correctly
1237 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1239 GEOMImpl_IPrism aCI (aFunction);
1241 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1243 if (aRefBase.IsNull()) return NULL;
1245 aCI.SetBase(aRefBase);
1250 //Compute the Prism value
1252 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1255 if (!GetSolver()->ComputeFunction(aFunction)) {
1256 SetErrorCode("Extrusion can not be created, check input data");
1260 catch (Standard_Failure) {
1261 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1262 SetErrorCode(aFail->GetMessageString());
1266 //Make a Python command
1267 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1268 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1274 //=============================================================================
1278 //=============================================================================
1279 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1280 Handle(GEOM_Object) thePath)
1284 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1286 //Add a new Pipe object
1287 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1289 //Add a new Pipe function
1290 Handle(GEOM_Function) aFunction =
1291 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1292 if (aFunction.IsNull()) return NULL;
1294 //Check if the function is set correctly
1295 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1297 GEOMImpl_IPipe aCI (aFunction);
1299 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1300 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1302 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1304 aCI.SetBase(aRefBase);
1305 aCI.SetPath(aRefPath);
1307 //Compute the Pipe value
1309 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1312 if (!GetSolver()->ComputeFunction(aFunction)) {
1313 SetErrorCode("Pipe driver failed");
1317 catch (Standard_Failure) {
1318 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1319 SetErrorCode(aFail->GetMessageString());
1323 //Make a Python command
1324 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1325 << theBase << ", " << thePath << ")";
1332 //=============================================================================
1334 * MakeRevolutionAxisAngle
1336 //=============================================================================
1337 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1338 Handle(GEOM_Object) theAxis,
1343 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1345 //Add a new Revolution object
1346 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1348 //Add a new Revolution function for creation a revolution relatively to axis
1349 Handle(GEOM_Function) aFunction =
1350 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1351 if (aFunction.IsNull()) return NULL;
1353 //Check if the function is set correctly
1354 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1356 GEOMImpl_IRevolution aCI (aFunction);
1358 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1359 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1361 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1363 aCI.SetBase(aRefBase);
1364 aCI.SetAxis(aRefAxis);
1365 aCI.SetAngle(theAngle);
1367 //Compute the Revolution value
1369 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1372 if (!GetSolver()->ComputeFunction(aFunction)) {
1373 SetErrorCode("Revolution driver failed");
1377 catch (Standard_Failure) {
1378 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1379 SetErrorCode(aFail->GetMessageString());
1383 //Make a Python command
1384 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1385 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1391 //=============================================================================
1393 * MakeRevolutionAxisAngle2Ways
1395 //=============================================================================
1396 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1397 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1401 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1403 //Add a new Revolution object
1404 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1406 //Add a new Revolution function for creation a revolution relatively to axis
1407 Handle(GEOM_Function) aFunction =
1408 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1409 if (aFunction.IsNull()) return NULL;
1411 //Check if the function is set correctly
1412 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1414 GEOMImpl_IRevolution aCI (aFunction);
1416 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1417 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1419 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1421 aCI.SetBase(aRefBase);
1422 aCI.SetAxis(aRefAxis);
1423 aCI.SetAngle(theAngle);
1425 //Compute the Revolution value
1427 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1430 if (!GetSolver()->ComputeFunction(aFunction)) {
1431 SetErrorCode("Revolution driver failed");
1435 catch (Standard_Failure) {
1436 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1437 SetErrorCode(aFail->GetMessageString());
1441 //Make a Python command
1442 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1443 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1449 //=============================================================================
1453 //=============================================================================
1454 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1455 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1456 double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1460 if (theShape.IsNull()) return NULL;
1462 //Add a new Filling object
1463 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1465 //Add a new Filling function for creation a filling from a compound
1466 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1467 if (aFunction.IsNull()) return NULL;
1469 //Check if the function is set correctly
1470 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1472 GEOMImpl_IFilling aFI (aFunction);
1474 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1476 if (aRefShape.IsNull()) return NULL;
1478 aFI.SetShape(aRefShape);
1479 aFI.SetMinDeg(theMinDeg);
1480 aFI.SetMaxDeg(theMaxDeg);
1481 aFI.SetTol2D(theTol2D);
1482 aFI.SetTol3D(theTol3D);
1483 aFI.SetNbIter(theNbIter);
1484 aFI.SetApprox(isApprox);
1486 //Compute the Solid value
1488 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1491 if (!GetSolver()->ComputeFunction(aFunction)) {
1492 SetErrorCode("Filling driver failed");
1496 catch (Standard_Failure) {
1497 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1498 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1499 SetErrorCode("B-Spline surface construction failed");
1501 SetErrorCode(aFail->GetMessageString());
1505 //Make a Python command
1506 GEOM::TPythonDump pd (aFunction);
1507 pd << aFilling << " = geompy.MakeFilling("
1508 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1509 << theTol2D << ", " << theTol3D << ", " << theNbIter;
1511 pd << ", " << isApprox;
1518 //=============================================================================
1522 //=============================================================================
1523 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1524 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1529 Handle(GEOM_Object) anObj;
1531 if(theSeqSections.IsNull())
1534 Standard_Integer nbObj = theSeqSections->Length();
1538 //Add a new ThruSections object
1539 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1542 //Add a new ThruSections function
1544 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1545 Handle(GEOM_Function) aFunction =
1546 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1547 if (aFunction.IsNull()) return anObj;
1549 //Check if the function is set correctly
1550 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1552 GEOMImpl_IThruSections aCI (aFunction);
1554 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1556 Standard_Integer i =1;
1557 for( ; i <= nbObj; i++) {
1559 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1563 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1564 if(!aSectObj.IsNull())
1566 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1567 if(!aRefSect.IsNull())
1568 aSeqSections->Append(aRefSect);
1572 if(!aSeqSections->Length())
1575 aCI.SetSections(aSeqSections);
1576 aCI.SetSolidMode(theModeSolid);
1577 aCI.SetPrecision(thePreci);
1579 //Compute the ThruSections value
1581 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1584 if (!GetSolver()->ComputeFunction(aFunction)) {
1585 SetErrorCode("ThruSections driver failed");
1589 catch (Standard_Failure) {
1590 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1591 SetErrorCode(aFail->GetMessageString());
1595 //Make a Python command
1596 GEOM::TPythonDump pyDump(aFunction);
1597 pyDump << aThruSect << " = geompy.MakeThruSections([";
1599 for(i =1 ; i <= nbObj; i++) {
1601 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1605 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1606 if(!aSectObj.IsNull()) {
1613 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1622 //=============================================================================
1624 * MakePipeWithDifferentSections
1626 //=============================================================================
1627 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1628 const Handle(TColStd_HSequenceOfTransient)& theBases,
1629 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1630 const Handle(GEOM_Object)& thePath,
1631 bool theWithContact,
1632 bool theWithCorrections)
1634 Handle(GEOM_Object) anObj;
1636 if(theBases.IsNull())
1639 Standard_Integer nbBases = theBases->Length();
1644 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1645 //Add a new Pipe object
1646 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1648 //Add a new Pipe function
1650 Handle(GEOM_Function) aFunction =
1651 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1652 if (aFunction.IsNull()) return anObj;
1654 //Check if the function is set correctly
1655 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1657 GEOMImpl_IPipeDiffSect aCI (aFunction);
1659 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1660 if(aRefPath.IsNull())
1663 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1664 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1666 Standard_Integer i =1;
1667 for( ; i <= nbBases; i++) {
1669 Handle(Standard_Transient) anItem = theBases->Value(i);
1673 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1676 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1677 if(aRefBase.IsNull())
1681 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1682 if(anItemLoc.IsNull())
1685 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1688 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1689 if(aRefLoc.IsNull())
1691 aSeqLocs->Append(aRefLoc);
1693 aSeqBases->Append(aRefBase);
1696 if(!aSeqBases->Length())
1699 aCI.SetBases(aSeqBases);
1700 aCI.SetLocations(aSeqLocs);
1701 aCI.SetPath(aRefPath);
1702 aCI.SetWithContactMode(theWithContact);
1703 aCI.SetWithCorrectionMode(theWithCorrections);
1705 //Compute the Pipe value
1707 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1710 if (!GetSolver()->ComputeFunction(aFunction)) {
1711 SetErrorCode("Pipe with defferent section driver failed");
1715 catch (Standard_Failure) {
1716 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1717 SetErrorCode(aFail->GetMessageString());
1721 //Make a Python command
1722 GEOM::TPythonDump pyDump(aFunction);
1723 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1725 for(i =1 ; i <= nbBases; i++) {
1727 Handle(Standard_Transient) anItem = theBases->Value(i);
1731 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1732 if(!anObj.IsNull()) {
1742 for(i =1 ; i <= nbLocs; i++) {
1744 Handle(Standard_Transient) anItem = theLocations->Value(i);
1748 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1749 if(!anObj.IsNull()) {
1756 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1765 //=============================================================================
1767 * MakePipeWithShellSections
1769 //=============================================================================
1770 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1771 const Handle(TColStd_HSequenceOfTransient)& theBases,
1772 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1773 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1774 const Handle(GEOM_Object)& thePath,
1775 bool theWithContact,
1776 bool theWithCorrections)
1778 Handle(GEOM_Object) anObj;
1780 if(theBases.IsNull())
1783 Standard_Integer nbBases = theBases->Length();
1788 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1790 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1792 //Add a new Pipe object
1793 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1795 //Add a new Pipe function
1797 Handle(GEOM_Function) aFunction =
1798 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1799 if (aFunction.IsNull()) return anObj;
1801 //Check if the function is set correctly
1802 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1804 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1805 GEOMImpl_IPipeShellSect aCI (aFunction);
1807 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1808 if(aRefPath.IsNull())
1811 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1812 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1813 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1815 Standard_Integer i =1;
1816 for( ; i <= nbBases; i++) {
1818 Handle(Standard_Transient) anItem = theBases->Value(i);
1821 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1824 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1825 if(aRefBase.IsNull())
1828 if( nbSubBases >= nbBases ) {
1829 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1830 if(aSubItem.IsNull())
1832 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1833 if(aSubBase.IsNull())
1835 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1836 if(aRefSubBase.IsNull())
1838 aSeqSubBases->Append(aRefSubBase);
1842 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1843 if(anItemLoc.IsNull())
1845 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1848 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1849 if(aRefLoc.IsNull())
1851 aSeqLocs->Append(aRefLoc);
1854 aSeqBases->Append(aRefBase);
1857 if(!aSeqBases->Length())
1860 aCI.SetBases(aSeqBases);
1861 aCI.SetSubBases(aSeqSubBases);
1862 aCI.SetLocations(aSeqLocs);
1863 aCI.SetPath(aRefPath);
1864 aCI.SetWithContactMode(theWithContact);
1865 aCI.SetWithCorrectionMode(theWithCorrections);
1867 //Compute the Pipe value
1869 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1872 if (!GetSolver()->ComputeFunction(aFunction)) {
1873 SetErrorCode("Pipe with shell sections driver failed");
1877 catch (Standard_Failure) {
1878 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1879 SetErrorCode(aFail->GetMessageString());
1883 //Make a Python command
1884 GEOM::TPythonDump pyDump(aFunction);
1885 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1887 for(i =1 ; i <= nbBases; i++) {
1889 Handle(Standard_Transient) anItem = theBases->Value(i);
1893 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1894 if(!anObj.IsNull()) {
1904 for(i =1 ; i <= nbSubBases; i++) {
1906 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1910 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1911 if(!anObj.IsNull()) {
1921 for(i =1 ; i <= nbLocs; i++) {
1923 Handle(Standard_Transient) anItem = theLocations->Value(i);
1927 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1928 if(!anObj.IsNull()) {
1935 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1943 //=============================================================================
1945 * MakePipeShellsWithoutPath
1947 //=============================================================================
1948 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1949 const Handle(TColStd_HSequenceOfTransient)& theBases,
1950 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1952 Handle(GEOM_Object) anObj;
1954 if(theBases.IsNull())
1957 Standard_Integer nbBases = theBases->Length();
1962 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1964 //Add a new Pipe object
1965 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1967 //Add a new Pipe function
1969 Handle(GEOM_Function) aFunction =
1970 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1971 if (aFunction.IsNull()) return anObj;
1973 //Check if the function is set correctly
1974 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1976 GEOMImpl_IPipeShellSect aCI (aFunction);
1978 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1979 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1981 Standard_Integer i =1;
1982 for( ; i <= nbBases; i++) {
1984 Handle(Standard_Transient) anItem = theBases->Value(i);
1987 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1990 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1991 if(aRefBase.IsNull())
1995 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1996 if(anItemLoc.IsNull())
1998 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2001 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2002 if(aRefLoc.IsNull())
2004 aSeqLocs->Append(aRefLoc);
2007 aSeqBases->Append(aRefBase);
2010 if(!aSeqBases->Length())
2013 aCI.SetBases(aSeqBases);
2014 aCI.SetLocations(aSeqLocs);
2016 //Compute the Pipe value
2018 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2021 if (!GetSolver()->ComputeFunction(aFunction)) {
2022 SetErrorCode("Pipe with shell sections without path driver failed");
2026 catch (Standard_Failure) {
2027 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2028 SetErrorCode(aFail->GetMessageString());
2032 //Make a Python command
2033 GEOM::TPythonDump pyDump(aFunction);
2034 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2036 for(i =1 ; i <= nbBases; i++) {
2038 Handle(Standard_Transient) anItem = theBases->Value(i);
2042 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2043 if(!anObj.IsNull()) {
2053 for(i =1 ; i <= nbLocs; i++) {
2055 Handle(Standard_Transient) anItem = theLocations->Value(i);
2059 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2060 if(!anObj.IsNull()) {
2075 //=============================================================================
2077 * MakePipeBiNormalAlongVector
2079 //=============================================================================
2080 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2081 Handle(GEOM_Object) thePath,
2082 Handle(GEOM_Object) theVec)
2086 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2088 //Add a new Pipe object
2089 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2091 //Add a new Pipe function
2092 Handle(GEOM_Function) aFunction =
2093 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2094 if (aFunction.IsNull()) return NULL;
2096 //Check if the function is set correctly
2097 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2099 GEOMImpl_IPipeBiNormal aCI (aFunction);
2101 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2102 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2103 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2105 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2107 aCI.SetBase(aRefBase);
2108 aCI.SetPath(aRefPath);
2109 aCI.SetVector(aRefVec);
2111 //Compute the Pipe value
2113 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2116 if (!GetSolver()->ComputeFunction(aFunction)) {
2117 SetErrorCode("Pipe driver failed");
2121 catch (Standard_Failure) {
2122 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2123 SetErrorCode(aFail->GetMessageString());
2127 //Make a Python command
2128 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2129 << theBase << ", " << thePath << ", " << theVec << ")";