3 #include "GEOMImpl_I3DPrimOperations.hxx"
7 #include "Utils_ExceptHandlers.hxx"
9 #include <TFunction_DriverTable.hxx>
10 #include <TFunction_Driver.hxx>
11 #include <TFunction_Logbook.hxx>
12 #include <TDF_Tool.hxx>
14 #include "GEOM_Function.hxx"
15 #include "GEOMImpl_Types.hxx"
17 #include "GEOMImpl_BoxDriver.hxx"
18 #include "GEOMImpl_CylinderDriver.hxx"
19 #include "GEOMImpl_ConeDriver.hxx"
20 #include "GEOMImpl_SphereDriver.hxx"
21 #include "GEOMImpl_TorusDriver.hxx"
22 #include "GEOMImpl_PrismDriver.hxx"
23 #include "GEOMImpl_PipeDriver.hxx"
24 #include "GEOMImpl_RevolutionDriver.hxx"
25 #include "GEOMImpl_ShapeDriver.hxx"
26 #include "GEOMImpl_FillingDriver.hxx"
28 #include "GEOMImpl_IBox.hxx"
29 #include "GEOMImpl_ICylinder.hxx"
30 #include "GEOMImpl_ICone.hxx"
31 #include "GEOMImpl_ISphere.hxx"
32 #include "GEOMImpl_ITorus.hxx"
33 #include "GEOMImpl_IPrism.hxx"
34 #include "GEOMImpl_IPipe.hxx"
35 #include "GEOMImpl_IRevolution.hxx"
36 #include "GEOMImpl_IShapes.hxx"
37 #include "GEOMImpl_IFilling.hxx"
39 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
41 //=============================================================================
45 //=============================================================================
46 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
47 : GEOM_IOperations(theEngine, theDocID)
49 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
52 //=============================================================================
56 //=============================================================================
57 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
59 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
63 //=============================================================================
67 //=============================================================================
68 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
72 //Add a new Box object
73 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
75 //Add a new Box function with DX_DY_DZ parameters
76 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
77 if (aFunction.IsNull()) return NULL;
79 //Check if the function is set correctly
80 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
82 GEOMImpl_IBox aBI (aFunction);
88 //Compute the box value
90 if (!GetSolver()->ComputeFunction(aFunction)) {
91 SetErrorCode("Box driver failed");
95 catch (Standard_Failure) {
96 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
97 SetErrorCode(aFail->GetMessageString());
101 //Make a Python command
102 TCollection_AsciiString anEntry, aDescr("");
103 TDF_Tool::Entry(aBox->GetEntry(), anEntry);
105 aDescr += " = geompy.MakeBoxDXDYDZ(";
106 aDescr += (TCollection_AsciiString(theDX)+", ");
107 aDescr += (TCollection_AsciiString(theDY)+", ");
108 aDescr += (TCollection_AsciiString(theDZ)+")");
110 aFunction->SetDescription(aDescr);
117 //=============================================================================
121 //=============================================================================
122 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
123 Handle(GEOM_Object) thePnt2)
127 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
129 //Add a new Box object
130 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
132 //Add a new Box function for creation a box relatively to two points
133 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
134 if (aFunction.IsNull()) return NULL;
136 //Check if the function is set correctly
137 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
139 GEOMImpl_IBox aBI (aFunction);
141 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
142 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
144 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
146 aBI.SetRef1(aRefFunction1);
147 aBI.SetRef2(aRefFunction2);
149 //Compute the Box value
151 if (!GetSolver()->ComputeFunction(aFunction)) {
152 SetErrorCode("Box driver failed");
156 catch (Standard_Failure) {
157 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
158 SetErrorCode(aFail->GetMessageString());
162 //Make a Python command
163 TCollection_AsciiString anEntry, aDescr("");
164 TDF_Tool::Entry(aBox->GetEntry(), anEntry);
166 aDescr += " = geompy.MakeBoxTwoPnt(";
167 TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
168 aDescr += (anEntry+", ");
169 TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
170 aDescr += (anEntry+")");
172 aFunction->SetDescription(aDescr);
179 //=============================================================================
183 //=============================================================================
184 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
188 //Add a new Cylinder object
189 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
191 //Add a new Cylinder function with R and H parameters
192 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
193 if (aFunction.IsNull()) return NULL;
195 //Check if the function is set correctly
196 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
198 GEOMImpl_ICylinder aCI (aFunction);
203 //Compute the Cylinder value
205 if (!GetSolver()->ComputeFunction(aFunction)) {
206 SetErrorCode("Cylinder driver failed");
210 catch (Standard_Failure) {
211 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
212 SetErrorCode(aFail->GetMessageString());
216 //Make a Python command
217 TCollection_AsciiString anEntry, aDescr("");
218 TDF_Tool::Entry(aCylinder->GetEntry(), anEntry);
220 aDescr += " = geompy.MakeCylinderRH(";
221 aDescr += (TCollection_AsciiString(theR)+", ");
222 aDescr += (TCollection_AsciiString(theH)+")");
224 aFunction->SetDescription(aDescr);
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 TCollection_AsciiString anEntry, aDescr("");
282 TDF_Tool::Entry(aCylinder->GetEntry(), anEntry);
284 aDescr += " = geompy.MakeCylinder(";
285 TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
286 aDescr += (anEntry+", ");
287 TDF_Tool::Entry(theVec->GetEntry(), anEntry);
288 aDescr += (anEntry+", ");
289 aDescr += (TCollection_AsciiString(theR)+", ");
290 aDescr += (TCollection_AsciiString(theH)+")");
292 aFunction->SetDescription(aDescr);
299 //=============================================================================
303 //=============================================================================
304 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
309 //Add a new Cone object
310 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
312 //Add a new Cone function with R and H parameters
313 Handle(GEOM_Function) aFunction =
314 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
315 if (aFunction.IsNull()) return NULL;
317 //Check if the function is set correctly
318 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
320 GEOMImpl_ICone aCI (aFunction);
326 //Compute the Cone value
328 if (!GetSolver()->ComputeFunction(aFunction)) {
329 SetErrorCode("Cone driver failed");
333 catch (Standard_Failure) {
334 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
335 SetErrorCode(aFail->GetMessageString());
339 //Make a Python command
340 TCollection_AsciiString anEntry, aDescr("");
341 TDF_Tool::Entry(aCone->GetEntry(), anEntry);
343 aDescr += " = geompy.MakeConeR1R2H(";
344 aDescr += (TCollection_AsciiString(theR1)+", ");
345 aDescr += (TCollection_AsciiString(theR2)+", ");
346 aDescr += (TCollection_AsciiString(theH)+")");
348 aFunction->SetDescription(aDescr);
355 //=============================================================================
357 * MakeConePntVecR1R2H
359 //=============================================================================
360 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
361 Handle(GEOM_Object) theVec,
362 double theR1, double theR2,
367 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
369 //Add a new Cone object
370 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
372 //Add a new Cone function for creation a cone relatively to point and vector
373 Handle(GEOM_Function) aFunction =
374 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
375 if (aFunction.IsNull()) return NULL;
377 //Check if the function is set correctly
378 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
380 GEOMImpl_ICone aCI (aFunction);
382 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
383 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
385 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
387 aCI.SetPoint(aRefPnt);
388 aCI.SetVector(aRefVec);
393 //Compute the Cone value
395 if (!GetSolver()->ComputeFunction(aFunction)) {
396 SetErrorCode("Cone driver failed");
400 catch (Standard_Failure) {
401 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
402 SetErrorCode(aFail->GetMessageString());
406 //Make a Python command
407 TCollection_AsciiString anEntry, aDescr("");
408 TDF_Tool::Entry(aCone->GetEntry(), anEntry);
410 aDescr += " = geompy.MakeCone(";
411 TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
412 aDescr += (anEntry+", ");
413 TDF_Tool::Entry(theVec->GetEntry(), anEntry);
414 aDescr += (anEntry+", ");
415 aDescr += (TCollection_AsciiString(theR1)+", ");
416 aDescr += (TCollection_AsciiString(theR2)+", ");
417 aDescr += (TCollection_AsciiString(theH)+")");
419 aFunction->SetDescription(aDescr);
426 //=============================================================================
430 //=============================================================================
431 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
435 //Add a new Sphere object
436 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
438 //Add a new Sphere function with R parameter
439 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
440 if (aFunction.IsNull()) return NULL;
442 //Check if the function is set correctly
443 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
445 GEOMImpl_ISphere aCI (aFunction);
449 //Compute the Sphere value
451 if (!GetSolver()->ComputeFunction(aFunction)) {
452 SetErrorCode("Sphere driver failed");
456 catch (Standard_Failure) {
457 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
458 SetErrorCode(aFail->GetMessageString());
462 //Make a Python command
463 TCollection_AsciiString anEntry, aDescr("");
464 TDF_Tool::Entry(aSphere->GetEntry(), anEntry);
466 aDescr += " = geompy.MakeSphereR(";
467 aDescr += (TCollection_AsciiString(theR)+")");
469 aFunction->SetDescription(aDescr);
476 //=============================================================================
480 //=============================================================================
481 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
486 if (thePnt.IsNull()) return NULL;
488 //Add a new Point object
489 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
491 //Add a new Sphere function for creation a sphere relatively to point
492 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
493 if (aFunction.IsNull()) return NULL;
495 //Check if the function is set correctly
496 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
498 GEOMImpl_ISphere aCI (aFunction);
500 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
502 if (aRefPnt.IsNull()) return NULL;
504 aCI.SetPoint(aRefPnt);
507 //Compute the Sphere value
509 if (!GetSolver()->ComputeFunction(aFunction)) {
510 SetErrorCode("Sphere driver failed");
514 catch (Standard_Failure) {
515 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
516 SetErrorCode(aFail->GetMessageString());
520 //Make a Python command
521 TCollection_AsciiString anEntry, aDescr("");
522 TDF_Tool::Entry(aSphere->GetEntry(), anEntry);
524 aDescr += " = geompy.MakeSpherePntR(";
525 TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
526 aDescr += (anEntry+", ");
527 aDescr += (TCollection_AsciiString(theR)+")");
529 aFunction->SetDescription(aDescr);
536 //=============================================================================
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
542 (double theRMajor, double theRMinor)
546 //Add a new Torus object
547 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
549 //Add a new Torus function
550 Handle(GEOM_Function) aFunction =
551 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
552 if (aFunction.IsNull()) return NULL;
554 //Check if the function is set correctly
555 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
557 GEOMImpl_ITorus aCI (aFunction);
559 aCI.SetRMajor(theRMajor);
560 aCI.SetRMinor(theRMinor);
562 //Compute the Torus value
564 if (!GetSolver()->ComputeFunction(aFunction)) {
565 SetErrorCode("Torus driver failed");
569 catch (Standard_Failure) {
570 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
571 SetErrorCode(aFail->GetMessageString());
575 //Make a Python command
576 TCollection_AsciiString anEntry, aDescr("");
577 TDF_Tool::Entry(anEll->GetEntry(), anEntry);
579 aDescr += " = geompy.MakeTorusRR(";
580 aDescr += (TCollection_AsciiString(theRMajor)+", ");
581 aDescr += (TCollection_AsciiString(theRMinor)+")");
583 aFunction->SetDescription(aDescr);
589 //=============================================================================
593 //=============================================================================
594 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
595 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
596 double theRMajor, double theRMinor)
600 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
602 //Add a new Torus object
603 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
605 //Add a new Torus function
606 Handle(GEOM_Function) aFunction =
607 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
608 if (aFunction.IsNull()) return NULL;
610 //Check if the function is set correctly
611 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
613 GEOMImpl_ITorus aCI (aFunction);
615 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
616 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
618 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
620 aCI.SetCenter(aRefPnt);
621 aCI.SetVector(aRefVec);
622 aCI.SetRMajor(theRMajor);
623 aCI.SetRMinor(theRMinor);
625 //Compute the Torus value
627 if (!GetSolver()->ComputeFunction(aFunction)) {
628 SetErrorCode("Torus driver failed");
632 catch (Standard_Failure) {
633 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
634 SetErrorCode(aFail->GetMessageString());
638 //Make a Python command
639 TCollection_AsciiString anEntry, aDescr("");
640 TDF_Tool::Entry(anEll->GetEntry(), anEntry);
642 aDescr += " = geompy.MakeTorus(";
643 TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
644 aDescr += (anEntry+", ");
645 TDF_Tool::Entry(theVec->GetEntry(), anEntry);
646 aDescr += (anEntry+", ");
647 aDescr += (TCollection_AsciiString(theRMajor)+", ");
648 aDescr += (TCollection_AsciiString(theRMinor)+")");
650 aFunction->SetDescription(aDescr);
657 //=============================================================================
661 //=============================================================================
662 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
663 Handle(GEOM_Object) theVec,
668 if (theBase.IsNull() || theVec.IsNull()) return NULL;
670 //Add a new Prism object
671 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
673 //Add a new Prism function for creation a Prism relatively to vector
674 Handle(GEOM_Function) aFunction =
675 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
676 if (aFunction.IsNull()) return NULL;
678 //Check if the function is set correctly
679 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
681 GEOMImpl_IPrism aCI (aFunction);
683 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
684 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
686 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
688 aCI.SetBase(aRefBase);
689 aCI.SetVector(aRefVec);
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 TCollection_AsciiString anEntry, aDescr("");
707 TDF_Tool::Entry(aPrism->GetEntry(), anEntry);
709 aDescr += " = geompy.MakePrismVecH(";
710 TDF_Tool::Entry(theBase->GetEntry(), anEntry);
711 aDescr += (anEntry+", ");
712 TDF_Tool::Entry(theVec->GetEntry(), anEntry);
713 aDescr += (anEntry+", ");
714 aDescr += (TCollection_AsciiString(theH)+")");
716 aFunction->SetDescription(aDescr);
722 //=============================================================================
726 //=============================================================================
727 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
728 (Handle(GEOM_Object) theBase,
729 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
733 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
735 //Add a new Prism object
736 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
738 //Add a new Prism function for creation a Prism relatively to two points
739 Handle(GEOM_Function) aFunction =
740 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
741 if (aFunction.IsNull()) return NULL;
743 //Check if the function is set correctly
744 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
746 GEOMImpl_IPrism aCI (aFunction);
748 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
749 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
750 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
752 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
754 aCI.SetBase(aRefBase);
755 aCI.SetFirstPoint(aRefPnt1);
756 aCI.SetLastPoint(aRefPnt2);
758 //Compute the Prism value
760 if (!GetSolver()->ComputeFunction(aFunction)) {
761 SetErrorCode("Prism driver failed");
765 catch (Standard_Failure) {
766 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
767 SetErrorCode(aFail->GetMessageString());
771 //Make a Python command
772 TCollection_AsciiString anEntry, aDescr("");
773 TDF_Tool::Entry(aPrism->GetEntry(), anEntry);
775 aDescr += " = geompy.MakePrism(";
776 TDF_Tool::Entry(theBase->GetEntry(), anEntry);
777 aDescr += (anEntry+", ");
778 TDF_Tool::Entry(thePoint1->GetEntry(), anEntry);
779 aDescr += (anEntry+", ");
780 TDF_Tool::Entry(thePoint2->GetEntry(), anEntry);
781 aDescr += (anEntry+")");
783 aFunction->SetDescription(aDescr);
790 //=============================================================================
794 //=============================================================================
795 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
796 Handle(GEOM_Object) thePath)
800 if (theBase.IsNull() || thePath.IsNull()) return NULL;
802 //Add a new Pipe object
803 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
805 //Add a new Pipe function
806 Handle(GEOM_Function) aFunction =
807 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
808 if (aFunction.IsNull()) return NULL;
810 //Check if the function is set correctly
811 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
813 GEOMImpl_IPipe aCI (aFunction);
815 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
816 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
818 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
820 aCI.SetBase(aRefBase);
821 aCI.SetPath(aRefPath);
823 //Compute the Pipe value
825 if (!GetSolver()->ComputeFunction(aFunction)) {
826 SetErrorCode("Pipe driver failed");
830 catch (Standard_Failure) {
831 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
832 SetErrorCode(aFail->GetMessageString());
836 //Make a Python command
837 TCollection_AsciiString anEntry, aDescr;
838 TDF_Tool::Entry(aPipe->GetEntry(), anEntry);
839 aDescr += (anEntry + " = geompy.MakePipe(");
840 TDF_Tool::Entry(theBase->GetEntry(), anEntry);
841 aDescr += (anEntry + ", ");
842 TDF_Tool::Entry(thePath->GetEntry(), anEntry);
843 aDescr += (anEntry + ")");
845 aFunction->SetDescription(aDescr);
852 //=============================================================================
854 * MakeRevolutionAxisAngle
856 //=============================================================================
857 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
858 Handle(GEOM_Object) theAxis,
863 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
865 //Add a new Revolution object
866 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
868 //Add a new Revolution function for creation a revolution relatively to axis
869 Handle(GEOM_Function) aFunction =
870 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
871 if (aFunction.IsNull()) return NULL;
873 //Check if the function is set correctly
874 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
876 GEOMImpl_IRevolution aCI (aFunction);
878 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
879 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
881 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
883 aCI.SetBase(aRefBase);
884 aCI.SetAxis(aRefAxis);
885 aCI.SetAngle(theAngle);
887 //Compute the Revolution value
889 if (!GetSolver()->ComputeFunction(aFunction)) {
890 SetErrorCode("Revolution driver failed");
894 catch (Standard_Failure) {
895 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
896 SetErrorCode(aFail->GetMessageString());
900 //Make a Python command
901 TCollection_AsciiString anEntry, aDescr("import math\n\t");
902 TDF_Tool::Entry(aRevolution->GetEntry(), anEntry);
904 aDescr += " = geompy.MakeRevolution(";
905 TDF_Tool::Entry(theBase->GetEntry(), anEntry);
906 aDescr += (anEntry+", ");
907 TDF_Tool::Entry(theAxis->GetEntry(), anEntry);
908 aDescr += (anEntry+", ");
909 aDescr += (TCollection_AsciiString(theAngle/PI)+"*math.pi)");
911 aFunction->SetDescription(aDescr);
918 //=============================================================================
922 //=============================================================================
923 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
927 if (theShell.IsNull()) return NULL;
929 //Add a new Solid object
930 Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
932 //Add a new Solid function for creation a solid from a shell
933 Handle(GEOM_Function) aFunction =
934 aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
935 if (aFunction.IsNull()) return NULL;
937 //Check if the function is set correctly
938 if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
940 GEOMImpl_IShapes aCI (aFunction);
942 Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
944 if (aRefShell.IsNull()) return NULL;
946 aCI.SetBase(aRefShell);
948 //Compute the Solid value
950 if (!GetSolver()->ComputeFunction(aFunction)) {
951 SetErrorCode("Solid driver failed");
955 catch (Standard_Failure) {
956 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
957 SetErrorCode(aFail->GetMessageString());
961 //Make a Python command
962 TCollection_AsciiString anEntry, aDescr("");
963 TDF_Tool::Entry(aSolid->GetEntry(), anEntry);
965 aDescr += " = geompy.MakeSolid(";
966 TDF_Tool::Entry(theShell->GetEntry(), anEntry);
967 aDescr += (anEntry+")");
969 aFunction->SetDescription(aDescr);
975 //=============================================================================
979 //=============================================================================
980 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter)
984 if (theShape.IsNull()) return NULL;
986 //Add a new Filling object
987 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
989 //Add a new Filling function for creation a filling from a compound
990 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
991 if (aFunction.IsNull()) return NULL;
993 //Check if the function is set correctly
994 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
996 GEOMImpl_IFilling aFI (aFunction);
998 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1000 if (aRefShape.IsNull()) return NULL;
1002 aFI.SetShape(aRefShape);
1003 aFI.SetMinDeg(theMinDeg);
1004 aFI.SetMaxDeg(theMaxDeg);
1005 aFI.SetTol2D(theTol2D);
1006 aFI.SetTol3D(theTol3D);
1007 aFI.SetNbIter(theNbIter);
1009 //Compute the Solid value
1011 if (!GetSolver()->ComputeFunction(aFunction)) {
1012 SetErrorCode("Fiiling driver failed");
1016 catch (Standard_Failure) {
1017 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1018 SetErrorCode(aFail->GetMessageString());
1022 //Make a Python command
1023 TCollection_AsciiString anEntry, aDescr("");
1024 TDF_Tool::Entry(aFilling->GetEntry(), anEntry);
1026 aDescr += " = geompy.MakeFilling(";
1027 TDF_Tool::Entry(theShape->GetEntry(), anEntry);
1028 aDescr += (anEntry+", ");
1029 aDescr += (TCollection_AsciiString(theMinDeg)+", ");
1030 aDescr += (TCollection_AsciiString(theMaxDeg)+", ");
1031 aDescr += (TCollection_AsciiString(theTol2D)+", ");
1032 aDescr += (TCollection_AsciiString(theTol3D)+", ");
1033 aDescr += (TCollection_AsciiString(theNbIter)+")");
1035 aFunction->SetDescription(aDescr);