1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_I3DPrimOperations.hxx>
26 #include "utilities.h"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TFunction_Logbook.hxx>
33 #include <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_Types.hxx>
40 #include <GEOMImpl_BoxDriver.hxx>
41 #include <GEOMImpl_CylinderDriver.hxx>
42 #include <GEOMImpl_ConeDriver.hxx>
43 #include <GEOMImpl_SphereDriver.hxx>
44 #include <GEOMImpl_TorusDriver.hxx>
45 #include <GEOMImpl_PrismDriver.hxx>
46 #include <GEOMImpl_PipeDriver.hxx>
47 #include <GEOMImpl_RevolutionDriver.hxx>
48 #include <GEOMImpl_ShapeDriver.hxx>
49 #include <GEOMImpl_FillingDriver.hxx>
50 #include <GEOMImpl_ThruSectionsDriver.hxx>
52 #include <GEOMImpl_IBox.hxx>
53 #include <GEOMImpl_ICylinder.hxx>
54 #include <GEOMImpl_ICone.hxx>
55 #include <GEOMImpl_ISphere.hxx>
56 #include <GEOMImpl_ITorus.hxx>
57 #include <GEOMImpl_IPrism.hxx>
58 #include <GEOMImpl_IPipe.hxx>
59 #include <GEOMImpl_IRevolution.hxx>
60 #include <GEOMImpl_IShapes.hxx>
61 #include <GEOMImpl_IFilling.hxx>
62 #include <GEOMImpl_IThruSections.hxx>
63 #include <GEOMImpl_IPipeDiffSect.hxx>
64 #include <GEOMImpl_IPipeShellSect.hxx>
65 #include <GEOMImpl_IPipeBiNormal.hxx>
67 #include <Standard_Failure.hxx>
68 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
70 //=============================================================================
74 //=============================================================================
75 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
76 : GEOM_IOperations(theEngine, theDocID)
78 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
81 //=============================================================================
85 //=============================================================================
86 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
88 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
92 //=============================================================================
96 //=============================================================================
97 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
101 //Add a new Box object
102 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
104 //Add a new Box function with DX_DY_DZ parameters
105 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
106 if (aFunction.IsNull()) return NULL;
108 //Check if the function is set correctly
109 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
111 GEOMImpl_IBox aBI (aFunction);
117 //Compute the box value
119 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
122 if (!GetSolver()->ComputeFunction(aFunction)) {
123 SetErrorCode("Box driver failed");
127 catch (Standard_Failure) {
128 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
129 SetErrorCode(aFail->GetMessageString());
133 //Make a Python command
134 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
135 << theDX << ", " << theDY << ", " << theDZ << ")";
142 //=============================================================================
146 //=============================================================================
147 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
148 Handle(GEOM_Object) thePnt2)
152 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
154 //Add a new Box object
155 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
157 //Add a new Box function for creation a box relatively to two points
158 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
159 if (aFunction.IsNull()) return NULL;
161 //Check if the function is set correctly
162 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
164 GEOMImpl_IBox aBI (aFunction);
166 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
167 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
169 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
171 aBI.SetRef1(aRefFunction1);
172 aBI.SetRef2(aRefFunction2);
174 //Compute the Box value
176 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
179 if (!GetSolver()->ComputeFunction(aFunction)) {
180 SetErrorCode("Box driver failed");
184 catch (Standard_Failure) {
185 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
186 SetErrorCode(aFail->GetMessageString());
190 //Make a Python command
191 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
192 << thePnt1 << ", " << thePnt2 << ")";
199 //=============================================================================
203 //=============================================================================
204 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
208 //Add a new Cylinder object
209 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
211 //Add a new Cylinder function with R and H parameters
212 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
213 if (aFunction.IsNull()) return NULL;
215 //Check if the function is set correctly
216 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
218 GEOMImpl_ICylinder aCI (aFunction);
223 //Compute the Cylinder value
225 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
228 if (!GetSolver()->ComputeFunction(aFunction)) {
229 SetErrorCode("Cylinder driver failed");
233 catch (Standard_Failure) {
234 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
235 SetErrorCode(aFail->GetMessageString());
239 //Make a Python command
240 GEOM::TPythonDump(aFunction) << aCylinder
241 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
248 //=============================================================================
250 * MakeCylinderPntVecRH
252 //=============================================================================
253 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
254 Handle(GEOM_Object) theVec,
255 double theR, double theH)
259 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
261 //Add a new Cylinder object
262 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
264 //Add a new Cylinder function for creation a cylinder relatively to point and vector
265 Handle(GEOM_Function) aFunction =
266 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
267 if (aFunction.IsNull()) return NULL;
269 //Check if the function is set correctly
270 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
272 GEOMImpl_ICylinder aCI (aFunction);
274 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
275 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
277 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
279 aCI.SetPoint(aRefPnt);
280 aCI.SetVector(aRefVec);
284 //Compute the Cylinder value
286 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
289 if (!GetSolver()->ComputeFunction(aFunction)) {
290 SetErrorCode("Cylinder driver failed");
294 catch (Standard_Failure) {
295 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
296 SetErrorCode(aFail->GetMessageString());
300 //Make a Python command
301 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
302 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
309 //=============================================================================
313 //=============================================================================
314 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
319 //Add a new Cone object
320 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
322 //Add a new Cone function with R and H parameters
323 Handle(GEOM_Function) aFunction =
324 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
325 if (aFunction.IsNull()) return NULL;
327 //Check if the function is set correctly
328 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
330 GEOMImpl_ICone aCI (aFunction);
336 //Compute the Cone value
338 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
341 if (!GetSolver()->ComputeFunction(aFunction)) {
342 SetErrorCode("Cone driver failed");
346 catch (Standard_Failure) {
347 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
348 SetErrorCode(aFail->GetMessageString());
352 //Make a Python command
353 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
354 << theR1 << ", " << theR2 << ", " << theH << ")";
361 //=============================================================================
363 * MakeConePntVecR1R2H
365 //=============================================================================
366 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
367 Handle(GEOM_Object) theVec,
368 double theR1, double theR2,
373 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
375 //Add a new Cone object
376 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
378 //Add a new Cone function for creation a cone relatively to point and vector
379 Handle(GEOM_Function) aFunction =
380 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
381 if (aFunction.IsNull()) return NULL;
383 //Check if the function is set correctly
384 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
386 GEOMImpl_ICone aCI (aFunction);
388 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
389 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
391 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
393 aCI.SetPoint(aRefPnt);
394 aCI.SetVector(aRefVec);
399 //Compute the Cone value
401 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
404 if (!GetSolver()->ComputeFunction(aFunction)) {
405 SetErrorCode("Cone driver failed");
409 catch (Standard_Failure) {
410 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
411 SetErrorCode(aFail->GetMessageString());
415 //Make a Python command
416 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
417 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
424 //=============================================================================
428 //=============================================================================
429 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
433 //Add a new Sphere object
434 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
436 //Add a new Sphere function with R parameter
437 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
438 if (aFunction.IsNull()) return NULL;
440 //Check if the function is set correctly
441 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
443 GEOMImpl_ISphere aCI (aFunction);
447 //Compute the Sphere value
449 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
452 if (!GetSolver()->ComputeFunction(aFunction)) {
453 SetErrorCode("Sphere driver failed");
457 catch (Standard_Failure) {
458 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
459 SetErrorCode(aFail->GetMessageString());
463 //Make a Python command
464 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
471 //=============================================================================
475 //=============================================================================
476 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
481 if (thePnt.IsNull()) return NULL;
483 //Add a new Point object
484 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
486 //Add a new Sphere function for creation a sphere relatively to point
487 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
488 if (aFunction.IsNull()) return NULL;
490 //Check if the function is set correctly
491 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
493 GEOMImpl_ISphere aCI (aFunction);
495 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
497 if (aRefPnt.IsNull()) return NULL;
499 aCI.SetPoint(aRefPnt);
502 //Compute the Sphere value
504 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
507 if (!GetSolver()->ComputeFunction(aFunction)) {
508 SetErrorCode("Sphere driver failed");
512 catch (Standard_Failure) {
513 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
514 SetErrorCode(aFail->GetMessageString());
518 //Make a Python command
519 GEOM::TPythonDump(aFunction) << aSphere
520 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
527 //=============================================================================
531 //=============================================================================
532 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
533 (double theRMajor, double theRMinor)
537 //Add a new Torus object
538 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
540 //Add a new Torus function
541 Handle(GEOM_Function) aFunction =
542 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
543 if (aFunction.IsNull()) return NULL;
545 //Check if the function is set correctly
546 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
548 GEOMImpl_ITorus aCI (aFunction);
550 aCI.SetRMajor(theRMajor);
551 aCI.SetRMinor(theRMinor);
553 //Compute the Torus value
555 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
558 if (!GetSolver()->ComputeFunction(aFunction)) {
559 SetErrorCode("Torus driver failed");
563 catch (Standard_Failure) {
564 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
565 SetErrorCode(aFail->GetMessageString());
569 //Make a Python command
570 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
571 << theRMajor << ", " << theRMinor << ")";
577 //=============================================================================
581 //=============================================================================
582 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
583 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
584 double theRMajor, double theRMinor)
588 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
590 //Add a new Torus object
591 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
593 //Add a new Torus function
594 Handle(GEOM_Function) aFunction =
595 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
596 if (aFunction.IsNull()) return NULL;
598 //Check if the function is set correctly
599 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
601 GEOMImpl_ITorus aCI (aFunction);
603 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
604 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
606 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
608 aCI.SetCenter(aRefPnt);
609 aCI.SetVector(aRefVec);
610 aCI.SetRMajor(theRMajor);
611 aCI.SetRMinor(theRMinor);
613 //Compute the Torus value
615 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
618 if (!GetSolver()->ComputeFunction(aFunction)) {
619 SetErrorCode("Torus driver failed");
623 catch (Standard_Failure) {
624 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
625 SetErrorCode(aFail->GetMessageString());
629 //Make a Python command
630 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
631 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
638 //=============================================================================
642 //=============================================================================
643 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
644 Handle(GEOM_Object) theVec,
649 if (theBase.IsNull() || theVec.IsNull()) return NULL;
651 //Add a new Prism object
652 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
654 //Add a new Prism function for creation a Prism relatively to vector
655 Handle(GEOM_Function) aFunction =
656 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
657 if (aFunction.IsNull()) return NULL;
659 //Check if the function is set correctly
660 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
662 GEOMImpl_IPrism aCI (aFunction);
664 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
665 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
667 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
669 aCI.SetBase(aRefBase);
670 aCI.SetVector(aRefVec);
673 //Compute the Prism value
675 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
678 if (!GetSolver()->ComputeFunction(aFunction)) {
679 //SetErrorCode("Prism driver failed");
680 SetErrorCode("Extrusion can not be created, check input data");
684 catch (Standard_Failure) {
685 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
686 SetErrorCode(aFail->GetMessageString());
690 //Make a Python command
691 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
692 << theBase << ", " << theVec << ", " << theH << ")";
698 //=============================================================================
702 //=============================================================================
703 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
704 Handle(GEOM_Object) theVec,
709 if (theBase.IsNull() || theVec.IsNull()) return NULL;
711 //Add a new Prism object
712 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
714 //Add a new Prism function for creation a Prism relatively to vector
715 Handle(GEOM_Function) aFunction =
716 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
717 if (aFunction.IsNull()) return NULL;
719 //Check if the function is set correctly
720 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
722 GEOMImpl_IPrism aCI (aFunction);
724 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
725 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
727 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
729 aCI.SetBase(aRefBase);
730 aCI.SetVector(aRefVec);
733 //Compute the Prism value
735 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
738 if (!GetSolver()->ComputeFunction(aFunction)) {
739 //SetErrorCode("Prism driver failed");
740 SetErrorCode("Extrusion can not be created, check input data");
744 catch (Standard_Failure) {
745 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
746 SetErrorCode(aFail->GetMessageString());
750 //Make a Python command
751 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
752 << theBase << ", " << theVec << ", " << theH << ")";
758 //=============================================================================
762 //=============================================================================
763 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
764 (Handle(GEOM_Object) theBase,
765 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
769 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
771 //Add a new Prism object
772 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
774 //Add a new Prism function for creation a Prism relatively to two points
775 Handle(GEOM_Function) aFunction =
776 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
777 if (aFunction.IsNull()) return NULL;
779 //Check if the function is set correctly
780 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
782 GEOMImpl_IPrism aCI (aFunction);
784 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
785 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
786 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
788 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
790 aCI.SetBase(aRefBase);
791 aCI.SetFirstPoint(aRefPnt1);
792 aCI.SetLastPoint(aRefPnt2);
794 //Compute the Prism value
796 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
799 if (!GetSolver()->ComputeFunction(aFunction)) {
800 //SetErrorCode("Prism driver failed");
801 SetErrorCode("Extrusion can not be created, check input data");
805 catch (Standard_Failure) {
806 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
807 SetErrorCode(aFail->GetMessageString());
811 //Make a Python command
812 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
813 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
819 //=============================================================================
821 * MakePrismTwoPnt2Ways
823 //=============================================================================
824 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
825 (Handle(GEOM_Object) theBase,
826 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
830 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
832 //Add a new Prism object
833 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
835 //Add a new Prism function for creation a Prism relatively to two points
836 Handle(GEOM_Function) aFunction =
837 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
838 if (aFunction.IsNull()) return NULL;
840 //Check if the function is set correctly
841 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
843 GEOMImpl_IPrism aCI (aFunction);
845 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
846 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
847 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
849 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
851 aCI.SetBase(aRefBase);
852 aCI.SetFirstPoint(aRefPnt1);
853 aCI.SetLastPoint(aRefPnt2);
855 //Compute the Prism value
857 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
860 if (!GetSolver()->ComputeFunction(aFunction)) {
861 //SetErrorCode("Prism driver failed");
862 SetErrorCode("Extrusion can not be created, check input data");
866 catch (Standard_Failure) {
867 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
868 SetErrorCode(aFail->GetMessageString());
872 //Make a Python command
873 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
874 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
881 //=============================================================================
885 //=============================================================================
886 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
887 Handle(GEOM_Object) thePath)
891 if (theBase.IsNull() || thePath.IsNull()) return NULL;
893 //Add a new Pipe object
894 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
896 //Add a new Pipe function
897 Handle(GEOM_Function) aFunction =
898 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
899 if (aFunction.IsNull()) return NULL;
901 //Check if the function is set correctly
902 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
904 GEOMImpl_IPipe aCI (aFunction);
906 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
907 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
909 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
911 aCI.SetBase(aRefBase);
912 aCI.SetPath(aRefPath);
914 //Compute the Pipe value
916 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
919 if (!GetSolver()->ComputeFunction(aFunction)) {
920 SetErrorCode("Pipe driver failed");
924 catch (Standard_Failure) {
925 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
926 SetErrorCode(aFail->GetMessageString());
930 //Make a Python command
931 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
932 << theBase << ", " << thePath << ")";
939 //=============================================================================
941 * MakeRevolutionAxisAngle
943 //=============================================================================
944 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
945 Handle(GEOM_Object) theAxis,
950 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
952 //Add a new Revolution object
953 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
955 //Add a new Revolution function for creation a revolution relatively to axis
956 Handle(GEOM_Function) aFunction =
957 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
958 if (aFunction.IsNull()) return NULL;
960 //Check if the function is set correctly
961 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
963 GEOMImpl_IRevolution aCI (aFunction);
965 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
966 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
968 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
970 aCI.SetBase(aRefBase);
971 aCI.SetAxis(aRefAxis);
972 aCI.SetAngle(theAngle);
974 //Compute the Revolution value
976 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
979 if (!GetSolver()->ComputeFunction(aFunction)) {
980 SetErrorCode("Revolution driver failed");
984 catch (Standard_Failure) {
985 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
986 SetErrorCode(aFail->GetMessageString());
990 //Make a Python command
991 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
992 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
998 //=============================================================================
1000 * MakeRevolutionAxisAngle2Ways
1002 //=============================================================================
1003 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1004 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1008 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1010 //Add a new Revolution object
1011 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1013 //Add a new Revolution function for creation a revolution relatively to axis
1014 Handle(GEOM_Function) aFunction =
1015 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1016 if (aFunction.IsNull()) return NULL;
1018 //Check if the function is set correctly
1019 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1021 GEOMImpl_IRevolution aCI (aFunction);
1023 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1024 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1026 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1028 aCI.SetBase(aRefBase);
1029 aCI.SetAxis(aRefAxis);
1030 aCI.SetAngle(theAngle);
1032 //Compute the Revolution value
1034 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1037 if (!GetSolver()->ComputeFunction(aFunction)) {
1038 SetErrorCode("Revolution driver failed");
1042 catch (Standard_Failure) {
1043 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1044 SetErrorCode(aFail->GetMessageString());
1048 //Make a Python command
1049 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1050 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1056 //=============================================================================
1060 //=============================================================================
1061 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
1065 if (theShell.IsNull()) return NULL;
1067 //Add a new Solid object
1068 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
1070 //Add a new Solid function for creation a solid from a shell
1071 Handle(GEOM_Function) aFunction =
1072 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
1073 if (aFunction.IsNull()) return NULL;
1075 //Check if the function is set correctly
1076 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
1078 GEOMImpl_IShapes aCI (aFunction);
1080 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
1082 if (aRefShell.IsNull()) return NULL;
1084 aCI.SetBase(aRefShell);
1086 //Compute the Solid value
1088 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1091 if (!GetSolver()->ComputeFunction(aFunction)) {
1092 SetErrorCode("Solid driver failed");
1096 catch (Standard_Failure) {
1097 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1098 SetErrorCode(aFail->GetMessageString());
1102 //Make a Python command
1103 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
1109 //=============================================================================
1113 //=============================================================================
1114 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1115 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1116 double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1120 if (theShape.IsNull()) return NULL;
1122 //Add a new Filling object
1123 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1125 //Add a new Filling function for creation a filling from a compound
1126 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1127 if (aFunction.IsNull()) return NULL;
1129 //Check if the function is set correctly
1130 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1132 GEOMImpl_IFilling aFI (aFunction);
1134 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1136 if (aRefShape.IsNull()) return NULL;
1138 aFI.SetShape(aRefShape);
1139 aFI.SetMinDeg(theMinDeg);
1140 aFI.SetMaxDeg(theMaxDeg);
1141 aFI.SetTol2D(theTol2D);
1142 aFI.SetTol3D(theTol3D);
1143 aFI.SetNbIter(theNbIter);
1144 aFI.SetApprox(isApprox);
1146 //Compute the Solid value
1148 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1151 if (!GetSolver()->ComputeFunction(aFunction)) {
1152 SetErrorCode("Filling driver failed");
1156 catch (Standard_Failure) {
1157 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1158 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1159 SetErrorCode("B-Spline surface construction failed");
1161 SetErrorCode(aFail->GetMessageString());
1165 //Make a Python command
1166 GEOM::TPythonDump pd (aFunction);
1167 pd << aFilling << " = geompy.MakeFilling("
1168 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1169 << theTol2D << ", " << theTol3D << ", " << theNbIter;
1171 pd << ", " << isApprox;
1178 //=============================================================================
1182 //=============================================================================
1183 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1184 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1189 Handle(GEOM_Object) anObj;
1191 if(theSeqSections.IsNull())
1194 Standard_Integer nbObj = theSeqSections->Length();
1198 //Add a new ThruSections object
1199 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1202 //Add a new ThruSections function
1204 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1205 Handle(GEOM_Function) aFunction =
1206 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1207 if (aFunction.IsNull()) return anObj;
1209 //Check if the function is set correctly
1210 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1212 GEOMImpl_IThruSections aCI (aFunction);
1214 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1216 Standard_Integer i =1;
1217 for( ; i <= nbObj; i++) {
1219 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1223 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1224 if(!aSectObj.IsNull())
1226 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1227 if(!aRefSect.IsNull())
1228 aSeqSections->Append(aRefSect);
1232 if(!aSeqSections->Length())
1235 aCI.SetSections(aSeqSections);
1236 aCI.SetSolidMode(theModeSolid);
1237 aCI.SetPrecision(thePreci);
1239 //Compute the ThruSections value
1241 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1244 if (!GetSolver()->ComputeFunction(aFunction)) {
1245 SetErrorCode("ThruSections driver failed");
1249 catch (Standard_Failure) {
1250 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1251 SetErrorCode(aFail->GetMessageString());
1255 //Make a Python command
1256 GEOM::TPythonDump pyDump(aFunction);
1257 pyDump << aThruSect << " = geompy.MakeThruSections([";
1259 for(i =1 ; i <= nbObj; i++) {
1261 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1265 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1266 if(!aSectObj.IsNull()) {
1273 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1282 //=============================================================================
1284 * MakePipeWithDifferentSections
1286 //=============================================================================
1287 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1288 const Handle(TColStd_HSequenceOfTransient)& theBases,
1289 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1290 const Handle(GEOM_Object)& thePath,
1291 bool theWithContact,
1292 bool theWithCorrections)
1294 Handle(GEOM_Object) anObj;
1296 if(theBases.IsNull())
1299 Standard_Integer nbBases = theBases->Length();
1304 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1305 //Add a new Pipe object
1306 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1308 //Add a new Pipe function
1310 Handle(GEOM_Function) aFunction =
1311 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1312 if (aFunction.IsNull()) return anObj;
1314 //Check if the function is set correctly
1315 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1317 GEOMImpl_IPipeDiffSect aCI (aFunction);
1319 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1320 if(aRefPath.IsNull())
1323 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1324 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1326 Standard_Integer i =1;
1327 for( ; i <= nbBases; i++) {
1329 Handle(Standard_Transient) anItem = theBases->Value(i);
1333 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1336 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1337 if(aRefBase.IsNull())
1341 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1342 if(anItemLoc.IsNull())
1345 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1348 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1349 if(aRefLoc.IsNull())
1351 aSeqLocs->Append(aRefLoc);
1353 aSeqBases->Append(aRefBase);
1356 if(!aSeqBases->Length())
1359 aCI.SetBases(aSeqBases);
1360 aCI.SetLocations(aSeqLocs);
1361 aCI.SetPath(aRefPath);
1362 aCI.SetWithContactMode(theWithContact);
1363 aCI.SetWithCorrectionMode(theWithCorrections);
1365 //Compute the Pipe value
1367 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1370 if (!GetSolver()->ComputeFunction(aFunction)) {
1371 SetErrorCode("Pipe with defferent section driver failed");
1375 catch (Standard_Failure) {
1376 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1377 SetErrorCode(aFail->GetMessageString());
1381 //Make a Python command
1382 GEOM::TPythonDump pyDump(aFunction);
1383 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1385 for(i =1 ; i <= nbBases; i++) {
1387 Handle(Standard_Transient) anItem = theBases->Value(i);
1391 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1392 if(!anObj.IsNull()) {
1402 for(i =1 ; i <= nbLocs; i++) {
1404 Handle(Standard_Transient) anItem = theLocations->Value(i);
1408 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1409 if(!anObj.IsNull()) {
1416 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1425 //=============================================================================
1427 * MakePipeWithShellSections
1429 //=============================================================================
1430 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1431 const Handle(TColStd_HSequenceOfTransient)& theBases,
1432 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1433 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1434 const Handle(GEOM_Object)& thePath,
1435 bool theWithContact,
1436 bool theWithCorrections)
1438 Handle(GEOM_Object) anObj;
1440 if(theBases.IsNull())
1443 Standard_Integer nbBases = theBases->Length();
1448 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1450 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1452 //Add a new Pipe object
1453 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1455 //Add a new Pipe function
1457 Handle(GEOM_Function) aFunction =
1458 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1459 if (aFunction.IsNull()) return anObj;
1461 //Check if the function is set correctly
1462 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1464 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1465 GEOMImpl_IPipeShellSect aCI (aFunction);
1467 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1468 if(aRefPath.IsNull())
1471 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1472 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1473 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1475 Standard_Integer i =1;
1476 for( ; i <= nbBases; i++) {
1478 Handle(Standard_Transient) anItem = theBases->Value(i);
1481 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1484 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1485 if(aRefBase.IsNull())
1488 if( nbSubBases >= nbBases ) {
1489 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1490 if(aSubItem.IsNull())
1492 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1493 if(aSubBase.IsNull())
1495 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1496 if(aRefSubBase.IsNull())
1498 aSeqSubBases->Append(aRefSubBase);
1502 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1503 if(anItemLoc.IsNull())
1505 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1508 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1509 if(aRefLoc.IsNull())
1511 aSeqLocs->Append(aRefLoc);
1514 aSeqBases->Append(aRefBase);
1517 if(!aSeqBases->Length())
1520 aCI.SetBases(aSeqBases);
1521 aCI.SetSubBases(aSeqSubBases);
1522 aCI.SetLocations(aSeqLocs);
1523 aCI.SetPath(aRefPath);
1524 aCI.SetWithContactMode(theWithContact);
1525 aCI.SetWithCorrectionMode(theWithCorrections);
1527 //Compute the Pipe value
1529 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1532 if (!GetSolver()->ComputeFunction(aFunction)) {
1533 SetErrorCode("Pipe with shell sections driver failed");
1537 catch (Standard_Failure) {
1538 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1539 SetErrorCode(aFail->GetMessageString());
1543 //Make a Python command
1544 GEOM::TPythonDump pyDump(aFunction);
1545 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1547 for(i =1 ; i <= nbBases; i++) {
1549 Handle(Standard_Transient) anItem = theBases->Value(i);
1553 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1554 if(!anObj.IsNull()) {
1564 for(i =1 ; i <= nbSubBases; i++) {
1566 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1570 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1571 if(!anObj.IsNull()) {
1581 for(i =1 ; i <= nbLocs; i++) {
1583 Handle(Standard_Transient) anItem = theLocations->Value(i);
1587 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1588 if(!anObj.IsNull()) {
1595 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1603 //=============================================================================
1605 * MakePipeShellsWithoutPath
1607 //=============================================================================
1608 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1609 const Handle(TColStd_HSequenceOfTransient)& theBases,
1610 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1612 Handle(GEOM_Object) anObj;
1614 if(theBases.IsNull())
1617 Standard_Integer nbBases = theBases->Length();
1622 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1624 //Add a new Pipe object
1625 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1627 //Add a new Pipe function
1629 Handle(GEOM_Function) aFunction =
1630 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1631 if (aFunction.IsNull()) return anObj;
1633 //Check if the function is set correctly
1634 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1636 GEOMImpl_IPipeShellSect aCI (aFunction);
1638 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1639 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1641 Standard_Integer i =1;
1642 for( ; i <= nbBases; i++) {
1644 Handle(Standard_Transient) anItem = theBases->Value(i);
1647 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1650 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1651 if(aRefBase.IsNull())
1655 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1656 if(anItemLoc.IsNull())
1658 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1661 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1662 if(aRefLoc.IsNull())
1664 aSeqLocs->Append(aRefLoc);
1667 aSeqBases->Append(aRefBase);
1670 if(!aSeqBases->Length())
1673 aCI.SetBases(aSeqBases);
1674 aCI.SetLocations(aSeqLocs);
1676 //Compute the Pipe value
1678 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1681 if (!GetSolver()->ComputeFunction(aFunction)) {
1682 SetErrorCode("Pipe with shell sections without path driver failed");
1686 catch (Standard_Failure) {
1687 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1688 SetErrorCode(aFail->GetMessageString());
1692 //Make a Python command
1693 GEOM::TPythonDump pyDump(aFunction);
1694 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
1696 for(i =1 ; i <= nbBases; i++) {
1698 Handle(Standard_Transient) anItem = theBases->Value(i);
1702 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1703 if(!anObj.IsNull()) {
1713 for(i =1 ; i <= nbLocs; i++) {
1715 Handle(Standard_Transient) anItem = theLocations->Value(i);
1719 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1720 if(!anObj.IsNull()) {
1735 //=============================================================================
1737 * MakePipeBiNormalAlongVector
1739 //=============================================================================
1740 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
1741 Handle(GEOM_Object) thePath,
1742 Handle(GEOM_Object) theVec)
1746 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
1748 //Add a new Pipe object
1749 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1751 //Add a new Pipe function
1752 Handle(GEOM_Function) aFunction =
1753 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
1754 if (aFunction.IsNull()) return NULL;
1756 //Check if the function is set correctly
1757 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1759 GEOMImpl_IPipeBiNormal aCI (aFunction);
1761 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1762 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1763 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1765 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
1767 aCI.SetBase(aRefBase);
1768 aCI.SetPath(aRefPath);
1769 aCI.SetVector(aRefVec);
1771 //Compute the Pipe value
1773 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1776 if (!GetSolver()->ComputeFunction(aFunction)) {
1777 SetErrorCode("Pipe driver failed");
1781 catch (Standard_Failure) {
1782 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1783 SetErrorCode(aFail->GetMessageString());
1787 //Make a Python command
1788 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
1789 << theBase << ", " << thePath << ", " << theVec << ")";