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