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