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/
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>
49 #include <GEOMImpl_IBox.hxx>
50 #include <GEOMImpl_ICylinder.hxx>
51 #include <GEOMImpl_ICone.hxx>
52 #include <GEOMImpl_ISphere.hxx>
53 #include <GEOMImpl_ITorus.hxx>
54 #include <GEOMImpl_IPrism.hxx>
55 #include <GEOMImpl_IPipe.hxx>
56 #include <GEOMImpl_IRevolution.hxx>
57 #include <GEOMImpl_IShapes.hxx>
58 #include <GEOMImpl_IFilling.hxx>
60 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
62 //=============================================================================
66 //=============================================================================
67 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
68 : GEOM_IOperations(theEngine, theDocID)
70 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
73 //=============================================================================
77 //=============================================================================
78 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
80 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
84 //=============================================================================
88 //=============================================================================
89 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
93 //Add a new Box object
94 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
96 //Add a new Box function with DX_DY_DZ parameters
97 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
98 if (aFunction.IsNull()) return NULL;
100 //Check if the function is set correctly
101 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
103 GEOMImpl_IBox aBI (aFunction);
109 //Compute the box value
111 if (!GetSolver()->ComputeFunction(aFunction)) {
112 SetErrorCode("Box driver failed");
116 catch (Standard_Failure) {
117 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
118 SetErrorCode(aFail->GetMessageString());
122 //Make a Python command
123 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
124 << theDX << ", " << theDY << ", " << theDZ << ")";
131 //=============================================================================
135 //=============================================================================
136 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
137 Handle(GEOM_Object) thePnt2)
141 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
143 //Add a new Box object
144 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
146 //Add a new Box function for creation a box relatively to two points
147 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
148 if (aFunction.IsNull()) return NULL;
150 //Check if the function is set correctly
151 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
153 GEOMImpl_IBox aBI (aFunction);
155 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
156 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
158 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
160 aBI.SetRef1(aRefFunction1);
161 aBI.SetRef2(aRefFunction2);
163 //Compute the Box value
165 if (!GetSolver()->ComputeFunction(aFunction)) {
166 SetErrorCode("Box driver failed");
170 catch (Standard_Failure) {
171 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
172 SetErrorCode(aFail->GetMessageString());
176 //Make a Python command
177 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
178 << thePnt1 << ", " << thePnt2 << ")";
185 //=============================================================================
189 //=============================================================================
190 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
194 //Add a new Cylinder object
195 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
197 //Add a new Cylinder function with R and H parameters
198 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
199 if (aFunction.IsNull()) return NULL;
201 //Check if the function is set correctly
202 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
204 GEOMImpl_ICylinder aCI (aFunction);
209 //Compute the Cylinder value
211 if (!GetSolver()->ComputeFunction(aFunction)) {
212 SetErrorCode("Cylinder driver failed");
216 catch (Standard_Failure) {
217 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
218 SetErrorCode(aFail->GetMessageString());
222 //Make a Python command
223 GEOM::TPythonDump(aFunction) << aCylinder
224 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
231 //=============================================================================
233 * MakeCylinderPntVecRH
235 //=============================================================================
236 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
237 Handle(GEOM_Object) theVec,
238 double theR, double theH)
242 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
244 //Add a new Cylinder object
245 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
247 //Add a new Cylinder function for creation a cylinder relatively to point and vector
248 Handle(GEOM_Function) aFunction =
249 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
250 if (aFunction.IsNull()) return NULL;
252 //Check if the function is set correctly
253 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
255 GEOMImpl_ICylinder aCI (aFunction);
257 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
258 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
260 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
262 aCI.SetPoint(aRefPnt);
263 aCI.SetVector(aRefVec);
267 //Compute the Cylinder value
269 if (!GetSolver()->ComputeFunction(aFunction)) {
270 SetErrorCode("Cylinder driver failed");
274 catch (Standard_Failure) {
275 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
276 SetErrorCode(aFail->GetMessageString());
280 //Make a Python command
281 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
282 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
289 //=============================================================================
293 //=============================================================================
294 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
299 //Add a new Cone object
300 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
302 //Add a new Cone function with R and H parameters
303 Handle(GEOM_Function) aFunction =
304 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
305 if (aFunction.IsNull()) return NULL;
307 //Check if the function is set correctly
308 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
310 GEOMImpl_ICone aCI (aFunction);
316 //Compute the Cone value
318 if (!GetSolver()->ComputeFunction(aFunction)) {
319 SetErrorCode("Cone driver failed");
323 catch (Standard_Failure) {
324 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
325 SetErrorCode(aFail->GetMessageString());
329 //Make a Python command
330 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
331 << theR1 << ", " << theR2 << ", " << theH << ")";
338 //=============================================================================
340 * MakeConePntVecR1R2H
342 //=============================================================================
343 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
344 Handle(GEOM_Object) theVec,
345 double theR1, double theR2,
350 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
352 //Add a new Cone object
353 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
355 //Add a new Cone function for creation a cone relatively to point and vector
356 Handle(GEOM_Function) aFunction =
357 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
358 if (aFunction.IsNull()) return NULL;
360 //Check if the function is set correctly
361 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
363 GEOMImpl_ICone aCI (aFunction);
365 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
366 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
368 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
370 aCI.SetPoint(aRefPnt);
371 aCI.SetVector(aRefVec);
376 //Compute the Cone value
378 if (!GetSolver()->ComputeFunction(aFunction)) {
379 SetErrorCode("Cone driver failed");
383 catch (Standard_Failure) {
384 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
385 SetErrorCode(aFail->GetMessageString());
389 //Make a Python command
390 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
391 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
398 //=============================================================================
402 //=============================================================================
403 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
407 //Add a new Sphere object
408 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
410 //Add a new Sphere function with R parameter
411 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
412 if (aFunction.IsNull()) return NULL;
414 //Check if the function is set correctly
415 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
417 GEOMImpl_ISphere aCI (aFunction);
421 //Compute the Sphere value
423 if (!GetSolver()->ComputeFunction(aFunction)) {
424 SetErrorCode("Sphere driver failed");
428 catch (Standard_Failure) {
429 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
430 SetErrorCode(aFail->GetMessageString());
434 //Make a Python command
435 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
442 //=============================================================================
446 //=============================================================================
447 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
452 if (thePnt.IsNull()) return NULL;
454 //Add a new Point object
455 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
457 //Add a new Sphere function for creation a sphere relatively to point
458 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
459 if (aFunction.IsNull()) return NULL;
461 //Check if the function is set correctly
462 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
464 GEOMImpl_ISphere aCI (aFunction);
466 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
468 if (aRefPnt.IsNull()) return NULL;
470 aCI.SetPoint(aRefPnt);
473 //Compute the Sphere value
475 if (!GetSolver()->ComputeFunction(aFunction)) {
476 SetErrorCode("Sphere driver failed");
480 catch (Standard_Failure) {
481 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
482 SetErrorCode(aFail->GetMessageString());
486 //Make a Python command
487 GEOM::TPythonDump(aFunction) << aSphere
488 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
495 //=============================================================================
499 //=============================================================================
500 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
501 (double theRMajor, double theRMinor)
505 //Add a new Torus object
506 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
508 //Add a new Torus function
509 Handle(GEOM_Function) aFunction =
510 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
511 if (aFunction.IsNull()) return NULL;
513 //Check if the function is set correctly
514 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
516 GEOMImpl_ITorus aCI (aFunction);
518 aCI.SetRMajor(theRMajor);
519 aCI.SetRMinor(theRMinor);
521 //Compute the Torus value
523 if (!GetSolver()->ComputeFunction(aFunction)) {
524 SetErrorCode("Torus driver failed");
528 catch (Standard_Failure) {
529 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
530 SetErrorCode(aFail->GetMessageString());
534 //Make a Python command
535 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
536 << theRMajor << ", " << theRMinor << ")";
542 //=============================================================================
546 //=============================================================================
547 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
548 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
549 double theRMajor, double theRMinor)
553 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
555 //Add a new Torus object
556 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
558 //Add a new Torus function
559 Handle(GEOM_Function) aFunction =
560 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
561 if (aFunction.IsNull()) return NULL;
563 //Check if the function is set correctly
564 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
566 GEOMImpl_ITorus aCI (aFunction);
568 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
569 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
571 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
573 aCI.SetCenter(aRefPnt);
574 aCI.SetVector(aRefVec);
575 aCI.SetRMajor(theRMajor);
576 aCI.SetRMinor(theRMinor);
578 //Compute the Torus value
580 if (!GetSolver()->ComputeFunction(aFunction)) {
581 SetErrorCode("Torus driver failed");
585 catch (Standard_Failure) {
586 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
587 SetErrorCode(aFail->GetMessageString());
591 //Make a Python command
592 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
593 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
600 //=============================================================================
604 //=============================================================================
605 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
606 Handle(GEOM_Object) theVec,
611 if (theBase.IsNull() || theVec.IsNull()) return NULL;
613 //Add a new Prism object
614 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
616 //Add a new Prism function for creation a Prism relatively to vector
617 Handle(GEOM_Function) aFunction =
618 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
619 if (aFunction.IsNull()) return NULL;
621 //Check if the function is set correctly
622 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
624 GEOMImpl_IPrism aCI (aFunction);
626 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
627 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
629 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
631 aCI.SetBase(aRefBase);
632 aCI.SetVector(aRefVec);
635 //Compute the Prism value
637 if (!GetSolver()->ComputeFunction(aFunction)) {
638 SetErrorCode("Prism driver failed");
642 catch (Standard_Failure) {
643 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
644 SetErrorCode(aFail->GetMessageString());
648 //Make a Python command
649 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
650 << theBase << ", " << theVec << ", " << theH << ")";
656 //=============================================================================
660 //=============================================================================
661 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
662 (Handle(GEOM_Object) theBase,
663 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
667 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
669 //Add a new Prism object
670 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
672 //Add a new Prism function for creation a Prism relatively to two points
673 Handle(GEOM_Function) aFunction =
674 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
675 if (aFunction.IsNull()) return NULL;
677 //Check if the function is set correctly
678 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
680 GEOMImpl_IPrism aCI (aFunction);
682 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
683 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
684 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
686 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
688 aCI.SetBase(aRefBase);
689 aCI.SetFirstPoint(aRefPnt1);
690 aCI.SetLastPoint(aRefPnt2);
692 //Compute the Prism value
694 if (!GetSolver()->ComputeFunction(aFunction)) {
695 SetErrorCode("Prism driver failed");
699 catch (Standard_Failure) {
700 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
701 SetErrorCode(aFail->GetMessageString());
705 //Make a Python command
706 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
707 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
714 //=============================================================================
718 //=============================================================================
719 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
720 Handle(GEOM_Object) thePath)
724 if (theBase.IsNull() || thePath.IsNull()) return NULL;
726 //Add a new Pipe object
727 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
729 //Add a new Pipe function
730 Handle(GEOM_Function) aFunction =
731 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
732 if (aFunction.IsNull()) return NULL;
734 //Check if the function is set correctly
735 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
737 GEOMImpl_IPipe aCI (aFunction);
739 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
740 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
742 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
744 aCI.SetBase(aRefBase);
745 aCI.SetPath(aRefPath);
747 //Compute the Pipe value
749 if (!GetSolver()->ComputeFunction(aFunction)) {
750 SetErrorCode("Pipe driver failed");
754 catch (Standard_Failure) {
755 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
756 SetErrorCode(aFail->GetMessageString());
760 //Make a Python command
761 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
762 << theBase << ", " << thePath << ")";
769 //=============================================================================
771 * MakeRevolutionAxisAngle
773 //=============================================================================
774 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
775 Handle(GEOM_Object) theAxis,
780 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
782 //Add a new Revolution object
783 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
785 //Add a new Revolution function for creation a revolution relatively to axis
786 Handle(GEOM_Function) aFunction =
787 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
788 if (aFunction.IsNull()) return NULL;
790 //Check if the function is set correctly
791 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
793 GEOMImpl_IRevolution aCI (aFunction);
795 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
796 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
798 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
800 aCI.SetBase(aRefBase);
801 aCI.SetAxis(aRefAxis);
802 aCI.SetAngle(theAngle);
804 //Compute the Revolution value
806 if (!GetSolver()->ComputeFunction(aFunction)) {
807 SetErrorCode("Revolution driver failed");
811 catch (Standard_Failure) {
812 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
813 SetErrorCode(aFail->GetMessageString());
817 //Make a Python command
818 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
819 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
826 //=============================================================================
830 //=============================================================================
831 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
835 if (theShell.IsNull()) return NULL;
837 //Add a new Solid object
838 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
840 //Add a new Solid function for creation a solid from a shell
841 Handle(GEOM_Function) aFunction =
842 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
843 if (aFunction.IsNull()) return NULL;
845 //Check if the function is set correctly
846 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
848 GEOMImpl_IShapes aCI (aFunction);
850 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
852 if (aRefShell.IsNull()) return NULL;
854 aCI.SetBase(aRefShell);
856 //Compute the Solid value
858 if (!GetSolver()->ComputeFunction(aFunction)) {
859 SetErrorCode("Solid driver failed");
863 catch (Standard_Failure) {
864 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
865 SetErrorCode(aFail->GetMessageString());
869 //Make a Python command
870 GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
876 //=============================================================================
880 //=============================================================================
881 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
882 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
883 double theTol2D, double theTol3D, int theNbIter)
887 if (theShape.IsNull()) return NULL;
889 //Add a new Filling object
890 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
892 //Add a new Filling function for creation a filling from a compound
893 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
894 if (aFunction.IsNull()) return NULL;
896 //Check if the function is set correctly
897 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
899 GEOMImpl_IFilling aFI (aFunction);
901 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
903 if (aRefShape.IsNull()) return NULL;
905 aFI.SetShape(aRefShape);
906 aFI.SetMinDeg(theMinDeg);
907 aFI.SetMaxDeg(theMaxDeg);
908 aFI.SetTol2D(theTol2D);
909 aFI.SetTol3D(theTol3D);
910 aFI.SetNbIter(theNbIter);
912 //Compute the Solid value
914 if (!GetSolver()->ComputeFunction(aFunction)) {
915 SetErrorCode("Filling driver failed");
919 catch (Standard_Failure) {
920 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
921 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
922 SetErrorCode("B-Spline surface construction failed");
924 SetErrorCode(aFail->GetMessageString());
928 //Make a Python command
929 GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling("
930 << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
931 << theTol2D << ", " << theTol3D << ", " << theNbIter << ")";