1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_I3DPrimOperations.hxx>
24 #include "utilities.h"
26 #include <Utils_ExceptHandlers.hxx>
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
36 #include <GEOMImpl_Types.hxx>
38 #include <GEOMImpl_BoxDriver.hxx>
39 #include <GEOMImpl_CylinderDriver.hxx>
40 #include <GEOMImpl_ConeDriver.hxx>
41 #include <GEOMImpl_SphereDriver.hxx>
42 #include <GEOMImpl_TorusDriver.hxx>
43 #include <GEOMImpl_PrismDriver.hxx>
44 #include <GEOMImpl_PipeDriver.hxx>
45 #include <GEOMImpl_RevolutionDriver.hxx>
46 #include <GEOMImpl_ShapeDriver.hxx>
47 #include <GEOMImpl_FillingDriver.hxx>
48 #include <GEOMImpl_ThruSectionsDriver.hxx>
50 #include <GEOMImpl_IBox.hxx>
51 #include <GEOMImpl_ICylinder.hxx>
52 #include <GEOMImpl_ICone.hxx>
53 #include <GEOMImpl_ISphere.hxx>
54 #include <GEOMImpl_ITorus.hxx>
55 #include <GEOMImpl_IPrism.hxx>
56 #include <GEOMImpl_IPipe.hxx>
57 #include <GEOMImpl_IRevolution.hxx>
58 #include <GEOMImpl_IShapes.hxx>
59 #include <GEOMImpl_IFilling.hxx>
60 #include <GEOMImpl_IThruSections.hxx>
61 #include <GEOMImpl_IPipeDiffSect.hxx>
63 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
65 //=============================================================================
69 //=============================================================================
70 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
71 : GEOM_IOperations(theEngine, theDocID)
73 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
76 //=============================================================================
80 //=============================================================================
81 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
83 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
87 //=============================================================================
91 //=============================================================================
92 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
96 //Add a new Box object
97 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
99 //Add a new Box function with DX_DY_DZ parameters
100 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
101 if (aFunction.IsNull()) return NULL;
103 //Check if the function is set correctly
104 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
106 GEOMImpl_IBox aBI (aFunction);
112 //Compute the box value
114 if (!GetSolver()->ComputeFunction(aFunction)) {
115 SetErrorCode("Box driver failed");
119 catch (Standard_Failure) {
120 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
121 SetErrorCode(aFail->GetMessageString());
125 //Make a Python command
126 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
127 << theDX << ", " << theDY << ", " << theDZ << ")";
134 //=============================================================================
138 //=============================================================================
139 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
140 Handle(GEOM_Object) thePnt2)
144 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
146 //Add a new Box object
147 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
149 //Add a new Box function for creation a box relatively to two points
150 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
151 if (aFunction.IsNull()) return NULL;
153 //Check if the function is set correctly
154 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
156 GEOMImpl_IBox aBI (aFunction);
158 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
159 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
161 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
163 aBI.SetRef1(aRefFunction1);
164 aBI.SetRef2(aRefFunction2);
166 //Compute the Box value
168 if (!GetSolver()->ComputeFunction(aFunction)) {
169 SetErrorCode("Box driver failed");
173 catch (Standard_Failure) {
174 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
175 SetErrorCode(aFail->GetMessageString());
179 //Make a Python command
180 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
181 << thePnt1 << ", " << thePnt2 << ")";
188 //=============================================================================
192 //=============================================================================
193 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
197 //Add a new Cylinder object
198 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
200 //Add a new Cylinder function with R and H parameters
201 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
202 if (aFunction.IsNull()) return NULL;
204 //Check if the function is set correctly
205 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
207 GEOMImpl_ICylinder aCI (aFunction);
212 //Compute the Cylinder value
214 if (!GetSolver()->ComputeFunction(aFunction)) {
215 SetErrorCode("Cylinder driver failed");
219 catch (Standard_Failure) {
220 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
221 SetErrorCode(aFail->GetMessageString());
225 //Make a Python command
226 GEOM::TPythonDump(aFunction) << aCylinder
227 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
234 //=============================================================================
236 * MakeCylinderPntVecRH
238 //=============================================================================
239 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
240 Handle(GEOM_Object) theVec,
241 double theR, double theH)
245 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
247 //Add a new Cylinder object
248 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
250 //Add a new Cylinder function for creation a cylinder relatively to point and vector
251 Handle(GEOM_Function) aFunction =
252 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
253 if (aFunction.IsNull()) return NULL;
255 //Check if the function is set correctly
256 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
258 GEOMImpl_ICylinder aCI (aFunction);
260 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
261 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
263 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
265 aCI.SetPoint(aRefPnt);
266 aCI.SetVector(aRefVec);
270 //Compute the Cylinder value
272 if (!GetSolver()->ComputeFunction(aFunction)) {
273 SetErrorCode("Cylinder driver failed");
277 catch (Standard_Failure) {
278 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
279 SetErrorCode(aFail->GetMessageString());
283 //Make a Python command
284 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
285 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
292 //=============================================================================
296 //=============================================================================
297 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
302 //Add a new Cone object
303 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
305 //Add a new Cone function with R and H parameters
306 Handle(GEOM_Function) aFunction =
307 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
308 if (aFunction.IsNull()) return NULL;
310 //Check if the function is set correctly
311 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
313 GEOMImpl_ICone aCI (aFunction);
319 //Compute the Cone value
321 if (!GetSolver()->ComputeFunction(aFunction)) {
322 SetErrorCode("Cone driver failed");
326 catch (Standard_Failure) {
327 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
328 SetErrorCode(aFail->GetMessageString());
332 //Make a Python command
333 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
334 << theR1 << ", " << theR2 << ", " << theH << ")";
341 //=============================================================================
343 * MakeConePntVecR1R2H
345 //=============================================================================
346 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
347 Handle(GEOM_Object) theVec,
348 double theR1, double theR2,
353 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
355 //Add a new Cone object
356 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
358 //Add a new Cone function for creation a cone relatively to point and vector
359 Handle(GEOM_Function) aFunction =
360 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
361 if (aFunction.IsNull()) return NULL;
363 //Check if the function is set correctly
364 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
366 GEOMImpl_ICone aCI (aFunction);
368 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
369 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
371 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
373 aCI.SetPoint(aRefPnt);
374 aCI.SetVector(aRefVec);
379 //Compute the Cone value
381 if (!GetSolver()->ComputeFunction(aFunction)) {
382 SetErrorCode("Cone driver failed");
386 catch (Standard_Failure) {
387 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
388 SetErrorCode(aFail->GetMessageString());
392 //Make a Python command
393 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
394 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
401 //=============================================================================
405 //=============================================================================
406 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
410 //Add a new Sphere object
411 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
413 //Add a new Sphere function with R parameter
414 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
415 if (aFunction.IsNull()) return NULL;
417 //Check if the function is set correctly
418 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
420 GEOMImpl_ISphere aCI (aFunction);
424 //Compute the Sphere value
426 if (!GetSolver()->ComputeFunction(aFunction)) {
427 SetErrorCode("Sphere driver failed");
431 catch (Standard_Failure) {
432 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
433 SetErrorCode(aFail->GetMessageString());
437 //Make a Python command
438 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
445 //=============================================================================
449 //=============================================================================
450 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
455 if (thePnt.IsNull()) return NULL;
457 //Add a new Point object
458 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
460 //Add a new Sphere function for creation a sphere relatively to point
461 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
462 if (aFunction.IsNull()) return NULL;
464 //Check if the function is set correctly
465 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
467 GEOMImpl_ISphere aCI (aFunction);
469 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
471 if (aRefPnt.IsNull()) return NULL;
473 aCI.SetPoint(aRefPnt);
476 //Compute the Sphere value
478 if (!GetSolver()->ComputeFunction(aFunction)) {
479 SetErrorCode("Sphere driver failed");
483 catch (Standard_Failure) {
484 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
485 SetErrorCode(aFail->GetMessageString());
489 //Make a Python command
490 GEOM::TPythonDump(aFunction) << aSphere
491 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
498 //=============================================================================
502 //=============================================================================
503 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
504 (double theRMajor, double theRMinor)
508 //Add a new Torus object
509 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
511 //Add a new Torus function
512 Handle(GEOM_Function) aFunction =
513 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
514 if (aFunction.IsNull()) return NULL;
516 //Check if the function is set correctly
517 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
519 GEOMImpl_ITorus aCI (aFunction);
521 aCI.SetRMajor(theRMajor);
522 aCI.SetRMinor(theRMinor);
524 //Compute the Torus value
526 if (!GetSolver()->ComputeFunction(aFunction)) {
527 SetErrorCode("Torus driver failed");
531 catch (Standard_Failure) {
532 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
533 SetErrorCode(aFail->GetMessageString());
537 //Make a Python command
538 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
539 << theRMajor << ", " << theRMinor << ")";
545 //=============================================================================
549 //=============================================================================
550 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
551 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
552 double theRMajor, double theRMinor)
556 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
558 //Add a new Torus object
559 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
561 //Add a new Torus function
562 Handle(GEOM_Function) aFunction =
563 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
564 if (aFunction.IsNull()) return NULL;
566 //Check if the function is set correctly
567 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
569 GEOMImpl_ITorus aCI (aFunction);
571 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
572 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
574 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
576 aCI.SetCenter(aRefPnt);
577 aCI.SetVector(aRefVec);
578 aCI.SetRMajor(theRMajor);
579 aCI.SetRMinor(theRMinor);
581 //Compute the Torus value
583 if (!GetSolver()->ComputeFunction(aFunction)) {
584 SetErrorCode("Torus driver failed");
588 catch (Standard_Failure) {
589 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
590 SetErrorCode(aFail->GetMessageString());
594 //Make a Python command
595 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
596 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
603 //=============================================================================
607 //=============================================================================
608 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
609 Handle(GEOM_Object) theVec,
614 if (theBase.IsNull() || theVec.IsNull()) return NULL;
616 //Add a new Prism object
617 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
619 //Add a new Prism function for creation a Prism relatively to vector
620 Handle(GEOM_Function) aFunction =
621 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
622 if (aFunction.IsNull()) return NULL;
624 //Check if the function is set correctly
625 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
627 GEOMImpl_IPrism aCI (aFunction);
629 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
630 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
632 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
634 aCI.SetBase(aRefBase);
635 aCI.SetVector(aRefVec);
638 //Compute the Prism value
640 if (!GetSolver()->ComputeFunction(aFunction)) {
641 SetErrorCode("Prism driver failed");
645 catch (Standard_Failure) {
646 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
647 SetErrorCode(aFail->GetMessageString());
651 //Make a Python command
652 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
653 << theBase << ", " << theVec << ", " << theH << ")";
659 //=============================================================================
663 //=============================================================================
664 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
665 (Handle(GEOM_Object) theBase,
666 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
670 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
672 //Add a new Prism object
673 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
675 //Add a new Prism function for creation a Prism relatively to two points
676 Handle(GEOM_Function) aFunction =
677 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
678 if (aFunction.IsNull()) return NULL;
680 //Check if the function is set correctly
681 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
683 GEOMImpl_IPrism aCI (aFunction);
685 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
686 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
687 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
689 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
691 aCI.SetBase(aRefBase);
692 aCI.SetFirstPoint(aRefPnt1);
693 aCI.SetLastPoint(aRefPnt2);
695 //Compute the Prism value
697 if (!GetSolver()->ComputeFunction(aFunction)) {
698 SetErrorCode("Prism driver failed");
702 catch (Standard_Failure) {
703 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
704 SetErrorCode(aFail->GetMessageString());
708 //Make a Python command
709 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
710 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
717 //=============================================================================
721 //=============================================================================
722 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
723 Handle(GEOM_Object) thePath)
727 if (theBase.IsNull() || thePath.IsNull()) return NULL;
729 //Add a new Pipe object
730 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
732 //Add a new Pipe function
733 Handle(GEOM_Function) aFunction =
734 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
735 if (aFunction.IsNull()) return NULL;
737 //Check if the function is set correctly
738 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
740 GEOMImpl_IPipe aCI (aFunction);
742 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
743 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
745 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
747 aCI.SetBase(aRefBase);
748 aCI.SetPath(aRefPath);
750 //Compute the Pipe value
752 if (!GetSolver()->ComputeFunction(aFunction)) {
753 SetErrorCode("Pipe driver failed");
757 catch (Standard_Failure) {
758 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
759 SetErrorCode(aFail->GetMessageString());
763 //Make a Python command
764 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
765 << theBase << ", " << thePath << ")";
772 //=============================================================================
774 * MakeRevolutionAxisAngle
776 //=============================================================================
777 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
778 Handle(GEOM_Object) theAxis,
783 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
785 //Add a new Revolution object
786 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
788 //Add a new Revolution function for creation a revolution relatively to axis
789 Handle(GEOM_Function) aFunction =
790 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
791 if (aFunction.IsNull()) return NULL;
793 //Check if the function is set correctly
794 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
796 GEOMImpl_IRevolution aCI (aFunction);
798 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
799 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
801 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
803 aCI.SetBase(aRefBase);
804 aCI.SetAxis(aRefAxis);
805 aCI.SetAngle(theAngle);
807 //Compute the Revolution value
809 if (!GetSolver()->ComputeFunction(aFunction)) {
810 SetErrorCode("Revolution driver failed");
814 catch (Standard_Failure) {
815 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
816 SetErrorCode(aFail->GetMessageString());
820 //Make a Python command
821 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
822 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
829 //=============================================================================
833 //=============================================================================
834 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
838 if (theShell.IsNull()) return NULL;
840 //Add a new Solid object
841 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
843 //Add a new Solid function for creation a solid from a shell
844 Handle(GEOM_Function) aFunction =
845 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
846 if (aFunction.IsNull()) return NULL;
848 //Check if the function is set correctly
849 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
851 GEOMImpl_IShapes aCI (aFunction);
853 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
855 if (aRefShell.IsNull()) return NULL;
857 aCI.SetBase(aRefShell);
859 //Compute the Solid value
861 if (!GetSolver()->ComputeFunction(aFunction)) {
862 SetErrorCode("Solid driver failed");
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) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
879 //=============================================================================
883 //=============================================================================
884 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
885 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
886 double theTol2D, double theTol3D, int theNbIter)
890 if (theShape.IsNull()) return NULL;
892 //Add a new Filling object
893 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
895 //Add a new Filling function for creation a filling from a compound
896 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
897 if (aFunction.IsNull()) return NULL;
899 //Check if the function is set correctly
900 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
902 GEOMImpl_IFilling aFI (aFunction);
904 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
906 if (aRefShape.IsNull()) return NULL;
908 aFI.SetShape(aRefShape);
909 aFI.SetMinDeg(theMinDeg);
910 aFI.SetMaxDeg(theMaxDeg);
911 aFI.SetTol2D(theTol2D);
912 aFI.SetTol3D(theTol3D);
913 aFI.SetNbIter(theNbIter);
915 //Compute the Solid value
917 if (!GetSolver()->ComputeFunction(aFunction)) {
918 SetErrorCode("Filling driver failed");
922 catch (Standard_Failure) {
923 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
924 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
925 SetErrorCode("B-Spline surface construction failed");
927 SetErrorCode(aFail->GetMessageString());
931 //Make a Python command
932 GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling("
933 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
934 << theTol2D << ", " << theTol3D << ", " << theNbIter << ")";
940 //=============================================================================
944 //=============================================================================
945 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
946 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
951 Handle(GEOM_Object) anObj;
953 if(theSeqSections.IsNull())
956 Standard_Integer nbObj = theSeqSections->Length();
960 //Add a new ThruSections object
961 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
964 //Add a new ThruSections function
966 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
967 Handle(GEOM_Function) aFunction =
968 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
969 if (aFunction.IsNull()) return anObj;
971 //Check if the function is set correctly
972 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
974 GEOMImpl_IThruSections aCI (aFunction);
976 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
978 Standard_Integer i =1;
979 for( ; i <= nbObj; i++) {
981 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
985 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
986 if(!aSectObj.IsNull())
988 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
989 if(!aRefSect.IsNull())
990 aSeqSections->Append(aRefSect);
994 if(!aSeqSections->Length())
997 aCI.SetSections(aSeqSections);
998 aCI.SetSolidMode(theModeSolid);
999 aCI.SetPrecision(thePreci);
1001 //Compute the ThruSections value
1003 if (!GetSolver()->ComputeFunction(aFunction)) {
1004 SetErrorCode("ThruSections driver failed");
1008 catch (Standard_Failure) {
1009 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1010 SetErrorCode(aFail->GetMessageString());
1014 //Make a Python command
1015 GEOM::TPythonDump pyDump(aFunction);
1016 pyDump << aThruSect << " = geompy.MakeThruSections([";
1018 for(i =1 ; i <= nbObj; i++) {
1020 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1024 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1025 if(!aSectObj.IsNull()) {
1032 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1040 //=============================================================================
1042 * MakePipeWithDifferentSections
1044 //=============================================================================
1045 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1046 const Handle(TColStd_HSequenceOfTransient)& theBases,
1047 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1048 const Handle(GEOM_Object)& thePath,
1049 bool theWithContact,
1050 bool theWithCorrections)
1052 Handle(GEOM_Object) anObj;
1054 if(theBases.IsNull())
1057 Standard_Integer nbBases = theBases->Length();
1062 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1063 //Add a new Pipe object
1064 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1066 //Add a new Pipe function
1068 Handle(GEOM_Function) aFunction =
1069 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1070 if (aFunction.IsNull()) return anObj;
1072 //Check if the function is set correctly
1073 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1075 GEOMImpl_IPipeDiffSect aCI (aFunction);
1077 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1078 if(aRefPath.IsNull())
1081 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1082 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1084 Standard_Integer i =1;
1085 for( ; i <= nbBases; i++) {
1087 Handle(Standard_Transient) anItem = theBases->Value(i);
1091 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1094 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1095 if(aRefBase.IsNull())
1099 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1100 if(anItemLoc.IsNull())
1103 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1106 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1107 if(aRefLoc.IsNull())
1109 aSeqLocs->Append(aRefLoc);
1111 aSeqBases->Append(aRefBase);
1114 if(!aSeqBases->Length())
1117 aCI.SetBases(aSeqBases);
1118 aCI.SetLocations(aSeqLocs);
1119 aCI.SetPath(aRefPath);
1120 aCI.SetWithContactMode(theWithContact);
1121 aCI.SetWithCorrectionMode(theWithCorrections);
1123 //Compute the Pipe value
1125 if (!GetSolver()->ComputeFunction(aFunction)) {
1126 SetErrorCode("Pipe with defferent section driver failed");
1130 catch (Standard_Failure) {
1131 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1132 SetErrorCode(aFail->GetMessageString());
1136 //Make a Python command
1137 GEOM::TPythonDump pyDump(aFunction);
1138 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1140 for(i =1 ; i <= nbBases; i++) {
1142 Handle(Standard_Transient) anItem = theBases->Value(i);
1146 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1147 if(!anObj.IsNull()) {
1157 for(i =1 ; i <= nbLocs; i++) {
1159 Handle(Standard_Transient) anItem = theLocations->Value(i);
1163 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1164 if(!anObj.IsNull()) {
1171 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";