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>
62 #include <GEOMImpl_IPipeShellSect.hxx>
64 #include <Standard_Failure.hxx>
65 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
67 //=============================================================================
71 //=============================================================================
72 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
73 : GEOM_IOperations(theEngine, theDocID)
75 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
78 //=============================================================================
82 //=============================================================================
83 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
85 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
89 //=============================================================================
93 //=============================================================================
94 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
98 //Add a new Box object
99 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
101 //Add a new Box function with DX_DY_DZ parameters
102 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
103 if (aFunction.IsNull()) return NULL;
105 //Check if the function is set correctly
106 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
108 GEOMImpl_IBox aBI (aFunction);
114 //Compute the box value
116 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
119 if (!GetSolver()->ComputeFunction(aFunction)) {
120 SetErrorCode("Box driver failed");
124 catch (Standard_Failure) {
125 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
126 SetErrorCode(aFail->GetMessageString());
130 //Make a Python command
131 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
132 << theDX << ", " << theDY << ", " << theDZ << ")";
139 //=============================================================================
143 //=============================================================================
144 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
145 Handle(GEOM_Object) thePnt2)
149 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
151 //Add a new Box object
152 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
154 //Add a new Box function for creation a box relatively to two points
155 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
156 if (aFunction.IsNull()) return NULL;
158 //Check if the function is set correctly
159 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
161 GEOMImpl_IBox aBI (aFunction);
163 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
164 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
166 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
168 aBI.SetRef1(aRefFunction1);
169 aBI.SetRef2(aRefFunction2);
171 //Compute the Box value
173 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
176 if (!GetSolver()->ComputeFunction(aFunction)) {
177 SetErrorCode("Box driver failed");
181 catch (Standard_Failure) {
182 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
183 SetErrorCode(aFail->GetMessageString());
187 //Make a Python command
188 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
189 << thePnt1 << ", " << thePnt2 << ")";
196 //=============================================================================
200 //=============================================================================
201 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
205 //Add a new Cylinder object
206 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
208 //Add a new Cylinder function with R and H parameters
209 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
210 if (aFunction.IsNull()) return NULL;
212 //Check if the function is set correctly
213 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
215 GEOMImpl_ICylinder aCI (aFunction);
220 //Compute the Cylinder value
222 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
225 if (!GetSolver()->ComputeFunction(aFunction)) {
226 SetErrorCode("Cylinder driver failed");
230 catch (Standard_Failure) {
231 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
232 SetErrorCode(aFail->GetMessageString());
236 //Make a Python command
237 GEOM::TPythonDump(aFunction) << aCylinder
238 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
245 //=============================================================================
247 * MakeCylinderPntVecRH
249 //=============================================================================
250 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
251 Handle(GEOM_Object) theVec,
252 double theR, double theH)
256 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
258 //Add a new Cylinder object
259 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
261 //Add a new Cylinder function for creation a cylinder relatively to point and vector
262 Handle(GEOM_Function) aFunction =
263 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
264 if (aFunction.IsNull()) return NULL;
266 //Check if the function is set correctly
267 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
269 GEOMImpl_ICylinder aCI (aFunction);
271 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
272 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
274 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
276 aCI.SetPoint(aRefPnt);
277 aCI.SetVector(aRefVec);
281 //Compute the Cylinder value
283 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
286 if (!GetSolver()->ComputeFunction(aFunction)) {
287 SetErrorCode("Cylinder driver failed");
291 catch (Standard_Failure) {
292 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
293 SetErrorCode(aFail->GetMessageString());
297 //Make a Python command
298 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
299 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
306 //=============================================================================
310 //=============================================================================
311 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
316 //Add a new Cone object
317 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
319 //Add a new Cone function with R and H parameters
320 Handle(GEOM_Function) aFunction =
321 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
322 if (aFunction.IsNull()) return NULL;
324 //Check if the function is set correctly
325 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
327 GEOMImpl_ICone aCI (aFunction);
333 //Compute the Cone value
335 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
338 if (!GetSolver()->ComputeFunction(aFunction)) {
339 SetErrorCode("Cone driver failed");
343 catch (Standard_Failure) {
344 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
345 SetErrorCode(aFail->GetMessageString());
349 //Make a Python command
350 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
351 << theR1 << ", " << theR2 << ", " << theH << ")";
358 //=============================================================================
360 * MakeConePntVecR1R2H
362 //=============================================================================
363 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
364 Handle(GEOM_Object) theVec,
365 double theR1, double theR2,
370 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
372 //Add a new Cone object
373 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
375 //Add a new Cone function for creation a cone relatively to point and vector
376 Handle(GEOM_Function) aFunction =
377 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
378 if (aFunction.IsNull()) return NULL;
380 //Check if the function is set correctly
381 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
383 GEOMImpl_ICone aCI (aFunction);
385 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
386 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
388 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
390 aCI.SetPoint(aRefPnt);
391 aCI.SetVector(aRefVec);
396 //Compute the Cone value
398 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
401 if (!GetSolver()->ComputeFunction(aFunction)) {
402 SetErrorCode("Cone driver failed");
406 catch (Standard_Failure) {
407 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
408 SetErrorCode(aFail->GetMessageString());
412 //Make a Python command
413 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
414 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
421 //=============================================================================
425 //=============================================================================
426 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
430 //Add a new Sphere object
431 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
433 //Add a new Sphere function with R parameter
434 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
435 if (aFunction.IsNull()) return NULL;
437 //Check if the function is set correctly
438 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
440 GEOMImpl_ISphere aCI (aFunction);
444 //Compute the Sphere value
446 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
449 if (!GetSolver()->ComputeFunction(aFunction)) {
450 SetErrorCode("Sphere driver failed");
454 catch (Standard_Failure) {
455 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
456 SetErrorCode(aFail->GetMessageString());
460 //Make a Python command
461 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
468 //=============================================================================
472 //=============================================================================
473 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
478 if (thePnt.IsNull()) return NULL;
480 //Add a new Point object
481 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
483 //Add a new Sphere function for creation a sphere relatively to point
484 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
485 if (aFunction.IsNull()) return NULL;
487 //Check if the function is set correctly
488 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
490 GEOMImpl_ISphere aCI (aFunction);
492 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
494 if (aRefPnt.IsNull()) return NULL;
496 aCI.SetPoint(aRefPnt);
499 //Compute the Sphere value
501 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
504 if (!GetSolver()->ComputeFunction(aFunction)) {
505 SetErrorCode("Sphere driver failed");
509 catch (Standard_Failure) {
510 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
511 SetErrorCode(aFail->GetMessageString());
515 //Make a Python command
516 GEOM::TPythonDump(aFunction) << aSphere
517 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
524 //=============================================================================
528 //=============================================================================
529 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
530 (double theRMajor, double theRMinor)
534 //Add a new Torus object
535 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
537 //Add a new Torus function
538 Handle(GEOM_Function) aFunction =
539 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
540 if (aFunction.IsNull()) return NULL;
542 //Check if the function is set correctly
543 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
545 GEOMImpl_ITorus aCI (aFunction);
547 aCI.SetRMajor(theRMajor);
548 aCI.SetRMinor(theRMinor);
550 //Compute the Torus value
552 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
555 if (!GetSolver()->ComputeFunction(aFunction)) {
556 SetErrorCode("Torus driver failed");
560 catch (Standard_Failure) {
561 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
562 SetErrorCode(aFail->GetMessageString());
566 //Make a Python command
567 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
568 << theRMajor << ", " << theRMinor << ")";
574 //=============================================================================
578 //=============================================================================
579 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
580 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
581 double theRMajor, double theRMinor)
585 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
587 //Add a new Torus object
588 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
590 //Add a new Torus function
591 Handle(GEOM_Function) aFunction =
592 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
593 if (aFunction.IsNull()) return NULL;
595 //Check if the function is set correctly
596 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
598 GEOMImpl_ITorus aCI (aFunction);
600 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
601 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
603 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
605 aCI.SetCenter(aRefPnt);
606 aCI.SetVector(aRefVec);
607 aCI.SetRMajor(theRMajor);
608 aCI.SetRMinor(theRMinor);
610 //Compute the Torus value
612 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
615 if (!GetSolver()->ComputeFunction(aFunction)) {
616 SetErrorCode("Torus driver failed");
620 catch (Standard_Failure) {
621 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
622 SetErrorCode(aFail->GetMessageString());
626 //Make a Python command
627 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
628 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
635 //=============================================================================
639 //=============================================================================
640 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
641 Handle(GEOM_Object) theVec,
646 if (theBase.IsNull() || theVec.IsNull()) return NULL;
648 //Add a new Prism object
649 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
651 //Add a new Prism function for creation a Prism relatively to vector
652 Handle(GEOM_Function) aFunction =
653 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
654 if (aFunction.IsNull()) return NULL;
656 //Check if the function is set correctly
657 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
659 GEOMImpl_IPrism aCI (aFunction);
661 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
662 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
664 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
666 aCI.SetBase(aRefBase);
667 aCI.SetVector(aRefVec);
670 //Compute the Prism value
672 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
675 if (!GetSolver()->ComputeFunction(aFunction)) {
676 //SetErrorCode("Prism driver failed");
677 SetErrorCode("Extrusion can not be created, check input data");
681 catch (Standard_Failure) {
682 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
683 SetErrorCode(aFail->GetMessageString());
687 //Make a Python command
688 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
689 << theBase << ", " << theVec << ", " << theH << ")";
695 //=============================================================================
699 //=============================================================================
700 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
701 (Handle(GEOM_Object) theBase,
702 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
706 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
708 //Add a new Prism object
709 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
711 //Add a new Prism function for creation a Prism relatively to two points
712 Handle(GEOM_Function) aFunction =
713 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
714 if (aFunction.IsNull()) return NULL;
716 //Check if the function is set correctly
717 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
719 GEOMImpl_IPrism aCI (aFunction);
721 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
722 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
723 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
725 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
727 aCI.SetBase(aRefBase);
728 aCI.SetFirstPoint(aRefPnt1);
729 aCI.SetLastPoint(aRefPnt2);
731 //Compute the Prism value
733 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
736 if (!GetSolver()->ComputeFunction(aFunction)) {
737 //SetErrorCode("Prism driver failed");
738 SetErrorCode("Extrusion can not be created, check input data");
742 catch (Standard_Failure) {
743 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
744 SetErrorCode(aFail->GetMessageString());
748 //Make a Python command
749 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
750 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
757 //=============================================================================
761 //=============================================================================
762 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
763 Handle(GEOM_Object) thePath)
767 if (theBase.IsNull() || thePath.IsNull()) return NULL;
769 //Add a new Pipe object
770 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
772 //Add a new Pipe function
773 Handle(GEOM_Function) aFunction =
774 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
775 if (aFunction.IsNull()) return NULL;
777 //Check if the function is set correctly
778 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
780 GEOMImpl_IPipe aCI (aFunction);
782 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
783 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
785 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
787 aCI.SetBase(aRefBase);
788 aCI.SetPath(aRefPath);
790 //Compute the Pipe value
792 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
795 if (!GetSolver()->ComputeFunction(aFunction)) {
796 SetErrorCode("Pipe driver failed");
800 catch (Standard_Failure) {
801 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
802 SetErrorCode(aFail->GetMessageString());
806 //Make a Python command
807 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
808 << theBase << ", " << thePath << ")";
815 //=============================================================================
817 * MakeRevolutionAxisAngle
819 //=============================================================================
820 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
821 Handle(GEOM_Object) theAxis,
826 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
828 //Add a new Revolution object
829 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
831 //Add a new Revolution function for creation a revolution relatively to axis
832 Handle(GEOM_Function) aFunction =
833 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
834 if (aFunction.IsNull()) return NULL;
836 //Check if the function is set correctly
837 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
839 GEOMImpl_IRevolution aCI (aFunction);
841 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
842 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
844 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
846 aCI.SetBase(aRefBase);
847 aCI.SetAxis(aRefAxis);
848 aCI.SetAngle(theAngle);
850 //Compute the Revolution value
852 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
855 if (!GetSolver()->ComputeFunction(aFunction)) {
856 SetErrorCode("Revolution driver failed");
860 catch (Standard_Failure) {
861 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
862 SetErrorCode(aFail->GetMessageString());
866 //Make a Python command
867 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
868 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
875 //=============================================================================
879 //=============================================================================
880 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
884 if (theShell.IsNull()) return NULL;
886 //Add a new Solid object
887 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
889 //Add a new Solid function for creation a solid from a shell
890 Handle(GEOM_Function) aFunction =
891 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
892 if (aFunction.IsNull()) return NULL;
894 //Check if the function is set correctly
895 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
897 GEOMImpl_IShapes aCI (aFunction);
899 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
901 if (aRefShell.IsNull()) return NULL;
903 aCI.SetBase(aRefShell);
905 //Compute the Solid value
907 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
910 if (!GetSolver()->ComputeFunction(aFunction)) {
911 SetErrorCode("Solid driver failed");
915 catch (Standard_Failure) {
916 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
917 SetErrorCode(aFail->GetMessageString());
921 //Make a Python command
922 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
928 //=============================================================================
932 //=============================================================================
933 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
934 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
935 double theTol2D, double theTol3D, int theNbIter)
939 if (theShape.IsNull()) return NULL;
941 //Add a new Filling object
942 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
944 //Add a new Filling function for creation a filling from a compound
945 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
946 if (aFunction.IsNull()) return NULL;
948 //Check if the function is set correctly
949 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
951 GEOMImpl_IFilling aFI (aFunction);
953 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
955 if (aRefShape.IsNull()) return NULL;
957 aFI.SetShape(aRefShape);
958 aFI.SetMinDeg(theMinDeg);
959 aFI.SetMaxDeg(theMaxDeg);
960 aFI.SetTol2D(theTol2D);
961 aFI.SetTol3D(theTol3D);
962 aFI.SetNbIter(theNbIter);
964 //Compute the Solid value
966 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
969 if (!GetSolver()->ComputeFunction(aFunction)) {
970 SetErrorCode("Filling driver failed");
974 catch (Standard_Failure) {
975 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
976 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
977 SetErrorCode("B-Spline surface construction failed");
979 SetErrorCode(aFail->GetMessageString());
983 //Make a Python command
984 GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling("
985 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
986 << theTol2D << ", " << theTol3D << ", " << theNbIter << ")";
992 //=============================================================================
996 //=============================================================================
997 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
998 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1003 Handle(GEOM_Object) anObj;
1005 if(theSeqSections.IsNull())
1008 Standard_Integer nbObj = theSeqSections->Length();
1012 //Add a new ThruSections object
1013 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1016 //Add a new ThruSections function
1018 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1019 Handle(GEOM_Function) aFunction =
1020 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1021 if (aFunction.IsNull()) return anObj;
1023 //Check if the function is set correctly
1024 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1026 GEOMImpl_IThruSections aCI (aFunction);
1028 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1030 Standard_Integer i =1;
1031 for( ; i <= nbObj; i++) {
1033 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1037 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1038 if(!aSectObj.IsNull())
1040 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1041 if(!aRefSect.IsNull())
1042 aSeqSections->Append(aRefSect);
1046 if(!aSeqSections->Length())
1049 aCI.SetSections(aSeqSections);
1050 aCI.SetSolidMode(theModeSolid);
1051 aCI.SetPrecision(thePreci);
1053 //Compute the ThruSections value
1055 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1058 if (!GetSolver()->ComputeFunction(aFunction)) {
1059 SetErrorCode("ThruSections driver failed");
1063 catch (Standard_Failure) {
1064 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1065 SetErrorCode(aFail->GetMessageString());
1069 //Make a Python command
1070 GEOM::TPythonDump pyDump(aFunction);
1071 pyDump << aThruSect << " = geompy.MakeThruSections([";
1073 for(i =1 ; i <= nbObj; i++) {
1075 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1079 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1080 if(!aSectObj.IsNull()) {
1087 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1096 //=============================================================================
1098 * MakePipeWithDifferentSections
1100 //=============================================================================
1101 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1102 const Handle(TColStd_HSequenceOfTransient)& theBases,
1103 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1104 const Handle(GEOM_Object)& thePath,
1105 bool theWithContact,
1106 bool theWithCorrections)
1108 Handle(GEOM_Object) anObj;
1110 if(theBases.IsNull())
1113 Standard_Integer nbBases = theBases->Length();
1118 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1119 //Add a new Pipe object
1120 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1122 //Add a new Pipe function
1124 Handle(GEOM_Function) aFunction =
1125 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1126 if (aFunction.IsNull()) return anObj;
1128 //Check if the function is set correctly
1129 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1131 GEOMImpl_IPipeDiffSect aCI (aFunction);
1133 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1134 if(aRefPath.IsNull())
1137 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1138 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1140 Standard_Integer i =1;
1141 for( ; i <= nbBases; i++) {
1143 Handle(Standard_Transient) anItem = theBases->Value(i);
1147 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1150 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1151 if(aRefBase.IsNull())
1155 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1156 if(anItemLoc.IsNull())
1159 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1162 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1163 if(aRefLoc.IsNull())
1165 aSeqLocs->Append(aRefLoc);
1167 aSeqBases->Append(aRefBase);
1170 if(!aSeqBases->Length())
1173 aCI.SetBases(aSeqBases);
1174 aCI.SetLocations(aSeqLocs);
1175 aCI.SetPath(aRefPath);
1176 aCI.SetWithContactMode(theWithContact);
1177 aCI.SetWithCorrectionMode(theWithCorrections);
1179 //Compute the Pipe value
1181 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1184 if (!GetSolver()->ComputeFunction(aFunction)) {
1185 SetErrorCode("Pipe with defferent section driver failed");
1189 catch (Standard_Failure) {
1190 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1191 SetErrorCode(aFail->GetMessageString());
1195 //Make a Python command
1196 GEOM::TPythonDump pyDump(aFunction);
1197 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1199 for(i =1 ; i <= nbBases; i++) {
1201 Handle(Standard_Transient) anItem = theBases->Value(i);
1205 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1206 if(!anObj.IsNull()) {
1216 for(i =1 ; i <= nbLocs; i++) {
1218 Handle(Standard_Transient) anItem = theLocations->Value(i);
1222 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1223 if(!anObj.IsNull()) {
1230 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1239 //=============================================================================
1241 * MakePipeWithShellSections
1243 //=============================================================================
1244 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1245 const Handle(TColStd_HSequenceOfTransient)& theBases,
1246 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1247 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1248 const Handle(GEOM_Object)& thePath,
1249 bool theWithContact,
1250 bool theWithCorrections)
1252 Handle(GEOM_Object) anObj;
1254 if(theBases.IsNull())
1257 Standard_Integer nbBases = theBases->Length();
1262 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1264 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1266 //Add a new Pipe object
1267 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1269 //Add a new Pipe function
1271 Handle(GEOM_Function) aFunction =
1272 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1273 if (aFunction.IsNull()) return anObj;
1275 //Check if the function is set correctly
1276 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1278 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1279 GEOMImpl_IPipeShellSect aCI (aFunction);
1281 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1282 if(aRefPath.IsNull())
1285 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1286 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1287 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1289 Standard_Integer i =1;
1290 for( ; i <= nbBases; i++) {
1292 Handle(Standard_Transient) anItem = theBases->Value(i);
1295 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1298 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1299 if(aRefBase.IsNull())
1302 if( nbSubBases >= nbBases ) {
1303 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1304 if(aSubItem.IsNull())
1306 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1307 if(aSubBase.IsNull())
1309 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1310 if(aRefSubBase.IsNull())
1312 aSeqSubBases->Append(aRefSubBase);
1316 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1317 if(anItemLoc.IsNull())
1319 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1322 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1323 if(aRefLoc.IsNull())
1325 aSeqLocs->Append(aRefLoc);
1328 aSeqBases->Append(aRefBase);
1331 if(!aSeqBases->Length())
1334 aCI.SetBases(aSeqBases);
1335 aCI.SetSubBases(aSeqSubBases);
1336 aCI.SetLocations(aSeqLocs);
1337 aCI.SetPath(aRefPath);
1338 aCI.SetWithContactMode(theWithContact);
1339 aCI.SetWithCorrectionMode(theWithCorrections);
1341 //Compute the Pipe value
1343 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1346 if (!GetSolver()->ComputeFunction(aFunction)) {
1347 SetErrorCode("Pipe with shell sections driver failed");
1351 catch (Standard_Failure) {
1352 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1353 SetErrorCode(aFail->GetMessageString());
1357 //Make a Python command
1358 GEOM::TPythonDump pyDump(aFunction);
1359 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1361 for(i =1 ; i <= nbBases; i++) {
1363 Handle(Standard_Transient) anItem = theBases->Value(i);
1367 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1368 if(!anObj.IsNull()) {
1378 for(i =1 ; i <= nbLocs; i++) {
1380 Handle(Standard_Transient) anItem = theLocations->Value(i);
1384 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1385 if(!anObj.IsNull()) {
1392 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";