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