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