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