1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_I3DPrimOperations.hxx>
24 #include "utilities.h"
26 #include <Utils_ExceptHandlers.hxx>
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
36 #include <GEOMImpl_Types.hxx>
38 #include <GEOMImpl_BoxDriver.hxx>
39 #include <GEOMImpl_CylinderDriver.hxx>
40 #include <GEOMImpl_ConeDriver.hxx>
41 #include <GEOMImpl_SphereDriver.hxx>
42 #include <GEOMImpl_TorusDriver.hxx>
43 #include <GEOMImpl_PrismDriver.hxx>
44 #include <GEOMImpl_PipeDriver.hxx>
45 #include <GEOMImpl_RevolutionDriver.hxx>
46 #include <GEOMImpl_ShapeDriver.hxx>
47 #include <GEOMImpl_FillingDriver.hxx>
48 #include <GEOMImpl_ThruSectionsDriver.hxx>
50 #include <GEOMImpl_IBox.hxx>
51 #include <GEOMImpl_ICylinder.hxx>
52 #include <GEOMImpl_ICone.hxx>
53 #include <GEOMImpl_ISphere.hxx>
54 #include <GEOMImpl_ITorus.hxx>
55 #include <GEOMImpl_IPrism.hxx>
56 #include <GEOMImpl_IPipe.hxx>
57 #include <GEOMImpl_IRevolution.hxx>
58 #include <GEOMImpl_IShapes.hxx>
59 #include <GEOMImpl_IFilling.hxx>
60 #include <GEOMImpl_IThruSections.hxx>
61 #include <GEOMImpl_IPipeDiffSect.hxx>
63 #include <Standard_Failure.hxx>
64 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
66 //=============================================================================
70 //=============================================================================
71 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
72 : GEOM_IOperations(theEngine, theDocID)
74 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
77 //=============================================================================
81 //=============================================================================
82 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
84 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
88 //=============================================================================
92 //=============================================================================
93 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
97 //Add a new Box object
98 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
100 //Add a new Box function with DX_DY_DZ parameters
101 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
102 if (aFunction.IsNull()) return NULL;
104 //Check if the function is set correctly
105 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
107 GEOMImpl_IBox aBI (aFunction);
113 //Compute the box value
115 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
118 if (!GetSolver()->ComputeFunction(aFunction)) {
119 SetErrorCode("Box driver failed");
123 catch (Standard_Failure) {
124 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
125 SetErrorCode(aFail->GetMessageString());
129 //Make a Python command
130 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
131 << theDX << ", " << theDY << ", " << theDZ << ")";
138 //=============================================================================
142 //=============================================================================
143 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
144 Handle(GEOM_Object) thePnt2)
148 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
150 //Add a new Box object
151 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
153 //Add a new Box function for creation a box relatively to two points
154 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
155 if (aFunction.IsNull()) return NULL;
157 //Check if the function is set correctly
158 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
160 GEOMImpl_IBox aBI (aFunction);
162 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
163 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
165 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
167 aBI.SetRef1(aRefFunction1);
168 aBI.SetRef2(aRefFunction2);
170 //Compute the Box value
172 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
175 if (!GetSolver()->ComputeFunction(aFunction)) {
176 SetErrorCode("Box driver failed");
180 catch (Standard_Failure) {
181 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
182 SetErrorCode(aFail->GetMessageString());
186 //Make a Python command
187 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
188 << thePnt1 << ", " << thePnt2 << ")";
195 //=============================================================================
199 //=============================================================================
200 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
204 //Add a new Cylinder object
205 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
207 //Add a new Cylinder function with R and H parameters
208 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
209 if (aFunction.IsNull()) return NULL;
211 //Check if the function is set correctly
212 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
214 GEOMImpl_ICylinder aCI (aFunction);
219 //Compute the Cylinder value
221 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
224 if (!GetSolver()->ComputeFunction(aFunction)) {
225 SetErrorCode("Cylinder driver failed");
229 catch (Standard_Failure) {
230 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
231 SetErrorCode(aFail->GetMessageString());
235 //Make a Python command
236 GEOM::TPythonDump(aFunction) << aCylinder
237 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
244 //=============================================================================
246 * MakeCylinderPntVecRH
248 //=============================================================================
249 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
250 Handle(GEOM_Object) theVec,
251 double theR, double theH)
255 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
257 //Add a new Cylinder object
258 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
260 //Add a new Cylinder function for creation a cylinder relatively to point and vector
261 Handle(GEOM_Function) aFunction =
262 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
263 if (aFunction.IsNull()) return NULL;
265 //Check if the function is set correctly
266 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
268 GEOMImpl_ICylinder aCI (aFunction);
270 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
271 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
273 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
275 aCI.SetPoint(aRefPnt);
276 aCI.SetVector(aRefVec);
280 //Compute the Cylinder value
282 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
285 if (!GetSolver()->ComputeFunction(aFunction)) {
286 SetErrorCode("Cylinder driver failed");
290 catch (Standard_Failure) {
291 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
292 SetErrorCode(aFail->GetMessageString());
296 //Make a Python command
297 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
298 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
305 //=============================================================================
309 //=============================================================================
310 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
315 //Add a new Cone object
316 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
318 //Add a new Cone function with R and H parameters
319 Handle(GEOM_Function) aFunction =
320 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
321 if (aFunction.IsNull()) return NULL;
323 //Check if the function is set correctly
324 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
326 GEOMImpl_ICone aCI (aFunction);
332 //Compute the Cone value
334 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
337 if (!GetSolver()->ComputeFunction(aFunction)) {
338 SetErrorCode("Cone driver failed");
342 catch (Standard_Failure) {
343 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
344 SetErrorCode(aFail->GetMessageString());
348 //Make a Python command
349 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
350 << theR1 << ", " << theR2 << ", " << theH << ")";
357 //=============================================================================
359 * MakeConePntVecR1R2H
361 //=============================================================================
362 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
363 Handle(GEOM_Object) theVec,
364 double theR1, double theR2,
369 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
371 //Add a new Cone object
372 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
374 //Add a new Cone function for creation a cone relatively to point and vector
375 Handle(GEOM_Function) aFunction =
376 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
377 if (aFunction.IsNull()) return NULL;
379 //Check if the function is set correctly
380 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
382 GEOMImpl_ICone aCI (aFunction);
384 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
385 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
387 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
389 aCI.SetPoint(aRefPnt);
390 aCI.SetVector(aRefVec);
395 //Compute the Cone value
397 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
400 if (!GetSolver()->ComputeFunction(aFunction)) {
401 SetErrorCode("Cone driver failed");
405 catch (Standard_Failure) {
406 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
407 SetErrorCode(aFail->GetMessageString());
411 //Make a Python command
412 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
413 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
420 //=============================================================================
424 //=============================================================================
425 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
429 //Add a new Sphere object
430 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
432 //Add a new Sphere function with R parameter
433 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
434 if (aFunction.IsNull()) return NULL;
436 //Check if the function is set correctly
437 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
439 GEOMImpl_ISphere aCI (aFunction);
443 //Compute the Sphere value
445 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
448 if (!GetSolver()->ComputeFunction(aFunction)) {
449 SetErrorCode("Sphere driver failed");
453 catch (Standard_Failure) {
454 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
455 SetErrorCode(aFail->GetMessageString());
459 //Make a Python command
460 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
467 //=============================================================================
471 //=============================================================================
472 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
477 if (thePnt.IsNull()) return NULL;
479 //Add a new Point object
480 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
482 //Add a new Sphere function for creation a sphere relatively to point
483 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
484 if (aFunction.IsNull()) return NULL;
486 //Check if the function is set correctly
487 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
489 GEOMImpl_ISphere aCI (aFunction);
491 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
493 if (aRefPnt.IsNull()) return NULL;
495 aCI.SetPoint(aRefPnt);
498 //Compute the Sphere value
500 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
503 if (!GetSolver()->ComputeFunction(aFunction)) {
504 SetErrorCode("Sphere driver failed");
508 catch (Standard_Failure) {
509 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
510 SetErrorCode(aFail->GetMessageString());
514 //Make a Python command
515 GEOM::TPythonDump(aFunction) << aSphere
516 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
523 //=============================================================================
527 //=============================================================================
528 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
529 (double theRMajor, double theRMinor)
533 //Add a new Torus object
534 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
536 //Add a new Torus function
537 Handle(GEOM_Function) aFunction =
538 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
539 if (aFunction.IsNull()) return NULL;
541 //Check if the function is set correctly
542 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
544 GEOMImpl_ITorus aCI (aFunction);
546 aCI.SetRMajor(theRMajor);
547 aCI.SetRMinor(theRMinor);
549 //Compute the Torus value
551 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
554 if (!GetSolver()->ComputeFunction(aFunction)) {
555 SetErrorCode("Torus driver failed");
559 catch (Standard_Failure) {
560 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
561 SetErrorCode(aFail->GetMessageString());
565 //Make a Python command
566 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
567 << theRMajor << ", " << theRMinor << ")";
573 //=============================================================================
577 //=============================================================================
578 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
579 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
580 double theRMajor, double theRMinor)
584 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
586 //Add a new Torus object
587 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
589 //Add a new Torus function
590 Handle(GEOM_Function) aFunction =
591 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
592 if (aFunction.IsNull()) return NULL;
594 //Check if the function is set correctly
595 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
597 GEOMImpl_ITorus aCI (aFunction);
599 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
600 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
602 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
604 aCI.SetCenter(aRefPnt);
605 aCI.SetVector(aRefVec);
606 aCI.SetRMajor(theRMajor);
607 aCI.SetRMinor(theRMinor);
609 //Compute the Torus value
611 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
614 if (!GetSolver()->ComputeFunction(aFunction)) {
615 SetErrorCode("Torus driver failed");
619 catch (Standard_Failure) {
620 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
621 SetErrorCode(aFail->GetMessageString());
625 //Make a Python command
626 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
627 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
634 //=============================================================================
638 //=============================================================================
639 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
640 Handle(GEOM_Object) theVec,
645 if (theBase.IsNull() || theVec.IsNull()) return NULL;
647 //Add a new Prism object
648 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
650 //Add a new Prism function for creation a Prism relatively to vector
651 Handle(GEOM_Function) aFunction =
652 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
653 if (aFunction.IsNull()) return NULL;
655 //Check if the function is set correctly
656 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
658 GEOMImpl_IPrism aCI (aFunction);
660 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
661 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
663 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
665 aCI.SetBase(aRefBase);
666 aCI.SetVector(aRefVec);
669 //Compute the Prism value
671 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
674 if (!GetSolver()->ComputeFunction(aFunction)) {
675 //SetErrorCode("Prism driver failed");
676 SetErrorCode("Extrusion can not be created, check input data");
680 catch (Standard_Failure) {
681 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
682 SetErrorCode(aFail->GetMessageString());
686 //Make a Python command
687 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
688 << theBase << ", " << theVec << ", " << theH << ")";
694 //=============================================================================
698 //=============================================================================
699 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
700 (Handle(GEOM_Object) theBase,
701 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
705 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
707 //Add a new Prism object
708 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
710 //Add a new Prism function for creation a Prism relatively to two points
711 Handle(GEOM_Function) aFunction =
712 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
713 if (aFunction.IsNull()) return NULL;
715 //Check if the function is set correctly
716 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
718 GEOMImpl_IPrism aCI (aFunction);
720 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
721 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
722 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
724 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
726 aCI.SetBase(aRefBase);
727 aCI.SetFirstPoint(aRefPnt1);
728 aCI.SetLastPoint(aRefPnt2);
730 //Compute the Prism value
732 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
735 if (!GetSolver()->ComputeFunction(aFunction)) {
736 //SetErrorCode("Prism driver failed");
737 SetErrorCode("Extrusion can not be created, check input data");
741 catch (Standard_Failure) {
742 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
743 SetErrorCode(aFail->GetMessageString());
747 //Make a Python command
748 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
749 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
756 //=============================================================================
760 //=============================================================================
761 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
762 Handle(GEOM_Object) thePath)
766 if (theBase.IsNull() || thePath.IsNull()) return NULL;
768 //Add a new Pipe object
769 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
771 //Add a new Pipe function
772 Handle(GEOM_Function) aFunction =
773 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
774 if (aFunction.IsNull()) return NULL;
776 //Check if the function is set correctly
777 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
779 GEOMImpl_IPipe aCI (aFunction);
781 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
782 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
784 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
786 aCI.SetBase(aRefBase);
787 aCI.SetPath(aRefPath);
789 //Compute the Pipe value
791 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
794 if (!GetSolver()->ComputeFunction(aFunction)) {
795 SetErrorCode("Pipe driver failed");
799 catch (Standard_Failure) {
800 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
801 SetErrorCode(aFail->GetMessageString());
805 //Make a Python command
806 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
807 << theBase << ", " << thePath << ")";
814 //=============================================================================
816 * MakeRevolutionAxisAngle
818 //=============================================================================
819 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
820 Handle(GEOM_Object) theAxis,
825 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
827 //Add a new Revolution object
828 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
830 //Add a new Revolution function for creation a revolution relatively to axis
831 Handle(GEOM_Function) aFunction =
832 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
833 if (aFunction.IsNull()) return NULL;
835 //Check if the function is set correctly
836 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
838 GEOMImpl_IRevolution aCI (aFunction);
840 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
841 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
843 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
845 aCI.SetBase(aRefBase);
846 aCI.SetAxis(aRefAxis);
847 aCI.SetAngle(theAngle);
849 //Compute the Revolution value
851 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
854 if (!GetSolver()->ComputeFunction(aFunction)) {
855 SetErrorCode("Revolution driver failed");
859 catch (Standard_Failure) {
860 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
861 SetErrorCode(aFail->GetMessageString());
865 //Make a Python command
866 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
867 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
874 //=============================================================================
878 //=============================================================================
879 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
883 if (theShell.IsNull()) return NULL;
885 //Add a new Solid object
886 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
888 //Add a new Solid function for creation a solid from a shell
889 Handle(GEOM_Function) aFunction =
890 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
891 if (aFunction.IsNull()) return NULL;
893 //Check if the function is set correctly
894 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
896 GEOMImpl_IShapes aCI (aFunction);
898 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
900 if (aRefShell.IsNull()) return NULL;
902 aCI.SetBase(aRefShell);
904 //Compute the Solid value
906 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
909 if (!GetSolver()->ComputeFunction(aFunction)) {
910 SetErrorCode("Solid driver failed");
914 catch (Standard_Failure) {
915 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
916 SetErrorCode(aFail->GetMessageString());
920 //Make a Python command
921 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
927 //=============================================================================
931 //=============================================================================
932 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
933 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
934 double theTol2D, double theTol3D, int theNbIter)
938 if (theShape.IsNull()) return NULL;
940 //Add a new Filling object
941 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
943 //Add a new Filling function for creation a filling from a compound
944 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
945 if (aFunction.IsNull()) return NULL;
947 //Check if the function is set correctly
948 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
950 GEOMImpl_IFilling aFI (aFunction);
952 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
954 if (aRefShape.IsNull()) return NULL;
956 aFI.SetShape(aRefShape);
957 aFI.SetMinDeg(theMinDeg);
958 aFI.SetMaxDeg(theMaxDeg);
959 aFI.SetTol2D(theTol2D);
960 aFI.SetTol3D(theTol3D);
961 aFI.SetNbIter(theNbIter);
963 //Compute the Solid value
965 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
968 if (!GetSolver()->ComputeFunction(aFunction)) {
969 SetErrorCode("Filling driver failed");
973 catch (Standard_Failure) {
974 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
975 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
976 SetErrorCode("B-Spline surface construction failed");
978 SetErrorCode(aFail->GetMessageString());
982 //Make a Python command
983 GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling("
984 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
985 << theTol2D << ", " << theTol3D << ", " << theNbIter << ")";
991 //=============================================================================
995 //=============================================================================
996 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
997 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1002 Handle(GEOM_Object) anObj;
1004 if(theSeqSections.IsNull())
1007 Standard_Integer nbObj = theSeqSections->Length();
1011 //Add a new ThruSections object
1012 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1015 //Add a new ThruSections function
1017 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1018 Handle(GEOM_Function) aFunction =
1019 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1020 if (aFunction.IsNull()) return anObj;
1022 //Check if the function is set correctly
1023 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1025 GEOMImpl_IThruSections aCI (aFunction);
1027 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1029 Standard_Integer i =1;
1030 for( ; i <= nbObj; i++) {
1032 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1036 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1037 if(!aSectObj.IsNull())
1039 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1040 if(!aRefSect.IsNull())
1041 aSeqSections->Append(aRefSect);
1045 if(!aSeqSections->Length())
1048 aCI.SetSections(aSeqSections);
1049 aCI.SetSolidMode(theModeSolid);
1050 aCI.SetPrecision(thePreci);
1052 //Compute the ThruSections value
1054 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1057 if (!GetSolver()->ComputeFunction(aFunction)) {
1058 SetErrorCode("ThruSections driver failed");
1062 catch (Standard_Failure) {
1063 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1064 SetErrorCode(aFail->GetMessageString());
1068 //Make a Python command
1069 GEOM::TPythonDump pyDump(aFunction);
1070 pyDump << aThruSect << " = geompy.MakeThruSections([";
1072 for(i =1 ; i <= nbObj; i++) {
1074 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1078 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1079 if(!aSectObj.IsNull()) {
1086 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1094 //=============================================================================
1096 * MakePipeWithDifferentSections
1098 //=============================================================================
1099 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1100 const Handle(TColStd_HSequenceOfTransient)& theBases,
1101 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1102 const Handle(GEOM_Object)& thePath,
1103 bool theWithContact,
1104 bool theWithCorrections)
1106 Handle(GEOM_Object) anObj;
1108 if(theBases.IsNull())
1111 Standard_Integer nbBases = theBases->Length();
1116 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1117 //Add a new Pipe object
1118 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1120 //Add a new Pipe function
1122 Handle(GEOM_Function) aFunction =
1123 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1124 if (aFunction.IsNull()) return anObj;
1126 //Check if the function is set correctly
1127 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1129 GEOMImpl_IPipeDiffSect aCI (aFunction);
1131 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1132 if(aRefPath.IsNull())
1135 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1136 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1138 Standard_Integer i =1;
1139 for( ; i <= nbBases; i++) {
1141 Handle(Standard_Transient) anItem = theBases->Value(i);
1145 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1148 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1149 if(aRefBase.IsNull())
1153 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1154 if(anItemLoc.IsNull())
1157 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1160 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1161 if(aRefLoc.IsNull())
1163 aSeqLocs->Append(aRefLoc);
1165 aSeqBases->Append(aRefBase);
1168 if(!aSeqBases->Length())
1171 aCI.SetBases(aSeqBases);
1172 aCI.SetLocations(aSeqLocs);
1173 aCI.SetPath(aRefPath);
1174 aCI.SetWithContactMode(theWithContact);
1175 aCI.SetWithCorrectionMode(theWithCorrections);
1177 //Compute the Pipe value
1179 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1182 if (!GetSolver()->ComputeFunction(aFunction)) {
1183 SetErrorCode("Pipe with defferent section driver failed");
1187 catch (Standard_Failure) {
1188 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1189 SetErrorCode(aFail->GetMessageString());
1193 //Make a Python command
1194 GEOM::TPythonDump pyDump(aFunction);
1195 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1197 for(i =1 ; i <= nbBases; i++) {
1199 Handle(Standard_Transient) anItem = theBases->Value(i);
1203 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1204 if(!anObj.IsNull()) {
1214 for(i =1 ; i <= nbLocs; i++) {
1216 Handle(Standard_Transient) anItem = theLocations->Value(i);
1220 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1221 if(!anObj.IsNull()) {
1228 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";