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