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