1 // Copyright (C) 2007-2010 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 <Precision.hxx>
72 #include <Standard_Failure.hxx>
73 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
75 //=============================================================================
79 //=============================================================================
80 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
81 : GEOM_IOperations(theEngine, theDocID)
83 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
86 //=============================================================================
90 //=============================================================================
91 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
93 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
97 //=============================================================================
101 //=============================================================================
102 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
106 //Add a new Box object
107 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
109 //Add a new Box function with DX_DY_DZ parameters
110 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
111 if (aFunction.IsNull()) return NULL;
113 //Check if the function is set correctly
114 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
116 GEOMImpl_IBox aBI (aFunction);
122 //Compute the box value
124 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
127 if (!GetSolver()->ComputeFunction(aFunction)) {
128 SetErrorCode("Box driver failed");
132 catch (Standard_Failure) {
133 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
134 SetErrorCode(aFail->GetMessageString());
138 //Make a Python command
139 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
140 << theDX << ", " << theDY << ", " << theDZ << ")";
147 //=============================================================================
151 //=============================================================================
152 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
153 Handle(GEOM_Object) thePnt2)
157 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
159 //Add a new Box object
160 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
162 //Add a new Box function for creation a box relatively to two points
163 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
164 if (aFunction.IsNull()) return NULL;
166 //Check if the function is set correctly
167 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
169 GEOMImpl_IBox aBI (aFunction);
171 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
172 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
174 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
176 aBI.SetRef1(aRefFunction1);
177 aBI.SetRef2(aRefFunction2);
179 //Compute the Box value
181 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
184 if (!GetSolver()->ComputeFunction(aFunction)) {
185 SetErrorCode("Box driver failed");
189 catch (Standard_Failure) {
190 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
191 SetErrorCode(aFail->GetMessageString());
195 //Make a Python command
196 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
197 << thePnt1 << ", " << thePnt2 << ")";
203 //=============================================================================
207 //=============================================================================
208 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
212 if (theH == 0 || theW == 0) return NULL;
214 //Add a new Face object
215 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
217 //Add a new Box function for creation a box relatively to two points
218 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
219 if (aFunction.IsNull()) return NULL;
221 //Check if the function is set correctly
222 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
224 GEOMImpl_IFace aFI (aFunction);
228 aFI.SetOrientation(theOrientation);
232 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
235 if (!GetSolver()->ComputeFunction(aFunction)) {
236 SetErrorCode("Face driver failed");
240 catch (Standard_Failure) {
241 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
242 SetErrorCode(aFail->GetMessageString());
246 //Make a Python command
247 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
248 << theH << ", " << theW << ", " << theOrientation << ")";
254 //=============================================================================
258 //=============================================================================
259 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
260 double theH, double theW)
264 if (theObj.IsNull()) return NULL;
266 //Add a new Face object
267 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
269 //Add a new Box function for creation a box relatively to two points
270 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
271 if (aFunction.IsNull()) return NULL;
273 //Check if the function is set correctly
274 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
276 GEOMImpl_IFace aFI (aFunction);
278 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
280 if (aRefFunction1.IsNull())
283 aFI.SetRef1(aRefFunction1);
289 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
292 if (!GetSolver()->ComputeFunction(aFunction)) {
293 SetErrorCode("Face driver failed");
297 catch (Standard_Failure) {
298 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
299 SetErrorCode(aFail->GetMessageString());
303 //Make a Python command
304 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
305 << theObj << ", " << theH << ", " << theW << ")";
311 //=============================================================================
315 //=============================================================================
316 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
317 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
321 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
323 //Add a new Disk object
324 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
326 //Add a new Disk function for creation a disk relatively to point and vector
327 Handle(GEOM_Function) aFunction =
328 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
329 if (aFunction.IsNull()) return NULL;
331 //Check if the function is set correctly
332 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
334 GEOMImpl_IDisk aCI (aFunction);
336 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
337 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
339 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
341 aCI.SetCenter(aRefPnt);
342 aCI.SetVector(aRefVec);
345 //Compute the Disk value
347 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
350 if (!GetSolver()->ComputeFunction(aFunction)) {
351 SetErrorCode("Disk driver failed");
355 catch (Standard_Failure) {
356 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
357 SetErrorCode(aFail->GetMessageString());
361 //Make a Python command
362 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
363 << thePnt << ", " << theVec << ", " << theR << ")";
369 //=============================================================================
373 //=============================================================================
374 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
375 Handle(GEOM_Object) thePnt2,
376 Handle(GEOM_Object) thePnt3)
380 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
382 //Add a new Disk object
383 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
385 //Add a new Disk function for creation a disk relatively to three points
386 Handle(GEOM_Function) aFunction =
387 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
388 if (aFunction.IsNull()) return NULL;
390 //Check if the function is set correctly
391 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
393 GEOMImpl_IDisk aCI (aFunction);
395 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
396 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
397 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
399 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
401 aCI.SetPoint1(aRefPnt1);
402 aCI.SetPoint2(aRefPnt2);
403 aCI.SetPoint3(aRefPnt3);
405 //Compute the Disk value
407 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
410 if (!GetSolver()->ComputeFunction(aFunction)) {
411 SetErrorCode("Disk driver failed");
415 catch (Standard_Failure) {
416 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
417 SetErrorCode(aFail->GetMessageString());
421 //Make a Python command
422 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
423 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
429 //=============================================================================
433 //=============================================================================
434 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
438 if (theR == 0 ) return NULL;
440 //Add a new Disk object
441 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
443 //Add a new Box function for creation a box relatively to two points
444 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
445 if (aFunction.IsNull()) return NULL;
447 //Check if the function is set correctly
448 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
450 GEOMImpl_IDisk aDI (aFunction);
453 aDI.SetOrientation(theOrientation);
457 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
460 if (!GetSolver()->ComputeFunction(aFunction)) {
461 SetErrorCode("Disk driver failed");
465 catch (Standard_Failure) {
466 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
467 SetErrorCode(aFail->GetMessageString());
471 //Make a Python command
472 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
473 << theR << ", " << theOrientation << ")";
479 //=============================================================================
483 //=============================================================================
484 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
488 //Add a new Cylinder object
489 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
491 //Add a new Cylinder function with R and H parameters
492 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
493 if (aFunction.IsNull()) return NULL;
495 //Check if the function is set correctly
496 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
498 GEOMImpl_ICylinder aCI (aFunction);
503 //Compute the Cylinder value
505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
508 if (!GetSolver()->ComputeFunction(aFunction)) {
509 SetErrorCode("Cylinder driver failed");
513 catch (Standard_Failure) {
514 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
515 SetErrorCode(aFail->GetMessageString());
519 //Make a Python command
520 GEOM::TPythonDump(aFunction) << aCylinder
521 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
528 //=============================================================================
530 * MakeCylinderPntVecRH
532 //=============================================================================
533 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
534 Handle(GEOM_Object) theVec,
535 double theR, double theH)
539 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
541 //Add a new Cylinder object
542 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
544 //Add a new Cylinder function for creation a cylinder relatively to point and vector
545 Handle(GEOM_Function) aFunction =
546 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
547 if (aFunction.IsNull()) return NULL;
549 //Check if the function is set correctly
550 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
552 GEOMImpl_ICylinder aCI (aFunction);
554 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
555 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
557 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
559 aCI.SetPoint(aRefPnt);
560 aCI.SetVector(aRefVec);
564 //Compute the Cylinder value
566 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
569 if (!GetSolver()->ComputeFunction(aFunction)) {
570 SetErrorCode("Cylinder driver failed");
574 catch (Standard_Failure) {
575 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
576 SetErrorCode(aFail->GetMessageString());
580 //Make a Python command
581 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
582 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
589 //=============================================================================
593 //=============================================================================
594 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
599 //Add a new Cone object
600 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
602 //Add a new Cone function with R and H parameters
603 Handle(GEOM_Function) aFunction =
604 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
605 if (aFunction.IsNull()) return NULL;
607 //Check if the function is set correctly
608 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
610 GEOMImpl_ICone aCI (aFunction);
616 //Compute the Cone value
618 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
621 if (!GetSolver()->ComputeFunction(aFunction)) {
622 SetErrorCode("Cone driver failed");
626 catch (Standard_Failure) {
627 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
628 SetErrorCode(aFail->GetMessageString());
632 //Make a Python command
633 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
634 << theR1 << ", " << theR2 << ", " << theH << ")";
641 //=============================================================================
643 * MakeConePntVecR1R2H
645 //=============================================================================
646 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
647 Handle(GEOM_Object) theVec,
648 double theR1, double theR2,
653 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
655 //Add a new Cone object
656 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
658 //Add a new Cone function for creation a cone relatively to point and vector
659 Handle(GEOM_Function) aFunction =
660 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
661 if (aFunction.IsNull()) return NULL;
663 //Check if the function is set correctly
664 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
666 GEOMImpl_ICone aCI (aFunction);
668 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
669 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
671 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
673 aCI.SetPoint(aRefPnt);
674 aCI.SetVector(aRefVec);
679 //Compute the Cone value
681 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
684 if (!GetSolver()->ComputeFunction(aFunction)) {
685 SetErrorCode("Cone driver failed");
689 catch (Standard_Failure) {
690 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
691 SetErrorCode(aFail->GetMessageString());
695 //Make a Python command
696 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
697 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
704 //=============================================================================
708 //=============================================================================
709 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
713 //Add a new Sphere object
714 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
716 //Add a new Sphere function with R parameter
717 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
718 if (aFunction.IsNull()) return NULL;
720 //Check if the function is set correctly
721 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
723 GEOMImpl_ISphere aCI (aFunction);
727 //Compute the Sphere value
729 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
732 if (!GetSolver()->ComputeFunction(aFunction)) {
733 SetErrorCode("Sphere driver failed");
737 catch (Standard_Failure) {
738 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
739 SetErrorCode(aFail->GetMessageString());
743 //Make a Python command
744 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
751 //=============================================================================
755 //=============================================================================
756 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
761 if (thePnt.IsNull()) return NULL;
763 //Add a new Point object
764 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
766 //Add a new Sphere function for creation a sphere relatively to point
767 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
768 if (aFunction.IsNull()) return NULL;
770 //Check if the function is set correctly
771 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
773 GEOMImpl_ISphere aCI (aFunction);
775 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
777 if (aRefPnt.IsNull()) return NULL;
779 aCI.SetPoint(aRefPnt);
782 //Compute the Sphere value
784 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
787 if (!GetSolver()->ComputeFunction(aFunction)) {
788 SetErrorCode("Sphere driver failed");
792 catch (Standard_Failure) {
793 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
794 SetErrorCode(aFail->GetMessageString());
798 //Make a Python command
799 GEOM::TPythonDump(aFunction) << aSphere
800 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
807 //=============================================================================
811 //=============================================================================
812 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
813 (double theRMajor, double theRMinor)
817 //Add a new Torus object
818 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
820 //Add a new Torus function
821 Handle(GEOM_Function) aFunction =
822 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
823 if (aFunction.IsNull()) return NULL;
825 //Check if the function is set correctly
826 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
828 GEOMImpl_ITorus aCI (aFunction);
830 aCI.SetRMajor(theRMajor);
831 aCI.SetRMinor(theRMinor);
833 //Compute the Torus value
835 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
838 if (!GetSolver()->ComputeFunction(aFunction)) {
839 SetErrorCode("Torus driver failed");
843 catch (Standard_Failure) {
844 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
845 SetErrorCode(aFail->GetMessageString());
849 //Make a Python command
850 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
851 << theRMajor << ", " << theRMinor << ")";
857 //=============================================================================
861 //=============================================================================
862 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
863 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
864 double theRMajor, double theRMinor)
868 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
870 //Add a new Torus object
871 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
873 //Add a new Torus function
874 Handle(GEOM_Function) aFunction =
875 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
876 if (aFunction.IsNull()) return NULL;
878 //Check if the function is set correctly
879 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
881 GEOMImpl_ITorus aCI (aFunction);
883 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
884 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
886 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
888 aCI.SetCenter(aRefPnt);
889 aCI.SetVector(aRefVec);
890 aCI.SetRMajor(theRMajor);
891 aCI.SetRMinor(theRMinor);
893 //Compute the Torus value
895 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
898 if (!GetSolver()->ComputeFunction(aFunction)) {
899 SetErrorCode("Torus driver failed");
903 catch (Standard_Failure) {
904 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
905 SetErrorCode(aFail->GetMessageString());
909 //Make a Python command
910 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
911 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
918 //=============================================================================
922 //=============================================================================
923 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
924 Handle(GEOM_Object) theVec,
925 double theH, double theScaleFactor)
929 if (theBase.IsNull() || theVec.IsNull()) return NULL;
931 //Add a new Prism object
932 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
934 //Add a new Prism function for creation a Prism relatively to vector
935 Handle(GEOM_Function) aFunction =
936 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
937 if (aFunction.IsNull()) return NULL;
939 //Check if the function is set correctly
940 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
942 GEOMImpl_IPrism aCI (aFunction);
944 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
945 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
947 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
949 aCI.SetBase(aRefBase);
950 aCI.SetVector(aRefVec);
952 aCI.SetScale(theScaleFactor);
954 //Compute the Prism value
956 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
959 if (!GetSolver()->ComputeFunction(aFunction)) {
960 //SetErrorCode("Prism driver failed");
961 SetErrorCode("Extrusion can not be created, check input data");
965 catch (Standard_Failure) {
966 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
967 SetErrorCode(aFail->GetMessageString());
971 //Make a Python command
972 GEOM::TPythonDump pd (aFunction);
973 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
974 if (theScaleFactor > Precision::Confusion())
975 pd << ", " << theScaleFactor << ")";
983 //=============================================================================
987 //=============================================================================
988 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
989 Handle(GEOM_Object) theVec,
994 if (theBase.IsNull() || theVec.IsNull()) return NULL;
996 //Add a new Prism object
997 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
999 //Add a new Prism function for creation a Prism relatively to vector
1000 Handle(GEOM_Function) aFunction =
1001 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1002 if (aFunction.IsNull()) return NULL;
1004 //Check if the function is set correctly
1005 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1007 GEOMImpl_IPrism aCI (aFunction);
1009 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1010 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1012 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1014 aCI.SetBase(aRefBase);
1015 aCI.SetVector(aRefVec);
1018 //Compute the Prism value
1020 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1023 if (!GetSolver()->ComputeFunction(aFunction)) {
1024 //SetErrorCode("Prism driver failed");
1025 SetErrorCode("Extrusion can not be created, check input data");
1029 catch (Standard_Failure) {
1030 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1031 SetErrorCode(aFail->GetMessageString());
1035 //Make a Python command
1036 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1037 << theBase << ", " << theVec << ", " << theH << ")";
1043 //=============================================================================
1047 //=============================================================================
1048 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1049 (Handle(GEOM_Object) theBase,
1050 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1051 double theScaleFactor)
1055 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1057 //Add a new Prism object
1058 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1060 //Add a new Prism function for creation a Prism relatively to two points
1061 Handle(GEOM_Function) aFunction =
1062 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1063 if (aFunction.IsNull()) return NULL;
1065 //Check if the function is set correctly
1066 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1068 GEOMImpl_IPrism aCI (aFunction);
1070 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1071 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1072 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1074 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1076 aCI.SetBase(aRefBase);
1077 aCI.SetFirstPoint(aRefPnt1);
1078 aCI.SetLastPoint(aRefPnt2);
1079 aCI.SetScale(theScaleFactor);
1081 //Compute the Prism value
1083 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1086 if (!GetSolver()->ComputeFunction(aFunction)) {
1087 //SetErrorCode("Prism driver failed");
1088 SetErrorCode("Extrusion can not be created, check input data");
1092 catch (Standard_Failure) {
1093 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1094 SetErrorCode(aFail->GetMessageString());
1098 //Make a Python command
1099 GEOM::TPythonDump pd (aFunction);
1100 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1101 if (theScaleFactor > Precision::Confusion())
1102 pd << ", " << theScaleFactor << ")";
1110 //=============================================================================
1112 * MakePrismTwoPnt2Ways
1114 //=============================================================================
1115 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1116 (Handle(GEOM_Object) theBase,
1117 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1121 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1123 //Add a new Prism object
1124 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1126 //Add a new Prism function for creation a Prism relatively to two points
1127 Handle(GEOM_Function) aFunction =
1128 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1129 if (aFunction.IsNull()) return NULL;
1131 //Check if the function is set correctly
1132 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1134 GEOMImpl_IPrism aCI (aFunction);
1136 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1137 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1138 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1140 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1142 aCI.SetBase(aRefBase);
1143 aCI.SetFirstPoint(aRefPnt1);
1144 aCI.SetLastPoint(aRefPnt2);
1146 //Compute the Prism value
1148 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1151 if (!GetSolver()->ComputeFunction(aFunction)) {
1152 //SetErrorCode("Prism driver failed");
1153 SetErrorCode("Extrusion can not be created, check input data");
1157 catch (Standard_Failure) {
1158 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1159 SetErrorCode(aFail->GetMessageString());
1163 //Make a Python command
1164 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1165 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1171 //=============================================================================
1175 //=============================================================================
1176 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1177 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1178 double theScaleFactor)
1182 if (theBase.IsNull()) return NULL;
1184 //Add a new Prism object
1185 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1187 //Add a new Prism function for creation a Prism by DXDYDZ
1188 Handle(GEOM_Function) aFunction =
1189 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1190 if (aFunction.IsNull()) return NULL;
1192 //Check if the function is set correctly
1193 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1195 GEOMImpl_IPrism aCI (aFunction);
1197 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1199 if (aRefBase.IsNull()) return NULL;
1201 aCI.SetBase(aRefBase);
1205 aCI.SetScale(theScaleFactor);
1207 //Compute the Prism value
1209 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1212 if (!GetSolver()->ComputeFunction(aFunction)) {
1213 SetErrorCode("Extrusion can not be created, check input data");
1217 catch (Standard_Failure) {
1218 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1219 SetErrorCode(aFail->GetMessageString());
1223 //Make a Python command
1224 GEOM::TPythonDump pd (aFunction);
1225 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1226 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1227 if (theScaleFactor > Precision::Confusion())
1228 pd << ", " << theScaleFactor << ")";
1236 //=============================================================================
1238 * MakePrismDXDYDZ_2WAYS
1240 //=============================================================================
1241 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1242 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1246 if (theBase.IsNull()) return NULL;
1248 //Add a new Prism object
1249 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1251 //Add a new Prism function for creation a Prism by DXDYDZ
1252 Handle(GEOM_Function) aFunction =
1253 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1254 if (aFunction.IsNull()) return NULL;
1256 //Check if the function is set correctly
1257 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1259 GEOMImpl_IPrism aCI (aFunction);
1261 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1263 if (aRefBase.IsNull()) return NULL;
1265 aCI.SetBase(aRefBase);
1270 //Compute the Prism value
1272 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1275 if (!GetSolver()->ComputeFunction(aFunction)) {
1276 SetErrorCode("Extrusion can not be created, check input data");
1280 catch (Standard_Failure) {
1281 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1282 SetErrorCode(aFail->GetMessageString());
1286 //Make a Python command
1287 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1288 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1294 //=============================================================================
1298 //=============================================================================
1299 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1300 Handle(GEOM_Object) thePath)
1304 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1306 //Add a new Pipe object
1307 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1309 //Add a new Pipe function
1310 Handle(GEOM_Function) aFunction =
1311 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1312 if (aFunction.IsNull()) return NULL;
1314 //Check if the function is set correctly
1315 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1317 GEOMImpl_IPipe aCI (aFunction);
1319 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1320 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1322 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1324 aCI.SetBase(aRefBase);
1325 aCI.SetPath(aRefPath);
1327 //Compute the Pipe value
1329 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1332 if (!GetSolver()->ComputeFunction(aFunction)) {
1333 SetErrorCode("Pipe driver failed");
1337 catch (Standard_Failure) {
1338 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1339 SetErrorCode(aFail->GetMessageString());
1343 //Make a Python command
1344 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1345 << theBase << ", " << thePath << ")";
1352 //=============================================================================
1354 * MakeRevolutionAxisAngle
1356 //=============================================================================
1357 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1358 Handle(GEOM_Object) theAxis,
1363 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1365 //Add a new Revolution object
1366 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1368 //Add a new Revolution function for creation a revolution relatively to axis
1369 Handle(GEOM_Function) aFunction =
1370 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1371 if (aFunction.IsNull()) return NULL;
1373 //Check if the function is set correctly
1374 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1376 GEOMImpl_IRevolution aCI (aFunction);
1378 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1379 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1381 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1383 aCI.SetBase(aRefBase);
1384 aCI.SetAxis(aRefAxis);
1385 aCI.SetAngle(theAngle);
1387 //Compute the Revolution value
1389 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1392 if (!GetSolver()->ComputeFunction(aFunction)) {
1393 SetErrorCode("Revolution driver failed");
1397 catch (Standard_Failure) {
1398 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1399 SetErrorCode(aFail->GetMessageString());
1403 //Make a Python command
1404 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1405 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1411 //=============================================================================
1413 * MakeRevolutionAxisAngle2Ways
1415 //=============================================================================
1416 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1417 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1421 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1423 //Add a new Revolution object
1424 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1426 //Add a new Revolution function for creation a revolution relatively to axis
1427 Handle(GEOM_Function) aFunction =
1428 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1429 if (aFunction.IsNull()) return NULL;
1431 //Check if the function is set correctly
1432 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1434 GEOMImpl_IRevolution aCI (aFunction);
1436 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1437 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1439 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1441 aCI.SetBase(aRefBase);
1442 aCI.SetAxis(aRefAxis);
1443 aCI.SetAngle(theAngle);
1445 //Compute the Revolution value
1447 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1450 if (!GetSolver()->ComputeFunction(aFunction)) {
1451 SetErrorCode("Revolution driver failed");
1455 catch (Standard_Failure) {
1456 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1457 SetErrorCode(aFail->GetMessageString());
1461 //Make a Python command
1462 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1463 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1469 //=============================================================================
1473 //=============================================================================
1474 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1475 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1476 double theTol2D, double theTol3D, int theNbIter,
1477 int theMethod, bool isApprox)
1481 if (theShape.IsNull()) return NULL;
1483 //Add a new Filling object
1484 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1486 //Add a new Filling function for creation a filling from a compound
1487 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1488 if (aFunction.IsNull()) return NULL;
1490 //Check if the function is set correctly
1491 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1493 GEOMImpl_IFilling aFI (aFunction);
1495 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1497 if (aRefShape.IsNull()) return NULL;
1499 aFI.SetShape(aRefShape);
1500 aFI.SetMinDeg(theMinDeg);
1501 aFI.SetMaxDeg(theMaxDeg);
1502 aFI.SetTol2D(theTol2D);
1503 aFI.SetTol3D(theTol3D);
1504 aFI.SetNbIter(theNbIter);
1505 aFI.SetApprox(isApprox);
1506 aFI.SetMethod(theMethod);
1508 //Compute the Solid value
1510 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1513 if (!GetSolver()->ComputeFunction(aFunction)) {
1514 SetErrorCode("Filling driver failed");
1518 catch (Standard_Failure) {
1519 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1520 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1521 SetErrorCode("B-Spline surface construction failed");
1523 SetErrorCode(aFail->GetMessageString());
1527 //Make a Python command
1528 GEOM::TPythonDump pd (aFunction);
1529 pd << aFilling << " = geompy.MakeFilling("
1530 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1531 << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
1532 if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
1533 else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
1534 else pd << "GEOM.FOM_Default";
1536 pd << ", " << isApprox ;
1543 //=============================================================================
1547 //=============================================================================
1548 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1549 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1554 Handle(GEOM_Object) anObj;
1556 if(theSeqSections.IsNull())
1559 Standard_Integer nbObj = theSeqSections->Length();
1563 //Add a new ThruSections object
1564 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1567 //Add a new ThruSections function
1569 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1570 Handle(GEOM_Function) aFunction =
1571 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1572 if (aFunction.IsNull()) return anObj;
1574 //Check if the function is set correctly
1575 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1577 GEOMImpl_IThruSections aCI (aFunction);
1579 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1581 Standard_Integer i =1;
1582 for( ; i <= nbObj; i++) {
1584 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1588 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1589 if(!aSectObj.IsNull())
1591 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1592 if(!aRefSect.IsNull())
1593 aSeqSections->Append(aRefSect);
1597 if(!aSeqSections->Length())
1600 aCI.SetSections(aSeqSections);
1601 aCI.SetSolidMode(theModeSolid);
1602 aCI.SetPrecision(thePreci);
1604 //Compute the ThruSections value
1606 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1609 if (!GetSolver()->ComputeFunction(aFunction)) {
1610 SetErrorCode("ThruSections driver failed");
1614 catch (Standard_Failure) {
1615 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1616 SetErrorCode(aFail->GetMessageString());
1620 //Make a Python command
1621 GEOM::TPythonDump pyDump(aFunction);
1622 pyDump << aThruSect << " = geompy.MakeThruSections([";
1624 for(i =1 ; i <= nbObj; i++) {
1626 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1630 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1631 if(!aSectObj.IsNull()) {
1638 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1645 //=============================================================================
1647 * MakePipeWithDifferentSections
1649 //=============================================================================
1650 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1651 const Handle(TColStd_HSequenceOfTransient)& theBases,
1652 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1653 const Handle(GEOM_Object)& thePath,
1654 bool theWithContact,
1655 bool theWithCorrections)
1657 Handle(GEOM_Object) anObj;
1659 if(theBases.IsNull())
1662 Standard_Integer nbBases = theBases->Length();
1667 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1668 //Add a new Pipe object
1669 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1671 //Add a new Pipe function
1673 Handle(GEOM_Function) aFunction =
1674 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1675 if (aFunction.IsNull()) return anObj;
1677 //Check if the function is set correctly
1678 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1680 GEOMImpl_IPipeDiffSect aCI (aFunction);
1682 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1683 if(aRefPath.IsNull())
1686 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1687 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1689 Standard_Integer i =1;
1690 for( ; i <= nbBases; i++) {
1692 Handle(Standard_Transient) anItem = theBases->Value(i);
1696 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1699 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1700 if(aRefBase.IsNull())
1704 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1705 if(anItemLoc.IsNull())
1708 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1711 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1712 if(aRefLoc.IsNull())
1714 aSeqLocs->Append(aRefLoc);
1716 aSeqBases->Append(aRefBase);
1719 if(!aSeqBases->Length())
1722 aCI.SetBases(aSeqBases);
1723 aCI.SetLocations(aSeqLocs);
1724 aCI.SetPath(aRefPath);
1725 aCI.SetWithContactMode(theWithContact);
1726 aCI.SetWithCorrectionMode(theWithCorrections);
1728 //Compute the Pipe value
1730 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1733 if (!GetSolver()->ComputeFunction(aFunction)) {
1734 SetErrorCode("Pipe with defferent section driver failed");
1738 catch (Standard_Failure) {
1739 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1740 SetErrorCode(aFail->GetMessageString());
1744 //Make a Python command
1745 GEOM::TPythonDump pyDump(aFunction);
1746 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1748 for(i =1 ; i <= nbBases; i++) {
1750 Handle(Standard_Transient) anItem = theBases->Value(i);
1754 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1755 if(!anObj.IsNull()) {
1764 for(i =1 ; i <= nbLocs; i++) {
1766 Handle(Standard_Transient) anItem = theLocations->Value(i);
1770 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1771 if(!anObj.IsNull()) {
1778 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1785 //=============================================================================
1787 * MakePipeWithShellSections
1789 //=============================================================================
1790 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1791 const Handle(TColStd_HSequenceOfTransient)& theBases,
1792 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1793 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1794 const Handle(GEOM_Object)& thePath,
1795 bool theWithContact,
1796 bool theWithCorrections)
1798 Handle(GEOM_Object) anObj;
1800 if(theBases.IsNull())
1803 Standard_Integer nbBases = theBases->Length();
1808 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1810 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1812 //Add a new Pipe object
1813 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1815 //Add a new Pipe function
1817 Handle(GEOM_Function) aFunction =
1818 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1819 if (aFunction.IsNull()) return anObj;
1821 //Check if the function is set correctly
1822 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1824 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1825 GEOMImpl_IPipeShellSect aCI (aFunction);
1827 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1828 if(aRefPath.IsNull())
1831 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1832 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1833 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1835 Standard_Integer i =1;
1836 for( ; i <= nbBases; i++) {
1838 Handle(Standard_Transient) anItem = theBases->Value(i);
1841 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1844 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1845 if(aRefBase.IsNull())
1848 if( nbSubBases >= nbBases ) {
1849 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1850 if(aSubItem.IsNull())
1852 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1853 if(aSubBase.IsNull())
1855 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1856 if(aRefSubBase.IsNull())
1858 aSeqSubBases->Append(aRefSubBase);
1862 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1863 if(anItemLoc.IsNull())
1865 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1868 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1869 if(aRefLoc.IsNull())
1871 aSeqLocs->Append(aRefLoc);
1874 aSeqBases->Append(aRefBase);
1877 if(!aSeqBases->Length())
1880 aCI.SetBases(aSeqBases);
1881 aCI.SetSubBases(aSeqSubBases);
1882 aCI.SetLocations(aSeqLocs);
1883 aCI.SetPath(aRefPath);
1884 aCI.SetWithContactMode(theWithContact);
1885 aCI.SetWithCorrectionMode(theWithCorrections);
1887 //Compute the Pipe value
1889 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1892 if (!GetSolver()->ComputeFunction(aFunction)) {
1893 SetErrorCode("Pipe with shell sections driver failed");
1897 catch (Standard_Failure) {
1898 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1899 SetErrorCode(aFail->GetMessageString());
1903 //Make a Python command
1904 GEOM::TPythonDump pyDump(aFunction);
1905 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1907 for(i =1 ; i <= nbBases; i++) {
1909 Handle(Standard_Transient) anItem = theBases->Value(i);
1913 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1914 if(!anObj.IsNull()) {
1923 for(i =1 ; i <= nbSubBases; i++) {
1925 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1929 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1930 if(!anObj.IsNull()) {
1939 for(i =1 ; i <= nbLocs; i++) {
1941 Handle(Standard_Transient) anItem = theLocations->Value(i);
1945 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1946 if(!anObj.IsNull()) {
1953 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1961 //=============================================================================
1963 * MakePipeShellsWithoutPath
1965 //=============================================================================
1966 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1967 const Handle(TColStd_HSequenceOfTransient)& theBases,
1968 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1970 Handle(GEOM_Object) anObj;
1972 if(theBases.IsNull())
1975 Standard_Integer nbBases = theBases->Length();
1980 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1982 //Add a new Pipe object
1983 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1985 //Add a new Pipe function
1987 Handle(GEOM_Function) aFunction =
1988 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1989 if (aFunction.IsNull()) return anObj;
1991 //Check if the function is set correctly
1992 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1994 GEOMImpl_IPipeShellSect aCI (aFunction);
1996 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1997 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1999 Standard_Integer i =1;
2000 for( ; i <= nbBases; i++) {
2002 Handle(Standard_Transient) anItem = theBases->Value(i);
2005 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2008 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2009 if(aRefBase.IsNull())
2013 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2014 if(anItemLoc.IsNull())
2016 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2019 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2020 if(aRefLoc.IsNull())
2022 aSeqLocs->Append(aRefLoc);
2025 aSeqBases->Append(aRefBase);
2028 if(!aSeqBases->Length())
2031 aCI.SetBases(aSeqBases);
2032 aCI.SetLocations(aSeqLocs);
2034 //Compute the Pipe value
2036 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2039 if (!GetSolver()->ComputeFunction(aFunction)) {
2040 SetErrorCode("Pipe with shell sections without path driver failed");
2044 catch (Standard_Failure) {
2045 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2046 SetErrorCode(aFail->GetMessageString());
2050 //Make a Python command
2051 GEOM::TPythonDump pyDump(aFunction);
2052 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2054 for(i =1 ; i <= nbBases; i++) {
2056 Handle(Standard_Transient) anItem = theBases->Value(i);
2060 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2061 if(!anObj.IsNull()) {
2070 for(i =1 ; i <= nbLocs; i++) {
2072 Handle(Standard_Transient) anItem = theLocations->Value(i);
2076 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2077 if(!anObj.IsNull()) {
2092 //=============================================================================
2094 * MakePipeBiNormalAlongVector
2096 //=============================================================================
2097 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2098 Handle(GEOM_Object) thePath,
2099 Handle(GEOM_Object) theVec)
2103 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2105 //Add a new Pipe object
2106 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2108 //Add a new Pipe function
2109 Handle(GEOM_Function) aFunction =
2110 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2111 if (aFunction.IsNull()) return NULL;
2113 //Check if the function is set correctly
2114 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2116 GEOMImpl_IPipeBiNormal aCI (aFunction);
2118 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2119 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2120 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2122 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2124 aCI.SetBase(aRefBase);
2125 aCI.SetPath(aRefPath);
2126 aCI.SetVector(aRefVec);
2128 //Compute the Pipe value
2130 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2133 if (!GetSolver()->ComputeFunction(aFunction)) {
2134 SetErrorCode("Pipe driver failed");
2138 catch (Standard_Failure) {
2139 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2140 SetErrorCode(aFail->GetMessageString());
2144 //Make a Python command
2145 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2146 << theBase << ", " << thePath << ", " << theVec << ")";