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