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