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