Salome HOME
ENV: Windows porting.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_I3DPrimOperations.cxx
1 #include <Standard_Stream.hxx>
2
3 #include <GEOMImpl_I3DPrimOperations.hxx>
4
5 #include "utilities.h"
6 #include <OpUtil.hxx>
7 #include <Utils_ExceptHandlers.hxx>
8
9 #include <TFunction_DriverTable.hxx>
10 #include <TFunction_Driver.hxx>
11 #include <TFunction_Logbook.hxx>
12 #include <TDF_Tool.hxx>
13
14 #include <GEOM_Function.hxx>
15 #include <GEOM_PythonDump.hxx>
16
17 #include <GEOMImpl_Types.hxx>
18
19 #include <GEOMImpl_BoxDriver.hxx>
20 #include <GEOMImpl_CylinderDriver.hxx>
21 #include <GEOMImpl_ConeDriver.hxx>
22 #include <GEOMImpl_SphereDriver.hxx>
23 #include <GEOMImpl_TorusDriver.hxx>
24 #include <GEOMImpl_PrismDriver.hxx>
25 #include <GEOMImpl_PipeDriver.hxx>
26 #include <GEOMImpl_RevolutionDriver.hxx>
27 #include <GEOMImpl_ShapeDriver.hxx>
28 #include <GEOMImpl_FillingDriver.hxx>
29
30 #include <GEOMImpl_IBox.hxx>
31 #include <GEOMImpl_ICylinder.hxx>
32 #include <GEOMImpl_ICone.hxx>
33 #include <GEOMImpl_ISphere.hxx>
34 #include <GEOMImpl_ITorus.hxx>
35 #include <GEOMImpl_IPrism.hxx>
36 #include <GEOMImpl_IPipe.hxx>
37 #include <GEOMImpl_IRevolution.hxx>
38 #include <GEOMImpl_IShapes.hxx>
39 #include <GEOMImpl_IFilling.hxx>
40
41 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
42
43 //=============================================================================
44 /*!
45  *   constructor:
46  */
47 //=============================================================================
48 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
49 : GEOM_IOperations(theEngine, theDocID)
50 {
51   MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
52 }
53
54 //=============================================================================
55 /*!
56  *  destructor
57  */
58 //=============================================================================
59 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
60 {
61   MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
62 }
63
64
65 //=============================================================================
66 /*!
67  *  MakeBoxDXDYDZ
68  */
69 //=============================================================================
70 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
71 {
72   SetErrorCode(KO);
73
74   //Add a new Box object
75   Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
76
77   //Add a new Box function with DX_DY_DZ parameters
78   Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
79   if (aFunction.IsNull()) return NULL;
80
81   //Check if the function is set correctly
82   if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
83
84   GEOMImpl_IBox aBI (aFunction);
85
86   aBI.SetDX(theDX);
87   aBI.SetDY(theDY);
88   aBI.SetDZ(theDZ);
89
90   //Compute the box value
91   try {
92     if (!GetSolver()->ComputeFunction(aFunction)) {
93       SetErrorCode("Box driver failed");
94       return NULL;
95     }
96   }
97   catch (Standard_Failure) {
98     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
99     SetErrorCode(aFail->GetMessageString());
100     return NULL;
101   }
102
103   //Make a Python command
104   GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
105     << theDX << ", " << theDY << ", " << theDZ << ")";
106
107   SetErrorCode(OK);
108   return aBox;
109 }
110
111
112 //=============================================================================
113 /*!
114  *  MakeBoxTwoPnt
115  */
116 //=============================================================================
117 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
118                                                                Handle(GEOM_Object) thePnt2)
119 {
120   SetErrorCode(KO);
121
122   if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
123
124   //Add a new Box object
125   Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
126
127   //Add a new Box function for creation a box relatively to two points
128   Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
129   if (aFunction.IsNull()) return NULL;
130
131   //Check if the function is set correctly
132   if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
133
134   GEOMImpl_IBox aBI (aFunction);
135
136   Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
137   Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
138
139   if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
140
141   aBI.SetRef1(aRefFunction1);
142   aBI.SetRef2(aRefFunction2);
143
144   //Compute the Box value
145   try {
146     if (!GetSolver()->ComputeFunction(aFunction)) {
147       SetErrorCode("Box driver failed");
148       return NULL;
149     }
150   }
151   catch (Standard_Failure) {
152     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
153     SetErrorCode(aFail->GetMessageString());
154     return NULL;
155   }
156
157   //Make a Python command
158   GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
159     << thePnt1 << ", " << thePnt2 << ")";
160
161   SetErrorCode(OK);
162   return aBox;
163 }
164
165
166 //=============================================================================
167 /*!
168  *  MakeCylinderRH
169  */
170 //=============================================================================
171 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
172 {
173   SetErrorCode(KO);
174
175   //Add a new Cylinder object
176   Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
177
178   //Add a new Cylinder function with R and H parameters
179   Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
180   if (aFunction.IsNull()) return NULL;
181
182   //Check if the function is set correctly
183   if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
184
185   GEOMImpl_ICylinder aCI (aFunction);
186
187   aCI.SetR(theR);
188   aCI.SetH(theH);
189
190   //Compute the Cylinder value
191   try {
192     if (!GetSolver()->ComputeFunction(aFunction)) {
193       SetErrorCode("Cylinder driver failed");
194       return NULL;
195     }
196   }
197   catch (Standard_Failure) {
198     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
199     SetErrorCode(aFail->GetMessageString());
200     return NULL;
201   }
202
203   //Make a Python command
204   GEOM::TPythonDump(aFunction) << aCylinder
205     << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
206
207   SetErrorCode(OK);
208   return aCylinder;
209 }
210
211
212 //=============================================================================
213 /*!
214  *  MakeCylinderPntVecRH
215  */
216 //=============================================================================
217 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
218                                                                       Handle(GEOM_Object) theVec,
219                                                                       double theR, double theH)
220 {
221   SetErrorCode(KO);
222
223   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
224
225   //Add a new Cylinder object
226   Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
227
228   //Add a new Cylinder function for creation a cylinder relatively to point and vector
229   Handle(GEOM_Function) aFunction =
230     aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
231   if (aFunction.IsNull()) return NULL;
232
233   //Check if the function is set correctly
234   if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
235
236   GEOMImpl_ICylinder aCI (aFunction);
237
238   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
239   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
240
241   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
242
243   aCI.SetPoint(aRefPnt);
244   aCI.SetVector(aRefVec);
245   aCI.SetR(theR);
246   aCI.SetH(theH);
247
248   //Compute the Cylinder value
249   try {
250     if (!GetSolver()->ComputeFunction(aFunction)) {
251       SetErrorCode("Cylinder driver failed");
252       return NULL;
253     }
254   }
255   catch (Standard_Failure) {
256     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
257     SetErrorCode(aFail->GetMessageString());
258     return NULL;
259   }
260
261   //Make a Python command
262   GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
263     << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
264
265   SetErrorCode(OK);
266   return aCylinder;
267 }
268
269
270 //=============================================================================
271 /*!
272  *  MakeConeR1R2H
273  */
274 //=============================================================================
275 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
276                                                                double theH)
277 {
278   SetErrorCode(KO);
279
280   //Add a new Cone object
281   Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
282
283   //Add a new Cone function with R and H parameters
284   Handle(GEOM_Function) aFunction =
285     aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
286   if (aFunction.IsNull()) return NULL;
287
288   //Check if the function is set correctly
289   if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
290
291   GEOMImpl_ICone aCI (aFunction);
292
293   aCI.SetR1(theR1);
294   aCI.SetR2(theR2);
295   aCI.SetH(theH);
296
297   //Compute the Cone value
298   try {
299     if (!GetSolver()->ComputeFunction(aFunction)) {
300       SetErrorCode("Cone driver failed");
301       return NULL;
302     }
303   }
304   catch (Standard_Failure) {
305     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
306     SetErrorCode(aFail->GetMessageString());
307     return NULL;
308   }
309
310   //Make a Python command
311   GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
312     << theR1 << ", " << theR2 << ", " << theH << ")";
313
314   SetErrorCode(OK);
315   return aCone;
316 }
317
318
319 //=============================================================================
320 /*!
321  *  MakeConePntVecR1R2H
322  */
323 //=============================================================================
324 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
325                                                                      Handle(GEOM_Object) theVec,
326                                                                      double theR1, double theR2,
327                                                                      double theH)
328 {
329   SetErrorCode(KO);
330
331   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
332
333   //Add a new Cone object
334   Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
335
336   //Add a new Cone function for creation a cone relatively to point and vector
337   Handle(GEOM_Function) aFunction =
338     aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
339   if (aFunction.IsNull()) return NULL;
340
341   //Check if the function is set correctly
342   if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
343
344   GEOMImpl_ICone aCI (aFunction);
345
346   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
347   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
348
349   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
350
351   aCI.SetPoint(aRefPnt);
352   aCI.SetVector(aRefVec);
353   aCI.SetR1(theR1);
354   aCI.SetR2(theR2);
355   aCI.SetH(theH);
356
357   //Compute the Cone value
358   try {
359     if (!GetSolver()->ComputeFunction(aFunction)) {
360       SetErrorCode("Cone driver failed");
361       return NULL;
362     }
363   }
364   catch (Standard_Failure) {
365     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
366     SetErrorCode(aFail->GetMessageString());
367     return NULL;
368   }
369
370   //Make a Python command
371   GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
372     << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
373
374   SetErrorCode(OK);
375   return aCone;
376 }
377
378
379 //=============================================================================
380 /*!
381  *  MakeSphereR
382  */
383 //=============================================================================
384 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
385 {
386   SetErrorCode(KO);
387
388   //Add a new Sphere object
389   Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
390
391   //Add a new Sphere function with R parameter
392   Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
393   if (aFunction.IsNull()) return NULL;
394
395   //Check if the function is set correctly
396   if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
397
398   GEOMImpl_ISphere aCI (aFunction);
399
400   aCI.SetR(theR);
401
402   //Compute the Sphere value
403   try {
404     if (!GetSolver()->ComputeFunction(aFunction)) {
405       SetErrorCode("Sphere driver failed");
406       return NULL;
407     }
408   }
409   catch (Standard_Failure) {
410     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
411     SetErrorCode(aFail->GetMessageString());
412     return NULL;
413   }
414
415   //Make a Python command
416   GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
417
418   SetErrorCode(OK);
419   return aSphere;
420 }
421
422
423 //=============================================================================
424 /*!
425  *  MakeSpherePntR
426  */
427 //=============================================================================
428 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
429                                                                 double theR)
430 {
431   SetErrorCode(KO);
432
433   if (thePnt.IsNull()) return NULL;
434
435   //Add a new Point object
436   Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
437
438   //Add a new Sphere function for creation a sphere relatively to point
439   Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
440   if (aFunction.IsNull()) return NULL;
441
442   //Check if the function is set correctly
443   if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
444
445   GEOMImpl_ISphere aCI (aFunction);
446
447   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
448
449   if (aRefPnt.IsNull()) return NULL;
450
451   aCI.SetPoint(aRefPnt);
452   aCI.SetR(theR);
453
454   //Compute the Sphere value
455   try {
456     if (!GetSolver()->ComputeFunction(aFunction)) {
457       SetErrorCode("Sphere driver failed");
458       return NULL;
459     }
460   }
461   catch (Standard_Failure) {
462     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
463     SetErrorCode(aFail->GetMessageString());
464     return NULL;
465   }
466
467   //Make a Python command
468   GEOM::TPythonDump(aFunction) << aSphere
469     << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
470
471   SetErrorCode(OK);
472   return aSphere;
473 }
474
475
476 //=============================================================================
477 /*!
478  *  MakeTorusRR
479  */
480 //=============================================================================
481 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
482                                            (double theRMajor, double theRMinor)
483 {
484   SetErrorCode(KO);
485
486   //Add a new Torus object
487   Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
488
489   //Add a new Torus function
490   Handle(GEOM_Function) aFunction =
491     anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
492   if (aFunction.IsNull()) return NULL;
493
494   //Check if the function is set correctly
495   if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
496
497   GEOMImpl_ITorus aCI (aFunction);
498
499   aCI.SetRMajor(theRMajor);
500   aCI.SetRMinor(theRMinor);
501
502   //Compute the Torus value
503   try {
504     if (!GetSolver()->ComputeFunction(aFunction)) {
505       SetErrorCode("Torus driver failed");
506       return NULL;
507     }
508   }
509   catch (Standard_Failure) {
510     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
511     SetErrorCode(aFail->GetMessageString());
512     return NULL;
513   }
514
515   //Make a Python command
516   GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
517     << theRMajor << ", " << theRMinor << ")";
518
519   SetErrorCode(OK);
520   return anEll;
521 }
522
523 //=============================================================================
524 /*!
525  *  MakeTorusPntVecRR
526  */
527 //=============================================================================
528 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
529                        (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
530                         double theRMajor, double theRMinor)
531 {
532   SetErrorCode(KO);
533
534   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
535
536   //Add a new Torus object
537   Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
538
539   //Add a new Torus function
540   Handle(GEOM_Function) aFunction =
541     anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
542   if (aFunction.IsNull()) return NULL;
543
544   //Check if the function is set correctly
545   if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
546
547   GEOMImpl_ITorus aCI (aFunction);
548
549   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
550   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
551
552   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
553
554   aCI.SetCenter(aRefPnt);
555   aCI.SetVector(aRefVec);
556   aCI.SetRMajor(theRMajor);
557   aCI.SetRMinor(theRMinor);
558
559   //Compute the Torus value
560   try {
561     if (!GetSolver()->ComputeFunction(aFunction)) {
562       SetErrorCode("Torus driver failed");
563       return NULL;
564     }
565   }
566   catch (Standard_Failure) {
567     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
568     SetErrorCode(aFail->GetMessageString());
569     return NULL;
570   }
571
572   //Make a Python command
573   GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
574     << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
575
576   SetErrorCode(OK);
577   return anEll;
578 }
579
580
581 //=============================================================================
582 /*!
583  *  MakePrismVecH
584  */
585 //=============================================================================
586 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
587                                                                Handle(GEOM_Object) theVec,
588                                                                double theH)
589 {
590   SetErrorCode(KO);
591
592   if (theBase.IsNull() || theVec.IsNull()) return NULL;
593
594   //Add a new Prism object
595   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
596
597   //Add a new Prism function for creation a Prism relatively to vector
598   Handle(GEOM_Function) aFunction =
599     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
600   if (aFunction.IsNull()) return NULL;
601
602   //Check if the function is set correctly
603   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
604
605   GEOMImpl_IPrism aCI (aFunction);
606
607   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
608   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
609
610   if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
611
612   aCI.SetBase(aRefBase);
613   aCI.SetVector(aRefVec);
614   aCI.SetH(theH);
615
616   //Compute the Prism value
617   try {
618     if (!GetSolver()->ComputeFunction(aFunction)) {
619       SetErrorCode("Prism driver failed");
620       return NULL;
621     }
622   }
623   catch (Standard_Failure) {
624     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
625     SetErrorCode(aFail->GetMessageString());
626     return NULL;
627   }
628
629   //Make a Python command
630   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
631     << theBase << ", " << theVec << ", " << theH << ")";
632
633   SetErrorCode(OK);
634   return aPrism;
635 }
636
637 //=============================================================================
638 /*!
639  *  MakePrismTwoPnt
640  */
641 //=============================================================================
642 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
643        (Handle(GEOM_Object) theBase,
644         Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
645 {
646   SetErrorCode(KO);
647
648   if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
649
650   //Add a new Prism object
651   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
652
653   //Add a new Prism function for creation a Prism relatively to two points
654   Handle(GEOM_Function) aFunction =
655     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
656   if (aFunction.IsNull()) return NULL;
657
658   //Check if the function is set correctly
659   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
660
661   GEOMImpl_IPrism aCI (aFunction);
662
663   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
664   Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
665   Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
666
667   if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
668
669   aCI.SetBase(aRefBase);
670   aCI.SetFirstPoint(aRefPnt1);
671   aCI.SetLastPoint(aRefPnt2);
672
673   //Compute the Prism value
674   try {
675     if (!GetSolver()->ComputeFunction(aFunction)) {
676       SetErrorCode("Prism driver failed");
677       return NULL;
678     }
679   }
680   catch (Standard_Failure) {
681     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
682     SetErrorCode(aFail->GetMessageString());
683     return NULL;
684   }
685
686   //Make a Python command
687   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
688     << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
689
690   SetErrorCode(OK);
691   return aPrism;
692 }
693
694
695 //=============================================================================
696 /*!
697  *  MakePipe
698  */
699 //=============================================================================
700 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
701                                                           Handle(GEOM_Object) thePath)
702 {
703   SetErrorCode(KO);
704
705   if (theBase.IsNull() || thePath.IsNull()) return NULL;
706
707   //Add a new Pipe object
708   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
709
710   //Add a new Pipe function
711   Handle(GEOM_Function) aFunction =
712     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
713   if (aFunction.IsNull()) return NULL;
714
715   //Check if the function is set correctly
716   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
717
718   GEOMImpl_IPipe aCI (aFunction);
719
720   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
721   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
722
723   if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
724
725   aCI.SetBase(aRefBase);
726   aCI.SetPath(aRefPath);
727
728   //Compute the Pipe value
729   try {
730     if (!GetSolver()->ComputeFunction(aFunction)) {
731       SetErrorCode("Pipe driver failed");
732       return NULL;
733     }
734   }
735   catch (Standard_Failure) {
736     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
737     SetErrorCode(aFail->GetMessageString());
738     return NULL;
739   }
740
741   //Make a Python command
742   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
743     << theBase << ", " << thePath << ")";
744
745   SetErrorCode(OK);
746   return aPipe;
747 }
748
749
750 //=============================================================================
751 /*!
752  *  MakeRevolutionAxisAngle
753  */
754 //=============================================================================
755 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
756                                                                          Handle(GEOM_Object) theAxis,
757                                                                          double theAngle)
758 {
759   SetErrorCode(KO);
760
761   if (theBase.IsNull() || theAxis.IsNull()) return NULL;
762
763   //Add a new Revolution object
764   Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
765
766   //Add a new Revolution function for creation a revolution relatively to axis
767   Handle(GEOM_Function) aFunction =
768     aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
769   if (aFunction.IsNull()) return NULL;
770
771   //Check if the function is set correctly
772   if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
773
774   GEOMImpl_IRevolution aCI (aFunction);
775
776   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
777   Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
778
779   if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
780
781   aCI.SetBase(aRefBase);
782   aCI.SetAxis(aRefAxis);
783   aCI.SetAngle(theAngle);
784
785   //Compute the Revolution value
786   try {
787     if (!GetSolver()->ComputeFunction(aFunction)) {
788       SetErrorCode("Revolution driver failed");
789       return NULL;
790     }
791   }
792   catch (Standard_Failure) {
793     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
794     SetErrorCode(aFail->GetMessageString());
795     return NULL;
796   }
797
798   //Make a Python command
799   GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
800     << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
801
802   SetErrorCode(OK);
803   return aRevolution;
804 }
805
806
807 //=============================================================================
808 /*!
809  *  MakeSolidShell
810  */
811 //=============================================================================
812 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
813 {
814   SetErrorCode(KO);
815
816   if (theShell.IsNull()) return NULL;
817
818   //Add a new Solid object
819   Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
820
821   //Add a new Solid function for creation a solid from a shell
822   Handle(GEOM_Function) aFunction =
823     aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
824   if (aFunction.IsNull()) return NULL;
825
826   //Check if the function is set correctly
827   if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
828
829   GEOMImpl_IShapes aCI (aFunction);
830
831   Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
832
833   if (aRefShell.IsNull()) return NULL;
834
835   aCI.SetBase(aRefShell);
836
837   //Compute the Solid value
838   try {
839     if (!GetSolver()->ComputeFunction(aFunction)) {
840       SetErrorCode("Solid driver failed");
841       return NULL;
842     }
843   }
844   catch (Standard_Failure) {
845     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
846     SetErrorCode(aFail->GetMessageString());
847     return NULL;
848   }
849
850   //Make a Python command
851   GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
852
853   SetErrorCode(OK);
854   return aSolid;
855 }
856
857 //=============================================================================
858 /*!
859  *  MakeFilling
860  */
861 //=============================================================================
862 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
863        (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
864         double theTol2D, double theTol3D, int theNbIter)
865 {
866   SetErrorCode(KO);
867
868   if (theShape.IsNull()) return NULL;
869
870   //Add a new Filling object
871   Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
872
873   //Add a new Filling function for creation a filling  from a compound
874   Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
875   if (aFunction.IsNull()) return NULL;
876
877   //Check if the function is set correctly
878   if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
879
880   GEOMImpl_IFilling aFI (aFunction);
881
882   Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
883
884   if (aRefShape.IsNull()) return NULL;
885
886   aFI.SetShape(aRefShape);
887   aFI.SetMinDeg(theMinDeg);
888   aFI.SetMaxDeg(theMaxDeg);
889   aFI.SetTol2D(theTol2D);
890   aFI.SetTol3D(theTol3D);
891   aFI.SetNbIter(theNbIter);
892
893   //Compute the Solid value
894   try {
895     if (!GetSolver()->ComputeFunction(aFunction)) {
896       SetErrorCode("Filling driver failed");
897       return NULL;
898     }
899   }
900   catch (Standard_Failure) {
901     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
902     if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
903       SetErrorCode("B-Spline surface construction failed");
904     else
905       SetErrorCode(aFail->GetMessageString());
906     return NULL;
907   }
908
909   //Make a Python command
910   GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling("
911     << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
912       << theTol2D << ", " << theTol3D << ", " << theNbIter << ")";
913
914   SetErrorCode(OK);
915   return aFilling;
916 }