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>
63 #include <GEOMImpl_IPipeBiNormal.hxx>
65 #include <Standard_Failure.hxx>
66 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
68 //=============================================================================
72 //=============================================================================
73 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
74 : GEOM_IOperations(theEngine, theDocID)
76 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
79 //=============================================================================
83 //=============================================================================
84 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
86 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
90 //=============================================================================
94 //=============================================================================
95 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
99 //Add a new Box object
100 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
102 //Add a new Box function with DX_DY_DZ parameters
103 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
104 if (aFunction.IsNull()) return NULL;
106 //Check if the function is set correctly
107 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
109 GEOMImpl_IBox aBI (aFunction);
115 //Compute the box value
117 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
120 if (!GetSolver()->ComputeFunction(aFunction)) {
121 SetErrorCode("Box driver failed");
125 catch (Standard_Failure) {
126 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
127 SetErrorCode(aFail->GetMessageString());
131 //Make a Python command
132 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
133 << theDX << ", " << theDY << ", " << theDZ << ")";
140 //=============================================================================
144 //=============================================================================
145 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
146 Handle(GEOM_Object) thePnt2)
150 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
152 //Add a new Box object
153 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
155 //Add a new Box function for creation a box relatively to two points
156 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
157 if (aFunction.IsNull()) return NULL;
159 //Check if the function is set correctly
160 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
162 GEOMImpl_IBox aBI (aFunction);
164 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
165 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
167 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
169 aBI.SetRef1(aRefFunction1);
170 aBI.SetRef2(aRefFunction2);
172 //Compute the Box value
174 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
177 if (!GetSolver()->ComputeFunction(aFunction)) {
178 SetErrorCode("Box driver failed");
182 catch (Standard_Failure) {
183 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
184 SetErrorCode(aFail->GetMessageString());
188 //Make a Python command
189 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
190 << thePnt1 << ", " << thePnt2 << ")";
197 //=============================================================================
201 //=============================================================================
202 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
206 //Add a new Cylinder object
207 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
209 //Add a new Cylinder function with R and H parameters
210 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
211 if (aFunction.IsNull()) return NULL;
213 //Check if the function is set correctly
214 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
216 GEOMImpl_ICylinder aCI (aFunction);
221 //Compute the Cylinder value
223 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
226 if (!GetSolver()->ComputeFunction(aFunction)) {
227 SetErrorCode("Cylinder driver failed");
231 catch (Standard_Failure) {
232 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
233 SetErrorCode(aFail->GetMessageString());
237 //Make a Python command
238 GEOM::TPythonDump(aFunction) << aCylinder
239 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
246 //=============================================================================
248 * MakeCylinderPntVecRH
250 //=============================================================================
251 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
252 Handle(GEOM_Object) theVec,
253 double theR, double theH)
257 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
259 //Add a new Cylinder object
260 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
262 //Add a new Cylinder function for creation a cylinder relatively to point and vector
263 Handle(GEOM_Function) aFunction =
264 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
265 if (aFunction.IsNull()) return NULL;
267 //Check if the function is set correctly
268 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
270 GEOMImpl_ICylinder aCI (aFunction);
272 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
273 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
275 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
277 aCI.SetPoint(aRefPnt);
278 aCI.SetVector(aRefVec);
282 //Compute the Cylinder value
284 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
287 if (!GetSolver()->ComputeFunction(aFunction)) {
288 SetErrorCode("Cylinder driver failed");
292 catch (Standard_Failure) {
293 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
294 SetErrorCode(aFail->GetMessageString());
298 //Make a Python command
299 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
300 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
307 //=============================================================================
311 //=============================================================================
312 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
317 //Add a new Cone object
318 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
320 //Add a new Cone function with R and H parameters
321 Handle(GEOM_Function) aFunction =
322 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
323 if (aFunction.IsNull()) return NULL;
325 //Check if the function is set correctly
326 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
328 GEOMImpl_ICone aCI (aFunction);
334 //Compute the Cone value
336 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
339 if (!GetSolver()->ComputeFunction(aFunction)) {
340 SetErrorCode("Cone driver failed");
344 catch (Standard_Failure) {
345 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
346 SetErrorCode(aFail->GetMessageString());
350 //Make a Python command
351 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
352 << theR1 << ", " << theR2 << ", " << theH << ")";
359 //=============================================================================
361 * MakeConePntVecR1R2H
363 //=============================================================================
364 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
365 Handle(GEOM_Object) theVec,
366 double theR1, double theR2,
371 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
373 //Add a new Cone object
374 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
376 //Add a new Cone function for creation a cone relatively to point and vector
377 Handle(GEOM_Function) aFunction =
378 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
379 if (aFunction.IsNull()) return NULL;
381 //Check if the function is set correctly
382 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
384 GEOMImpl_ICone aCI (aFunction);
386 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
387 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
389 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
391 aCI.SetPoint(aRefPnt);
392 aCI.SetVector(aRefVec);
397 //Compute the Cone value
399 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
402 if (!GetSolver()->ComputeFunction(aFunction)) {
403 SetErrorCode("Cone driver failed");
407 catch (Standard_Failure) {
408 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
409 SetErrorCode(aFail->GetMessageString());
413 //Make a Python command
414 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
415 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
422 //=============================================================================
426 //=============================================================================
427 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
431 //Add a new Sphere object
432 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
434 //Add a new Sphere function with R parameter
435 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
436 if (aFunction.IsNull()) return NULL;
438 //Check if the function is set correctly
439 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
441 GEOMImpl_ISphere aCI (aFunction);
445 //Compute the Sphere value
447 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
450 if (!GetSolver()->ComputeFunction(aFunction)) {
451 SetErrorCode("Sphere driver failed");
455 catch (Standard_Failure) {
456 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
457 SetErrorCode(aFail->GetMessageString());
461 //Make a Python command
462 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
469 //=============================================================================
473 //=============================================================================
474 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
479 if (thePnt.IsNull()) return NULL;
481 //Add a new Point object
482 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
484 //Add a new Sphere function for creation a sphere relatively to point
485 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
486 if (aFunction.IsNull()) return NULL;
488 //Check if the function is set correctly
489 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
491 GEOMImpl_ISphere aCI (aFunction);
493 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
495 if (aRefPnt.IsNull()) return NULL;
497 aCI.SetPoint(aRefPnt);
500 //Compute the Sphere value
502 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
505 if (!GetSolver()->ComputeFunction(aFunction)) {
506 SetErrorCode("Sphere driver failed");
510 catch (Standard_Failure) {
511 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
512 SetErrorCode(aFail->GetMessageString());
516 //Make a Python command
517 GEOM::TPythonDump(aFunction) << aSphere
518 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
525 //=============================================================================
529 //=============================================================================
530 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
531 (double theRMajor, double theRMinor)
535 //Add a new Torus object
536 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
538 //Add a new Torus function
539 Handle(GEOM_Function) aFunction =
540 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
541 if (aFunction.IsNull()) return NULL;
543 //Check if the function is set correctly
544 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
546 GEOMImpl_ITorus aCI (aFunction);
548 aCI.SetRMajor(theRMajor);
549 aCI.SetRMinor(theRMinor);
551 //Compute the Torus value
553 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
556 if (!GetSolver()->ComputeFunction(aFunction)) {
557 SetErrorCode("Torus driver failed");
561 catch (Standard_Failure) {
562 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
563 SetErrorCode(aFail->GetMessageString());
567 //Make a Python command
568 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
569 << theRMajor << ", " << theRMinor << ")";
575 //=============================================================================
579 //=============================================================================
580 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
581 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
582 double theRMajor, double theRMinor)
586 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
588 //Add a new Torus object
589 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
591 //Add a new Torus function
592 Handle(GEOM_Function) aFunction =
593 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
594 if (aFunction.IsNull()) return NULL;
596 //Check if the function is set correctly
597 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
599 GEOMImpl_ITorus aCI (aFunction);
601 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
602 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
604 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
606 aCI.SetCenter(aRefPnt);
607 aCI.SetVector(aRefVec);
608 aCI.SetRMajor(theRMajor);
609 aCI.SetRMinor(theRMinor);
611 //Compute the Torus value
613 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
616 if (!GetSolver()->ComputeFunction(aFunction)) {
617 SetErrorCode("Torus driver failed");
621 catch (Standard_Failure) {
622 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
623 SetErrorCode(aFail->GetMessageString());
627 //Make a Python command
628 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
629 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
636 //=============================================================================
640 //=============================================================================
641 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
642 Handle(GEOM_Object) theVec,
647 if (theBase.IsNull() || theVec.IsNull()) return NULL;
649 //Add a new Prism object
650 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
652 //Add a new Prism function for creation a Prism relatively to vector
653 Handle(GEOM_Function) aFunction =
654 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
655 if (aFunction.IsNull()) return NULL;
657 //Check if the function is set correctly
658 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
660 GEOMImpl_IPrism aCI (aFunction);
662 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
663 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
665 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
667 aCI.SetBase(aRefBase);
668 aCI.SetVector(aRefVec);
671 //Compute the Prism value
673 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
676 if (!GetSolver()->ComputeFunction(aFunction)) {
677 //SetErrorCode("Prism driver failed");
678 SetErrorCode("Extrusion can not be created, check input data");
682 catch (Standard_Failure) {
683 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
684 SetErrorCode(aFail->GetMessageString());
688 //Make a Python command
689 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
690 << theBase << ", " << theVec << ", " << theH << ")";
696 //=============================================================================
700 //=============================================================================
701 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
702 Handle(GEOM_Object) theVec,
707 if (theBase.IsNull() || theVec.IsNull()) return NULL;
709 //Add a new Prism object
710 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
712 //Add a new Prism function for creation a Prism relatively to vector
713 Handle(GEOM_Function) aFunction =
714 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
715 if (aFunction.IsNull()) return NULL;
717 //Check if the function is set correctly
718 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
720 GEOMImpl_IPrism aCI (aFunction);
722 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
723 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
725 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
727 aCI.SetBase(aRefBase);
728 aCI.SetVector(aRefVec);
731 //Compute the Prism value
733 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
736 if (!GetSolver()->ComputeFunction(aFunction)) {
737 //SetErrorCode("Prism driver failed");
738 SetErrorCode("Extrusion can not be created, check input data");
742 catch (Standard_Failure) {
743 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
744 SetErrorCode(aFail->GetMessageString());
748 //Make a Python command
749 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
750 << theBase << ", " << theVec << ", " << theH << ")";
756 //=============================================================================
760 //=============================================================================
761 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
762 (Handle(GEOM_Object) theBase,
763 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
767 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
769 //Add a new Prism object
770 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
772 //Add a new Prism function for creation a Prism relatively to two points
773 Handle(GEOM_Function) aFunction =
774 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
775 if (aFunction.IsNull()) return NULL;
777 //Check if the function is set correctly
778 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
780 GEOMImpl_IPrism aCI (aFunction);
782 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
783 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
784 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
786 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
788 aCI.SetBase(aRefBase);
789 aCI.SetFirstPoint(aRefPnt1);
790 aCI.SetLastPoint(aRefPnt2);
792 //Compute the Prism value
794 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
797 if (!GetSolver()->ComputeFunction(aFunction)) {
798 //SetErrorCode("Prism driver failed");
799 SetErrorCode("Extrusion can not be created, check input data");
803 catch (Standard_Failure) {
804 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
805 SetErrorCode(aFail->GetMessageString());
809 //Make a Python command
810 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
811 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
817 //=============================================================================
819 * MakePrismTwoPnt2Ways
821 //=============================================================================
822 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
823 (Handle(GEOM_Object) theBase,
824 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
828 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
830 //Add a new Prism object
831 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
833 //Add a new Prism function for creation a Prism relatively to two points
834 Handle(GEOM_Function) aFunction =
835 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
836 if (aFunction.IsNull()) return NULL;
838 //Check if the function is set correctly
839 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
841 GEOMImpl_IPrism aCI (aFunction);
843 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
844 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
845 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
847 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
849 aCI.SetBase(aRefBase);
850 aCI.SetFirstPoint(aRefPnt1);
851 aCI.SetLastPoint(aRefPnt2);
853 //Compute the Prism value
855 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
858 if (!GetSolver()->ComputeFunction(aFunction)) {
859 //SetErrorCode("Prism driver failed");
860 SetErrorCode("Extrusion can not be created, check input data");
864 catch (Standard_Failure) {
865 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
866 SetErrorCode(aFail->GetMessageString());
870 //Make a Python command
871 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
872 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
879 //=============================================================================
883 //=============================================================================
884 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
885 Handle(GEOM_Object) thePath)
889 if (theBase.IsNull() || thePath.IsNull()) return NULL;
891 //Add a new Pipe object
892 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
894 //Add a new Pipe function
895 Handle(GEOM_Function) aFunction =
896 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
897 if (aFunction.IsNull()) return NULL;
899 //Check if the function is set correctly
900 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
902 GEOMImpl_IPipe aCI (aFunction);
904 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
905 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
907 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
909 aCI.SetBase(aRefBase);
910 aCI.SetPath(aRefPath);
912 //Compute the Pipe value
914 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
917 if (!GetSolver()->ComputeFunction(aFunction)) {
918 SetErrorCode("Pipe driver failed");
922 catch (Standard_Failure) {
923 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
924 SetErrorCode(aFail->GetMessageString());
928 //Make a Python command
929 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
930 << theBase << ", " << thePath << ")";
937 //=============================================================================
939 * MakeRevolutionAxisAngle
941 //=============================================================================
942 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
943 Handle(GEOM_Object) theAxis,
948 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
950 //Add a new Revolution object
951 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
953 //Add a new Revolution function for creation a revolution relatively to axis
954 Handle(GEOM_Function) aFunction =
955 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
956 if (aFunction.IsNull()) return NULL;
958 //Check if the function is set correctly
959 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
961 GEOMImpl_IRevolution aCI (aFunction);
963 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
964 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
966 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
968 aCI.SetBase(aRefBase);
969 aCI.SetAxis(aRefAxis);
970 aCI.SetAngle(theAngle);
972 //Compute the Revolution value
974 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
977 if (!GetSolver()->ComputeFunction(aFunction)) {
978 SetErrorCode("Revolution driver failed");
982 catch (Standard_Failure) {
983 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
984 SetErrorCode(aFail->GetMessageString());
988 //Make a Python command
989 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
990 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
996 //=============================================================================
998 * MakeRevolutionAxisAngle2Ways
1000 //=============================================================================
1001 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1002 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1006 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1008 //Add a new Revolution object
1009 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1011 //Add a new Revolution function for creation a revolution relatively to axis
1012 Handle(GEOM_Function) aFunction =
1013 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1014 if (aFunction.IsNull()) return NULL;
1016 //Check if the function is set correctly
1017 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1019 GEOMImpl_IRevolution aCI (aFunction);
1021 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1022 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1024 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1026 aCI.SetBase(aRefBase);
1027 aCI.SetAxis(aRefAxis);
1028 aCI.SetAngle(theAngle);
1030 //Compute the Revolution value
1032 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1035 if (!GetSolver()->ComputeFunction(aFunction)) {
1036 SetErrorCode("Revolution driver failed");
1040 catch (Standard_Failure) {
1041 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1042 SetErrorCode(aFail->GetMessageString());
1046 //Make a Python command
1047 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1048 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1054 //=============================================================================
1058 //=============================================================================
1059 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
1063 if (theShell.IsNull()) return NULL;
1065 //Add a new Solid object
1066 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
1068 //Add a new Solid function for creation a solid from a shell
1069 Handle(GEOM_Function) aFunction =
1070 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
1071 if (aFunction.IsNull()) return NULL;
1073 //Check if the function is set correctly
1074 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
1076 GEOMImpl_IShapes aCI (aFunction);
1078 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
1080 if (aRefShell.IsNull()) return NULL;
1082 aCI.SetBase(aRefShell);
1084 //Compute the Solid value
1086 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1089 if (!GetSolver()->ComputeFunction(aFunction)) {
1090 SetErrorCode("Solid driver failed");
1094 catch (Standard_Failure) {
1095 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1096 SetErrorCode(aFail->GetMessageString());
1100 //Make a Python command
1101 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
1107 //=============================================================================
1111 //=============================================================================
1112 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1113 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1114 double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1118 if (theShape.IsNull()) return NULL;
1120 //Add a new Filling object
1121 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1123 //Add a new Filling function for creation a filling from a compound
1124 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1125 if (aFunction.IsNull()) return NULL;
1127 //Check if the function is set correctly
1128 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1130 GEOMImpl_IFilling aFI (aFunction);
1132 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1134 if (aRefShape.IsNull()) return NULL;
1136 aFI.SetShape(aRefShape);
1137 aFI.SetMinDeg(theMinDeg);
1138 aFI.SetMaxDeg(theMaxDeg);
1139 aFI.SetTol2D(theTol2D);
1140 aFI.SetTol3D(theTol3D);
1141 aFI.SetNbIter(theNbIter);
1142 aFI.SetApprox(isApprox);
1144 //Compute the Solid value
1146 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1149 if (!GetSolver()->ComputeFunction(aFunction)) {
1150 SetErrorCode("Filling driver failed");
1154 catch (Standard_Failure) {
1155 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1156 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1157 SetErrorCode("B-Spline surface construction failed");
1159 SetErrorCode(aFail->GetMessageString());
1163 //Make a Python command
1164 GEOM::TPythonDump pd (aFunction);
1165 pd << aFilling << " = geompy.MakeFilling("
1166 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1167 << theTol2D << ", " << theTol3D << ", " << theNbIter;
1169 pd << ", " << isApprox;
1176 //=============================================================================
1180 //=============================================================================
1181 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1182 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1187 Handle(GEOM_Object) anObj;
1189 if(theSeqSections.IsNull())
1192 Standard_Integer nbObj = theSeqSections->Length();
1196 //Add a new ThruSections object
1197 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1200 //Add a new ThruSections function
1202 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1203 Handle(GEOM_Function) aFunction =
1204 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1205 if (aFunction.IsNull()) return anObj;
1207 //Check if the function is set correctly
1208 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1210 GEOMImpl_IThruSections aCI (aFunction);
1212 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1214 Standard_Integer i =1;
1215 for( ; i <= nbObj; i++) {
1217 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1221 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1222 if(!aSectObj.IsNull())
1224 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1225 if(!aRefSect.IsNull())
1226 aSeqSections->Append(aRefSect);
1230 if(!aSeqSections->Length())
1233 aCI.SetSections(aSeqSections);
1234 aCI.SetSolidMode(theModeSolid);
1235 aCI.SetPrecision(thePreci);
1237 //Compute the ThruSections value
1239 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1242 if (!GetSolver()->ComputeFunction(aFunction)) {
1243 SetErrorCode("ThruSections driver failed");
1247 catch (Standard_Failure) {
1248 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1249 SetErrorCode(aFail->GetMessageString());
1253 //Make a Python command
1254 GEOM::TPythonDump pyDump(aFunction);
1255 pyDump << aThruSect << " = geompy.MakeThruSections([";
1257 for(i =1 ; i <= nbObj; i++) {
1259 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1263 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1264 if(!aSectObj.IsNull()) {
1271 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1280 //=============================================================================
1282 * MakePipeWithDifferentSections
1284 //=============================================================================
1285 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1286 const Handle(TColStd_HSequenceOfTransient)& theBases,
1287 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1288 const Handle(GEOM_Object)& thePath,
1289 bool theWithContact,
1290 bool theWithCorrections)
1292 Handle(GEOM_Object) anObj;
1294 if(theBases.IsNull())
1297 Standard_Integer nbBases = theBases->Length();
1302 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1303 //Add a new Pipe object
1304 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1306 //Add a new Pipe function
1308 Handle(GEOM_Function) aFunction =
1309 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1310 if (aFunction.IsNull()) return anObj;
1312 //Check if the function is set correctly
1313 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1315 GEOMImpl_IPipeDiffSect aCI (aFunction);
1317 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1318 if(aRefPath.IsNull())
1321 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1322 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1324 Standard_Integer i =1;
1325 for( ; i <= nbBases; i++) {
1327 Handle(Standard_Transient) anItem = theBases->Value(i);
1331 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1334 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1335 if(aRefBase.IsNull())
1339 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1340 if(anItemLoc.IsNull())
1343 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1346 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1347 if(aRefLoc.IsNull())
1349 aSeqLocs->Append(aRefLoc);
1351 aSeqBases->Append(aRefBase);
1354 if(!aSeqBases->Length())
1357 aCI.SetBases(aSeqBases);
1358 aCI.SetLocations(aSeqLocs);
1359 aCI.SetPath(aRefPath);
1360 aCI.SetWithContactMode(theWithContact);
1361 aCI.SetWithCorrectionMode(theWithCorrections);
1363 //Compute the Pipe value
1365 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1368 if (!GetSolver()->ComputeFunction(aFunction)) {
1369 SetErrorCode("Pipe with defferent section driver failed");
1373 catch (Standard_Failure) {
1374 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1375 SetErrorCode(aFail->GetMessageString());
1379 //Make a Python command
1380 GEOM::TPythonDump pyDump(aFunction);
1381 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1383 for(i =1 ; i <= nbBases; i++) {
1385 Handle(Standard_Transient) anItem = theBases->Value(i);
1389 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1390 if(!anObj.IsNull()) {
1400 for(i =1 ; i <= nbLocs; i++) {
1402 Handle(Standard_Transient) anItem = theLocations->Value(i);
1406 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1407 if(!anObj.IsNull()) {
1414 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1423 //=============================================================================
1425 * MakePipeWithShellSections
1427 //=============================================================================
1428 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1429 const Handle(TColStd_HSequenceOfTransient)& theBases,
1430 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1431 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1432 const Handle(GEOM_Object)& thePath,
1433 bool theWithContact,
1434 bool theWithCorrections)
1436 Handle(GEOM_Object) anObj;
1438 if(theBases.IsNull())
1441 Standard_Integer nbBases = theBases->Length();
1446 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1448 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1450 //Add a new Pipe object
1451 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1453 //Add a new Pipe function
1455 Handle(GEOM_Function) aFunction =
1456 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1457 if (aFunction.IsNull()) return anObj;
1459 //Check if the function is set correctly
1460 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1462 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1463 GEOMImpl_IPipeShellSect aCI (aFunction);
1465 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1466 if(aRefPath.IsNull())
1469 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1470 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1471 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1473 Standard_Integer i =1;
1474 for( ; i <= nbBases; i++) {
1476 Handle(Standard_Transient) anItem = theBases->Value(i);
1479 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1482 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1483 if(aRefBase.IsNull())
1486 if( nbSubBases >= nbBases ) {
1487 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1488 if(aSubItem.IsNull())
1490 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1491 if(aSubBase.IsNull())
1493 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1494 if(aRefSubBase.IsNull())
1496 aSeqSubBases->Append(aRefSubBase);
1500 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1501 if(anItemLoc.IsNull())
1503 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1506 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1507 if(aRefLoc.IsNull())
1509 aSeqLocs->Append(aRefLoc);
1512 aSeqBases->Append(aRefBase);
1515 if(!aSeqBases->Length())
1518 aCI.SetBases(aSeqBases);
1519 aCI.SetSubBases(aSeqSubBases);
1520 aCI.SetLocations(aSeqLocs);
1521 aCI.SetPath(aRefPath);
1522 aCI.SetWithContactMode(theWithContact);
1523 aCI.SetWithCorrectionMode(theWithCorrections);
1525 //Compute the Pipe value
1527 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1530 if (!GetSolver()->ComputeFunction(aFunction)) {
1531 SetErrorCode("Pipe with shell sections driver failed");
1535 catch (Standard_Failure) {
1536 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1537 SetErrorCode(aFail->GetMessageString());
1541 //Make a Python command
1542 GEOM::TPythonDump pyDump(aFunction);
1543 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1545 for(i =1 ; i <= nbBases; i++) {
1547 Handle(Standard_Transient) anItem = theBases->Value(i);
1551 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1552 if(!anObj.IsNull()) {
1562 for(i =1 ; i <= nbSubBases; i++) {
1564 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1568 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1569 if(!anObj.IsNull()) {
1579 for(i =1 ; i <= nbLocs; i++) {
1581 Handle(Standard_Transient) anItem = theLocations->Value(i);
1585 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1586 if(!anObj.IsNull()) {
1593 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1601 //=============================================================================
1603 * MakePipeShellsWithoutPath
1605 //=============================================================================
1606 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1607 const Handle(TColStd_HSequenceOfTransient)& theBases,
1608 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1610 Handle(GEOM_Object) anObj;
1612 if(theBases.IsNull())
1615 Standard_Integer nbBases = theBases->Length();
1620 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1622 //Add a new Pipe object
1623 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1625 //Add a new Pipe function
1627 Handle(GEOM_Function) aFunction =
1628 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1629 if (aFunction.IsNull()) return anObj;
1631 //Check if the function is set correctly
1632 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1634 GEOMImpl_IPipeShellSect aCI (aFunction);
1636 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1637 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1639 Standard_Integer i =1;
1640 for( ; i <= nbBases; i++) {
1642 Handle(Standard_Transient) anItem = theBases->Value(i);
1645 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1648 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1649 if(aRefBase.IsNull())
1653 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1654 if(anItemLoc.IsNull())
1656 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1659 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1660 if(aRefLoc.IsNull())
1662 aSeqLocs->Append(aRefLoc);
1665 aSeqBases->Append(aRefBase);
1668 if(!aSeqBases->Length())
1671 aCI.SetBases(aSeqBases);
1672 aCI.SetLocations(aSeqLocs);
1674 //Compute the Pipe value
1676 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1679 if (!GetSolver()->ComputeFunction(aFunction)) {
1680 SetErrorCode("Pipe with shell sections without path driver failed");
1684 catch (Standard_Failure) {
1685 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1686 SetErrorCode(aFail->GetMessageString());
1690 //Make a Python command
1691 GEOM::TPythonDump pyDump(aFunction);
1692 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
1694 for(i =1 ; i <= nbBases; i++) {
1696 Handle(Standard_Transient) anItem = theBases->Value(i);
1700 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1701 if(!anObj.IsNull()) {
1711 for(i =1 ; i <= nbLocs; i++) {
1713 Handle(Standard_Transient) anItem = theLocations->Value(i);
1717 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1718 if(!anObj.IsNull()) {
1733 //=============================================================================
1735 * MakePipeBiNormalAlongVector
1737 //=============================================================================
1738 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
1739 Handle(GEOM_Object) thePath,
1740 Handle(GEOM_Object) theVec)
1744 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
1746 //Add a new Pipe object
1747 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1749 //Add a new Pipe function
1750 Handle(GEOM_Function) aFunction =
1751 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
1752 if (aFunction.IsNull()) return NULL;
1754 //Check if the function is set correctly
1755 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1757 GEOMImpl_IPipeBiNormal aCI (aFunction);
1759 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1760 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1761 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1763 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
1765 aCI.SetBase(aRefBase);
1766 aCI.SetPath(aRefPath);
1767 aCI.SetVector(aRefVec);
1769 //Compute the Pipe value
1771 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1774 if (!GetSolver()->ComputeFunction(aFunction)) {
1775 SetErrorCode("Pipe driver failed");
1779 catch (Standard_Failure) {
1780 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1781 SetErrorCode(aFail->GetMessageString());
1785 //Make a Python command
1786 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
1787 << theBase << ", " << thePath << ", " << theVec << ")";