Salome HOME
Merging with WPdev
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_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_IShapesOperations_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 #include <TColStd_HSequenceOfTransient.hxx>
32 #include <TColStd_HArray1OfInteger.hxx>
33
34 //=============================================================================
35 /*!
36  *   constructor:
37  */
38 //=============================================================================
39 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
40                                                     GEOM::GEOM_Gen_ptr theEngine,
41                                                     ::GEOMImpl_IShapesOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 {
44   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
45 }
46
47 //=============================================================================
48 /*!
49  *  destructor
50  */
51 //=============================================================================
52 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
53 {
54   MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
55 }
56
57
58 //=============================================================================
59 /*!
60  *  MakeEdge
61  */
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
64                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
65 {
66   GEOM::GEOM_Object_var aGEOMObject;
67
68   //Set a not done flag
69   GetOperations()->SetNotDone();
70
71   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
72
73   //Get the reference points
74   Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
75     (thePnt1->GetStudyID(), thePnt1->GetEntry());
76   Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
77     (thePnt2->GetStudyID(), thePnt2->GetEntry());
78
79   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
80
81   //Create the Edge
82   Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
83   if (!GetOperations()->IsDone() || anObject.IsNull())
84     return aGEOMObject._retn();
85
86   return GetObject(anObject);
87 }
88
89 //=============================================================================
90 /*!
91  *  MakeWire
92  */
93 //=============================================================================
94 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
95                                       (const GEOM::ListOfGO& theEdgesAndWires)
96 {
97   GEOM::GEOM_Object_var aGEOMObject;
98
99   //Set a not done flag
100   GetOperations()->SetNotDone();
101
102   int ind, aLen;
103   list<Handle(GEOM_Object)> aShapes;
104
105   //Get the shapes
106   aLen = theEdgesAndWires.length();
107   for (ind = 0; ind < aLen; ind++) {
108     if (theEdgesAndWires[ind] == NULL) return aGEOMObject._retn();
109     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
110       (theEdgesAndWires[ind]->GetStudyID(), theEdgesAndWires[ind]->GetEntry());
111     if (aSh.IsNull()) return aGEOMObject._retn();
112     aShapes.push_back(aSh);
113   }
114
115   // Make Solid
116   Handle(GEOM_Object) anObject =
117     GetOperations()->MakeWire(aShapes);
118   if (!GetOperations()->IsDone() || anObject.IsNull())
119     return aGEOMObject._retn();
120
121   return GetObject(anObject);
122 }
123
124 //=============================================================================
125 /*!
126  *  MakeFace
127  */
128 //=============================================================================
129 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
130                       (GEOM::GEOM_Object_ptr theWire,
131                        const CORBA::Boolean  isPlanarWanted)
132 {
133   GEOM::GEOM_Object_var aGEOMObject;
134
135   //Set a not done flag
136   GetOperations()->SetNotDone();
137
138   if (theWire == NULL) return aGEOMObject._retn();
139
140   //Get the reference wire
141   Handle(GEOM_Object) aWire = GetOperations()->GetEngine()->GetObject
142     (theWire->GetStudyID(), theWire->GetEntry());
143
144   if (aWire.IsNull()) return aGEOMObject._retn();
145
146   //Create the Face
147   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
148   if (!GetOperations()->IsDone() || anObject.IsNull())
149     return aGEOMObject._retn();
150
151   return GetObject(anObject);
152 }
153
154 //=============================================================================
155 /*!
156  *  MakeFaceWires
157  */
158 //=============================================================================
159 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
160                                          (const GEOM::ListOfGO& theWires,
161                                           const CORBA::Boolean  isPlanarWanted)
162 {
163   GEOM::GEOM_Object_var aGEOMObject;
164
165   //Set a not done flag
166   GetOperations()->SetNotDone();
167
168   int ind, aLen;
169   list<Handle(GEOM_Object)> aShapes;
170
171   //Get the shapes
172   aLen = theWires.length();
173   for (ind = 0; ind < aLen; ind++) {
174     if (theWires[ind] == NULL) return aGEOMObject._retn();
175     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
176       (theWires[ind]->GetStudyID(), theWires[ind]->GetEntry());
177     if (aSh.IsNull()) return aGEOMObject._retn();
178     aShapes.push_back(aSh);
179   }
180
181   // Make Face
182   Handle(GEOM_Object) anObject =
183     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
184   if (!GetOperations()->IsDone() || anObject.IsNull())
185     return aGEOMObject._retn();
186
187   return GetObject(anObject);
188 }
189
190 //=============================================================================
191 /*!
192  *  MakeShell
193  */
194 //=============================================================================
195 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
196                                       (const GEOM::ListOfGO& theFacesAndShells)
197 {
198   GEOM::GEOM_Object_var aGEOMObject;
199
200   //Set a not done flag
201   GetOperations()->SetNotDone();
202
203   int ind, aLen;
204   list<Handle(GEOM_Object)> aShapes;
205
206   //Get the shapes
207   aLen = theFacesAndShells.length();
208   for (ind = 0; ind < aLen; ind++) {
209     if (theFacesAndShells[ind] == NULL) return aGEOMObject._retn();
210     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
211       (theFacesAndShells[ind]->GetStudyID(), theFacesAndShells[ind]->GetEntry());
212     if (aSh.IsNull()) return aGEOMObject._retn();
213     aShapes.push_back(aSh);
214   }
215
216   // Make Solid
217   Handle(GEOM_Object) anObject =
218     GetOperations()->MakeShell(aShapes);
219   if (!GetOperations()->IsDone() || anObject.IsNull())
220     return aGEOMObject._retn();
221
222   return GetObject(anObject);
223 }
224
225 //=============================================================================
226 /*!
227  *  MakeSolidShell
228  */
229 //=============================================================================
230 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
231                                                 (GEOM::GEOM_Object_ptr theShell)
232 {
233   GEOM::GEOM_Object_var aGEOMObject;
234
235   //Set a not done flag
236   GetOperations()->SetNotDone();
237
238   if (theShell == NULL) return aGEOMObject._retn();
239
240   //Get the reference objects
241   Handle(GEOM_Object) aShell = GetOperations()->GetEngine()->GetObject
242     (theShell->GetStudyID(), theShell->GetEntry());
243
244   if (aShell.IsNull()) return aGEOMObject._retn();
245
246   //Create the Solid
247   Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
248   if (!GetOperations()->IsDone() || anObject.IsNull())
249     return aGEOMObject._retn();
250
251   return GetObject(anObject);
252 }
253
254 //=============================================================================
255 /*!
256  *  MakeSolidShells
257  */
258 //=============================================================================
259 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
260                                       (const GEOM::ListOfGO& theShells)
261 {
262   GEOM::GEOM_Object_var aGEOMObject;
263
264   //Set a not done flag
265   GetOperations()->SetNotDone();
266
267   int ind, aLen;
268   list<Handle(GEOM_Object)> aShapes;
269
270   //Get the shapes
271   aLen = theShells.length();
272   for (ind = 0; ind < aLen; ind++) {
273     if (theShells[ind] == NULL) return aGEOMObject._retn();
274     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
275       (theShells[ind]->GetStudyID(), theShells[ind]->GetEntry());
276     if (aSh.IsNull()) return aGEOMObject._retn();
277     aShapes.push_back(aSh);
278   }
279
280   // Make Solid
281   Handle(GEOM_Object) anObject =
282     GetOperations()->MakeSolidShells(aShapes);
283   if (!GetOperations()->IsDone() || anObject.IsNull())
284     return aGEOMObject._retn();
285
286   return GetObject(anObject);
287 }
288
289 //=============================================================================
290 /*!
291  *  MakeCompound
292  */
293 //=============================================================================
294 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
295                                       (const GEOM::ListOfGO& theShapes)
296 {
297   GEOM::GEOM_Object_var aGEOMObject;
298
299   //Set a not done flag
300   GetOperations()->SetNotDone();
301
302   int ind, aLen;
303   list<Handle(GEOM_Object)> aShapes;
304
305   //Get the shapes
306   aLen = theShapes.length();
307   for (ind = 0; ind < aLen; ind++) {
308     if (theShapes[ind] == NULL) return aGEOMObject._retn();
309     Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
310       (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
311     if (aSh.IsNull()) return aGEOMObject._retn();
312     aShapes.push_back(aSh);
313   }
314
315   // Make Solid
316   Handle(GEOM_Object) anObject =
317     GetOperations()->MakeCompound(aShapes);
318   if (!GetOperations()->IsDone() || anObject.IsNull())
319     return aGEOMObject._retn();
320
321   return GetObject(anObject);
322 }
323
324 //=============================================================================
325 /*!
326  *  MakeGlueFaces
327  */
328 //=============================================================================
329 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
330                                            (GEOM::GEOM_Object_ptr theShape,
331                                             const CORBA::Double   theTolerance)
332 {
333   GEOM::GEOM_Object_var aGEOMObject;
334
335   //Set a not done flag
336   GetOperations()->SetNotDone();
337
338   if (theShape == NULL) return aGEOMObject._retn();
339
340   //Get the reference objects
341   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
342     (theShape->GetStudyID(), theShape->GetEntry());
343
344   if (aShape.IsNull()) return aGEOMObject._retn();
345
346   //Perform the gluing
347   Handle(GEOM_Object) anObject =
348     GetOperations()->MakeGlueFaces(aShape, theTolerance);
349   //if (!GetOperations()->IsDone() || anObject.IsNull())
350   // to allow warning
351   if (anObject.IsNull())
352     return aGEOMObject._retn();
353
354   return GetObject(anObject);
355 }
356
357 //=============================================================================
358 /*!
359  *  MakeExplode
360  */
361 //=============================================================================
362 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
363                                                        const CORBA::Long     theShapeType,
364                                                        const CORBA::Boolean  isSorted)
365 {
366   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
367   if (theShape == NULL) return aSeq._retn();
368
369   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
370     (theShape->GetStudyID(), theShape->GetEntry());
371
372   Handle(TColStd_HSequenceOfTransient) aHSeq =
373     GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
374   if (!GetOperations()->IsDone() || aHSeq.IsNull())
375     return aSeq._retn();
376
377   Standard_Integer aLength = aHSeq->Length();
378   aSeq->length(aLength);
379   for (Standard_Integer i = 1; i <= aLength; i++)
380     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
381
382   return aSeq._retn();
383 }
384
385 //=============================================================================
386 /*!
387  *  SubShapeAllIDs
388  */
389 //=============================================================================
390 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
391                                                             const CORBA::Long     theShapeType,
392                                                             const CORBA::Boolean  isSorted)
393 {
394   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
395   if (theShape == NULL) return aSeq._retn();
396
397   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
398     (theShape->GetStudyID(), theShape->GetEntry());
399
400   Handle(TColStd_HSequenceOfInteger) aHSeq =
401     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
402   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
403
404   Standard_Integer aLength = aHSeq->Length();
405   aSeq->length(aLength);
406   for (Standard_Integer i = 1; i <= aLength; i++)
407     aSeq[i-1] = aHSeq->Value(i);
408
409   return aSeq._retn();
410 }
411
412 //=============================================================================
413 /*!
414  *  GetSubShape
415  */
416 //=============================================================================
417 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
418                                            (GEOM::GEOM_Object_ptr theMainShape,
419                                             const CORBA::Long     theID)
420 {
421   GEOM::GEOM_Object_var aGEOMObject;
422
423   //Set a not done flag
424   GetOperations()->SetNotDone();
425
426   if (theMainShape == NULL) return aGEOMObject._retn();
427
428   //Get the reference objects
429   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
430     (theMainShape->GetStudyID(), theMainShape->GetEntry());
431
432   if (aShape.IsNull()) return aGEOMObject._retn();
433
434   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
435   if (!GetOperations()->IsDone() || anObject.IsNull())
436     return aGEOMObject._retn();
437
438   return GetObject(anObject);
439 }
440
441 //=============================================================================
442 /*!
443  *  GetSubShapeIndex
444  */
445 //=============================================================================
446 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
447   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
448 {
449   if (theMainShape == NULL || theSubShape == NULL) return -1;
450
451   //Get the reference shapes
452   Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject
453     (theMainShape->GetStudyID(), theMainShape->GetEntry());
454   Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
455     (theSubShape->GetStudyID(), theSubShape->GetEntry());
456   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
457
458   //Get the unique ID of <theSubShape> inside <theMainShape>
459   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
460   if (!GetOperations()->IsDone())
461     return -1;
462
463   return anID;
464 }
465
466 //=============================================================================
467 /*!
468  *  GetTopologyIndex
469  */
470 //=============================================================================
471 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
472   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
473 {
474   if (theMainShape == NULL || theSubShape == NULL) return -1;
475
476   //Get the reference shapes
477   Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject
478     (theMainShape->GetStudyID(), theMainShape->GetEntry());
479   Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
480     (theSubShape->GetStudyID(), theSubShape->GetEntry());
481   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
482
483   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
484   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
485   if (!GetOperations()->IsDone())
486     return -1;
487
488   return anID;
489 }
490
491 //=============================================================================
492 /*!
493  *  GetShapeTypeString
494  */
495 //=============================================================================
496 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
497 {
498   if (theShape == NULL) return NULL;
499
500   //Get the reference shape
501   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
502     (theShape->GetStudyID(), theShape->GetEntry());
503
504   if (aShape.IsNull()) return NULL;
505
506   // Get shape parameters
507   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
508   return CORBA::string_dup(aDescription.ToCString());
509 }
510
511 //=============================================================================
512 /*!
513  *  NumberOfFaces
514  */
515 //=============================================================================
516 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
517 {
518   if (theShape == NULL) return -1;
519
520   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
521     (theShape->GetStudyID(), theShape->GetEntry());
522
523   CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
524   if (!GetOperations()->IsDone()) return -1;
525
526   return aNb;
527 }
528
529 //=============================================================================
530 /*!
531  *  NumberOfEdges
532  */
533 //=============================================================================
534 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
535 {
536   if (theShape == NULL) return -1;
537
538   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
539     (theShape->GetStudyID(), theShape->GetEntry());
540
541   CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
542   if (!GetOperations()->IsDone()) return -1;
543
544   return aNb;
545 }
546
547 //=============================================================================
548 /*!
549  *  ChangeOrientation
550  */
551 //=============================================================================
552 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
553                                                 (GEOM::GEOM_Object_ptr theShape)
554 {
555   GEOM::GEOM_Object_var aGEOMObject;
556
557   //Set a not done flag
558   GetOperations()->SetNotDone();
559
560   if (theShape == NULL) return aGEOMObject._retn();
561
562   //Get the reference objects
563   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
564     (theShape->GetStudyID(), theShape->GetEntry());
565
566   if (aShape.IsNull()) return aGEOMObject._retn();
567
568   //Create the Solid
569   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
570   if (!GetOperations()->IsDone() || anObject.IsNull())
571     return aGEOMObject._retn();
572
573   return GetObject(anObject);
574 }
575
576 //=============================================================================
577 /*!
578  *  GetFreeFacesIDs
579  */
580 //=============================================================================
581 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
582 {
583   //Set a not done flag
584   GetOperations()->SetNotDone();
585
586   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
587   if (theShape == NULL) return aSeq._retn();
588
589   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
590     (theShape->GetStudyID(), theShape->GetEntry());
591
592   Handle(TColStd_HSequenceOfInteger) aHSeq =
593     GetOperations()->GetFreeFacesIDs(aShape);
594   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
595
596   Standard_Integer aLength = aHSeq->Length();
597   aSeq->length(aLength);
598   for (Standard_Integer i = 1; i <= aLength; i++)
599     aSeq[i-1] = aHSeq->Value(i);
600
601   return aSeq._retn();
602 }
603
604 //=============================================================================
605 /*!
606  *  GetSharedShapes
607  */
608 //=============================================================================
609 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
610                                           (GEOM::GEOM_Object_ptr theShape1,
611                                            GEOM::GEOM_Object_ptr theShape2,
612                                            const CORBA::Long     theShapeType)
613 {
614   //Set a not done flag
615   GetOperations()->SetNotDone();
616
617   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
618   if (theShape1 == NULL ||
619       theShape2 == NULL) return aSeq._retn();
620
621   Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
622     (theShape1->GetStudyID(), theShape1->GetEntry());
623   Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
624     (theShape2->GetStudyID(), theShape2->GetEntry());
625
626   if (aShape1.IsNull() ||
627       aShape2.IsNull()) return aSeq._retn();
628
629   Handle(TColStd_HSequenceOfTransient) aHSeq =
630     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
631   if (!GetOperations()->IsDone() || aHSeq.IsNull())
632     return aSeq._retn();
633
634   Standard_Integer aLength = aHSeq->Length();
635   aSeq->length(aLength);
636   for (Standard_Integer i = 1; i <= aLength; i++)
637     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
638
639   return aSeq._retn();
640 }
641
642 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
643 {
644   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
645
646   switch (theState) {
647   case GEOM::ST_ON:
648     aState = GEOMAlgo_ST_ON;
649     break;
650   case GEOM::ST_OUT:
651     aState = GEOMAlgo_ST_OUT;
652     break;
653   case GEOM::ST_ONOUT:
654     aState = GEOMAlgo_ST_ONOUT;
655     break;
656   case GEOM::ST_IN:
657     aState = GEOMAlgo_ST_IN;
658     break;
659   case GEOM::ST_ONIN:
660     aState = GEOMAlgo_ST_ONIN;
661     break;
662   default:
663     break;
664   }
665
666   return aState;
667 }
668
669 //=============================================================================
670 /*!
671  *  GetShapesOnPlane
672  */
673 //=============================================================================
674 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
675                                                 (GEOM::GEOM_Object_ptr   theShape,
676                                                  const CORBA::Long       theShapeType,
677                                                  GEOM::GEOM_Object_ptr   theAx1,
678                                                  const GEOM::shape_state theState)
679 {
680   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
681
682   //Set a not done flag
683   GetOperations()->SetNotDone();
684
685   if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
686
687   //Get the reference objects
688   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
689     (theShape->GetStudyID(), theShape->GetEntry());
690   Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
691     (theAx1->GetStudyID(), theAx1->GetEntry());
692
693   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
694
695   //Get Shapes On Plane
696   Handle(TColStd_HSequenceOfTransient) aHSeq =
697     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
698   if (!GetOperations()->IsDone() || aHSeq.IsNull())
699     return aSeq._retn();
700
701   Standard_Integer aLength = aHSeq->Length();
702   aSeq->length(aLength);
703   for (Standard_Integer i = 1; i <= aLength; i++)
704     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
705
706   return aSeq._retn();
707 }
708
709 //=============================================================================
710 /*!
711  *  GetShapesOnPlaneWithLocation
712  */
713 //=============================================================================
714 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
715                                                 (GEOM::GEOM_Object_ptr   theShape,
716                                                  const CORBA::Long       theShapeType,
717                                                  GEOM::GEOM_Object_ptr   theAx1,
718                                                  GEOM::GEOM_Object_ptr   thePnt,
719                                                  const GEOM::shape_state theState)
720 {
721   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
722
723   //Set a not done flag
724   GetOperations()->SetNotDone();
725
726   if (theShape == NULL || theAx1 == NULL || thePnt == NULL) return aSeq._retn();
727
728   //Get the reference objects
729   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
730     (theShape->GetStudyID(), theShape->GetEntry());
731   Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
732     (theAx1->GetStudyID(), theAx1->GetEntry());
733   Handle(GEOM_Object) anPnt = GetOperations()->GetEngine()->GetObject
734     (thePnt->GetStudyID(), thePnt->GetEntry());
735
736   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
737
738   //Get Shapes On Plane
739   Handle(TColStd_HSequenceOfTransient) aHSeq =
740     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
741   if (!GetOperations()->IsDone() || aHSeq.IsNull())
742     return aSeq._retn();
743
744   Standard_Integer aLength = aHSeq->Length();
745   aSeq->length(aLength);
746   for (Standard_Integer i = 1; i <= aLength; i++)
747     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
748
749   return aSeq._retn();
750 }
751
752 //=============================================================================
753 /*!
754  *  GetShapesOnCylinder
755  */
756 //=============================================================================
757 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
758                                                 (GEOM::GEOM_Object_ptr   theShape,
759                                                  const CORBA::Long       theShapeType,
760                                                  GEOM::GEOM_Object_ptr   theAxis,
761                                                  const CORBA::Double     theRadius,
762                                                  const GEOM::shape_state theState)
763 {
764   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
765
766   //Set a not done flag
767   GetOperations()->SetNotDone();
768
769   if (theShape == NULL || theAxis == NULL) return aSeq._retn();
770
771   //Get the reference objects
772   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
773     (theShape->GetStudyID(), theShape->GetEntry());
774   Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
775     (theAxis->GetStudyID(), theAxis->GetEntry());
776
777   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
778
779   //Get Shapes On Cylinder
780   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
781     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
782   if (!GetOperations()->IsDone() || aHSeq.IsNull())
783     return aSeq._retn();
784
785   Standard_Integer aLength = aHSeq->Length();
786   aSeq->length(aLength);
787   for (Standard_Integer i = 1; i <= aLength; i++)
788     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
789
790   return aSeq._retn();
791 }
792
793 //=============================================================================
794 /*!
795  *  GetShapesOnSphere
796  */
797 //=============================================================================
798 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
799                                                 (GEOM::GEOM_Object_ptr   theShape,
800                                                  const CORBA::Long       theShapeType,
801                                                  GEOM::GEOM_Object_ptr   theCenter,
802                                                  const CORBA::Double     theRadius,
803                                                  const GEOM::shape_state theState)
804 {
805   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
806
807   //Set a not done flag
808   GetOperations()->SetNotDone();
809
810   if (theShape == NULL || theCenter == NULL) return aSeq._retn();
811
812   //Get the reference objects
813   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
814     (theShape->GetStudyID(), theShape->GetEntry());
815   Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
816     (theCenter->GetStudyID(), theCenter->GetEntry());
817
818   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
819
820   //Get Shapes On Sphere
821   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
822     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
823   if (!GetOperations()->IsDone() || aHSeq.IsNull())
824     return aSeq._retn();
825
826   Standard_Integer aLength = aHSeq->Length();
827   aSeq->length(aLength);
828   for (Standard_Integer i = 1; i <= aLength; i++)
829     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
830
831   return aSeq._retn();
832 }
833
834 //=============================================================================
835 /*!
836  *  GetShapesOnQuadrangle
837  */
838 //=============================================================================
839 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
840                                                 (GEOM::GEOM_Object_ptr theShape,
841                                                  CORBA::Long           theShapeType,
842                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
843                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
844                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
845                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
846                                                  GEOM::shape_state     theState)
847 {
848   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
849
850   //Set a not done flag
851   GetOperations()->SetNotDone();
852
853   if (theShape            == NULL ||
854       theTopLeftPoint     == NULL ||   
855       theTopRigthPoint    == NULL || 
856       theBottomLeftPoint  == NULL ||
857       theBottomRigthPoint == NULL )
858     return aSeq._retn();
859
860   //Get the reference objects
861   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
862     (theShape->GetStudyID(), theShape->GetEntry());
863   Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
864     (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
865   Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
866     (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
867   Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
868     (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
869   Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
870     (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
871
872   if (aShape.IsNull() ||
873       aTopLeftPoint.IsNull() ||
874       aTopRigthPoint.IsNull() ||
875       aBottomLeftPoint.IsNull() ||
876       aBottomRigthPoint.IsNull() )
877     return aSeq._retn();
878
879   //Get Shapes On Quadrangle
880   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
881     (aShape, theShapeType,
882      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
883      ShapeState(theState));
884   if (!GetOperations()->IsDone() || aHSeq.IsNull())
885     return aSeq._retn();
886
887   Standard_Integer aLength = aHSeq->Length();
888   aSeq->length(aLength);
889   for (Standard_Integer i = 1; i <= aLength; i++)
890     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
891
892   return aSeq._retn();
893 }
894
895 //=============================================================================
896 /*!
897  *  GetShapesOnPlaneIDs
898  */
899 //=============================================================================
900 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
901                                                 (GEOM::GEOM_Object_ptr   theShape,
902                                                  const CORBA::Long       theShapeType,
903                                                  GEOM::GEOM_Object_ptr   theAx1,
904                                                  const GEOM::shape_state theState)
905 {
906   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
907
908   //Set a not done flag
909   GetOperations()->SetNotDone();
910
911   if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
912
913   //Get the reference objects
914   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
915     (theShape->GetStudyID(), theShape->GetEntry());
916   Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
917     (theAx1->GetStudyID(), theAx1->GetEntry());
918
919   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
920
921   //Get Shapes On Plane
922   Handle(TColStd_HSequenceOfInteger) aHSeq =
923     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
924   if (!GetOperations()->IsDone() || aHSeq.IsNull())
925     return aSeq._retn();
926
927   Standard_Integer aLength = aHSeq->Length();
928   aSeq->length(aLength);
929   for (Standard_Integer i = 1; i <= aLength; i++)
930     aSeq[i-1] = aHSeq->Value(i);
931
932   return aSeq._retn();
933 }
934
935 //=============================================================================
936 /*!
937  *  GetShapesOnPlaneWithLocationIDs
938  */
939 //=============================================================================
940 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
941                                                 (GEOM::GEOM_Object_ptr   theShape,
942                                                  const CORBA::Long       theShapeType,
943                                                  GEOM::GEOM_Object_ptr   theAx1,
944                                                  GEOM::GEOM_Object_ptr   thePnt,
945                                                  const GEOM::shape_state theState)
946 {
947   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
948
949   //Set a not done flag
950   GetOperations()->SetNotDone();
951
952   if (theShape == NULL || theAx1 == NULL || thePnt == NULL) return aSeq._retn();
953
954   //Get the reference objects
955   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
956     (theShape->GetStudyID(), theShape->GetEntry());
957   Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
958     (theAx1->GetStudyID(), theAx1->GetEntry());
959   Handle(GEOM_Object) anPnt = GetOperations()->GetEngine()->GetObject
960     (thePnt->GetStudyID(), thePnt->GetEntry());
961
962   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
963
964   //Get Shapes On Plane
965   Handle(TColStd_HSequenceOfInteger) aHSeq =
966     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
967   if (!GetOperations()->IsDone() || aHSeq.IsNull())
968     return aSeq._retn();
969
970   Standard_Integer aLength = aHSeq->Length();
971   aSeq->length(aLength);
972   for (Standard_Integer i = 1; i <= aLength; i++)
973     aSeq[i-1] = aHSeq->Value(i);
974
975   return aSeq._retn();
976 }
977
978 //=============================================================================
979 /*!
980  *  GetShapesOnCylinderIDs
981  */
982 //=============================================================================
983 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
984                                                 (GEOM::GEOM_Object_ptr   theShape,
985                                                  const CORBA::Long       theShapeType,
986                                                  GEOM::GEOM_Object_ptr   theAxis,
987                                                  const CORBA::Double     theRadius,
988                                                  const GEOM::shape_state theState)
989 {
990   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
991
992   //Set a not done flag
993   GetOperations()->SetNotDone();
994
995   if (theShape == NULL || theAxis == NULL) return aSeq._retn();
996
997   //Get the reference objects
998   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
999     (theShape->GetStudyID(), theShape->GetEntry());
1000   Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
1001     (theAxis->GetStudyID(), theAxis->GetEntry());
1002
1003   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1004
1005   //Get Shapes On Cylinder
1006   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1007     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1008   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1009     return aSeq._retn();
1010
1011   Standard_Integer aLength = aHSeq->Length();
1012   aSeq->length(aLength);
1013   for (Standard_Integer i = 1; i <= aLength; i++)
1014     aSeq[i-1] = aHSeq->Value(i);
1015
1016   return aSeq._retn();
1017 }
1018
1019 //=============================================================================
1020 /*!
1021  *  GetShapesOnSphereIDs
1022  */
1023 //=============================================================================
1024 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1025                                                 (GEOM::GEOM_Object_ptr   theShape,
1026                                                  const CORBA::Long       theShapeType,
1027                                                  GEOM::GEOM_Object_ptr   theCenter,
1028                                                  const CORBA::Double     theRadius,
1029                                                  const GEOM::shape_state theState)
1030 {
1031   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1032
1033   //Set a not done flag
1034   GetOperations()->SetNotDone();
1035
1036   if (theShape == NULL || theCenter == NULL) return aSeq._retn();
1037
1038   //Get the reference objects
1039   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1040     (theShape->GetStudyID(), theShape->GetEntry());
1041   Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
1042     (theCenter->GetStudyID(), theCenter->GetEntry());
1043
1044   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1045
1046   //Get Shapes On Sphere
1047   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1048     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1049   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1050     return aSeq._retn();
1051
1052   Standard_Integer aLength = aHSeq->Length();
1053   aSeq->length(aLength);
1054   for (Standard_Integer i = 1; i <= aLength; i++)
1055     aSeq[i-1] = aHSeq->Value(i);
1056
1057   return aSeq._retn();
1058 }
1059
1060 //=============================================================================
1061 /*!
1062  *  GetShapesOnQuadrangleIDs
1063  */
1064 //=============================================================================
1065 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1066                                                 (GEOM::GEOM_Object_ptr theShape,
1067                                                  CORBA::Long           theShapeType,
1068                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1069                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1070                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1071                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1072                                                  GEOM::shape_state     theState)
1073 {
1074   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1075
1076   //Set a not done flag
1077   GetOperations()->SetNotDone();
1078
1079   if (theShape            == NULL ||
1080       theTopLeftPoint     == NULL ||   
1081       theTopRigthPoint    == NULL || 
1082       theBottomLeftPoint  == NULL ||
1083       theBottomRigthPoint == NULL )
1084     return aSeq._retn();
1085
1086   //Get the reference objects
1087   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1088     (theShape->GetStudyID(), theShape->GetEntry());
1089   Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
1090     (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
1091   Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
1092     (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
1093   Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
1094     (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
1095   Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
1096     (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
1097
1098   if (aShape.IsNull() ||
1099       aTopLeftPoint.IsNull() ||
1100       aTopRigthPoint.IsNull() ||
1101       aBottomLeftPoint.IsNull() ||
1102       aBottomRigthPoint.IsNull() )
1103     return aSeq._retn();
1104
1105   //Get Shapes On Quadrangle
1106   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1107     (aShape, theShapeType,
1108      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1109      ShapeState(theState));
1110   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1111     return aSeq._retn();
1112
1113   Standard_Integer aLength = aHSeq->Length();
1114   aSeq->length(aLength);
1115   for (Standard_Integer i = 1; i <= aLength; i++)
1116     aSeq[i-1] = aHSeq->Value(i);
1117
1118   return aSeq._retn();
1119 }
1120
1121 //=============================================================================
1122 /*!
1123  *  GetShapesOnBox
1124  */
1125 //=============================================================================
1126 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1127                                                 (GEOM::GEOM_Object_ptr theBox,
1128                                                  GEOM::GEOM_Object_ptr theShape,
1129                                                  CORBA::Long           theShapeType,
1130                                                  GEOM::shape_state     theState)
1131 {
1132   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1133
1134   //Set a not done flag
1135   GetOperations()->SetNotDone();
1136
1137   if ( theShape == NULL ||  theBox == NULL )
1138     return aSeq._retn();
1139
1140   //Get the reference objects
1141   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1142     (theShape->GetStudyID(), theShape->GetEntry());
1143   Handle(GEOM_Object) aBox = GetOperations()->GetEngine()->GetObject
1144     (theShape->GetStudyID(), theBox->GetEntry());
1145
1146   if (aShape.IsNull() || aBox.IsNull() )
1147     return aSeq._retn();
1148
1149   //Get Shapes On Box
1150   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1151     (aBox,aShape, theShapeType,ShapeState(theState));
1152   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1153     return aSeq._retn();
1154
1155   Standard_Integer aLength = aHSeq->Length();
1156   aSeq->length(aLength);
1157   for (Standard_Integer i = 1; i <= aLength; i++)
1158     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1159
1160   return aSeq._retn();
1161 }
1162
1163 //=============================================================================
1164 /*!
1165  *  GetShapesOnQuadrangleIDs
1166  */
1167 //=============================================================================
1168 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1169                                                 (GEOM::GEOM_Object_ptr theBox,
1170                                                  GEOM::GEOM_Object_ptr theShape,
1171                                                  CORBA::Long           theShapeType,
1172                                                  GEOM::shape_state     theState)
1173 {
1174   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1175
1176   //Set a not done flag
1177   GetOperations()->SetNotDone();
1178
1179   if ( theShape == NULL ||  theBox == NULL )
1180     return aSeq._retn();
1181
1182   //Get the reference objects
1183   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1184     (theShape->GetStudyID(), theShape->GetEntry());
1185   Handle(GEOM_Object) aBox = GetOperations()->GetEngine()->GetObject
1186     (theShape->GetStudyID(), theBox->GetEntry());
1187
1188   if (aShape.IsNull() || aBox.IsNull() )
1189     return aSeq._retn();
1190
1191   //Get Shapes On Box
1192   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1193     (aBox,aShape, theShapeType,ShapeState(theState));
1194   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1195     return aSeq._retn();
1196
1197   Standard_Integer aLength = aHSeq->Length();
1198   aSeq->length(aLength);
1199   for (Standard_Integer i = 1; i <= aLength; i++)
1200     aSeq[i-1] = aHSeq->Value(i);
1201
1202   return aSeq._retn();
1203 }
1204
1205 //=============================================================================
1206 /*!
1207  *  GetInPlace
1208  */
1209 //=============================================================================
1210 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1211                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1212                                            GEOM::GEOM_Object_ptr theShapeWhat)
1213 {
1214   GEOM::GEOM_Object_var aGEOMObject;
1215
1216   //Set a not done flag
1217   GetOperations()->SetNotDone();
1218
1219   if (theShapeWhere == NULL ||
1220       theShapeWhat == NULL) return aGEOMObject._retn();
1221
1222   //Get the reference objects
1223   Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
1224     (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
1225   Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
1226     (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
1227
1228   if (aShapeWhere.IsNull() ||
1229       aShapeWhat.IsNull()) return aGEOMObject._retn();
1230
1231   //Get Shapes in place of aShapeWhat
1232   Handle(GEOM_Object) anObject =
1233     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1234   if (!GetOperations()->IsDone() || anObject.IsNull())
1235     return aGEOMObject._retn();
1236
1237   return GetObject(anObject);
1238 }
1239
1240 //=============================================================================
1241 /*!
1242  *  GetSame
1243  */
1244 //=============================================================================
1245 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1246                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1247                                            GEOM::GEOM_Object_ptr theShapeWhat)
1248 {
1249   GEOM::GEOM_Object_var aGEOMObject;
1250
1251   //Set a not done flag
1252   GetOperations()->SetNotDone();
1253
1254   if (theShapeWhere == NULL ||
1255       theShapeWhat == NULL) return aGEOMObject._retn();
1256
1257   //Get the reference objects
1258   Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
1259     (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
1260   Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
1261     (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
1262
1263   if (aShapeWhere.IsNull() ||
1264       aShapeWhat.IsNull()) return aGEOMObject._retn();
1265
1266   //Get Shapes in place of aShapeWhat
1267   Handle(GEOM_Object) anObject =
1268     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1269   if (!GetOperations()->IsDone() || anObject.IsNull())
1270     return aGEOMObject._retn();
1271
1272   return GetObject(anObject);
1273 }
1274