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