Salome HOME
Fix problem with GetShapesOnCylinder: CRASH, when result can not be obtained
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 using namespace std;
2
3 #include "GEOM_IShapesOperations_i.hh"
4
5 #include "utilities.h"
6 #include "OpUtil.hxx"
7 #include "Utils_ExceptHandlers.hxx"
8
9 #include "GEOM_Engine.hxx"
10 #include "GEOM_Object.hxx"
11
12 #include <TColStd_HSequenceOfTransient.hxx>
13 #include <TColStd_HArray1OfInteger.hxx>
14
15 //=============================================================================
16 /*!
17  *   constructor:
18  */
19 //=============================================================================
20 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
21                                                     GEOM::GEOM_Gen_ptr theEngine,
22                                                     ::GEOMImpl_IShapesOperations* theImpl)
23 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
24 {
25   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
26 }
27
28 //=============================================================================
29 /*!
30  *  destructor
31  */
32 //=============================================================================
33 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
34 {
35   MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
36 }
37
38
39 //=============================================================================
40 /*!
41  *  MakeEdge
42  */
43 //=============================================================================
44 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
45                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
46 {
47   GEOM::GEOM_Object_var aGEOMObject;
48
49   //Set a not done flag
50   GetOperations()->SetNotDone();
51
52   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
53
54   //Get the reference points
55   Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
56     (thePnt1->GetStudyID(), thePnt1->GetEntry());
57   Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
58     (thePnt2->GetStudyID(), thePnt2->GetEntry());
59
60   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
61
62   //Create the Edge
63   Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
64   if (!GetOperations()->IsDone() || anObject.IsNull())
65     return aGEOMObject._retn();
66
67   return GetObject(anObject);
68 }
69
70 //=============================================================================
71 /*!
72  *  MakeWire
73  */
74 //=============================================================================
75 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
76                                       (const GEOM::ListOfGO& theEdgesAndWires)
77 {
78   GEOM::GEOM_Object_var aGEOMObject;
79
80   //Set a not done flag
81   GetOperations()->SetNotDone();
82
83   int ind, aLen;
84   list<Handle(GEOM_Object)> aShapes;
85
86   //Get the shapes
87   aLen = theEdgesAndWires.length();
88   for (ind = 0; ind < aLen; ind++) {
89     if (theEdgesAndWires[ind] == NULL) return aGEOMObject._retn();
90     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
91       (theEdgesAndWires[ind]->GetStudyID(), theEdgesAndWires[ind]->GetEntry());
92     if (aSh.IsNull()) return aGEOMObject._retn();
93     aShapes.push_back(aSh);
94   }
95
96   // Make Solid
97   Handle(GEOM_Object) anObject =
98     GetOperations()->MakeWire(aShapes);
99   if (!GetOperations()->IsDone() || anObject.IsNull())
100     return aGEOMObject._retn();
101
102   return GetObject(anObject);
103 }
104
105 //=============================================================================
106 /*!
107  *  MakeFace
108  */
109 //=============================================================================
110 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
111                       (GEOM::GEOM_Object_ptr theWire,
112                        const CORBA::Boolean  isPlanarWanted)
113 {
114   GEOM::GEOM_Object_var aGEOMObject;
115
116   //Set a not done flag
117   GetOperations()->SetNotDone();
118
119   if (theWire == NULL) return aGEOMObject._retn();
120
121   //Get the reference wire
122   Handle(GEOM_Object) aWire = GetOperations()->GetEngine()->GetObject
123     (theWire->GetStudyID(), theWire->GetEntry());
124
125   if (aWire.IsNull()) return aGEOMObject._retn();
126
127   //Create the Face
128   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
129   if (!GetOperations()->IsDone() || anObject.IsNull())
130     return aGEOMObject._retn();
131
132   return GetObject(anObject);
133 }
134
135 //=============================================================================
136 /*!
137  *  MakeFaceWires
138  */
139 //=============================================================================
140 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
141                                          (const GEOM::ListOfGO& theWires,
142                                           const CORBA::Boolean  isPlanarWanted)
143 {
144   GEOM::GEOM_Object_var aGEOMObject;
145
146   //Set a not done flag
147   GetOperations()->SetNotDone();
148
149   int ind, aLen;
150   list<Handle(GEOM_Object)> aShapes;
151
152   //Get the shapes
153   aLen = theWires.length();
154   for (ind = 0; ind < aLen; ind++) {
155     if (theWires[ind] == NULL) return aGEOMObject._retn();
156     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
157       (theWires[ind]->GetStudyID(), theWires[ind]->GetEntry());
158     if (aSh.IsNull()) return aGEOMObject._retn();
159     aShapes.push_back(aSh);
160   }
161
162   // Make Face
163   Handle(GEOM_Object) anObject =
164     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
165   if (!GetOperations()->IsDone() || anObject.IsNull())
166     return aGEOMObject._retn();
167
168   return GetObject(anObject);
169 }
170
171 //=============================================================================
172 /*!
173  *  MakeShell
174  */
175 //=============================================================================
176 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
177                                       (const GEOM::ListOfGO& theFacesAndShells)
178 {
179   GEOM::GEOM_Object_var aGEOMObject;
180
181   //Set a not done flag
182   GetOperations()->SetNotDone();
183
184   int ind, aLen;
185   list<Handle(GEOM_Object)> aShapes;
186
187   //Get the shapes
188   aLen = theFacesAndShells.length();
189   for (ind = 0; ind < aLen; ind++) {
190     if (theFacesAndShells[ind] == NULL) return aGEOMObject._retn();
191     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
192       (theFacesAndShells[ind]->GetStudyID(), theFacesAndShells[ind]->GetEntry());
193     if (aSh.IsNull()) return aGEOMObject._retn();
194     aShapes.push_back(aSh);
195   }
196
197   // Make Solid
198   Handle(GEOM_Object) anObject =
199     GetOperations()->MakeShell(aShapes);
200   if (!GetOperations()->IsDone() || anObject.IsNull())
201     return aGEOMObject._retn();
202
203   return GetObject(anObject);
204 }
205
206 //=============================================================================
207 /*!
208  *  MakeSolidShell
209  */
210 //=============================================================================
211 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
212                                                 (GEOM::GEOM_Object_ptr theShell)
213 {
214   GEOM::GEOM_Object_var aGEOMObject;
215
216   //Set a not done flag
217   GetOperations()->SetNotDone();
218
219   if (theShell == NULL) return aGEOMObject._retn();
220
221   //Get the reference objects
222   Handle(GEOM_Object) aShell = GetOperations()->GetEngine()->GetObject
223     (theShell->GetStudyID(), theShell->GetEntry());
224
225   if (aShell.IsNull()) return aGEOMObject._retn();
226
227   //Create the Solid
228   Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
229   if (!GetOperations()->IsDone() || anObject.IsNull())
230     return aGEOMObject._retn();
231
232   return GetObject(anObject);
233 }
234
235 //=============================================================================
236 /*!
237  *  MakeSolidShells
238  */
239 //=============================================================================
240 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
241                                       (const GEOM::ListOfGO& theShells)
242 {
243   GEOM::GEOM_Object_var aGEOMObject;
244
245   //Set a not done flag
246   GetOperations()->SetNotDone();
247
248   int ind, aLen;
249   list<Handle(GEOM_Object)> aShapes;
250
251   //Get the shapes
252   aLen = theShells.length();
253   for (ind = 0; ind < aLen; ind++) {
254     if (theShells[ind] == NULL) return aGEOMObject._retn();
255     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
256       (theShells[ind]->GetStudyID(), theShells[ind]->GetEntry());
257     if (aSh.IsNull()) return aGEOMObject._retn();
258     aShapes.push_back(aSh);
259   }
260
261   // Make Solid
262   Handle(GEOM_Object) anObject =
263     GetOperations()->MakeSolidShells(aShapes);
264   if (!GetOperations()->IsDone() || anObject.IsNull())
265     return aGEOMObject._retn();
266
267   return GetObject(anObject);
268 }
269
270 //=============================================================================
271 /*!
272  *  MakeCompound
273  */
274 //=============================================================================
275 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
276                                       (const GEOM::ListOfGO& theShapes)
277 {
278   GEOM::GEOM_Object_var aGEOMObject;
279
280   //Set a not done flag
281   GetOperations()->SetNotDone();
282
283   int ind, aLen;
284   list<Handle(GEOM_Object)> aShapes;
285
286   //Get the shapes
287   aLen = theShapes.length();
288   for (ind = 0; ind < aLen; ind++) {
289     if (theShapes[ind] == NULL) return aGEOMObject._retn();
290     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
291       (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
292     if (aSh.IsNull()) return aGEOMObject._retn();
293     aShapes.push_back(aSh);
294   }
295
296   // Make Solid
297   Handle(GEOM_Object) anObject =
298     GetOperations()->MakeCompound(aShapes);
299   if (!GetOperations()->IsDone() || anObject.IsNull())
300     return aGEOMObject._retn();
301
302   return GetObject(anObject);
303 }
304
305 //=============================================================================
306 /*!
307  *  MakeGlueFaces
308  */
309 //=============================================================================
310 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
311                                            (GEOM::GEOM_Object_ptr theShape,
312                                             const CORBA::Double   theTolerance)
313 {
314   GEOM::GEOM_Object_var aGEOMObject;
315
316   //Set a not done flag
317   GetOperations()->SetNotDone();
318
319   if (theShape == NULL) return aGEOMObject._retn();
320
321   //Get the reference objects
322   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
323     (theShape->GetStudyID(), theShape->GetEntry());
324
325   if (aShape.IsNull()) return aGEOMObject._retn();
326
327   //Perform the gluing
328   Handle(GEOM_Object) anObject =
329     GetOperations()->MakeGlueFaces(aShape, theTolerance);
330   //if (!GetOperations()->IsDone() || anObject.IsNull())
331   // to allow warning
332   if (anObject.IsNull())
333     return aGEOMObject._retn();
334
335   return GetObject(anObject);
336 }
337
338 //=============================================================================
339 /*!
340  *  MakeExplode
341  */
342 //=============================================================================
343 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
344                                                        const CORBA::Long     theShapeType,
345                                                        const CORBA::Boolean  isSorted)
346 {
347   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
348   if (theShape == NULL) return aSeq._retn();
349
350   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
351     (theShape->GetStudyID(), theShape->GetEntry());
352
353   Handle(TColStd_HSequenceOfTransient) aHSeq =
354     GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
355   if (!GetOperations()->IsDone() || aHSeq.IsNull())
356     return aSeq._retn();
357
358   Standard_Integer aLength = aHSeq->Length();
359   aSeq->length(aLength);
360   for (Standard_Integer i = 1; i <= aLength; i++)
361     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
362
363   return aSeq._retn();
364 }
365
366 //=============================================================================
367 /*!
368  *  SubShapeAllIDs
369  */
370 //=============================================================================
371 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
372                                                             const CORBA::Long     theShapeType,
373                                                             const CORBA::Boolean  isSorted)
374 {
375   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
376   if (theShape == NULL) return aSeq._retn();
377
378   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
379     (theShape->GetStudyID(), theShape->GetEntry());
380
381   Handle(TColStd_HSequenceOfInteger) aHSeq =
382     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
383   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
384
385   Standard_Integer aLength = aHSeq->Length();
386   aSeq->length(aLength);
387   for (Standard_Integer i = 1; i <= aLength; i++)
388     aSeq[i-1] = aHSeq->Value(i);
389
390   return aSeq._retn();
391 }
392
393 //=============================================================================
394 /*!
395  *  GetSubShape
396  */
397 //=============================================================================
398 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
399                                            (GEOM::GEOM_Object_ptr theMainShape,
400                                             const CORBA::Long     theID)
401 {
402   GEOM::GEOM_Object_var aGEOMObject;
403
404   //Set a not done flag
405   GetOperations()->SetNotDone();
406
407   if (theMainShape == NULL) return aGEOMObject._retn();
408
409   //Get the reference objects
410   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
411     (theMainShape->GetStudyID(), theMainShape->GetEntry());
412
413   if (aShape.IsNull()) return aGEOMObject._retn();
414
415   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
416   if (!GetOperations()->IsDone() || anObject.IsNull())
417     return aGEOMObject._retn();
418
419   return GetObject(anObject);
420 }
421
422 //=============================================================================
423 /*!
424  *  NumberOfFaces
425  */
426 //=============================================================================
427 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
428 {
429   if (theShape == NULL) return -1;
430
431   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
432     (theShape->GetStudyID(), theShape->GetEntry());
433
434   CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
435   if (!GetOperations()->IsDone()) return -1;
436
437   return aNb;
438 }
439
440 //=============================================================================
441 /*!
442  *  NumberOfEdges
443  */
444 //=============================================================================
445 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
446 {
447   if (theShape == NULL) return -1;
448
449   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
450     (theShape->GetStudyID(), theShape->GetEntry());
451
452   CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
453   if (!GetOperations()->IsDone()) return -1;
454
455   return aNb;
456 }
457
458 //=============================================================================
459 /*!
460  *  ChangeOrientation
461  */
462 //=============================================================================
463 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
464                                                 (GEOM::GEOM_Object_ptr theShape)
465 {
466   GEOM::GEOM_Object_var aGEOMObject;
467
468   //Set a not done flag
469   GetOperations()->SetNotDone();
470
471   if (theShape == NULL) return aGEOMObject._retn();
472
473   //Get the reference objects
474   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
475     (theShape->GetStudyID(), theShape->GetEntry());
476
477   if (aShape.IsNull()) return aGEOMObject._retn();
478
479   //Create the Solid
480   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
481   if (!GetOperations()->IsDone() || anObject.IsNull())
482     return aGEOMObject._retn();
483
484   return GetObject(anObject);
485 }
486
487 //=============================================================================
488 /*!
489  *  GetFreeFacesIDs
490  */
491 //=============================================================================
492 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
493 {
494   //Set a not done flag
495   GetOperations()->SetNotDone();
496
497   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
498   if (theShape == NULL) return aSeq._retn();
499
500   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
501     (theShape->GetStudyID(), theShape->GetEntry());
502
503   Handle(TColStd_HSequenceOfInteger) aHSeq =
504     GetOperations()->GetFreeFacesIDs(aShape);
505   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
506
507   Standard_Integer aLength = aHSeq->Length();
508   aSeq->length(aLength);
509   for (Standard_Integer i = 1; i <= aLength; i++)
510     aSeq[i-1] = aHSeq->Value(i);
511
512   return aSeq._retn();
513 }
514
515 //=============================================================================
516 /*!
517  *  GetSharedShapes
518  */
519 //=============================================================================
520 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
521                                           (GEOM::GEOM_Object_ptr theShape1,
522                                            GEOM::GEOM_Object_ptr theShape2,
523                                            const CORBA::Long     theShapeType)
524 {
525   //Set a not done flag
526   GetOperations()->SetNotDone();
527
528   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
529   if (theShape1 == NULL ||
530       theShape2 == NULL) return aSeq._retn();
531
532   Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
533     (theShape1->GetStudyID(), theShape1->GetEntry());
534   Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
535     (theShape2->GetStudyID(), theShape2->GetEntry());
536
537   if (aShape1.IsNull() ||
538       aShape2.IsNull()) return aSeq._retn();
539
540   Handle(TColStd_HSequenceOfTransient) aHSeq =
541     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
542   if (!GetOperations()->IsDone() || aHSeq.IsNull())
543     return aSeq._retn();
544
545   Standard_Integer aLength = aHSeq->Length();
546   aSeq->length(aLength);
547   for (Standard_Integer i = 1; i <= aLength; i++)
548     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
549
550   return aSeq._retn();
551 }
552
553 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
554 {
555   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
556
557   switch (theState) {
558   case GEOM::ST_ON:
559     aState = GEOMAlgo_ST_ON;
560     break;
561   case GEOM::ST_OUT:
562     aState = GEOMAlgo_ST_OUT;
563     break;
564   case GEOM::ST_ONOUT:
565     aState = GEOMAlgo_ST_ONOUT;
566     break;
567   case GEOM::ST_IN:
568     aState = GEOMAlgo_ST_IN;
569     break;
570   case GEOM::ST_ONIN:
571     aState = GEOMAlgo_ST_ONIN;
572     break;
573   default:
574     break;
575   }
576
577   return aState;
578 }
579
580 //=============================================================================
581 /*!
582  *  GetShapesOnPlane
583  */
584 //=============================================================================
585 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
586                                                 (GEOM::GEOM_Object_ptr   theShape,
587                                                  const CORBA::Long       theShapeType,
588                                                  GEOM::GEOM_Object_ptr   theAx1,
589                                                  const GEOM::shape_state theState)
590 {
591   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
592
593   //Set a not done flag
594   GetOperations()->SetNotDone();
595
596   if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
597
598   //Get the reference objects
599   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
600     (theShape->GetStudyID(), theShape->GetEntry());
601   Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
602     (theAx1->GetStudyID(), theAx1->GetEntry());
603
604   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
605
606   //Get Shapes On Plane
607   Handle(TColStd_HSequenceOfTransient) aHSeq =
608     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
609   if (!GetOperations()->IsDone() || aHSeq.IsNull())
610     return aSeq._retn();
611
612   Standard_Integer aLength = aHSeq->Length();
613   aSeq->length(aLength);
614   for (Standard_Integer i = 1; i <= aLength; i++)
615     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
616
617   return aSeq._retn();
618 }
619
620 //=============================================================================
621 /*!
622  *  GetShapesOnCylinder
623  */
624 //=============================================================================
625 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
626                                                 (GEOM::GEOM_Object_ptr   theShape,
627                                                  const CORBA::Long       theShapeType,
628                                                  GEOM::GEOM_Object_ptr   theAxis,
629                                                  const CORBA::Double     theRadius,
630                                                  const GEOM::shape_state theState)
631 {
632   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
633
634   //Set a not done flag
635   GetOperations()->SetNotDone();
636
637   if (theShape == NULL || theAxis == NULL) return aSeq._retn();
638
639   //Get the reference objects
640   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
641     (theShape->GetStudyID(), theShape->GetEntry());
642   Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
643     (theAxis->GetStudyID(), theAxis->GetEntry());
644
645   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
646
647   //Get Shapes On Cylinder
648   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
649     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
650   if (!GetOperations()->IsDone() || aHSeq.IsNull())
651     return aSeq._retn();
652
653   Standard_Integer aLength = aHSeq->Length();
654   aSeq->length(aLength);
655   for (Standard_Integer i = 1; i <= aLength; i++)
656     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
657
658   return aSeq._retn();
659 }
660
661 //=============================================================================
662 /*!
663  *  GetShapesOnSphere
664  */
665 //=============================================================================
666 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
667                                                 (GEOM::GEOM_Object_ptr   theShape,
668                                                  const CORBA::Long       theShapeType,
669                                                  GEOM::GEOM_Object_ptr   theCenter,
670                                                  const CORBA::Double     theRadius,
671                                                  const GEOM::shape_state theState)
672 {
673   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
674
675   //Set a not done flag
676   GetOperations()->SetNotDone();
677
678   if (theShape == NULL || theCenter == NULL) return aSeq._retn();
679
680   //Get the reference objects
681   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
682     (theShape->GetStudyID(), theShape->GetEntry());
683   Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
684     (theCenter->GetStudyID(), theCenter->GetEntry());
685
686   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
687
688   //Get Shapes On Sphere
689   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
690     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
691   if (!GetOperations()->IsDone() || aHSeq.IsNull())
692     return aSeq._retn();
693
694   Standard_Integer aLength = aHSeq->Length();
695   aSeq->length(aLength);
696   for (Standard_Integer i = 1; i <= aLength; i++)
697     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
698
699   return aSeq._retn();
700 }
701
702 //=============================================================================
703 /*!
704  *  GetInPlace
705  */
706 //=============================================================================
707 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
708                                           (GEOM::GEOM_Object_ptr theShapeWhere,
709                                            GEOM::GEOM_Object_ptr theShapeWhat)
710 {
711   GEOM::GEOM_Object_var aGEOMObject;
712
713   //Set a not done flag
714   GetOperations()->SetNotDone();
715
716   if (theShapeWhere == NULL ||
717       theShapeWhat == NULL) return aGEOMObject._retn();
718
719   //Get the reference objects
720   Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
721     (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
722   Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
723     (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
724
725   if (aShapeWhere.IsNull() ||
726       aShapeWhat.IsNull()) return aGEOMObject._retn();
727
728   //Get Shapes in place of aShapeWhat
729   Handle(GEOM_Object) anObject =
730     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
731   if (!GetOperations()->IsDone() || anObject.IsNull())
732     return aGEOMObject._retn();
733
734   return GetObject(anObject);
735 }