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::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
701 Handle(GEOM_Object) theVec,
706 if (theBase.IsNull() || theVec.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 vector
712 Handle(GEOM_Function) aFunction =
713 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
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) aRefVec = theVec->GetLastFunction();
724 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
726 aCI.SetBase(aRefBase);
727 aCI.SetVector(aRefVec);
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.MakePrismVecH2Ways("
749 << theBase << ", " << theVec << ", " << theH << ")";
755 //=============================================================================
759 //=============================================================================
760 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
761 (Handle(GEOM_Object) theBase,
762 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
766 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
768 //Add a new Prism object
769 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
771 //Add a new Prism function for creation a Prism relatively to two points
772 Handle(GEOM_Function) aFunction =
773 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
774 if (aFunction.IsNull()) return NULL;
776 //Check if the function is set correctly
777 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
779 GEOMImpl_IPrism aCI (aFunction);
781 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
782 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
783 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
785 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
787 aCI.SetBase(aRefBase);
788 aCI.SetFirstPoint(aRefPnt1);
789 aCI.SetLastPoint(aRefPnt2);
791 //Compute the Prism value
793 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
796 if (!GetSolver()->ComputeFunction(aFunction)) {
797 //SetErrorCode("Prism driver failed");
798 SetErrorCode("Extrusion can not be created, check input data");
802 catch (Standard_Failure) {
803 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
804 SetErrorCode(aFail->GetMessageString());
808 //Make a Python command
809 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
810 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
816 //=============================================================================
818 * MakePrismTwoPnt2Ways
820 //=============================================================================
821 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
822 (Handle(GEOM_Object) theBase,
823 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
827 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
829 //Add a new Prism object
830 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
832 //Add a new Prism function for creation a Prism relatively to two points
833 Handle(GEOM_Function) aFunction =
834 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
835 if (aFunction.IsNull()) return NULL;
837 //Check if the function is set correctly
838 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
840 GEOMImpl_IPrism aCI (aFunction);
842 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
843 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
844 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
846 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
848 aCI.SetBase(aRefBase);
849 aCI.SetFirstPoint(aRefPnt1);
850 aCI.SetLastPoint(aRefPnt2);
852 //Compute the Prism value
854 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
857 if (!GetSolver()->ComputeFunction(aFunction)) {
858 //SetErrorCode("Prism driver failed");
859 SetErrorCode("Extrusion can not be created, check input data");
863 catch (Standard_Failure) {
864 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
865 SetErrorCode(aFail->GetMessageString());
869 //Make a Python command
870 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
871 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
878 //=============================================================================
882 //=============================================================================
883 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
884 Handle(GEOM_Object) thePath)
888 if (theBase.IsNull() || thePath.IsNull()) return NULL;
890 //Add a new Pipe object
891 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
893 //Add a new Pipe function
894 Handle(GEOM_Function) aFunction =
895 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
896 if (aFunction.IsNull()) return NULL;
898 //Check if the function is set correctly
899 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
901 GEOMImpl_IPipe aCI (aFunction);
903 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
904 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
906 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
908 aCI.SetBase(aRefBase);
909 aCI.SetPath(aRefPath);
911 //Compute the Pipe value
913 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
916 if (!GetSolver()->ComputeFunction(aFunction)) {
917 SetErrorCode("Pipe driver failed");
921 catch (Standard_Failure) {
922 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
923 SetErrorCode(aFail->GetMessageString());
927 //Make a Python command
928 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
929 << theBase << ", " << thePath << ")";
936 //=============================================================================
938 * MakeRevolutionAxisAngle
940 //=============================================================================
941 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
942 Handle(GEOM_Object) theAxis,
947 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
949 //Add a new Revolution object
950 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
952 //Add a new Revolution function for creation a revolution relatively to axis
953 Handle(GEOM_Function) aFunction =
954 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
955 if (aFunction.IsNull()) return NULL;
957 //Check if the function is set correctly
958 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
960 GEOMImpl_IRevolution aCI (aFunction);
962 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
963 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
965 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
967 aCI.SetBase(aRefBase);
968 aCI.SetAxis(aRefAxis);
969 aCI.SetAngle(theAngle);
971 //Compute the Revolution value
973 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
976 if (!GetSolver()->ComputeFunction(aFunction)) {
977 SetErrorCode("Revolution driver failed");
981 catch (Standard_Failure) {
982 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
983 SetErrorCode(aFail->GetMessageString());
987 //Make a Python command
988 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
989 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
995 //=============================================================================
997 * MakeRevolutionAxisAngle2Ways
999 //=============================================================================
1000 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1001 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1005 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1007 //Add a new Revolution object
1008 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1010 //Add a new Revolution function for creation a revolution relatively to axis
1011 Handle(GEOM_Function) aFunction =
1012 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1013 if (aFunction.IsNull()) return NULL;
1015 //Check if the function is set correctly
1016 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1018 GEOMImpl_IRevolution aCI (aFunction);
1020 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1021 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1023 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1025 aCI.SetBase(aRefBase);
1026 aCI.SetAxis(aRefAxis);
1027 aCI.SetAngle(theAngle);
1029 //Compute the Revolution value
1031 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1034 if (!GetSolver()->ComputeFunction(aFunction)) {
1035 SetErrorCode("Revolution driver failed");
1039 catch (Standard_Failure) {
1040 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1041 SetErrorCode(aFail->GetMessageString());
1045 //Make a Python command
1046 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1047 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1053 //=============================================================================
1057 //=============================================================================
1058 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
1062 if (theShell.IsNull()) return NULL;
1064 //Add a new Solid object
1065 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
1067 //Add a new Solid function for creation a solid from a shell
1068 Handle(GEOM_Function) aFunction =
1069 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
1070 if (aFunction.IsNull()) return NULL;
1072 //Check if the function is set correctly
1073 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
1075 GEOMImpl_IShapes aCI (aFunction);
1077 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
1079 if (aRefShell.IsNull()) return NULL;
1081 aCI.SetBase(aRefShell);
1083 //Compute the Solid value
1085 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1088 if (!GetSolver()->ComputeFunction(aFunction)) {
1089 SetErrorCode("Solid driver failed");
1093 catch (Standard_Failure) {
1094 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1095 SetErrorCode(aFail->GetMessageString());
1099 //Make a Python command
1100 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
1106 //=============================================================================
1110 //=============================================================================
1111 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1112 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1113 double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1117 if (theShape.IsNull()) return NULL;
1119 //Add a new Filling object
1120 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1122 //Add a new Filling function for creation a filling from a compound
1123 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1124 if (aFunction.IsNull()) return NULL;
1126 //Check if the function is set correctly
1127 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1129 GEOMImpl_IFilling aFI (aFunction);
1131 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1133 if (aRefShape.IsNull()) return NULL;
1135 aFI.SetShape(aRefShape);
1136 aFI.SetMinDeg(theMinDeg);
1137 aFI.SetMaxDeg(theMaxDeg);
1138 aFI.SetTol2D(theTol2D);
1139 aFI.SetTol3D(theTol3D);
1140 aFI.SetNbIter(theNbIter);
1141 aFI.SetApprox(isApprox);
1143 //Compute the Solid value
1145 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1148 if (!GetSolver()->ComputeFunction(aFunction)) {
1149 SetErrorCode("Filling driver failed");
1153 catch (Standard_Failure) {
1154 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1155 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1156 SetErrorCode("B-Spline surface construction failed");
1158 SetErrorCode(aFail->GetMessageString());
1162 //Make a Python command
1163 GEOM::TPythonDump pd (aFunction);
1164 pd << aFilling << " = geompy.MakeFilling("
1165 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1166 << theTol2D << ", " << theTol3D << ", " << theNbIter;
1168 pd << ", " << isApprox;
1175 //=============================================================================
1179 //=============================================================================
1180 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1181 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1186 Handle(GEOM_Object) anObj;
1188 if(theSeqSections.IsNull())
1191 Standard_Integer nbObj = theSeqSections->Length();
1195 //Add a new ThruSections object
1196 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1199 //Add a new ThruSections function
1201 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1202 Handle(GEOM_Function) aFunction =
1203 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1204 if (aFunction.IsNull()) return anObj;
1206 //Check if the function is set correctly
1207 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1209 GEOMImpl_IThruSections aCI (aFunction);
1211 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1213 Standard_Integer i =1;
1214 for( ; i <= nbObj; i++) {
1216 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1220 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1221 if(!aSectObj.IsNull())
1223 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1224 if(!aRefSect.IsNull())
1225 aSeqSections->Append(aRefSect);
1229 if(!aSeqSections->Length())
1232 aCI.SetSections(aSeqSections);
1233 aCI.SetSolidMode(theModeSolid);
1234 aCI.SetPrecision(thePreci);
1236 //Compute the ThruSections value
1238 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1241 if (!GetSolver()->ComputeFunction(aFunction)) {
1242 SetErrorCode("ThruSections driver failed");
1246 catch (Standard_Failure) {
1247 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1248 SetErrorCode(aFail->GetMessageString());
1252 //Make a Python command
1253 GEOM::TPythonDump pyDump(aFunction);
1254 pyDump << aThruSect << " = geompy.MakeThruSections([";
1256 for(i =1 ; i <= nbObj; i++) {
1258 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1262 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1263 if(!aSectObj.IsNull()) {
1270 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1279 //=============================================================================
1281 * MakePipeWithDifferentSections
1283 //=============================================================================
1284 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1285 const Handle(TColStd_HSequenceOfTransient)& theBases,
1286 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1287 const Handle(GEOM_Object)& thePath,
1288 bool theWithContact,
1289 bool theWithCorrections)
1291 Handle(GEOM_Object) anObj;
1293 if(theBases.IsNull())
1296 Standard_Integer nbBases = theBases->Length();
1301 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1302 //Add a new Pipe object
1303 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1305 //Add a new Pipe function
1307 Handle(GEOM_Function) aFunction =
1308 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1309 if (aFunction.IsNull()) return anObj;
1311 //Check if the function is set correctly
1312 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1314 GEOMImpl_IPipeDiffSect aCI (aFunction);
1316 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1317 if(aRefPath.IsNull())
1320 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1321 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1323 Standard_Integer i =1;
1324 for( ; i <= nbBases; i++) {
1326 Handle(Standard_Transient) anItem = theBases->Value(i);
1330 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1333 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1334 if(aRefBase.IsNull())
1338 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1339 if(anItemLoc.IsNull())
1342 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1345 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1346 if(aRefLoc.IsNull())
1348 aSeqLocs->Append(aRefLoc);
1350 aSeqBases->Append(aRefBase);
1353 if(!aSeqBases->Length())
1356 aCI.SetBases(aSeqBases);
1357 aCI.SetLocations(aSeqLocs);
1358 aCI.SetPath(aRefPath);
1359 aCI.SetWithContactMode(theWithContact);
1360 aCI.SetWithCorrectionMode(theWithCorrections);
1362 //Compute the Pipe value
1364 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1367 if (!GetSolver()->ComputeFunction(aFunction)) {
1368 SetErrorCode("Pipe with defferent section driver failed");
1372 catch (Standard_Failure) {
1373 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1374 SetErrorCode(aFail->GetMessageString());
1378 //Make a Python command
1379 GEOM::TPythonDump pyDump(aFunction);
1380 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1382 for(i =1 ; i <= nbBases; i++) {
1384 Handle(Standard_Transient) anItem = theBases->Value(i);
1388 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1389 if(!anObj.IsNull()) {
1399 for(i =1 ; i <= nbLocs; i++) {
1401 Handle(Standard_Transient) anItem = theLocations->Value(i);
1405 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1406 if(!anObj.IsNull()) {
1413 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1422 //=============================================================================
1424 * MakePipeWithShellSections
1426 //=============================================================================
1427 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1428 const Handle(TColStd_HSequenceOfTransient)& theBases,
1429 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1430 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1431 const Handle(GEOM_Object)& thePath,
1432 bool theWithContact,
1433 bool theWithCorrections)
1435 Handle(GEOM_Object) anObj;
1437 if(theBases.IsNull())
1440 Standard_Integer nbBases = theBases->Length();
1445 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1447 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1449 //Add a new Pipe object
1450 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1452 //Add a new Pipe function
1454 Handle(GEOM_Function) aFunction =
1455 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1456 if (aFunction.IsNull()) return anObj;
1458 //Check if the function is set correctly
1459 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1461 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1462 GEOMImpl_IPipeShellSect aCI (aFunction);
1464 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1465 if(aRefPath.IsNull())
1468 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1469 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1470 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1472 Standard_Integer i =1;
1473 for( ; i <= nbBases; i++) {
1475 Handle(Standard_Transient) anItem = theBases->Value(i);
1478 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1481 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1482 if(aRefBase.IsNull())
1485 if( nbSubBases >= nbBases ) {
1486 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1487 if(aSubItem.IsNull())
1489 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1490 if(aSubBase.IsNull())
1492 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1493 if(aRefSubBase.IsNull())
1495 aSeqSubBases->Append(aRefSubBase);
1499 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1500 if(anItemLoc.IsNull())
1502 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1505 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1506 if(aRefLoc.IsNull())
1508 aSeqLocs->Append(aRefLoc);
1511 aSeqBases->Append(aRefBase);
1514 if(!aSeqBases->Length())
1517 aCI.SetBases(aSeqBases);
1518 aCI.SetSubBases(aSeqSubBases);
1519 aCI.SetLocations(aSeqLocs);
1520 aCI.SetPath(aRefPath);
1521 aCI.SetWithContactMode(theWithContact);
1522 aCI.SetWithCorrectionMode(theWithCorrections);
1524 //Compute the Pipe value
1526 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1529 if (!GetSolver()->ComputeFunction(aFunction)) {
1530 SetErrorCode("Pipe with shell sections driver failed");
1534 catch (Standard_Failure) {
1535 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1536 SetErrorCode(aFail->GetMessageString());
1540 //Make a Python command
1541 GEOM::TPythonDump pyDump(aFunction);
1542 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1544 for(i =1 ; i <= nbBases; i++) {
1546 Handle(Standard_Transient) anItem = theBases->Value(i);
1550 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1551 if(!anObj.IsNull()) {
1561 for(i =1 ; i <= nbSubBases; i++) {
1563 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1567 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1568 if(!anObj.IsNull()) {
1578 for(i =1 ; i <= nbLocs; i++) {
1580 Handle(Standard_Transient) anItem = theLocations->Value(i);
1584 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1585 if(!anObj.IsNull()) {
1592 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1600 //=============================================================================
1602 * MakePipeShellsWithoutPath
1604 //=============================================================================
1605 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1606 const Handle(TColStd_HSequenceOfTransient)& theBases,
1607 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1609 Handle(GEOM_Object) anObj;
1611 if(theBases.IsNull())
1614 Standard_Integer nbBases = theBases->Length();
1619 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1621 //Add a new Pipe object
1622 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1624 //Add a new Pipe function
1626 Handle(GEOM_Function) aFunction =
1627 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1628 if (aFunction.IsNull()) return anObj;
1630 //Check if the function is set correctly
1631 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1633 GEOMImpl_IPipeShellSect aCI (aFunction);
1635 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1636 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1638 Standard_Integer i =1;
1639 for( ; i <= nbBases; i++) {
1641 Handle(Standard_Transient) anItem = theBases->Value(i);
1644 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1647 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1648 if(aRefBase.IsNull())
1652 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1653 if(anItemLoc.IsNull())
1655 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1658 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1659 if(aRefLoc.IsNull())
1661 aSeqLocs->Append(aRefLoc);
1664 aSeqBases->Append(aRefBase);
1667 if(!aSeqBases->Length())
1670 aCI.SetBases(aSeqBases);
1671 aCI.SetLocations(aSeqLocs);
1673 //Compute the Pipe value
1675 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1678 if (!GetSolver()->ComputeFunction(aFunction)) {
1679 SetErrorCode("Pipe with shell sections without path driver failed");
1683 catch (Standard_Failure) {
1684 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1685 SetErrorCode(aFail->GetMessageString());
1689 //Make a Python command
1690 GEOM::TPythonDump pyDump(aFunction);
1691 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
1693 for(i =1 ; i <= nbBases; i++) {
1695 Handle(Standard_Transient) anItem = theBases->Value(i);
1699 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1700 if(!anObj.IsNull()) {
1710 for(i =1 ; i <= nbLocs; i++) {
1712 Handle(Standard_Transient) anItem = theLocations->Value(i);
1716 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1717 if(!anObj.IsNull()) {