Salome HOME
Fix for bug Bug IPAL20288 (4x: CRASH after trying to build a sketch).
[modules/geom.git] / src / GEOM_I / GEOM_I3DPrimOperations_i.cc
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #include <Standard_Stream.hxx>
21
22 #include "GEOM_I3DPrimOperations_i.hh"
23
24 #include "utilities.h"
25 #include "OpUtil.hxx"
26 #include "Utils_ExceptHandlers.hxx"
27
28 #include "GEOM_Engine.hxx"
29 #include "GEOM_Object.hxx"
30
31 //=============================================================================
32 /*!
33  *   constructor:
34  */
35 //=============================================================================
36 GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_I3DPrimOperations* theImpl)
37 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
38 {
39   MESSAGE("GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i");
40 }
41
42 //=============================================================================
43 /*!
44  *  destructor
45  */
46 //=============================================================================
47 GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i()
48 {
49   MESSAGE("GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i");
50 }
51
52
53 //=============================================================================
54 /*!
55  *  MakeBoxDXDYDZ
56  */
57 //=============================================================================
58 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxDXDYDZ (CORBA::Double theDX,
59                                                                CORBA::Double theDY,
60                                                                CORBA::Double theDZ)
61 {
62   GEOM::GEOM_Object_var aGEOMObject;
63
64   //Set a not done flag
65   GetOperations()->SetNotDone();
66    
67   //Create the Box
68   Handle(GEOM_Object) anObject = GetOperations()->MakeBoxDXDYDZ(theDX, theDY, theDZ);
69   if (!GetOperations()->IsDone() || anObject.IsNull())
70     return aGEOMObject._retn();
71  
72   return GetObject(anObject);
73 }
74
75 //=============================================================================
76 /*!
77  *  MakeBoxTwoPnt
78  */
79 //=============================================================================
80 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt
81                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
82 {
83   GEOM::GEOM_Object_var aGEOMObject;
84
85   //Set a not done flag
86   GetOperations()->SetNotDone();
87
88   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
89
90   //Get the reference points
91   Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
92     (thePnt1->GetStudyID(), thePnt1->GetEntry());
93   Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
94     (thePnt2->GetStudyID(), thePnt2->GetEntry());
95
96   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
97
98   //Create the Box
99   Handle(GEOM_Object) anObject = GetOperations()->MakeBoxTwoPnt(aPnt1, aPnt2);
100   if (!GetOperations()->IsDone() || anObject.IsNull())
101     return aGEOMObject._retn();
102
103   return GetObject(anObject);
104 }
105
106 //=============================================================================
107 /*!
108  *  MakeCylinderRH
109  */
110 //=============================================================================
111 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR,
112                                                                 CORBA::Double theH)
113 {
114   GEOM::GEOM_Object_var aGEOMObject;
115
116   //Set a not done flag
117   GetOperations()->SetNotDone();
118
119   //Create the Cylinder
120   Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRH(theR, theH);
121   if (!GetOperations()->IsDone() || anObject.IsNull())
122     return aGEOMObject._retn();
123
124   return GetObject(anObject);
125 }
126
127 //=============================================================================
128 /*!
129  *  MakeCylinderPntVecRH
130  */
131 //=============================================================================
132 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH
133                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
134                        CORBA::Double theR, CORBA::Double theH)
135 {
136   GEOM::GEOM_Object_var aGEOMObject;
137
138   //Set a not done flag
139   GetOperations()->SetNotDone();
140
141   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
142
143   //Get the reference points
144   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
145     (thePnt->GetStudyID(), thePnt->GetEntry());
146   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
147     (theVec->GetStudyID(), theVec->GetEntry());
148
149   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
150
151   //Create the Cylinder
152   Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRH(aPnt, aVec, theR, theH);
153   if (!GetOperations()->IsDone() || anObject.IsNull())
154     return aGEOMObject._retn();
155
156   return GetObject(anObject);
157 }
158
159 //=============================================================================
160 /*!
161  *  MakeConeR1R2H
162  */
163 //=============================================================================
164 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConeR1R2H (CORBA::Double theR1,
165                                                                CORBA::Double theR2,
166                                                                CORBA::Double theH)
167 {
168   GEOM::GEOM_Object_var aGEOMObject;
169
170   //Set a not done flag
171   GetOperations()->SetNotDone();
172
173   //Create the Cone
174   Handle(GEOM_Object) anObject = GetOperations()->MakeConeR1R2H(theR1, theR2, theH);
175   if (!GetOperations()->IsDone() || anObject.IsNull())
176     return aGEOMObject._retn();
177
178   return GetObject(anObject);
179 }
180
181 //=============================================================================
182 /*!
183  *  MakeConePntVecR1R2H
184  */
185 //=============================================================================
186 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConePntVecR1R2H
187                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
188                        CORBA::Double theR1, CORBA::Double theR2, CORBA::Double theH)
189 {
190   GEOM::GEOM_Object_var aGEOMObject;
191
192   //Set a not done flag
193   GetOperations()->SetNotDone();
194
195   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
196
197   //Get the reference points
198   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
199     (thePnt->GetStudyID(), thePnt->GetEntry());
200   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
201     (theVec->GetStudyID(), theVec->GetEntry());
202
203   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
204
205   //Create the Cone
206   Handle(GEOM_Object) anObject =
207       GetOperations()->MakeConePntVecR1R2H(aPnt, aVec, theR1, theR2, theH);
208   if (!GetOperations()->IsDone() || anObject.IsNull())
209     return aGEOMObject._retn();
210
211   return GetObject(anObject);
212 }
213
214 //=============================================================================
215 /*!
216  *  MakeSphereR
217  */
218 //=============================================================================
219 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSphereR (CORBA::Double theR)
220 {
221   GEOM::GEOM_Object_var aGEOMObject;
222
223   //Set a not done flag
224   GetOperations()->SetNotDone();
225
226   //Create the Cone
227   Handle(GEOM_Object) anObject = GetOperations()->MakeSphereR(theR);
228   if (!GetOperations()->IsDone() || anObject.IsNull())
229     return aGEOMObject._retn();
230
231   return GetObject(anObject);
232 }
233
234 //=============================================================================
235 /*!
236  *  MakeSpherePntR
237  */
238 //=============================================================================
239 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSpherePntR
240                       (GEOM::GEOM_Object_ptr thePnt, CORBA::Double theR)
241 {
242   GEOM::GEOM_Object_var aGEOMObject;
243
244   //Set a not done flag
245   GetOperations()->SetNotDone();
246
247   if (thePnt == NULL) return aGEOMObject._retn();
248
249   //Get the reference point
250   CORBA::String_var entry=thePnt->GetEntry();
251   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
252     (thePnt->GetStudyID(), entry);
253
254   if (aPnt.IsNull()) return aGEOMObject._retn();
255
256   //Create the Sphere
257   Handle(GEOM_Object) anObject =
258       GetOperations()->MakeSpherePntR(aPnt, theR);
259   if (!GetOperations()->IsDone() || anObject.IsNull())
260     return aGEOMObject._retn();
261
262   return GetObject(anObject);
263 }
264
265 //=============================================================================
266 /*!
267  *  MakeTorusRR
268  */
269 //=============================================================================
270 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusRR
271                       (CORBA::Double theRMajor, CORBA::Double theRMinor)
272 {
273   GEOM::GEOM_Object_var aGEOMObject;
274
275   //Set a not done flag
276   GetOperations()->SetNotDone();
277
278   // Make Torus
279   Handle(GEOM_Object) anObject =
280     GetOperations()->MakeTorusRR(theRMajor, theRMinor);
281   if (!GetOperations()->IsDone() || anObject.IsNull())
282     return aGEOMObject._retn();
283
284   return GetObject(anObject);
285 }
286
287 //=============================================================================
288 /*!
289  *  MakeTorusPntVecRR
290  */
291 //=============================================================================
292 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusPntVecRR
293                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
294                        CORBA::Double theRMajor, CORBA::Double theRMinor)
295 {
296   GEOM::GEOM_Object_var aGEOMObject;
297
298   //Set a not done flag
299   GetOperations()->SetNotDone();
300
301   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
302
303   //Get the reference points
304   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
305     (thePnt->GetStudyID(), thePnt->GetEntry());
306   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
307     (theVec->GetStudyID(), theVec->GetEntry());
308
309   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
310
311   // Make Torus
312   Handle(GEOM_Object) anObject =
313     GetOperations()->MakeTorusPntVecRR(aPnt, aVec, theRMajor, theRMinor);
314   if (!GetOperations()->IsDone() || anObject.IsNull())
315     return aGEOMObject._retn();
316
317   return GetObject(anObject);
318 }
319
320 //=============================================================================
321 /*!
322  *  MakePrismVecH
323  */
324 //=============================================================================
325 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH
326                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec,
327                        CORBA::Double theH)
328 {
329   GEOM::GEOM_Object_var aGEOMObject;
330
331   //Set a not done flag
332   GetOperations()->SetNotDone();
333
334   if (theBase == NULL || theVec == NULL) return aGEOMObject._retn();
335
336   //Get the reference objects
337   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
338     (theBase->GetStudyID(), theBase->GetEntry());
339   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
340     (theVec->GetStudyID(), theVec->GetEntry());
341
342   if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
343
344   //Create the Prism
345   Handle(GEOM_Object) anObject =
346       GetOperations()->MakePrismVecH(aBase, aVec, theH);
347   if (!GetOperations()->IsDone() || anObject.IsNull())
348     return aGEOMObject._retn();
349
350   return GetObject(anObject);
351 }
352
353 //=============================================================================
354 /*!
355  *  MakePrismVecH2Ways
356  */
357 //=============================================================================
358 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH2Ways
359                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec,
360                        CORBA::Double theH)
361 {
362   GEOM::GEOM_Object_var aGEOMObject;
363
364   //Set a not done flag
365   GetOperations()->SetNotDone();
366
367   if (theBase == NULL || theVec == NULL) return aGEOMObject._retn();
368
369   //Get the reference objects
370   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
371     (theBase->GetStudyID(), theBase->GetEntry());
372   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
373     (theVec->GetStudyID(), theVec->GetEntry());
374
375   if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
376
377   //Create the Prism
378   Handle(GEOM_Object) anObject =
379       GetOperations()->MakePrismVecH2Ways(aBase, aVec, theH);
380   if (!GetOperations()->IsDone() || anObject.IsNull())
381     return aGEOMObject._retn();
382
383   return GetObject(anObject);
384 }
385
386 //=============================================================================
387 /*!
388  *  MakePrismTwoPnt
389  */
390 //=============================================================================
391 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt
392                                              (GEOM::GEOM_Object_ptr theBase,
393                                               GEOM::GEOM_Object_ptr thePoint1,
394                                               GEOM::GEOM_Object_ptr thePoint2)
395 {
396   GEOM::GEOM_Object_var aGEOMObject;
397
398   //Set a not done flag
399   GetOperations()->SetNotDone();
400
401   if (theBase == NULL || thePoint1 == NULL || thePoint2 == NULL)
402     return aGEOMObject._retn();
403
404   //Get the reference objects
405   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
406     (theBase->GetStudyID(), theBase->GetEntry());
407   Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
408     (thePoint1->GetStudyID(), thePoint1->GetEntry());
409   Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
410     (thePoint2->GetStudyID(), thePoint2->GetEntry());
411
412   if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull())
413     return aGEOMObject._retn();
414
415   //Create the Prism
416   Handle(GEOM_Object) anObject =
417     GetOperations()->MakePrismTwoPnt(aBase, aPoint1, aPoint2);
418   if (!GetOperations()->IsDone() || anObject.IsNull())
419     return aGEOMObject._retn();
420
421   return GetObject(anObject);
422 }
423
424 //=============================================================================
425 /*!
426  *  MakePrismTwoPnt2Ways
427  */
428 //=============================================================================
429 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt2Ways
430                                              (GEOM::GEOM_Object_ptr theBase,
431                                               GEOM::GEOM_Object_ptr thePoint1,
432                                               GEOM::GEOM_Object_ptr thePoint2)
433 {
434   GEOM::GEOM_Object_var aGEOMObject;
435
436   //Set a not done flag
437   GetOperations()->SetNotDone();
438
439   if (theBase == NULL || thePoint1 == NULL || thePoint2 == NULL)
440     return aGEOMObject._retn();
441
442   //Get the reference objects
443   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
444     (theBase->GetStudyID(), theBase->GetEntry());
445   Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
446     (thePoint1->GetStudyID(), thePoint1->GetEntry());
447   Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
448     (thePoint2->GetStudyID(), thePoint2->GetEntry());
449
450   if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull())
451     return aGEOMObject._retn();
452
453   //Create the Prism
454   Handle(GEOM_Object) anObject =
455     GetOperations()->MakePrismTwoPnt2Ways(aBase, aPoint1, aPoint2);
456   if (!GetOperations()->IsDone() || anObject.IsNull())
457     return aGEOMObject._retn();
458
459   return GetObject(anObject);
460 }
461
462 //=============================================================================
463 /*!
464  *  MakePipe
465  */
466 //=============================================================================
467 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipe
468                  (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath)
469 {
470   GEOM::GEOM_Object_var aGEOMObject;
471
472   //Set a not done flag
473   GetOperations()->SetNotDone();
474
475   if (theBase == NULL || thePath == NULL) return aGEOMObject._retn();
476
477   //Get the reference objects
478   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
479     (theBase->GetStudyID(), theBase->GetEntry());
480   Handle(GEOM_Object) aPath = GetOperations()->GetEngine()->GetObject
481     (thePath->GetStudyID(), thePath->GetEntry());
482
483   if (aBase.IsNull() || aPath.IsNull()) return aGEOMObject._retn();
484
485   //Create the Pipe
486   Handle(GEOM_Object) anObject =
487     GetOperations()->MakePipe(aBase, aPath);
488   if (!GetOperations()->IsDone() || anObject.IsNull())
489     return aGEOMObject._retn();
490
491   return GetObject(anObject);
492 }
493
494 //=============================================================================
495 /*!
496  *  MakeRevolutionAxisAngle
497  */
498 //=============================================================================
499 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle
500                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis,
501                        CORBA::Double theAngle)
502 {
503   GEOM::GEOM_Object_var aGEOMObject;
504
505   //Set a not done flag
506   GetOperations()->SetNotDone();
507
508   if (theBase == NULL || theAxis == NULL) return aGEOMObject._retn();
509
510   //Get the reference objects
511   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
512     (theBase->GetStudyID(), theBase->GetEntry());
513   Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
514     (theAxis->GetStudyID(), theAxis->GetEntry());
515
516   if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn();
517
518   //Create the Revolution
519   Handle(GEOM_Object) anObject =
520       GetOperations()->MakeRevolutionAxisAngle(aBase, anAxis, theAngle);
521   if (!GetOperations()->IsDone() || anObject.IsNull())
522     return aGEOMObject._retn();
523
524   return GetObject(anObject);
525 }
526
527 //=============================================================================
528 /*!
529  *  MakeRevolutionAxisAngle2Ways
530  */
531 //=============================================================================
532 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle2Ways
533                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis,
534                        CORBA::Double theAngle)
535 {
536   GEOM::GEOM_Object_var aGEOMObject;
537
538   //Set a not done flag
539   GetOperations()->SetNotDone();
540
541   if (theBase == NULL || theAxis == NULL) return aGEOMObject._retn();
542
543   //Get the reference objects
544   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
545     (theBase->GetStudyID(), theBase->GetEntry());
546   Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
547     (theAxis->GetStudyID(), theAxis->GetEntry());
548
549   if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn();
550
551   //Create the Revolution
552   Handle(GEOM_Object) anObject =
553       GetOperations()->MakeRevolutionAxisAngle2Ways(aBase, anAxis, theAngle);
554   if (!GetOperations()->IsDone() || anObject.IsNull())
555     return aGEOMObject._retn();
556
557   return GetObject(anObject);
558 }
559
560 //=============================================================================
561 /*!
562  *  MakeFilling
563  */
564 //=============================================================================
565 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape,
566                                                             CORBA::Long theMinDeg,
567                                                             CORBA::Long theMaxDeg,
568                                                             CORBA::Double theTol2D,
569                                                             CORBA::Double theTol3D,
570                                                             CORBA::Long theNbIter,
571                                                             CORBA::Boolean theApprox)
572 {
573   GEOM::GEOM_Object_var aGEOMObject;
574
575   //Set a not done flag
576   GetOperations()->SetNotDone();
577
578   if (theShape == NULL) return aGEOMObject._retn();
579
580   //Get the reference objects
581   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
582     (theShape->GetStudyID(), theShape->GetEntry());
583
584   if (aShape.IsNull()) return aGEOMObject._retn();
585
586   //Create the Solid
587   Handle(GEOM_Object) anObject = GetOperations()->MakeFilling(aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, theApprox);
588   if (!GetOperations()->IsDone() || anObject.IsNull())
589     return aGEOMObject._retn();
590
591   return GetObject(anObject);
592 }
593
594 //=============================================================================
595 /*!
596  *  MakeThruSections
597  */
598 //=============================================================================
599 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeThruSections(const GEOM::ListOfGO& theSeqSections,
600                                                                  CORBA::Boolean theModeSolid,
601                                                                  CORBA::Double thePreci,
602                                                                  CORBA::Boolean theRuled)
603 {
604    GEOM::GEOM_Object_var aGEOMObject;
605
606   //Set a not done flag
607   GetOperations()->SetNotDone();
608   Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
609   int ind, aLen;
610
611   //Get the shapes
612   aLen = theSeqSections.length();
613   for (ind = 0; ind < aLen; ind++) {
614     if (theSeqSections[ind] == NULL) continue;
615     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
616       (theSeqSections[ind]->GetStudyID(), theSeqSections[ind]->GetEntry());
617     if (!aSh.IsNull())
618       aSeqSections->Append(aSh);
619   }
620   if(!aSeqSections->Length())
621     return aGEOMObject._retn();
622
623   // Make shell or solid
624   Handle(GEOM_Object) anObject =
625     GetOperations()->MakeThruSections(aSeqSections,theModeSolid,thePreci,theRuled);
626   if (!GetOperations()->IsDone() || anObject.IsNull())
627     return aGEOMObject._retn();
628
629   return GetObject(anObject);
630 }
631
632 //=============================================================================
633 /*!
634  *  MakePipeWithDifferentSections
635  */
636 //=============================================================================
637 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeWithDifferentSections(const GEOM::ListOfGO& theBases,
638                                                                               const GEOM::ListOfGO& theLocations,
639                                                                               GEOM::GEOM_Object_ptr thePath,
640                                                                               CORBA::Boolean theWithContact,
641                                                                               CORBA::Boolean theWithCorrections)
642 {
643    GEOM::GEOM_Object_var aGEOMObject;
644
645   //Set a not done flag
646   GetOperations()->SetNotDone();
647   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
648   Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient;
649   int ind=0, aNbBases =0,aNbLocs=0;
650   
651   //Get the shapes
652   aNbBases = theBases.length();
653   aNbLocs = theLocations.length();
654
655   if( aNbLocs &&  aNbBases != aNbLocs)
656     return aGEOMObject._retn();
657   
658    Handle(GEOM_Object) aPath = GetOperations()->GetEngine()->GetObject
659       (thePath->GetStudyID(), thePath->GetEntry());
660    if(aPath.IsNull())
661      return aGEOMObject._retn();
662
663   for (ind = 0; ind < aNbBases; ind++) {
664     if (theBases[ind] == NULL) continue;
665     Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject(theBases[ind]->GetStudyID(), 
666                         theBases[ind]->GetEntry());
667     if(aBase.IsNull())
668       continue;
669     if(aNbLocs)
670     {
671       Handle(GEOM_Object) aLoc = GetOperations()->GetEngine()->GetObject
672         (theLocations[ind]->GetStudyID(), theLocations[ind]->GetEntry());
673       if(aLoc.IsNull())
674         continue;
675       aSeqLocations->Append(aLoc);
676     }
677     aSeqBases->Append(aBase);
678   }
679   if(!aSeqBases->Length())
680     return aGEOMObject._retn();
681
682   // Make pipe
683   Handle(GEOM_Object) anObject =
684     GetOperations()->MakePipeWithDifferentSections(aSeqBases,aSeqLocations ,aPath,
685                                                    theWithContact,theWithCorrections);
686   if (!GetOperations()->IsDone() || anObject.IsNull())
687     return aGEOMObject._retn();
688
689   return GetObject(anObject);
690 }
691
692
693 //=============================================================================
694 /*!
695  *  MakePipeWithShellSections
696  */
697 //=============================================================================
698 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeWithShellSections
699                  (const GEOM::ListOfGO& theBases,
700                   const GEOM::ListOfGO& theSubBases,
701                   const GEOM::ListOfGO& theLocations,
702                   GEOM::GEOM_Object_ptr thePath,
703                   CORBA::Boolean theWithContact,
704                   CORBA::Boolean theWithCorrections)
705 {
706   GEOM::GEOM_Object_var aGEOMObject;
707
708   //Set a not done flag
709   GetOperations()->SetNotDone();
710   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
711   Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
712   Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient;
713   int ind=0, aNbBases=0, aNbSubBases=0, aNbLocs=0;
714   
715   //Get the shapes
716   aNbBases = theBases.length();
717   aNbSubBases = theSubBases.length();
718   aNbLocs = theLocations.length();
719
720   if( aNbLocs &&  aNbBases != aNbLocs)
721     return aGEOMObject._retn();
722   
723    Handle(GEOM_Object) aPath = GetOperations()->GetEngine()->GetObject
724       (thePath->GetStudyID(), thePath->GetEntry());
725    if(aPath.IsNull())
726      return aGEOMObject._retn();
727
728   for (ind = 0; ind < aNbBases; ind++) {
729     if (theBases[ind] == NULL) continue;
730     Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->
731       GetObject(theBases[ind]->GetStudyID(), theBases[ind]->GetEntry());
732     if(aBase.IsNull())
733       continue;
734     if(aNbLocs) {
735       Handle(GEOM_Object) aLoc = GetOperations()->GetEngine()->GetObject
736         (theLocations[ind]->GetStudyID(), theLocations[ind]->GetEntry());
737       if(aLoc.IsNull())
738         continue;
739       aSeqLocations->Append(aLoc);
740     }
741     aSeqBases->Append(aBase);
742
743     if(aNbSubBases>=aNbBases) {
744       Handle(GEOM_Object) aSubBase = GetOperations()->GetEngine()->
745         GetObject(theSubBases[ind]->GetStudyID(), theSubBases[ind]->GetEntry());
746       if(aSubBase.IsNull()) {
747         aSeqSubBases->Clear();
748         aNbSubBases = 0;
749         continue;
750       }
751       aSeqSubBases->Append(aSubBase);
752     }
753
754   }
755   if(!aSeqBases->Length())
756     return aGEOMObject._retn();
757
758   // Make pipe
759   Handle(GEOM_Object) anObject =
760     GetOperations()->MakePipeWithShellSections(aSeqBases, aSeqSubBases,
761                                                aSeqLocations, aPath,
762                                                theWithContact, theWithCorrections);
763   if (!GetOperations()->IsDone() || anObject.IsNull())
764     return aGEOMObject._retn();
765
766   return GetObject(anObject);
767 }
768
769
770 //=============================================================================
771 /*!
772  *  MakePipeShellsWithoutPath
773  */
774 //=============================================================================
775 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeShellsWithoutPath
776                  (const GEOM::ListOfGO& theBases,
777                   const GEOM::ListOfGO& theLocations)
778 {
779   GEOM::GEOM_Object_var aGEOMObject;
780
781   //Set a not done flag
782   GetOperations()->SetNotDone();
783   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
784   Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient;
785   int ind=0, aNbBases=0, aNbLocs=0;
786   
787   //Get the shapes
788   aNbBases = theBases.length();
789   aNbLocs = theLocations.length();
790
791   if( aNbLocs &&  aNbBases != aNbLocs)
792     return aGEOMObject._retn();
793   
794   for (ind = 0; ind < aNbBases; ind++) {
795     if (theBases[ind] == NULL) continue;
796     Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->
797       GetObject(theBases[ind]->GetStudyID(), theBases[ind]->GetEntry());
798     if(aBase.IsNull())
799       continue;
800     if(aNbLocs) {
801       Handle(GEOM_Object) aLoc = GetOperations()->GetEngine()->GetObject
802         (theLocations[ind]->GetStudyID(), theLocations[ind]->GetEntry());
803       if(aLoc.IsNull())
804         continue;
805       aSeqLocations->Append(aLoc);
806     }
807     aSeqBases->Append(aBase);
808   }
809
810   if(!aSeqBases->Length())
811     return aGEOMObject._retn();
812
813   // Make pipe
814   Handle(GEOM_Object) anObject =
815     GetOperations()->MakePipeShellsWithoutPath(aSeqBases,aSeqLocations);
816
817   if (!GetOperations()->IsDone() || anObject.IsNull())
818     return aGEOMObject._retn();
819
820   return GetObject(anObject);
821 }