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