Salome HOME
Changes for bug 0020673.
[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         bool isUseOri, 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.SetUseOri(isUseOri);
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(isApprox)
1513     pd << ", " << isApprox;
1514   pd << ")";
1515
1516   SetErrorCode(OK);
1517   return aFilling;
1518 }
1519
1520 //=============================================================================
1521 /*!
1522  *  MakeThruSections
1523  */
1524 //=============================================================================
1525 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1526                                                 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1527                                                 bool theModeSolid,
1528                                                 double thePreci,
1529                                                 bool theRuled)
1530 {
1531   Handle(GEOM_Object) anObj;
1532   SetErrorCode(KO);
1533   if(theSeqSections.IsNull())
1534     return anObj;
1535
1536   Standard_Integer nbObj = theSeqSections->Length();
1537   if (!nbObj) 
1538     return anObj;
1539
1540   //Add a new ThruSections object
1541   Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1542
1543  
1544   //Add a new ThruSections function
1545
1546   int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1547   Handle(GEOM_Function) aFunction =
1548     aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1549   if (aFunction.IsNull()) return anObj;
1550
1551   //Check if the function is set correctly
1552   if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1553
1554   GEOMImpl_IThruSections aCI (aFunction);
1555
1556   Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1557
1558   Standard_Integer i =1;
1559   for( ; i <= nbObj; i++) {
1560
1561     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1562     if(anItem.IsNull())
1563       continue;
1564     
1565     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1566     if(!aSectObj.IsNull())
1567     {
1568       Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1569       if(!aRefSect.IsNull())
1570         aSeqSections->Append(aRefSect);
1571     }
1572   }
1573
1574   if(!aSeqSections->Length())
1575     return anObj;
1576
1577   aCI.SetSections(aSeqSections);
1578   aCI.SetSolidMode(theModeSolid);
1579   aCI.SetPrecision(thePreci);
1580
1581   //Compute the ThruSections value
1582   try {
1583 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1584     OCC_CATCH_SIGNALS;
1585 #endif
1586     if (!GetSolver()->ComputeFunction(aFunction)) {
1587       SetErrorCode("ThruSections driver failed");
1588       return anObj;
1589     }
1590   }
1591   catch (Standard_Failure) {
1592     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1593     SetErrorCode(aFail->GetMessageString());
1594     return anObj;
1595   }
1596
1597   //Make a Python command
1598   GEOM::TPythonDump pyDump(aFunction);
1599   pyDump << aThruSect << " = geompy.MakeThruSections([";
1600
1601   for(i =1 ; i <= nbObj; i++) {
1602
1603     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1604     if(anItem.IsNull())
1605       continue;
1606     
1607     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1608     if(!aSectObj.IsNull()) {
1609       pyDump<< aSectObj;
1610       if(i < nbObj)
1611         pyDump<<", ";
1612     }
1613   }
1614   
1615   pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1616
1617   SetErrorCode(OK);
1618   return aThruSect;
1619   
1620    
1621 }
1622
1623
1624 //=============================================================================
1625 /*!
1626  *  MakePipeWithDifferentSections
1627  */
1628 //=============================================================================
1629 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1630                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1631                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1632                 const Handle(GEOM_Object)& thePath,
1633                 bool theWithContact,
1634                 bool theWithCorrections)
1635 {
1636   Handle(GEOM_Object) anObj;
1637   SetErrorCode(KO);
1638   if(theBases.IsNull())
1639     return anObj;
1640
1641   Standard_Integer nbBases = theBases->Length();
1642   
1643   if (!nbBases)
1644     return anObj;
1645   
1646   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1647   //Add a new Pipe object
1648   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1649  
1650   //Add a new Pipe function
1651
1652   Handle(GEOM_Function) aFunction =
1653     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1654   if (aFunction.IsNull()) return anObj;
1655
1656   //Check if the function is set correctly
1657   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1658
1659   GEOMImpl_IPipeDiffSect aCI (aFunction);
1660
1661   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1662   if(aRefPath.IsNull())
1663     return anObj;
1664
1665   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1666   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1667
1668   Standard_Integer i =1;
1669   for( ; i <= nbBases; i++) {
1670
1671     Handle(Standard_Transient) anItem = theBases->Value(i);
1672     if(anItem.IsNull())
1673       continue;
1674     
1675     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1676     if(aBase.IsNull())
1677       continue;
1678     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1679     if(aRefBase.IsNull())
1680       continue;
1681     if(nbLocs)
1682     {
1683       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1684       if(anItemLoc.IsNull())
1685         continue;
1686     
1687       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1688       if(aLoc.IsNull())
1689         continue;
1690       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1691       if(aRefLoc.IsNull())
1692         continue;
1693       aSeqLocs->Append(aRefLoc);
1694     }
1695     aSeqBases->Append(aRefBase);
1696   }
1697
1698   if(!aSeqBases->Length())
1699     return anObj;
1700
1701   aCI.SetBases(aSeqBases);
1702   aCI.SetLocations(aSeqLocs);
1703   aCI.SetPath(aRefPath);
1704   aCI.SetWithContactMode(theWithContact);
1705   aCI.SetWithCorrectionMode(theWithCorrections);
1706   
1707   //Compute the Pipe value
1708   try {
1709 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1710     OCC_CATCH_SIGNALS;
1711 #endif
1712     if (!GetSolver()->ComputeFunction(aFunction)) {
1713       SetErrorCode("Pipe with defferent section driver failed");
1714       return anObj;
1715     }
1716   }
1717   catch (Standard_Failure) {
1718     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1719     SetErrorCode(aFail->GetMessageString());
1720     return anObj;
1721   }
1722
1723   //Make a Python command
1724   GEOM::TPythonDump pyDump(aFunction);
1725   pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1726
1727   for(i =1 ; i <= nbBases; i++) {
1728
1729     Handle(Standard_Transient) anItem = theBases->Value(i);
1730     if(anItem.IsNull())
1731       continue;
1732     
1733     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1734     if(!anObj.IsNull()) {
1735       pyDump<< anObj;
1736       if(i < nbBases)
1737         pyDump<<", ";
1738     }
1739     
1740   }
1741   
1742   pyDump<< "], [";
1743    
1744   for(i =1 ; i <= nbLocs; i++) {
1745
1746     Handle(Standard_Transient) anItem = theLocations->Value(i);
1747     if(anItem.IsNull())
1748       continue;
1749     
1750     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1751     if(!anObj.IsNull()) {
1752       pyDump<< anObj;
1753       if(i < nbLocs)
1754         pyDump<<", ";
1755     }
1756   }  
1757
1758   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1759
1760   SetErrorCode(OK);
1761   return aPipeDS;
1762   
1763    
1764 }
1765
1766
1767 //=============================================================================
1768 /*!
1769  *  MakePipeWithShellSections
1770  */
1771 //=============================================================================
1772 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1773                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1774                 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1775                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1776                 const Handle(GEOM_Object)& thePath,
1777                 bool theWithContact,
1778                 bool theWithCorrections)
1779 {
1780   Handle(GEOM_Object) anObj;
1781   SetErrorCode(KO);
1782   if(theBases.IsNull())
1783     return anObj;
1784
1785   Standard_Integer nbBases = theBases->Length();
1786   
1787   if (!nbBases)
1788     return anObj;
1789   
1790   Standard_Integer nbSubBases =  (theSubBases.IsNull() ? 0 :theSubBases->Length());
1791
1792   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1793
1794   //Add a new Pipe object
1795   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1796  
1797   //Add a new Pipe function
1798
1799   Handle(GEOM_Function) aFunction =
1800     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1801   if (aFunction.IsNull()) return anObj;
1802
1803   //Check if the function is set correctly
1804   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1805
1806   //GEOMImpl_IPipeDiffSect aCI (aFunction);
1807   GEOMImpl_IPipeShellSect aCI (aFunction);
1808
1809   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1810   if(aRefPath.IsNull())
1811     return anObj;
1812
1813   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1814   Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1815   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1816
1817   Standard_Integer i =1;
1818   for( ; i <= nbBases; i++) {
1819
1820     Handle(Standard_Transient) anItem = theBases->Value(i);
1821     if(anItem.IsNull())
1822       continue;
1823     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1824     if(aBase.IsNull())
1825       continue;
1826     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1827     if(aRefBase.IsNull())
1828       continue;
1829
1830     if( nbSubBases >= nbBases ) {
1831       Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1832       if(aSubItem.IsNull())
1833         continue;
1834       Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1835       if(aSubBase.IsNull())
1836         continue;
1837       Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1838       if(aRefSubBase.IsNull())
1839         continue;
1840       aSeqSubBases->Append(aRefSubBase);
1841     }
1842
1843     if(nbLocs) {
1844       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1845       if(anItemLoc.IsNull())
1846         continue;
1847       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1848       if(aLoc.IsNull())
1849         continue;
1850       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1851       if(aRefLoc.IsNull())
1852         continue;
1853       aSeqLocs->Append(aRefLoc);
1854     }
1855
1856     aSeqBases->Append(aRefBase);
1857   }
1858
1859   if(!aSeqBases->Length())
1860     return anObj;
1861
1862   aCI.SetBases(aSeqBases);
1863   aCI.SetSubBases(aSeqSubBases);
1864   aCI.SetLocations(aSeqLocs);
1865   aCI.SetPath(aRefPath);
1866   aCI.SetWithContactMode(theWithContact);
1867   aCI.SetWithCorrectionMode(theWithCorrections);
1868   
1869   //Compute the Pipe value
1870   try {
1871 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1872     OCC_CATCH_SIGNALS;
1873 #endif
1874     if (!GetSolver()->ComputeFunction(aFunction)) {
1875       SetErrorCode("Pipe with shell sections driver failed");
1876       return anObj;
1877     }
1878   }
1879   catch (Standard_Failure) {
1880     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1881     SetErrorCode(aFail->GetMessageString());
1882     return anObj;
1883   }
1884
1885   //Make a Python command
1886   GEOM::TPythonDump pyDump(aFunction);
1887   pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1888
1889   for(i =1 ; i <= nbBases; i++) {
1890
1891     Handle(Standard_Transient) anItem = theBases->Value(i);
1892     if(anItem.IsNull())
1893       continue;
1894     
1895     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1896     if(!anObj.IsNull()) {
1897       pyDump<< anObj;
1898       if(i < nbBases)
1899         pyDump<<", ";
1900     }
1901     
1902   }
1903   
1904   pyDump<< "], [";
1905    
1906   for(i =1 ; i <= nbSubBases; i++) {
1907
1908     Handle(Standard_Transient) anItem = theSubBases->Value(i);
1909     if(anItem.IsNull())
1910       continue;
1911     
1912     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1913     if(!anObj.IsNull()) {
1914       pyDump<< anObj;
1915       if(i < nbBases)
1916         pyDump<<", ";
1917     }
1918     
1919   }
1920   
1921   pyDump<< "], [";
1922    
1923   for(i =1 ; i <= nbLocs; i++) {
1924
1925     Handle(Standard_Transient) anItem = theLocations->Value(i);
1926     if(anItem.IsNull())
1927       continue;
1928     
1929     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1930     if(!anObj.IsNull()) {
1931       pyDump<< anObj;
1932       if(i < nbLocs)
1933         pyDump<<", ";
1934     }
1935   }  
1936
1937   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1938
1939   SetErrorCode(OK);
1940   return aPipeDS;
1941
1942 }
1943
1944
1945 //=============================================================================
1946 /*!
1947  *  MakePipeShellsWithoutPath
1948  */
1949 //=============================================================================
1950 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
1951                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1952                 const Handle(TColStd_HSequenceOfTransient)& theLocations)
1953 {
1954   Handle(GEOM_Object) anObj;
1955   SetErrorCode(KO);
1956   if(theBases.IsNull())
1957     return anObj;
1958
1959   Standard_Integer nbBases = theBases->Length();
1960   
1961   if (!nbBases)
1962     return anObj;
1963   
1964   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1965
1966   //Add a new Pipe object
1967   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1968  
1969   //Add a new Pipe function
1970
1971   Handle(GEOM_Function) aFunction =
1972     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
1973   if (aFunction.IsNull()) return anObj;
1974
1975   //Check if the function is set correctly
1976   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1977
1978   GEOMImpl_IPipeShellSect aCI (aFunction);
1979
1980   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1981   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1982
1983   Standard_Integer i =1;
1984   for( ; i <= nbBases; i++) {
1985
1986     Handle(Standard_Transient) anItem = theBases->Value(i);
1987     if(anItem.IsNull())
1988       continue;
1989     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1990     if(aBase.IsNull())
1991       continue;
1992     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1993     if(aRefBase.IsNull())
1994       continue;
1995
1996     if(nbLocs) {
1997       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1998       if(anItemLoc.IsNull())
1999         continue;
2000       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2001       if(aLoc.IsNull())
2002         continue;
2003       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2004       if(aRefLoc.IsNull())
2005         continue;
2006       aSeqLocs->Append(aRefLoc);
2007     }
2008
2009     aSeqBases->Append(aRefBase);
2010   }
2011
2012   if(!aSeqBases->Length())
2013     return anObj;
2014
2015   aCI.SetBases(aSeqBases);
2016   aCI.SetLocations(aSeqLocs);
2017   
2018   //Compute the Pipe value
2019   try {
2020 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2021     OCC_CATCH_SIGNALS;
2022 #endif
2023     if (!GetSolver()->ComputeFunction(aFunction)) {
2024       SetErrorCode("Pipe with shell sections without path driver failed");
2025       return anObj;
2026     }
2027   }
2028   catch (Standard_Failure) {
2029     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2030     SetErrorCode(aFail->GetMessageString());
2031     return anObj;
2032   }
2033
2034   //Make a Python command
2035   GEOM::TPythonDump pyDump(aFunction);
2036   pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2037
2038   for(i =1 ; i <= nbBases; i++) {
2039
2040     Handle(Standard_Transient) anItem = theBases->Value(i);
2041     if(anItem.IsNull())
2042       continue;
2043     
2044     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2045     if(!anObj.IsNull()) {
2046       pyDump<< anObj;
2047       if(i < nbBases)
2048         pyDump<<", ";
2049     }
2050     
2051   }
2052   
2053   pyDump<< "], [";
2054    
2055   for(i =1 ; i <= nbLocs; i++) {
2056
2057     Handle(Standard_Transient) anItem = theLocations->Value(i);
2058     if(anItem.IsNull())
2059       continue;
2060     
2061     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2062     if(!anObj.IsNull()) {
2063       pyDump<< anObj;
2064       if(i < nbLocs)
2065         pyDump<<", ";
2066     }
2067   }  
2068
2069   pyDump<< "])";
2070
2071   SetErrorCode(OK);
2072   return aPipeDS;
2073
2074 }
2075
2076
2077 //=============================================================================
2078 /*!
2079  *  MakePipeBiNormalAlongVector
2080  */
2081 //=============================================================================
2082 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2083                                                                              Handle(GEOM_Object) thePath,
2084                                                                              Handle(GEOM_Object) theVec)
2085 {
2086   SetErrorCode(KO);
2087
2088   if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2089
2090   //Add a new Pipe object
2091   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2092
2093   //Add a new Pipe function
2094   Handle(GEOM_Function) aFunction =
2095     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2096   if (aFunction.IsNull()) return NULL;
2097
2098   //Check if the function is set correctly
2099   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2100
2101   GEOMImpl_IPipeBiNormal aCI (aFunction);
2102
2103   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2104   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2105   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
2106
2107   if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2108
2109   aCI.SetBase(aRefBase);
2110   aCI.SetPath(aRefPath);
2111   aCI.SetVector(aRefVec);
2112
2113   //Compute the Pipe value
2114   try {
2115 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2116     OCC_CATCH_SIGNALS;
2117 #endif
2118     if (!GetSolver()->ComputeFunction(aFunction)) {
2119       SetErrorCode("Pipe driver failed");
2120       return NULL;
2121     }
2122   }
2123   catch (Standard_Failure) {
2124     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2125     SetErrorCode(aFail->GetMessageString());
2126     return NULL;
2127   }
2128
2129   //Make a Python command
2130   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2131     << theBase << ", " << thePath << ", " << theVec << ")";
2132
2133   SetErrorCode(OK);
2134   return aPipe;
2135 }
2136