Salome HOME
Bug 0020029: EDF 845 GEOM: impossible to set a negative angle for the revolution...
[modules/geom.git] / src / GEOMImpl / GEOMImpl_I3DPrimOperations.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #include <Standard_Stream.hxx>
21
22 #include <GEOMImpl_I3DPrimOperations.hxx>
23
24 #include "utilities.h"
25 #include <OpUtil.hxx>
26 #include <Utils_ExceptHandlers.hxx>
27
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
32
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
35
36 #include <GEOMImpl_Types.hxx>
37
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>
49
50 #include <GEOMImpl_IBox.hxx>
51 #include <GEOMImpl_ICylinder.hxx>
52 #include <GEOMImpl_ICone.hxx>
53 #include <GEOMImpl_ISphere.hxx>
54 #include <GEOMImpl_ITorus.hxx>
55 #include <GEOMImpl_IPrism.hxx>
56 #include <GEOMImpl_IPipe.hxx>
57 #include <GEOMImpl_IRevolution.hxx>
58 #include <GEOMImpl_IShapes.hxx>
59 #include <GEOMImpl_IFilling.hxx>
60 #include <GEOMImpl_IThruSections.hxx>
61 #include <GEOMImpl_IPipeDiffSect.hxx>
62 #include <GEOMImpl_IPipeShellSect.hxx>
63 #include <GEOMImpl_IPipeBiNormal.hxx>
64
65 #include <Standard_Failure.hxx>
66 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
67
68 //=============================================================================
69 /*!
70  *   constructor:
71  */
72 //=============================================================================
73 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
74 : GEOM_IOperations(theEngine, theDocID)
75 {
76   MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
77 }
78
79 //=============================================================================
80 /*!
81  *  destructor
82  */
83 //=============================================================================
84 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
85 {
86   MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
87 }
88
89
90 //=============================================================================
91 /*!
92  *  MakeBoxDXDYDZ
93  */
94 //=============================================================================
95 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
96 {
97   SetErrorCode(KO);
98
99   //Add a new Box object
100   Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
101
102   //Add a new Box function with DX_DY_DZ parameters
103   Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
104   if (aFunction.IsNull()) return NULL;
105
106   //Check if the function is set correctly
107   if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
108
109   GEOMImpl_IBox aBI (aFunction);
110
111   aBI.SetDX(theDX);
112   aBI.SetDY(theDY);
113   aBI.SetDZ(theDZ);
114
115   //Compute the box value
116   try {
117 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
118     OCC_CATCH_SIGNALS;
119 #endif
120     if (!GetSolver()->ComputeFunction(aFunction)) {
121       SetErrorCode("Box driver failed");
122       return NULL;
123     }
124   }
125   catch (Standard_Failure) {
126     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
127     SetErrorCode(aFail->GetMessageString());
128     return NULL;
129   }
130
131   //Make a Python command
132   GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
133     << theDX << ", " << theDY << ", " << theDZ << ")";
134
135   SetErrorCode(OK);
136   return aBox;
137 }
138
139
140 //=============================================================================
141 /*!
142  *  MakeBoxTwoPnt
143  */
144 //=============================================================================
145 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
146                                                                Handle(GEOM_Object) thePnt2)
147 {
148   SetErrorCode(KO);
149
150   if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
151
152   //Add a new Box object
153   Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
154
155   //Add a new Box function for creation a box relatively to two points
156   Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
157   if (aFunction.IsNull()) return NULL;
158
159   //Check if the function is set correctly
160   if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
161
162   GEOMImpl_IBox aBI (aFunction);
163
164   Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
165   Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
166
167   if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
168
169   aBI.SetRef1(aRefFunction1);
170   aBI.SetRef2(aRefFunction2);
171
172   //Compute the Box value
173   try {
174 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
175     OCC_CATCH_SIGNALS;
176 #endif
177     if (!GetSolver()->ComputeFunction(aFunction)) {
178       SetErrorCode("Box driver failed");
179       return NULL;
180     }
181   }
182   catch (Standard_Failure) {
183     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
184     SetErrorCode(aFail->GetMessageString());
185     return NULL;
186   }
187
188   //Make a Python command
189   GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
190     << thePnt1 << ", " << thePnt2 << ")";
191
192   SetErrorCode(OK);
193   return aBox;
194 }
195
196
197 //=============================================================================
198 /*!
199  *  MakeCylinderRH
200  */
201 //=============================================================================
202 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
203 {
204   SetErrorCode(KO);
205
206   //Add a new Cylinder object
207   Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
208
209   //Add a new Cylinder function with R and H parameters
210   Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
211   if (aFunction.IsNull()) return NULL;
212
213   //Check if the function is set correctly
214   if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
215
216   GEOMImpl_ICylinder aCI (aFunction);
217
218   aCI.SetR(theR);
219   aCI.SetH(theH);
220
221   //Compute the Cylinder value
222   try {
223 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
224     OCC_CATCH_SIGNALS;
225 #endif
226     if (!GetSolver()->ComputeFunction(aFunction)) {
227       SetErrorCode("Cylinder driver failed");
228       return NULL;
229     }
230   }
231   catch (Standard_Failure) {
232     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
233     SetErrorCode(aFail->GetMessageString());
234     return NULL;
235   }
236
237   //Make a Python command
238   GEOM::TPythonDump(aFunction) << aCylinder
239     << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
240
241   SetErrorCode(OK);
242   return aCylinder;
243 }
244
245
246 //=============================================================================
247 /*!
248  *  MakeCylinderPntVecRH
249  */
250 //=============================================================================
251 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
252                                                                       Handle(GEOM_Object) theVec,
253                                                                       double theR, double theH)
254 {
255   SetErrorCode(KO);
256
257   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
258
259   //Add a new Cylinder object
260   Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
261
262   //Add a new Cylinder function for creation a cylinder relatively to point and vector
263   Handle(GEOM_Function) aFunction =
264     aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
265   if (aFunction.IsNull()) return NULL;
266
267   //Check if the function is set correctly
268   if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
269
270   GEOMImpl_ICylinder aCI (aFunction);
271
272   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
273   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
274
275   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
276
277   aCI.SetPoint(aRefPnt);
278   aCI.SetVector(aRefVec);
279   aCI.SetR(theR);
280   aCI.SetH(theH);
281
282   //Compute the Cylinder value
283   try {
284 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
285     OCC_CATCH_SIGNALS;
286 #endif
287     if (!GetSolver()->ComputeFunction(aFunction)) {
288       SetErrorCode("Cylinder driver failed");
289       return NULL;
290     }
291   }
292   catch (Standard_Failure) {
293     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
294     SetErrorCode(aFail->GetMessageString());
295     return NULL;
296   }
297
298   //Make a Python command
299   GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
300     << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
301
302   SetErrorCode(OK);
303   return aCylinder;
304 }
305
306
307 //=============================================================================
308 /*!
309  *  MakeConeR1R2H
310  */
311 //=============================================================================
312 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
313                                                                double theH)
314 {
315   SetErrorCode(KO);
316
317   //Add a new Cone object
318   Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
319
320   //Add a new Cone function with R and H parameters
321   Handle(GEOM_Function) aFunction =
322     aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
323   if (aFunction.IsNull()) return NULL;
324
325   //Check if the function is set correctly
326   if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
327
328   GEOMImpl_ICone aCI (aFunction);
329
330   aCI.SetR1(theR1);
331   aCI.SetR2(theR2);
332   aCI.SetH(theH);
333
334   //Compute the Cone value
335   try {
336 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
337     OCC_CATCH_SIGNALS;
338 #endif
339     if (!GetSolver()->ComputeFunction(aFunction)) {
340       SetErrorCode("Cone driver failed");
341       return NULL;
342     }
343   }
344   catch (Standard_Failure) {
345     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
346     SetErrorCode(aFail->GetMessageString());
347     return NULL;
348   }
349
350   //Make a Python command
351   GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
352     << theR1 << ", " << theR2 << ", " << theH << ")";
353
354   SetErrorCode(OK);
355   return aCone;
356 }
357
358
359 //=============================================================================
360 /*!
361  *  MakeConePntVecR1R2H
362  */
363 //=============================================================================
364 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
365                                                                      Handle(GEOM_Object) theVec,
366                                                                      double theR1, double theR2,
367                                                                      double theH)
368 {
369   SetErrorCode(KO);
370
371   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
372
373   //Add a new Cone object
374   Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
375
376   //Add a new Cone function for creation a cone relatively to point and vector
377   Handle(GEOM_Function) aFunction =
378     aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
379   if (aFunction.IsNull()) return NULL;
380
381   //Check if the function is set correctly
382   if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
383
384   GEOMImpl_ICone aCI (aFunction);
385
386   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
387   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
388
389   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
390
391   aCI.SetPoint(aRefPnt);
392   aCI.SetVector(aRefVec);
393   aCI.SetR1(theR1);
394   aCI.SetR2(theR2);
395   aCI.SetH(theH);
396
397   //Compute the Cone value
398   try {
399 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
400     OCC_CATCH_SIGNALS;
401 #endif
402     if (!GetSolver()->ComputeFunction(aFunction)) {
403       SetErrorCode("Cone driver failed");
404       return NULL;
405     }
406   }
407   catch (Standard_Failure) {
408     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
409     SetErrorCode(aFail->GetMessageString());
410     return NULL;
411   }
412
413   //Make a Python command
414   GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
415     << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
416
417   SetErrorCode(OK);
418   return aCone;
419 }
420
421
422 //=============================================================================
423 /*!
424  *  MakeSphereR
425  */
426 //=============================================================================
427 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
428 {
429   SetErrorCode(KO);
430
431   //Add a new Sphere object
432   Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
433
434   //Add a new Sphere function with R parameter
435   Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
436   if (aFunction.IsNull()) return NULL;
437
438   //Check if the function is set correctly
439   if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
440
441   GEOMImpl_ISphere aCI (aFunction);
442
443   aCI.SetR(theR);
444
445   //Compute the Sphere value
446   try {
447 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
448     OCC_CATCH_SIGNALS;
449 #endif
450     if (!GetSolver()->ComputeFunction(aFunction)) {
451       SetErrorCode("Sphere driver failed");
452       return NULL;
453     }
454   }
455   catch (Standard_Failure) {
456     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
457     SetErrorCode(aFail->GetMessageString());
458     return NULL;
459   }
460
461   //Make a Python command
462   GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
463
464   SetErrorCode(OK);
465   return aSphere;
466 }
467
468
469 //=============================================================================
470 /*!
471  *  MakeSpherePntR
472  */
473 //=============================================================================
474 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
475                                                                 double theR)
476 {
477   SetErrorCode(KO);
478
479   if (thePnt.IsNull()) return NULL;
480
481   //Add a new Point object
482   Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
483
484   //Add a new Sphere function for creation a sphere relatively to point
485   Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
486   if (aFunction.IsNull()) return NULL;
487
488   //Check if the function is set correctly
489   if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
490
491   GEOMImpl_ISphere aCI (aFunction);
492
493   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
494
495   if (aRefPnt.IsNull()) return NULL;
496
497   aCI.SetPoint(aRefPnt);
498   aCI.SetR(theR);
499
500   //Compute the Sphere value
501   try {
502 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
503     OCC_CATCH_SIGNALS;
504 #endif
505     if (!GetSolver()->ComputeFunction(aFunction)) {
506       SetErrorCode("Sphere driver failed");
507       return NULL;
508     }
509   }
510   catch (Standard_Failure) {
511     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
512     SetErrorCode(aFail->GetMessageString());
513     return NULL;
514   }
515
516   //Make a Python command
517   GEOM::TPythonDump(aFunction) << aSphere
518     << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
519
520   SetErrorCode(OK);
521   return aSphere;
522 }
523
524
525 //=============================================================================
526 /*!
527  *  MakeTorusRR
528  */
529 //=============================================================================
530 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
531                                            (double theRMajor, double theRMinor)
532 {
533   SetErrorCode(KO);
534
535   //Add a new Torus object
536   Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
537
538   //Add a new Torus function
539   Handle(GEOM_Function) aFunction =
540     anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
541   if (aFunction.IsNull()) return NULL;
542
543   //Check if the function is set correctly
544   if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
545
546   GEOMImpl_ITorus aCI (aFunction);
547
548   aCI.SetRMajor(theRMajor);
549   aCI.SetRMinor(theRMinor);
550
551   //Compute the Torus value
552   try {
553 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
554     OCC_CATCH_SIGNALS;
555 #endif
556     if (!GetSolver()->ComputeFunction(aFunction)) {
557       SetErrorCode("Torus driver failed");
558       return NULL;
559     }
560   }
561   catch (Standard_Failure) {
562     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
563     SetErrorCode(aFail->GetMessageString());
564     return NULL;
565   }
566
567   //Make a Python command
568   GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
569     << theRMajor << ", " << theRMinor << ")";
570
571   SetErrorCode(OK);
572   return anEll;
573 }
574
575 //=============================================================================
576 /*!
577  *  MakeTorusPntVecRR
578  */
579 //=============================================================================
580 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
581                        (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
582                         double theRMajor, double theRMinor)
583 {
584   SetErrorCode(KO);
585
586   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
587
588   //Add a new Torus object
589   Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
590
591   //Add a new Torus function
592   Handle(GEOM_Function) aFunction =
593     anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
594   if (aFunction.IsNull()) return NULL;
595
596   //Check if the function is set correctly
597   if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
598
599   GEOMImpl_ITorus aCI (aFunction);
600
601   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
602   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
603
604   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
605
606   aCI.SetCenter(aRefPnt);
607   aCI.SetVector(aRefVec);
608   aCI.SetRMajor(theRMajor);
609   aCI.SetRMinor(theRMinor);
610
611   //Compute the Torus value
612   try {
613 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
614     OCC_CATCH_SIGNALS;
615 #endif
616     if (!GetSolver()->ComputeFunction(aFunction)) {
617       SetErrorCode("Torus driver failed");
618       return NULL;
619     }
620   }
621   catch (Standard_Failure) {
622     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
623     SetErrorCode(aFail->GetMessageString());
624     return NULL;
625   }
626
627   //Make a Python command
628   GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
629     << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
630
631   SetErrorCode(OK);
632   return anEll;
633 }
634
635
636 //=============================================================================
637 /*!
638  *  MakePrismVecH
639  */
640 //=============================================================================
641 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
642                                                                Handle(GEOM_Object) theVec,
643                                                                double theH)
644 {
645   SetErrorCode(KO);
646
647   if (theBase.IsNull() || theVec.IsNull()) return NULL;
648
649   //Add a new Prism object
650   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
651
652   //Add a new Prism function for creation a Prism relatively to vector
653   Handle(GEOM_Function) aFunction =
654     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
655   if (aFunction.IsNull()) return NULL;
656
657   //Check if the function is set correctly
658   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
659
660   GEOMImpl_IPrism aCI (aFunction);
661
662   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
663   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
664
665   if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
666
667   aCI.SetBase(aRefBase);
668   aCI.SetVector(aRefVec);
669   aCI.SetH(theH);
670
671   //Compute the Prism value
672   try {
673 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
674     OCC_CATCH_SIGNALS;
675 #endif
676     if (!GetSolver()->ComputeFunction(aFunction)) {
677       //SetErrorCode("Prism driver failed");
678       SetErrorCode("Extrusion can not be created, check input data");
679       return NULL;
680     }
681   }
682   catch (Standard_Failure) {
683     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
684     SetErrorCode(aFail->GetMessageString());
685     return NULL;
686   }
687
688   //Make a Python command
689   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
690     << theBase << ", " << theVec << ", " << theH << ")";
691
692   SetErrorCode(OK);
693   return aPrism;
694 }
695
696 //=============================================================================
697 /*!
698  *  MakePrismVecH2Ways
699  */
700 //=============================================================================
701 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
702                                                                     Handle(GEOM_Object) theVec,
703                                                                     double theH)
704 {
705   SetErrorCode(KO);
706
707   if (theBase.IsNull() || theVec.IsNull()) return NULL;
708
709   //Add a new Prism object
710   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
711
712   //Add a new Prism function for creation a Prism relatively to vector
713   Handle(GEOM_Function) aFunction =
714     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
715   if (aFunction.IsNull()) return NULL;
716
717   //Check if the function is set correctly
718   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
719
720   GEOMImpl_IPrism aCI (aFunction);
721
722   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
723   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
724
725   if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
726
727   aCI.SetBase(aRefBase);
728   aCI.SetVector(aRefVec);
729   aCI.SetH(theH);
730
731   //Compute the Prism value
732   try {
733 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
734     OCC_CATCH_SIGNALS;
735 #endif
736     if (!GetSolver()->ComputeFunction(aFunction)) {
737       //SetErrorCode("Prism driver failed");
738       SetErrorCode("Extrusion can not be created, check input data");
739       return NULL;
740     }
741   }
742   catch (Standard_Failure) {
743     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
744     SetErrorCode(aFail->GetMessageString());
745     return NULL;
746   }
747
748   //Make a Python command
749   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
750     << theBase << ", " << theVec << ", " << theH << ")";
751
752   SetErrorCode(OK);
753   return aPrism;
754 }
755
756 //=============================================================================
757 /*!
758  *  MakePrismTwoPnt
759  */
760 //=============================================================================
761 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
762        (Handle(GEOM_Object) theBase,
763         Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
764 {
765   SetErrorCode(KO);
766
767   if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
768
769   //Add a new Prism object
770   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
771
772   //Add a new Prism function for creation a Prism relatively to two points
773   Handle(GEOM_Function) aFunction =
774     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
775   if (aFunction.IsNull()) return NULL;
776
777   //Check if the function is set correctly
778   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
779
780   GEOMImpl_IPrism aCI (aFunction);
781
782   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
783   Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
784   Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
785
786   if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
787
788   aCI.SetBase(aRefBase);
789   aCI.SetFirstPoint(aRefPnt1);
790   aCI.SetLastPoint(aRefPnt2);
791
792   //Compute the Prism value
793   try {
794 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
795     OCC_CATCH_SIGNALS;
796 #endif
797     if (!GetSolver()->ComputeFunction(aFunction)) {
798       //SetErrorCode("Prism driver failed");
799       SetErrorCode("Extrusion can not be created, check input data");
800       return NULL;
801     }
802   }
803   catch (Standard_Failure) {
804     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
805     SetErrorCode(aFail->GetMessageString());
806     return NULL;
807   }
808
809   //Make a Python command
810   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
811     << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
812
813   SetErrorCode(OK);
814   return aPrism;
815 }
816
817 //=============================================================================
818 /*!
819  *  MakePrismTwoPnt2Ways
820  */
821 //=============================================================================
822 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
823        (Handle(GEOM_Object) theBase,
824         Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
825 {
826   SetErrorCode(KO);
827
828   if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
829
830   //Add a new Prism object
831   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
832
833   //Add a new Prism function for creation a Prism relatively to two points
834   Handle(GEOM_Function) aFunction =
835     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
836   if (aFunction.IsNull()) return NULL;
837
838   //Check if the function is set correctly
839   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
840
841   GEOMImpl_IPrism aCI (aFunction);
842
843   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
844   Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
845   Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
846
847   if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
848
849   aCI.SetBase(aRefBase);
850   aCI.SetFirstPoint(aRefPnt1);
851   aCI.SetLastPoint(aRefPnt2);
852
853   //Compute the Prism value
854   try {
855 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
856     OCC_CATCH_SIGNALS;
857 #endif
858     if (!GetSolver()->ComputeFunction(aFunction)) {
859       //SetErrorCode("Prism driver failed");
860       SetErrorCode("Extrusion can not be created, check input data");
861       return NULL;
862     }
863   }
864   catch (Standard_Failure) {
865     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
866     SetErrorCode(aFail->GetMessageString());
867     return NULL;
868   }
869
870   //Make a Python command
871   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
872     << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
873
874   SetErrorCode(OK);
875   return aPrism;
876 }
877
878
879 //=============================================================================
880 /*!
881  *  MakePipe
882  */
883 //=============================================================================
884 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
885                                                           Handle(GEOM_Object) thePath)
886 {
887   SetErrorCode(KO);
888
889   if (theBase.IsNull() || thePath.IsNull()) return NULL;
890
891   //Add a new Pipe object
892   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
893
894   //Add a new Pipe function
895   Handle(GEOM_Function) aFunction =
896     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
897   if (aFunction.IsNull()) return NULL;
898
899   //Check if the function is set correctly
900   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
901
902   GEOMImpl_IPipe aCI (aFunction);
903
904   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
905   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
906
907   if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
908
909   aCI.SetBase(aRefBase);
910   aCI.SetPath(aRefPath);
911
912   //Compute the Pipe value
913   try {
914 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
915     OCC_CATCH_SIGNALS;
916 #endif
917     if (!GetSolver()->ComputeFunction(aFunction)) {
918       SetErrorCode("Pipe driver failed");
919       return NULL;
920     }
921   }
922   catch (Standard_Failure) {
923     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
924     SetErrorCode(aFail->GetMessageString());
925     return NULL;
926   }
927
928   //Make a Python command
929   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
930     << theBase << ", " << thePath << ")";
931
932   SetErrorCode(OK);
933   return aPipe;
934 }
935
936
937 //=============================================================================
938 /*!
939  *  MakeRevolutionAxisAngle
940  */
941 //=============================================================================
942 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
943                                                                          Handle(GEOM_Object) theAxis,
944                                                                          double theAngle)
945 {
946   SetErrorCode(KO);
947
948   if (theBase.IsNull() || theAxis.IsNull()) return NULL;
949
950   //Add a new Revolution object
951   Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
952
953   //Add a new Revolution function for creation a revolution relatively to axis
954   Handle(GEOM_Function) aFunction =
955     aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
956   if (aFunction.IsNull()) return NULL;
957
958   //Check if the function is set correctly
959   if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
960
961   GEOMImpl_IRevolution aCI (aFunction);
962
963   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
964   Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
965
966   if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
967
968   aCI.SetBase(aRefBase);
969   aCI.SetAxis(aRefAxis);
970   aCI.SetAngle(theAngle);
971
972   //Compute the Revolution value
973   try {
974 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
975     OCC_CATCH_SIGNALS;
976 #endif
977     if (!GetSolver()->ComputeFunction(aFunction)) {
978       SetErrorCode("Revolution driver failed");
979       return NULL;
980     }
981   }
982   catch (Standard_Failure) {
983     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
984     SetErrorCode(aFail->GetMessageString());
985     return NULL;
986   }
987
988   //Make a Python command
989   GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
990     << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
991
992   SetErrorCode(OK);
993   return aRevolution;
994 }
995
996 //=============================================================================
997 /*!
998  *  MakeRevolutionAxisAngle2Ways
999  */
1000 //=============================================================================
1001 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1002                    (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1003 {
1004   SetErrorCode(KO);
1005
1006   if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1007
1008   //Add a new Revolution object
1009   Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1010
1011   //Add a new Revolution function for creation a revolution relatively to axis
1012   Handle(GEOM_Function) aFunction =
1013     aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1014   if (aFunction.IsNull()) return NULL;
1015
1016   //Check if the function is set correctly
1017   if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1018
1019   GEOMImpl_IRevolution aCI (aFunction);
1020
1021   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1022   Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1023
1024   if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1025
1026   aCI.SetBase(aRefBase);
1027   aCI.SetAxis(aRefAxis);
1028   aCI.SetAngle(theAngle);
1029
1030   //Compute the Revolution value
1031   try {
1032 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1033     OCC_CATCH_SIGNALS;
1034 #endif
1035     if (!GetSolver()->ComputeFunction(aFunction)) {
1036       SetErrorCode("Revolution driver failed");
1037       return NULL;
1038     }
1039   }
1040   catch (Standard_Failure) {
1041     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1042     SetErrorCode(aFail->GetMessageString());
1043     return NULL;
1044   }
1045
1046   //Make a Python command
1047   GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1048     << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1049
1050   SetErrorCode(OK);
1051   return aRevolution;
1052 }
1053
1054 //=============================================================================
1055 /*!
1056  *  MakeSolidShell
1057  */
1058 //=============================================================================
1059 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
1060 {
1061   SetErrorCode(KO);
1062
1063   if (theShell.IsNull()) return NULL;
1064
1065   //Add a new Solid object
1066   Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
1067
1068   //Add a new Solid function for creation a solid from a shell
1069   Handle(GEOM_Function) aFunction =
1070     aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
1071   if (aFunction.IsNull()) return NULL;
1072
1073   //Check if the function is set correctly
1074   if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
1075
1076   GEOMImpl_IShapes aCI (aFunction);
1077
1078   Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
1079
1080   if (aRefShell.IsNull()) return NULL;
1081
1082   aCI.SetBase(aRefShell);
1083
1084   //Compute the Solid value
1085   try {
1086 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1087     OCC_CATCH_SIGNALS;
1088 #endif
1089     if (!GetSolver()->ComputeFunction(aFunction)) {
1090       SetErrorCode("Solid driver failed");
1091       return NULL;
1092     }
1093   }
1094   catch (Standard_Failure) {
1095     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1096     SetErrorCode(aFail->GetMessageString());
1097     return NULL;
1098   }
1099
1100   //Make a Python command
1101   GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
1102
1103   SetErrorCode(OK);
1104   return aSolid;
1105 }
1106
1107 //=============================================================================
1108 /*!
1109  *  MakeFilling
1110  */
1111 //=============================================================================
1112 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1113        (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1114         double theTol2D, double theTol3D, int theNbIter, bool isApprox)
1115 {
1116   SetErrorCode(KO);
1117
1118   if (theShape.IsNull()) return NULL;
1119
1120   //Add a new Filling object
1121   Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1122
1123   //Add a new Filling function for creation a filling  from a compound
1124   Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1125   if (aFunction.IsNull()) return NULL;
1126
1127   //Check if the function is set correctly
1128   if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1129
1130   GEOMImpl_IFilling aFI (aFunction);
1131
1132   Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1133
1134   if (aRefShape.IsNull()) return NULL;
1135
1136   aFI.SetShape(aRefShape);
1137   aFI.SetMinDeg(theMinDeg);
1138   aFI.SetMaxDeg(theMaxDeg);
1139   aFI.SetTol2D(theTol2D);
1140   aFI.SetTol3D(theTol3D);
1141   aFI.SetNbIter(theNbIter);
1142   aFI.SetApprox(isApprox);
1143
1144   //Compute the Solid value
1145   try {
1146 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1147     OCC_CATCH_SIGNALS;
1148 #endif
1149     if (!GetSolver()->ComputeFunction(aFunction)) {
1150       SetErrorCode("Filling driver failed");
1151       return NULL;
1152     }
1153   }
1154   catch (Standard_Failure) {
1155     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1156     if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1157       SetErrorCode("B-Spline surface construction failed");
1158     else
1159       SetErrorCode(aFail->GetMessageString());
1160     return NULL;
1161   }
1162
1163   //Make a Python command
1164   GEOM::TPythonDump pd (aFunction);
1165   pd << aFilling << " = geompy.MakeFilling("
1166     << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
1167       << theTol2D << ", " << theTol3D << ", " << theNbIter;
1168   if(isApprox)
1169     pd << ", " << isApprox;
1170   pd << ")";
1171
1172   SetErrorCode(OK);
1173   return aFilling;
1174 }
1175
1176 //=============================================================================
1177 /*!
1178  *  MakeThruSections
1179  */
1180 //=============================================================================
1181 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1182                                                 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1183                                                 bool theModeSolid,
1184                                                 double thePreci,
1185                                                 bool theRuled)
1186 {
1187   Handle(GEOM_Object) anObj;
1188   SetErrorCode(KO);
1189   if(theSeqSections.IsNull())
1190     return anObj;
1191
1192   Standard_Integer nbObj = theSeqSections->Length();
1193   if (!nbObj) 
1194     return anObj;
1195
1196   //Add a new ThruSections object
1197   Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1198
1199  
1200   //Add a new ThruSections function
1201
1202   int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1203   Handle(GEOM_Function) aFunction =
1204     aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1205   if (aFunction.IsNull()) return anObj;
1206
1207   //Check if the function is set correctly
1208   if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1209
1210   GEOMImpl_IThruSections aCI (aFunction);
1211
1212   Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1213
1214   Standard_Integer i =1;
1215   for( ; i <= nbObj; i++) {
1216
1217     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1218     if(anItem.IsNull())
1219       continue;
1220     
1221     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1222     if(!aSectObj.IsNull())
1223     {
1224       Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1225       if(!aRefSect.IsNull())
1226         aSeqSections->Append(aRefSect);
1227     }
1228   }
1229
1230   if(!aSeqSections->Length())
1231     return anObj;
1232
1233   aCI.SetSections(aSeqSections);
1234   aCI.SetSolidMode(theModeSolid);
1235   aCI.SetPrecision(thePreci);
1236
1237   //Compute the ThruSections value
1238   try {
1239 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1240     OCC_CATCH_SIGNALS;
1241 #endif
1242     if (!GetSolver()->ComputeFunction(aFunction)) {
1243       SetErrorCode("ThruSections driver failed");
1244       return anObj;
1245     }
1246   }
1247   catch (Standard_Failure) {
1248     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1249     SetErrorCode(aFail->GetMessageString());
1250     return anObj;
1251   }
1252
1253   //Make a Python command
1254   GEOM::TPythonDump pyDump(aFunction);
1255   pyDump << aThruSect << " = geompy.MakeThruSections([";
1256
1257   for(i =1 ; i <= nbObj; i++) {
1258
1259     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1260     if(anItem.IsNull())
1261       continue;
1262     
1263     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1264     if(!aSectObj.IsNull()) {
1265       pyDump<< aSectObj;
1266       if(i < nbObj)
1267         pyDump<<", ";
1268     }
1269   }
1270   
1271   pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1272
1273   SetErrorCode(OK);
1274   return aThruSect;
1275   
1276    
1277 }
1278
1279
1280 //=============================================================================
1281 /*!
1282  *  MakePipeWithDifferentSections
1283  */
1284 //=============================================================================
1285 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1286                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1287                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1288                 const Handle(GEOM_Object)& thePath,
1289                 bool theWithContact,
1290                 bool theWithCorrections)
1291 {
1292   Handle(GEOM_Object) anObj;
1293   SetErrorCode(KO);
1294   if(theBases.IsNull())
1295     return anObj;
1296
1297   Standard_Integer nbBases = theBases->Length();
1298   
1299   if (!nbBases)
1300     return anObj;
1301   
1302   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1303   //Add a new Pipe object
1304   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1305  
1306   //Add a new Pipe function
1307
1308   Handle(GEOM_Function) aFunction =
1309     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1310   if (aFunction.IsNull()) return anObj;
1311
1312   //Check if the function is set correctly
1313   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1314
1315   GEOMImpl_IPipeDiffSect aCI (aFunction);
1316
1317   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1318   if(aRefPath.IsNull())
1319     return anObj;
1320
1321   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1322   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1323
1324   Standard_Integer i =1;
1325   for( ; i <= nbBases; i++) {
1326
1327     Handle(Standard_Transient) anItem = theBases->Value(i);
1328     if(anItem.IsNull())
1329       continue;
1330     
1331     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1332     if(aBase.IsNull())
1333       continue;
1334     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1335     if(aRefBase.IsNull())
1336       continue;
1337     if(nbLocs)
1338     {
1339       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1340       if(anItemLoc.IsNull())
1341         continue;
1342     
1343       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1344       if(aLoc.IsNull())
1345         continue;
1346       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1347       if(aRefLoc.IsNull())
1348         continue;
1349       aSeqLocs->Append(aRefLoc);
1350     }
1351     aSeqBases->Append(aRefBase);
1352   }
1353
1354   if(!aSeqBases->Length())
1355     return anObj;
1356
1357   aCI.SetBases(aSeqBases);
1358   aCI.SetLocations(aSeqLocs);
1359   aCI.SetPath(aRefPath);
1360   aCI.SetWithContactMode(theWithContact);
1361   aCI.SetWithCorrectionMode(theWithCorrections);
1362   
1363   //Compute the Pipe value
1364   try {
1365 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1366     OCC_CATCH_SIGNALS;
1367 #endif
1368     if (!GetSolver()->ComputeFunction(aFunction)) {
1369       SetErrorCode("Pipe with defferent section driver failed");
1370       return anObj;
1371     }
1372   }
1373   catch (Standard_Failure) {
1374     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1375     SetErrorCode(aFail->GetMessageString());
1376     return anObj;
1377   }
1378
1379   //Make a Python command
1380   GEOM::TPythonDump pyDump(aFunction);
1381   pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1382
1383   for(i =1 ; i <= nbBases; i++) {
1384
1385     Handle(Standard_Transient) anItem = theBases->Value(i);
1386     if(anItem.IsNull())
1387       continue;
1388     
1389     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1390     if(!anObj.IsNull()) {
1391       pyDump<< anObj;
1392       if(i < nbBases)
1393         pyDump<<", ";
1394     }
1395     
1396   }
1397   
1398   pyDump<< "], [";
1399    
1400   for(i =1 ; i <= nbLocs; i++) {
1401
1402     Handle(Standard_Transient) anItem = theLocations->Value(i);
1403     if(anItem.IsNull())
1404       continue;
1405     
1406     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1407     if(!anObj.IsNull()) {
1408       pyDump<< anObj;
1409       if(i < nbLocs)
1410         pyDump<<", ";
1411     }
1412   }  
1413
1414   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1415
1416   SetErrorCode(OK);
1417   return aPipeDS;
1418   
1419    
1420 }
1421
1422
1423 //=============================================================================
1424 /*!
1425  *  MakePipeWithShellSections
1426  */
1427 //=============================================================================
1428 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1429                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1430                 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1431                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1432                 const Handle(GEOM_Object)& thePath,
1433                 bool theWithContact,
1434                 bool theWithCorrections)
1435 {
1436   Handle(GEOM_Object) anObj;
1437   SetErrorCode(KO);
1438   if(theBases.IsNull())
1439     return anObj;
1440
1441   Standard_Integer nbBases = theBases->Length();
1442   
1443   if (!nbBases)
1444     return anObj;
1445   
1446   Standard_Integer nbSubBases =  (theSubBases.IsNull() ? 0 :theSubBases->Length());
1447
1448   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1449
1450   //Add a new Pipe object
1451   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1452  
1453   //Add a new Pipe function
1454
1455   Handle(GEOM_Function) aFunction =
1456     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1457   if (aFunction.IsNull()) return anObj;
1458
1459   //Check if the function is set correctly
1460   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1461
1462   //GEOMImpl_IPipeDiffSect aCI (aFunction);
1463   GEOMImpl_IPipeShellSect aCI (aFunction);
1464
1465   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1466   if(aRefPath.IsNull())
1467     return anObj;
1468
1469   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1470   Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1471   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1472
1473   Standard_Integer i =1;
1474   for( ; i <= nbBases; i++) {
1475
1476     Handle(Standard_Transient) anItem = theBases->Value(i);
1477     if(anItem.IsNull())
1478       continue;
1479     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1480     if(aBase.IsNull())
1481       continue;
1482     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1483     if(aRefBase.IsNull())
1484       continue;
1485
1486     if( nbSubBases >= nbBases ) {
1487       Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1488       if(aSubItem.IsNull())
1489         continue;
1490       Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1491       if(aSubBase.IsNull())
1492         continue;
1493       Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1494       if(aRefSubBase.IsNull())
1495         continue;
1496       aSeqSubBases->Append(aRefSubBase);
1497     }
1498
1499     if(nbLocs) {
1500       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1501       if(anItemLoc.IsNull())
1502         continue;
1503       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1504       if(aLoc.IsNull())
1505         continue;
1506       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1507       if(aRefLoc.IsNull())
1508         continue;
1509       aSeqLocs->Append(aRefLoc);
1510     }
1511
1512     aSeqBases->Append(aRefBase);
1513   }
1514
1515   if(!aSeqBases->Length())
1516     return anObj;
1517
1518   aCI.SetBases(aSeqBases);
1519   aCI.SetSubBases(aSeqSubBases);
1520   aCI.SetLocations(aSeqLocs);
1521   aCI.SetPath(aRefPath);
1522   aCI.SetWithContactMode(theWithContact);
1523   aCI.SetWithCorrectionMode(theWithCorrections);
1524   
1525   //Compute the Pipe value
1526   try {
1527 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1528     OCC_CATCH_SIGNALS;
1529 #endif
1530     if (!GetSolver()->ComputeFunction(aFunction)) {
1531       SetErrorCode("Pipe with shell sections driver failed");
1532       return anObj;
1533     }
1534   }
1535   catch (Standard_Failure) {
1536     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1537     SetErrorCode(aFail->GetMessageString());
1538     return anObj;
1539   }
1540
1541   //Make a Python command
1542   GEOM::TPythonDump pyDump(aFunction);
1543   pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1544
1545   for(i =1 ; i <= nbBases; i++) {
1546
1547     Handle(Standard_Transient) anItem = theBases->Value(i);
1548     if(anItem.IsNull())
1549       continue;
1550     
1551     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1552     if(!anObj.IsNull()) {
1553       pyDump<< anObj;
1554       if(i < nbBases)
1555         pyDump<<", ";
1556     }
1557     
1558   }
1559   
1560   pyDump<< "], [";
1561    
1562   for(i =1 ; i <= nbSubBases; i++) {
1563
1564     Handle(Standard_Transient) anItem = theSubBases->Value(i);
1565     if(anItem.IsNull())
1566       continue;
1567     
1568     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1569     if(!anObj.IsNull()) {
1570       pyDump<< anObj;
1571       if(i < nbBases)
1572         pyDump<<", ";
1573     }
1574     
1575   }
1576   
1577   pyDump<< "], [";
1578    
1579   for(i =1 ; i <= nbLocs; i++) {
1580
1581     Handle(Standard_Transient) anItem = theLocations->Value(i);
1582     if(anItem.IsNull())
1583       continue;
1584     
1585     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1586     if(!anObj.IsNull()) {
1587       pyDump<< anObj;
1588       if(i < nbLocs)
1589         pyDump<<", ";
1590     }
1591   }  
1592
1593   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1594
1595   SetErrorCode(OK);
1596   return aPipeDS;
1597
1598 }
1599
1600
1601 //=============================================================================
1602 /*!
1603  *  MakePipeShellsWithoutPath
1604  */
1605 //=============================================================================
1606 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1607                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1608                 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1609 {
1610   Handle(GEOM_Object) anObj;
1611   SetErrorCode(KO);
1612   if(theBases.IsNull())
1613     return anObj;
1614
1615   Standard_Integer nbBases = theBases->Length();
1616   
1617   if (!nbBases)
1618     return anObj;
1619   
1620   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1621
1622   //Add a new Pipe object
1623   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1624  
1625   //Add a new Pipe function
1626
1627   Handle(GEOM_Function) aFunction =
1628     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1629   if (aFunction.IsNull()) return anObj;
1630
1631   //Check if the function is set correctly
1632   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1633
1634   GEOMImpl_IPipeShellSect aCI (aFunction);
1635
1636   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1637   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1638
1639   Standard_Integer i =1;
1640   for( ; i <= nbBases; i++) {
1641
1642     Handle(Standard_Transient) anItem = theBases->Value(i);
1643     if(anItem.IsNull())
1644       continue;
1645     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1646     if(aBase.IsNull())
1647       continue;
1648     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1649     if(aRefBase.IsNull())
1650       continue;
1651
1652     if(nbLocs) {
1653       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1654       if(anItemLoc.IsNull())
1655         continue;
1656       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1657       if(aLoc.IsNull())
1658         continue;
1659       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1660       if(aRefLoc.IsNull())
1661         continue;
1662       aSeqLocs->Append(aRefLoc);
1663     }
1664
1665     aSeqBases->Append(aRefBase);
1666   }
1667
1668   if(!aSeqBases->Length())
1669     return anObj;
1670
1671   aCI.SetBases(aSeqBases);
1672   aCI.SetLocations(aSeqLocs);
1673   
1674   //Compute the Pipe value
1675   try {
1676 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1677     OCC_CATCH_SIGNALS;
1678 #endif
1679     if (!GetSolver()->ComputeFunction(aFunction)) {
1680       SetErrorCode("Pipe with shell sections without path driver failed");
1681       return anObj;
1682     }
1683   }
1684   catch (Standard_Failure) {
1685     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1686     SetErrorCode(aFail->GetMessageString());
1687     return anObj;
1688   }
1689
1690   //Make a Python command
1691   GEOM::TPythonDump pyDump(aFunction);
1692   pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
1693
1694   for(i =1 ; i <= nbBases; i++) {
1695
1696     Handle(Standard_Transient) anItem = theBases->Value(i);
1697     if(anItem.IsNull())
1698       continue;
1699     
1700     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1701     if(!anObj.IsNull()) {
1702       pyDump<< anObj;
1703       if(i < nbBases)
1704         pyDump<<", ";
1705     }
1706     
1707   }
1708   
1709   pyDump<< "], [";
1710    
1711   for(i =1 ; i <= nbLocs; i++) {
1712
1713     Handle(Standard_Transient) anItem = theLocations->Value(i);
1714     if(anItem.IsNull())
1715       continue;
1716     
1717     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1718     if(!anObj.IsNull()) {
1719       pyDump<< anObj;
1720       if(i < nbLocs)
1721         pyDump<<", ";
1722     }
1723   }  
1724
1725   pyDump<< "])";
1726
1727   SetErrorCode(OK);
1728   return aPipeDS;
1729
1730 }
1731
1732
1733 //=============================================================================
1734 /*!
1735  *  MakePipeBiNormalAlongVector
1736  */
1737 //=============================================================================
1738 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
1739                                                                              Handle(GEOM_Object) thePath,
1740                                                                              Handle(GEOM_Object) theVec)
1741 {
1742   SetErrorCode(KO);
1743
1744   if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
1745
1746   //Add a new Pipe object
1747   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1748
1749   //Add a new Pipe function
1750   Handle(GEOM_Function) aFunction =
1751     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
1752   if (aFunction.IsNull()) return NULL;
1753
1754   //Check if the function is set correctly
1755   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1756
1757   GEOMImpl_IPipeBiNormal aCI (aFunction);
1758
1759   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1760   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1761   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
1762
1763   if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
1764
1765   aCI.SetBase(aRefBase);
1766   aCI.SetPath(aRefPath);
1767   aCI.SetVector(aRefVec);
1768
1769   //Compute the Pipe value
1770   try {
1771 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1772     OCC_CATCH_SIGNALS;
1773 #endif
1774     if (!GetSolver()->ComputeFunction(aFunction)) {
1775       SetErrorCode("Pipe driver failed");
1776       return NULL;
1777     }
1778   }
1779   catch (Standard_Failure) {
1780     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1781     SetErrorCode(aFail->GetMessageString());
1782     return NULL;
1783   }
1784
1785   //Make a Python command
1786   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
1787     << theBase << ", " << thePath << ", " << theVec << ")";
1788
1789   SetErrorCode(OK);
1790   return aPipe;
1791 }
1792