Salome HOME
Merge remote-tracking branch 'origin/master' into rnc/t_shape_plugin
[modules/geom.git] / src / GEOMImpl / GEOMImpl_I3DPrimOperations.cxx
1 // Copyright (C) 2007-2014  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) GEOMImpl_I3DPrimOperations::MakeFilling
1619        (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1620         double theTol2D, double theTol3D, int theNbIter,
1621         int theMethod, bool isApprox)
1622 {
1623   SetErrorCode(KO);
1624
1625   if (theShape.IsNull()) return NULL;
1626
1627   //Add a new Filling object
1628   Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1629
1630   //Add a new Filling function for creation a filling  from a compound
1631   Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1632   if (aFunction.IsNull()) return NULL;
1633
1634   //Check if the function is set correctly
1635   if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1636
1637   GEOMImpl_IFilling aFI (aFunction);
1638
1639   Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1640
1641   if (aRefShape.IsNull()) return NULL;
1642
1643   aFI.SetShape(aRefShape);
1644   aFI.SetMinDeg(theMinDeg);
1645   aFI.SetMaxDeg(theMaxDeg);
1646   aFI.SetTol2D(theTol2D);
1647   aFI.SetTol3D(theTol3D);
1648   aFI.SetNbIter(theNbIter);
1649   aFI.SetApprox(isApprox);
1650   aFI.SetMethod(theMethod);
1651
1652   //Compute the Solid value
1653   try {
1654     OCC_CATCH_SIGNALS;
1655     if (!GetSolver()->ComputeFunction(aFunction)) {
1656       SetErrorCode("Filling driver failed");
1657       return NULL;
1658     }
1659   }
1660   catch (Standard_Failure) {
1661     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1662     if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1663       SetErrorCode("B-Spline surface construction failed");
1664     else
1665       SetErrorCode(aFail->GetMessageString());
1666     return NULL;
1667   }
1668
1669   //Make a Python command
1670   GEOM::TPythonDump pd (aFunction);
1671   pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1672   if ( theMinDeg != 2 )   pd << ", theMinDeg=" << theMinDeg ;
1673   if ( theMaxDeg != 5 )   pd << ", theMaxDeg=" << theMaxDeg ;
1674   if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1675                           pd << ", theTol2D=" << theTol2D ;
1676   if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1677                           pd << ", theTol3D=" << theTol3D ;
1678   if ( theNbIter != 0 )   pd << ", theNbIter=" << theNbIter ;
1679   if ( theMethod==1 )     pd << ", theMethod=GEOM.FOM_UseOri";
1680   else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1681   if(isApprox)            pd << ", isApprox=" << isApprox ;
1682   pd << ")";
1683
1684   SetErrorCode(OK);
1685   return aFilling;
1686 }
1687
1688 //=============================================================================
1689 /*!
1690  *  MakeThruSections
1691  */
1692 //=============================================================================
1693 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1694                                                 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1695                                                 bool theModeSolid,
1696                                                 double thePreci,
1697                                                 bool theRuled)
1698 {
1699   Handle(GEOM_Object) anObj;
1700   SetErrorCode(KO);
1701   if(theSeqSections.IsNull())
1702     return anObj;
1703
1704   Standard_Integer nbObj = theSeqSections->Length();
1705   if (!nbObj)
1706     return anObj;
1707
1708   //Add a new ThruSections object
1709   Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1710
1711
1712   //Add a new ThruSections function
1713
1714   int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1715   Handle(GEOM_Function) aFunction =
1716     aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1717   if (aFunction.IsNull()) return anObj;
1718
1719   //Check if the function is set correctly
1720   if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1721
1722   GEOMImpl_IThruSections aCI (aFunction);
1723
1724   Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1725
1726   Standard_Integer i =1;
1727   for( ; i <= nbObj; i++) {
1728
1729     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1730     if(anItem.IsNull())
1731       continue;
1732
1733     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1734     if(!aSectObj.IsNull())
1735     {
1736       Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1737       if(!aRefSect.IsNull())
1738         aSeqSections->Append(aRefSect);
1739     }
1740   }
1741
1742   if(!aSeqSections->Length())
1743     return anObj;
1744
1745   aCI.SetSections(aSeqSections);
1746   aCI.SetSolidMode(theModeSolid);
1747   aCI.SetPrecision(thePreci);
1748
1749   //Compute the ThruSections value
1750   try {
1751     OCC_CATCH_SIGNALS;
1752     if (!GetSolver()->ComputeFunction(aFunction)) {
1753       SetErrorCode("ThruSections driver failed");
1754       return anObj;
1755     }
1756   }
1757   catch (Standard_Failure) {
1758     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1759     SetErrorCode(aFail->GetMessageString());
1760     return anObj;
1761   }
1762
1763   //Make a Python command
1764   GEOM::TPythonDump pyDump(aFunction);
1765   pyDump << aThruSect << " = geompy.MakeThruSections([";
1766
1767   for(i =1 ; i <= nbObj; i++) {
1768
1769     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1770     if(anItem.IsNull())
1771       continue;
1772
1773     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1774     if(!aSectObj.IsNull()) {
1775       pyDump<< aSectObj;
1776       if(i < nbObj)
1777         pyDump<<", ";
1778     }
1779   }
1780
1781   pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1782
1783   SetErrorCode(OK);
1784   return aThruSect;
1785 }
1786
1787
1788 //=============================================================================
1789 /*!
1790  *  MakePipeWithDifferentSections
1791  */
1792 //=============================================================================
1793 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1794                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1795                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1796                 const Handle(GEOM_Object)& thePath,
1797                 bool theWithContact,
1798                 bool theWithCorrections)
1799 {
1800   Handle(GEOM_Object) anObj;
1801   SetErrorCode(KO);
1802   if(theBases.IsNull())
1803     return anObj;
1804
1805   Standard_Integer nbBases = theBases->Length();
1806
1807   if (!nbBases)
1808     return anObj;
1809
1810   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1811   //Add a new Pipe object
1812   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1813
1814   //Add a new Pipe function
1815
1816   Handle(GEOM_Function) aFunction =
1817     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1818   if (aFunction.IsNull()) return anObj;
1819
1820   //Check if the function is set correctly
1821   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1822
1823   GEOMImpl_IPipeDiffSect aCI (aFunction);
1824
1825   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1826   if(aRefPath.IsNull())
1827     return anObj;
1828
1829   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1830   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1831
1832   Standard_Integer i =1;
1833   for( ; i <= nbBases; i++) {
1834
1835     Handle(Standard_Transient) anItem = theBases->Value(i);
1836     if(anItem.IsNull())
1837       continue;
1838
1839     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1840     if(aBase.IsNull())
1841       continue;
1842     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1843     if(aRefBase.IsNull())
1844       continue;
1845     if(nbLocs)
1846     {
1847       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1848       if(anItemLoc.IsNull())
1849         continue;
1850
1851       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1852       if(aLoc.IsNull())
1853         continue;
1854       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1855       if(aRefLoc.IsNull())
1856         continue;
1857       aSeqLocs->Append(aRefLoc);
1858     }
1859     aSeqBases->Append(aRefBase);
1860   }
1861
1862   if(!aSeqBases->Length())
1863     return anObj;
1864
1865   aCI.SetBases(aSeqBases);
1866   aCI.SetLocations(aSeqLocs);
1867   aCI.SetPath(aRefPath);
1868   aCI.SetWithContactMode(theWithContact);
1869   aCI.SetWithCorrectionMode(theWithCorrections);
1870
1871   //Compute the Pipe value
1872   try {
1873     OCC_CATCH_SIGNALS;
1874     if (!GetSolver()->ComputeFunction(aFunction)) {
1875       SetErrorCode("Pipe with defferent section driver failed");
1876       return anObj;
1877     }
1878   }
1879   catch (Standard_Failure) {
1880     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1881     SetErrorCode(aFail->GetMessageString());
1882     return anObj;
1883   }
1884
1885   //Make a Python command
1886   GEOM::TPythonDump pyDump(aFunction);
1887   pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1888
1889   for(i =1 ; i <= nbBases; i++) {
1890
1891     Handle(Standard_Transient) anItem = theBases->Value(i);
1892     if(anItem.IsNull())
1893       continue;
1894
1895     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1896     if(!anObj.IsNull()) {
1897       pyDump<< anObj;
1898       if(i < nbBases)
1899         pyDump<<", ";
1900     }
1901   }
1902
1903   pyDump<< "], [";
1904
1905   for(i =1 ; i <= nbLocs; i++) {
1906
1907     Handle(Standard_Transient) anItem = theLocations->Value(i);
1908     if(anItem.IsNull())
1909       continue;
1910
1911     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1912     if(!anObj.IsNull()) {
1913       pyDump<< anObj;
1914       if(i < nbLocs)
1915         pyDump<<", ";
1916     }
1917   }
1918
1919   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1920
1921   SetErrorCode(OK);
1922   return aPipeDS;
1923 }
1924
1925
1926 //=============================================================================
1927 /*!
1928  *  MakePipeWithShellSections
1929  */
1930 //=============================================================================
1931 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1932                 const Handle(TColStd_HSequenceOfTransient)& theBases,
1933                 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1934                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1935                 const Handle(GEOM_Object)& thePath,
1936                 bool theWithContact,
1937                 bool theWithCorrections)
1938 {
1939   Handle(GEOM_Object) anObj;
1940   SetErrorCode(KO);
1941   if(theBases.IsNull())
1942     return anObj;
1943
1944   Standard_Integer nbBases = theBases->Length();
1945
1946   if (!nbBases)
1947     return anObj;
1948
1949   Standard_Integer nbSubBases =  (theSubBases.IsNull() ? 0 :theSubBases->Length());
1950
1951   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
1952
1953   //Add a new Pipe object
1954   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1955
1956   //Add a new Pipe function
1957
1958   Handle(GEOM_Function) aFunction =
1959     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1960   if (aFunction.IsNull()) return anObj;
1961
1962   //Check if the function is set correctly
1963   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1964
1965   //GEOMImpl_IPipeDiffSect aCI (aFunction);
1966   GEOMImpl_IPipeShellSect aCI (aFunction);
1967
1968   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1969   if(aRefPath.IsNull())
1970     return anObj;
1971
1972   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1973   Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1974   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1975
1976   Standard_Integer i =1;
1977   for( ; i <= nbBases; i++) {
1978
1979     Handle(Standard_Transient) anItem = theBases->Value(i);
1980     if(anItem.IsNull())
1981       continue;
1982     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1983     if(aBase.IsNull())
1984       continue;
1985     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1986     if(aRefBase.IsNull())
1987       continue;
1988
1989     if( nbSubBases >= nbBases ) {
1990       Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1991       if(aSubItem.IsNull())
1992         continue;
1993       Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1994       if(aSubBase.IsNull())
1995         continue;
1996       Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1997       if(aRefSubBase.IsNull())
1998         continue;
1999       aSeqSubBases->Append(aRefSubBase);
2000     }
2001
2002     if(nbLocs) {
2003       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2004       if(anItemLoc.IsNull())
2005         continue;
2006       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2007       if(aLoc.IsNull())
2008         continue;
2009       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2010       if(aRefLoc.IsNull())
2011         continue;
2012       aSeqLocs->Append(aRefLoc);
2013     }
2014
2015     aSeqBases->Append(aRefBase);
2016   }
2017
2018   if(!aSeqBases->Length())
2019     return anObj;
2020
2021   aCI.SetBases(aSeqBases);
2022   aCI.SetSubBases(aSeqSubBases);
2023   aCI.SetLocations(aSeqLocs);
2024   aCI.SetPath(aRefPath);
2025   aCI.SetWithContactMode(theWithContact);
2026   aCI.SetWithCorrectionMode(theWithCorrections);
2027
2028   //Compute the Pipe value
2029   try {
2030     OCC_CATCH_SIGNALS;
2031     if (!GetSolver()->ComputeFunction(aFunction)) {
2032       SetErrorCode("Pipe with shell sections driver failed");
2033       return anObj;
2034     }
2035   }
2036   catch (Standard_Failure) {
2037     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2038     SetErrorCode(aFail->GetMessageString());
2039     return anObj;
2040   }
2041
2042   //Make a Python command
2043   GEOM::TPythonDump pyDump(aFunction);
2044   pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
2045
2046   for(i =1 ; i <= nbBases; i++) {
2047
2048     Handle(Standard_Transient) anItem = theBases->Value(i);
2049     if(anItem.IsNull())
2050       continue;
2051
2052     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2053     if(!anObj.IsNull()) {
2054       pyDump<< anObj;
2055       if(i < nbBases)
2056         pyDump<<", ";
2057     }
2058   }
2059
2060   pyDump<< "], [";
2061
2062   for(i =1 ; i <= nbSubBases; i++) {
2063
2064     Handle(Standard_Transient) anItem = theSubBases->Value(i);
2065     if(anItem.IsNull())
2066       continue;
2067
2068     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2069     if(!anObj.IsNull()) {
2070       pyDump<< anObj;
2071       if(i < nbBases)
2072         pyDump<<", ";
2073     }
2074   }
2075
2076   pyDump<< "], [";
2077
2078   for(i =1 ; i <= nbLocs; i++) {
2079
2080     Handle(Standard_Transient) anItem = theLocations->Value(i);
2081     if(anItem.IsNull())
2082       continue;
2083
2084     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2085     if(!anObj.IsNull()) {
2086       pyDump<< anObj;
2087       if(i < nbLocs)
2088         pyDump<<", ";
2089     }
2090   }
2091
2092   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
2093
2094   SetErrorCode(OK);
2095   return aPipeDS;
2096
2097 }
2098
2099
2100 //=============================================================================
2101 /*!
2102  *  MakePipeShellsWithoutPath
2103  */
2104 //=============================================================================
2105 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2106                 const Handle(TColStd_HSequenceOfTransient)& theBases,
2107                 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2108 {
2109   Handle(GEOM_Object) anObj;
2110   SetErrorCode(KO);
2111   if(theBases.IsNull())
2112     return anObj;
2113
2114   Standard_Integer nbBases = theBases->Length();
2115
2116   if (!nbBases)
2117     return anObj;
2118
2119   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
2120
2121   //Add a new Pipe object
2122   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2123
2124   //Add a new Pipe function
2125
2126   Handle(GEOM_Function) aFunction =
2127     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2128   if (aFunction.IsNull()) return anObj;
2129
2130   //Check if the function is set correctly
2131   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2132
2133   GEOMImpl_IPipeShellSect aCI (aFunction);
2134
2135   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2136   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2137
2138   Standard_Integer i =1;
2139   for( ; i <= nbBases; i++) {
2140
2141     Handle(Standard_Transient) anItem = theBases->Value(i);
2142     if(anItem.IsNull())
2143       continue;
2144     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2145     if(aBase.IsNull())
2146       continue;
2147     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2148     if(aRefBase.IsNull())
2149       continue;
2150
2151     if(nbLocs) {
2152       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2153       if(anItemLoc.IsNull())
2154         continue;
2155       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2156       if(aLoc.IsNull())
2157         continue;
2158       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2159       if(aRefLoc.IsNull())
2160         continue;
2161       aSeqLocs->Append(aRefLoc);
2162     }
2163
2164     aSeqBases->Append(aRefBase);
2165   }
2166
2167   if(!aSeqBases->Length())
2168     return anObj;
2169
2170   aCI.SetBases(aSeqBases);
2171   aCI.SetLocations(aSeqLocs);
2172
2173   //Compute the Pipe value
2174   try {
2175     OCC_CATCH_SIGNALS;
2176     if (!GetSolver()->ComputeFunction(aFunction)) {
2177       SetErrorCode("Pipe with shell sections without path driver failed");
2178       return anObj;
2179     }
2180   }
2181   catch (Standard_Failure) {
2182     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2183     SetErrorCode(aFail->GetMessageString());
2184     return anObj;
2185   }
2186
2187   //Make a Python command
2188   GEOM::TPythonDump pyDump(aFunction);
2189   pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2190
2191   for(i =1 ; i <= nbBases; i++) {
2192
2193     Handle(Standard_Transient) anItem = theBases->Value(i);
2194     if(anItem.IsNull())
2195       continue;
2196
2197     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2198     if(!anObj.IsNull()) {
2199       pyDump<< anObj;
2200       if(i < nbBases)
2201         pyDump<<", ";
2202     }
2203   }
2204
2205   pyDump<< "], [";
2206
2207   for(i =1 ; i <= nbLocs; i++) {
2208
2209     Handle(Standard_Transient) anItem = theLocations->Value(i);
2210     if(anItem.IsNull())
2211       continue;
2212
2213     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2214     if(!anObj.IsNull()) {
2215       pyDump<< anObj;
2216       if(i < nbLocs)
2217         pyDump<<", ";
2218     }
2219   }
2220
2221   pyDump<< "])";
2222
2223   SetErrorCode(OK);
2224   return aPipeDS;
2225
2226 }
2227
2228 //=============================================================================
2229 /*!
2230  *  MakePipeBiNormalAlongVector
2231  */
2232 //=============================================================================
2233 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2234                                                                              Handle(GEOM_Object) thePath,
2235                                                                              Handle(GEOM_Object) theVec)
2236 {
2237   SetErrorCode(KO);
2238
2239   if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2240
2241   //Add a new Pipe object
2242   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2243
2244   //Add a new Pipe function
2245   Handle(GEOM_Function) aFunction =
2246     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2247   if (aFunction.IsNull()) return NULL;
2248
2249   //Check if the function is set correctly
2250   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2251
2252   GEOMImpl_IPipeBiNormal aCI (aFunction);
2253
2254   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2255   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2256   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
2257
2258   if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2259
2260   aCI.SetBase(aRefBase);
2261   aCI.SetPath(aRefPath);
2262   aCI.SetVector(aRefVec);
2263
2264   //Compute the Pipe value
2265   try {
2266     OCC_CATCH_SIGNALS;
2267     if (!GetSolver()->ComputeFunction(aFunction)) {
2268       SetErrorCode("Pipe driver failed");
2269       return NULL;
2270     }
2271   }
2272   catch (Standard_Failure) {
2273     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2274     SetErrorCode(aFail->GetMessageString());
2275     return NULL;
2276   }
2277
2278   //Make a Python command
2279   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2280     << theBase << ", " << thePath << ", " << theVec << ")";
2281
2282   SetErrorCode(OK);
2283   return aPipe;
2284 }
2285
2286 //=============================================================================
2287 /*!
2288  *  MakeThickening
2289  */
2290 //=============================================================================
2291 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2292                                                               double theOffset,
2293                                                               bool copy = true)
2294 {
2295   SetErrorCode(KO);
2296
2297   if (theObject.IsNull()) return NULL;
2298
2299   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2300   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2301
2302   //Add a new Offset function
2303   Handle(GEOM_Function) aFunction;
2304   Handle(GEOM_Object) aCopy; 
2305   if (copy)
2306   { 
2307     //Add a new Copy object
2308     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2309     aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2310   }
2311   else
2312     aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2313   
2314   if (aFunction.IsNull()) return NULL;
2315
2316   //Check if the function is set correctly
2317   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2318
2319   GEOMImpl_IOffset aTI (aFunction);
2320   aTI.SetShape(anOriginal);
2321   aTI.SetValue(theOffset);
2322
2323   //Compute the offset
2324   try {
2325     OCC_CATCH_SIGNALS;
2326     if (!GetSolver()->ComputeFunction(aFunction)) {
2327       SetErrorCode("Offset driver failed");
2328       return NULL;
2329     }
2330   }
2331   catch (Standard_Failure) {
2332     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2333     SetErrorCode(aFail->GetMessageString());
2334     return NULL;
2335   }
2336
2337   //Make a Python command
2338   if(copy)
2339   {
2340     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2341                                << theObject << ", " << theOffset << ")";
2342     SetErrorCode(OK);
2343     return aCopy;
2344   }
2345   else
2346   {
2347     GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2348                                << theObject << ", " << theOffset << ")";
2349     SetErrorCode(OK);
2350     return theObject;
2351   }
2352 }
2353
2354 //=============================================================================
2355 /*!
2356  *  RestorePath
2357  */
2358 //=============================================================================
2359 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2360                                                              Handle(GEOM_Object) theBase1,
2361                                                              Handle(GEOM_Object) theBase2)
2362 {
2363   SetErrorCode(KO);
2364
2365   if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2366
2367   // Add a new Path object
2368   Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2369
2370   // Add a new Path function
2371   Handle(GEOM_Function) aFunction =
2372     aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2373   if (aFunction.IsNull()) return NULL;
2374
2375   // Check if the function is set correctly
2376   if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2377
2378   GEOMImpl_IPipePath aCI (aFunction);
2379
2380   Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2381   Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2382   Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2383
2384   if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2385
2386   aCI.SetShape(aRefShape);
2387   aCI.SetBase1(aRefBase1);
2388   aCI.SetBase2(aRefBase2);
2389
2390   // Compute the Path value
2391   try {
2392     OCC_CATCH_SIGNALS;
2393     if (!GetSolver()->ComputeFunction(aFunction)) {
2394       SetErrorCode("PipePath driver failed");
2395       return NULL;
2396     }
2397   }
2398   catch (Standard_Failure) {
2399     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2400     SetErrorCode("RestorePath: inappropriate arguments given");
2401     return NULL;
2402   }
2403
2404   // Make a Python command
2405   GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2406     << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2407
2408   SetErrorCode(OK);
2409   return aPath;
2410 }
2411
2412 //=============================================================================
2413 /*!
2414  *  RestorePath
2415  */
2416 //=============================================================================
2417 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2418                          (Handle(GEOM_Object) theShape,
2419                           const Handle(TColStd_HSequenceOfTransient)& theBase1,
2420                           const Handle(TColStd_HSequenceOfTransient)& theBase2)
2421 {
2422   SetErrorCode(KO);
2423
2424   if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2425
2426   Standard_Integer nbBases1 = theBase1->Length();
2427   Standard_Integer nbBases2 = theBase2->Length();
2428
2429   if (!nbBases1 || !nbBases2)
2430     return NULL;
2431
2432   // Add a new Path object
2433   Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2434
2435   // Add a new Path function
2436   Handle(GEOM_Function) aFunction =
2437     aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2438   if (aFunction.IsNull()) return NULL;
2439
2440   // Check if the function is set correctly
2441   if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2442
2443   GEOMImpl_IPipePath aCI (aFunction);
2444
2445   Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2446   if (aRefShape.IsNull()) return NULL;
2447
2448   Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2449   Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2450
2451   Standard_Integer i;
2452   for (i = 1; i <= nbBases1; i++) {
2453     Handle(Standard_Transient) anItem = theBase1->Value(i);
2454     if (!anItem.IsNull()) {
2455       Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2456       if (!aBase.IsNull()) {
2457         Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2458         if (!aRefBase.IsNull())
2459           aSeqBases1->Append(aRefBase);
2460       }
2461     }
2462   }
2463   for (i = 1; i <= nbBases2; i++) {
2464     Handle(Standard_Transient) anItem = theBase2->Value(i);
2465     if (!anItem.IsNull()) {
2466       Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2467       if (!aBase.IsNull()) {
2468         Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2469         if (!aRefBase.IsNull())
2470           aSeqBases2->Append(aRefBase);
2471       }
2472     }
2473   }
2474   if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2475
2476   aCI.SetShape(aRefShape);
2477   aCI.SetBaseSeq1(aSeqBases1);
2478   aCI.SetBaseSeq2(aSeqBases2);
2479
2480   // Compute the Path value
2481   try {
2482     OCC_CATCH_SIGNALS;
2483     if (!GetSolver()->ComputeFunction(aFunction)) {
2484       SetErrorCode("PipePath driver failed");
2485       return NULL;
2486     }
2487   }
2488   catch (Standard_Failure) {
2489     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2490     SetErrorCode("RestorePath: inappropriate arguments given");
2491     return NULL;
2492   }
2493
2494   // Make a Python command
2495   GEOM::TPythonDump pyDump (aFunction);
2496   pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2497   for (i = 1; i <= nbBases1; i++) {
2498     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2499     if (!anObj.IsNull()) {
2500       pyDump << anObj;
2501       if (i < nbBases1)
2502         pyDump << ", ";
2503     }
2504   }
2505   pyDump<< "], [";
2506   for (i = 1; i <= nbBases2; i++) {
2507     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2508     if (!anObj.IsNull()) {
2509       pyDump << anObj;
2510       if (i < nbBases2)
2511         pyDump << ", ";
2512     }
2513   }
2514   pyDump << "])";
2515
2516   SetErrorCode(OK);
2517   return aPath;
2518 }