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