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