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