Salome HOME
IMPs 19998 and 21191: new gluing by PKV
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 //  Copyright (C) 2007-2010  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  *  MakeEdgeOnCurveByLength
91  */
92 //=============================================================================
93 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
94                   (GEOM::GEOM_Object_ptr theCurve,
95                    CORBA::Double         theLength,
96                    GEOM::GEOM_Object_ptr theStartPoint)
97 {
98   GEOM::GEOM_Object_var aGEOMObject;
99
100   //Set a not done flag
101   GetOperations()->SetNotDone();
102
103   //Get the reference curve
104   Handle(GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
105   if (aRefCurve.IsNull()) return aGEOMObject._retn();
106
107   //Get the reference point (can be NULL)
108   Handle(GEOM_Object) aRefPoint;
109   if (!CORBA::is_nil(theStartPoint)) {
110     aRefPoint = GetObjectImpl(theStartPoint);
111   }
112
113   //Create the point
114   Handle(GEOM_Object) anObject =
115     GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
116   if (!GetOperations()->IsDone() || anObject.IsNull())
117     return aGEOMObject._retn();
118
119   return GetObject(anObject);
120 }
121
122 //=============================================================================
123 /*!
124  *  MakeEdgeWire
125  */
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
128                       (GEOM::GEOM_Object_ptr theWire,
129                        const CORBA::Double theLinearTolerance,
130                        const CORBA::Double theAngularTolerance)
131 {
132   GEOM::GEOM_Object_var aGEOMObject;
133
134   //Set a not done flag
135   GetOperations()->SetNotDone();
136
137   //Get the source wire
138   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
139
140   if (aWire.IsNull()) return aGEOMObject._retn();
141
142   //Create the Edge
143   Handle(GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
144   if (!GetOperations()->IsDone() || anObject.IsNull())
145     return aGEOMObject._retn();
146
147   return GetObject(anObject);
148 }
149
150 //=============================================================================
151 /*!
152  *  MakeWire
153  */
154 //=============================================================================
155 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
156                            (const GEOM::ListOfGO& theEdgesAndWires,
157                             const CORBA::Double   theTolerance)
158 {
159   GEOM::GEOM_Object_var aGEOMObject;
160
161   //Set a not done flag
162   GetOperations()->SetNotDone();
163
164   int ind, aLen;
165   std::list<Handle(GEOM_Object)> aShapes;
166
167   //Get the shapes
168   aLen = theEdgesAndWires.length();
169   for (ind = 0; ind < aLen; ind++) {
170     Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
171     if (aSh.IsNull()) return aGEOMObject._retn();
172     aShapes.push_back(aSh);
173   }
174
175   // Make Solid
176   Handle(GEOM_Object) anObject =
177     GetOperations()->MakeWire(aShapes, theTolerance);
178   if (!GetOperations()->IsDone() || anObject.IsNull())
179     return aGEOMObject._retn();
180
181   return GetObject(anObject);
182 }
183
184 //=============================================================================
185 /*!
186  *  MakeFace
187  */
188 //=============================================================================
189 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
190                       (GEOM::GEOM_Object_ptr theWire,
191                        const CORBA::Boolean  isPlanarWanted)
192 {
193   GEOM::GEOM_Object_var aGEOMObject;
194
195   //Set a not done flag
196   GetOperations()->SetNotDone();
197
198   //Get the reference wire
199   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
200   if (aWire.IsNull()) return aGEOMObject._retn();
201
202   //Create the Face
203   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
204   if (!GetOperations()->IsDone() || anObject.IsNull())
205     return aGEOMObject._retn();
206
207   return GetObject(anObject);
208 }
209
210 //=============================================================================
211 /*!
212  *  MakeFaceWires
213  */
214 //=============================================================================
215 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
216                                          (const GEOM::ListOfGO& theWires,
217                                           const CORBA::Boolean  isPlanarWanted)
218 {
219   GEOM::GEOM_Object_var aGEOMObject;
220
221   //Set a not done flag
222   GetOperations()->SetNotDone();
223
224   int ind, aLen;
225   std::list<Handle(GEOM_Object)> aShapes;
226
227   //Get the shapes
228   aLen = theWires.length();
229   for (ind = 0; ind < aLen; ind++) {
230     Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
231     if (aSh.IsNull()) return aGEOMObject._retn();
232     aShapes.push_back(aSh);
233   }
234
235   // Make Face
236   Handle(GEOM_Object) anObject =
237     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
238   if (!GetOperations()->IsDone() || anObject.IsNull())
239     return aGEOMObject._retn();
240
241   return GetObject(anObject);
242 }
243
244 //=============================================================================
245 /*!
246  *  MakeShell
247  */
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
250                                       (const GEOM::ListOfGO& theFacesAndShells)
251 {
252   GEOM::GEOM_Object_var aGEOMObject;
253
254   //Set a not done flag
255   GetOperations()->SetNotDone();
256
257   int ind, aLen;
258   std::list<Handle(GEOM_Object)> aShapes;
259
260   //Get the shapes
261   aLen = theFacesAndShells.length();
262   for (ind = 0; ind < aLen; ind++) {
263     Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
264     if (aSh.IsNull()) return aGEOMObject._retn();
265     aShapes.push_back(aSh);
266   }
267
268   // Make Solid
269   Handle(GEOM_Object) anObject =
270     GetOperations()->MakeShell(aShapes);
271   if (!GetOperations()->IsDone() || anObject.IsNull())
272     return aGEOMObject._retn();
273
274   return GetObject(anObject);
275 }
276
277 //=============================================================================
278 /*!
279  *  MakeSolidShell
280  */
281 //=============================================================================
282 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
283                                                 (GEOM::GEOM_Object_ptr theShell)
284 {
285   GEOM::GEOM_Object_var aGEOMObject;
286
287   //Set a not done flag
288   GetOperations()->SetNotDone();
289
290   //Get the reference objects
291   Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
292   if (aShell.IsNull()) return aGEOMObject._retn();
293
294   std::list<Handle(GEOM_Object)> aShapes;
295   aShapes.push_back(aShell);
296
297   //Create the Solid
298   Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
299   if (!GetOperations()->IsDone() || anObject.IsNull())
300     return aGEOMObject._retn();
301
302   return GetObject(anObject);
303 }
304
305 //=============================================================================
306 /*!
307  *  MakeSolidShells
308  */
309 //=============================================================================
310 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
311                                       (const GEOM::ListOfGO& theShells)
312 {
313   GEOM::GEOM_Object_var aGEOMObject;
314
315   //Set a not done flag
316   GetOperations()->SetNotDone();
317
318   int ind, aLen;
319   std::list<Handle(GEOM_Object)> aShapes;
320
321   //Get the shapes
322   aLen = theShells.length();
323   for (ind = 0; ind < aLen; ind++) {
324     Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
325     if (aSh.IsNull()) return aGEOMObject._retn();
326     aShapes.push_back(aSh);
327   }
328
329   // Make Solid
330   Handle(GEOM_Object) anObject =
331     GetOperations()->MakeSolidShells(aShapes);
332   if (!GetOperations()->IsDone() || anObject.IsNull())
333     return aGEOMObject._retn();
334
335   return GetObject(anObject);
336 }
337
338 //=============================================================================
339 /*!
340  *  MakeCompound
341  */
342 //=============================================================================
343 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
344                                       (const GEOM::ListOfGO& theShapes)
345 {
346   GEOM::GEOM_Object_var aGEOMObject;
347
348   //Set a not done flag
349   GetOperations()->SetNotDone();
350
351   int ind, aLen;
352   std::list<Handle(GEOM_Object)> aShapes;
353
354   //Get the shapes
355   aLen = theShapes.length();
356   for (ind = 0; ind < aLen; ind++) {
357     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
358     if (aSh.IsNull()) return aGEOMObject._retn();
359     aShapes.push_back(aSh);
360   }
361
362   // Make Solid
363   Handle(GEOM_Object) anObject =
364     GetOperations()->MakeCompound(aShapes);
365   if (!GetOperations()->IsDone() || anObject.IsNull())
366     return aGEOMObject._retn();
367
368   return GetObject(anObject);
369 }
370
371 //=============================================================================
372 /*!
373  *  MakeGlueFaces
374  */
375 //=============================================================================
376 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
377                                            (GEOM::GEOM_Object_ptr theShape,
378                                             CORBA::Double   theTolerance,
379                                             CORBA::Boolean  doKeepNonSolids)
380 {
381   GEOM::GEOM_Object_var aGEOMObject;
382
383   //Set a not done flag
384   GetOperations()->SetNotDone();
385
386   //Get the reference objects
387   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
388   if (aShape.IsNull()) return aGEOMObject._retn();
389
390   //Perform the gluing
391   Handle(GEOM_Object) anObject =
392     GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
393   //if (!GetOperations()->IsDone() || anObject.IsNull())
394   // to allow warning
395   if (anObject.IsNull())
396     return aGEOMObject._retn();
397
398   return GetObject(anObject);
399 }
400
401 //=============================================================================
402 /*!
403  *  GetGlueFaces
404  */
405 //=============================================================================
406 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
407                                            (GEOM::GEOM_Object_ptr theShape,
408                                             const CORBA::Double   theTolerance)
409 {
410   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
411
412   //Set a not done flag
413   GetOperations()->SetNotDone();
414
415   //Get the reference objects
416   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
417   if (aShape.IsNull()) return aSeq._retn();
418
419   Handle(TColStd_HSequenceOfTransient) aHSeq =
420     //GetOperations()->GetGlueFaces(aShape, theTolerance);
421     GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_FACE);
422
423   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
424   // to allow warning
425   if(aHSeq.IsNull())
426     return aSeq._retn();
427
428   Standard_Integer aLength = aHSeq->Length();
429   aSeq->length(aLength);
430   for (Standard_Integer i = 1; i <= aLength; i++)
431     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
432
433   return aSeq._retn();
434 }
435
436 //=============================================================================
437 /*!
438  *  MakeGlueFacesByList
439  */
440 //=============================================================================
441 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
442                                            (GEOM::GEOM_Object_ptr theShape,
443                                             CORBA::Double   theTolerance,
444                                             const GEOM::ListOfGO& theFaces,
445                                             CORBA::Boolean  doKeepNonSolids)
446 {
447   GEOM::GEOM_Object_var aGEOMObject;
448
449   //Set a not done flag
450   GetOperations()->SetNotDone();
451
452   //Get the reference objects
453   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
454   if (aShape.IsNull()) return aGEOMObject._retn();
455
456   int ind, aLen;
457   std::list<Handle(GEOM_Object)> aFaces;
458   //Get the shapes
459   aLen = theFaces.length();
460   for (ind = 0; ind < aLen; ind++) {
461     Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
462     if (aSh.IsNull()) return aGEOMObject._retn();
463     aFaces.push_back(aSh);
464   }
465
466   //Perform the gluing
467   Handle(GEOM_Object) anObject =
468     GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
469   //if (!GetOperations()->IsDone() || anObject.IsNull())
470   // to allow warning
471   if (anObject.IsNull())
472     return aGEOMObject._retn();
473
474   return GetObject(anObject);
475 }
476
477 //=============================================================================
478 /*!
479  *  MakeGlueEdges
480  */
481 //=============================================================================
482 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
483                                            (GEOM::GEOM_Object_ptr theShape,
484                                             CORBA::Double   theTolerance)
485 {
486   GEOM::GEOM_Object_var aGEOMObject;
487
488   //Set a not done flag
489   GetOperations()->SetNotDone();
490
491   //Get the reference objects
492   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
493   if (aShape.IsNull()) return aGEOMObject._retn();
494
495   //Perform the gluing
496   Handle(GEOM_Object) anObject =
497     GetOperations()->MakeGlueEdges(aShape, theTolerance);
498   //if (!GetOperations()->IsDone() || anObject.IsNull())
499   // to allow warning
500   if (anObject.IsNull())
501     return aGEOMObject._retn();
502
503   return GetObject(anObject);
504 }
505
506 //=============================================================================
507 /*!
508  *  GetGlueEdges
509  */
510 //=============================================================================
511 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
512                                            (GEOM::GEOM_Object_ptr theShape,
513                                             const CORBA::Double   theTolerance)
514 {
515   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
516
517   //Set a not done flag
518   GetOperations()->SetNotDone();
519
520   //Get the reference objects
521   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
522   if (aShape.IsNull()) return aSeq._retn();
523
524   Handle(TColStd_HSequenceOfTransient) aHSeq =
525     GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_EDGE);
526
527   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
528   // to allow warning
529   if (aHSeq.IsNull())
530     return aSeq._retn();
531
532   Standard_Integer aLength = aHSeq->Length();
533   aSeq->length(aLength);
534   for (Standard_Integer i = 1; i <= aLength; i++)
535     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
536
537   return aSeq._retn();
538 }
539
540 //=============================================================================
541 /*!
542  *  MakeGlueEdgesByList
543  */
544 //=============================================================================
545 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList
546                                            (GEOM::GEOM_Object_ptr theShape,
547                                             CORBA::Double   theTolerance,
548                                             const GEOM::ListOfGO& theEdges)
549 {
550   GEOM::GEOM_Object_var aGEOMObject;
551
552   //Set a not done flag
553   GetOperations()->SetNotDone();
554
555   //Get the reference objects
556   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
557   if (aShape.IsNull()) return aGEOMObject._retn();
558
559   int ind, aLen;
560   std::list<Handle(GEOM_Object)> anEdges;
561   //Get the shapes
562   aLen = theEdges.length();
563   for (ind = 0; ind < aLen; ind++) {
564     Handle(GEOM_Object) aSh = GetObjectImpl(theEdges[ind]);
565     if (aSh.IsNull()) return aGEOMObject._retn();
566     anEdges.push_back(aSh);
567   }
568
569   //Perform the gluing
570   Handle(GEOM_Object) anObject =
571     GetOperations()->MakeGlueEdgesByList(aShape, theTolerance, anEdges);
572   //if (!GetOperations()->IsDone() || anObject.IsNull())
573   // to allow warning
574   if (anObject.IsNull())
575     return aGEOMObject._retn();
576
577   return GetObject(anObject);
578 }
579
580 //=============================================================================
581 /*!
582  *  GetExistingSubObjects
583  */
584 //=============================================================================
585 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
586                                                                  CORBA::Boolean        theGroupsOnly)
587 {
588   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
589
590   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
591   if (aShape.IsNull()) return aSeq._retn();
592
593   Handle(TColStd_HSequenceOfTransient) aHSeq =
594     GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
595   if (!GetOperations()->IsDone() || aHSeq.IsNull())
596     return aSeq._retn();
597
598   Standard_Integer aLength = aHSeq->Length();
599   aSeq->length(aLength);
600   for (Standard_Integer i = 1; i <= aLength; i++)
601     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
602
603   return aSeq._retn();
604 }
605
606 //=============================================================================
607 /*!
608  *  MakeExplode (including theShape itself, bad sorting)
609  */
610 //=============================================================================
611 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
612                                                        const CORBA::Long     theShapeType,
613                                                        const CORBA::Boolean  isSorted)
614 {
615   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
616
617   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
618   if (aShape.IsNull()) return aSeq._retn();
619
620   Handle(TColStd_HSequenceOfTransient) aHSeq =
621     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
622                                  GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
623   if (!GetOperations()->IsDone() || aHSeq.IsNull())
624     return aSeq._retn();
625
626   Standard_Integer aLength = aHSeq->Length();
627   aSeq->length(aLength);
628   for (Standard_Integer i = 1; i <= aLength; i++)
629     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
630
631   return aSeq._retn();
632 }
633
634 //=============================================================================
635 /*!
636  *  MakeAllSubShapes (including theShape itself, good sorting)
637  */
638 //=============================================================================
639 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
640                                                             const CORBA::Long     theShapeType,
641                                                             const CORBA::Boolean  isSorted)
642 {
643   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
644
645   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
646   if (aShape.IsNull()) return aSeq._retn();
647
648   Handle(TColStd_HSequenceOfTransient) aHSeq =
649     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
650                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
651   if (!GetOperations()->IsDone() || aHSeq.IsNull())
652     return aSeq._retn();
653
654   Standard_Integer aLength = aHSeq->Length();
655   aSeq->length(aLength);
656   for (Standard_Integer i = 1; i <= aLength; i++)
657     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
658
659   return aSeq._retn();
660 }
661
662 //=============================================================================
663 /*!
664  *  ExtractSubShapes (excluding theShape itself, good sorting)
665  */
666 //=============================================================================
667 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
668                                                             const CORBA::Long     theShapeType,
669                                                             const CORBA::Boolean  isSorted)
670 {
671   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
672
673   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
674   if (aShape.IsNull()) return aSeq._retn();
675
676   Handle(TColStd_HSequenceOfTransient) aHSeq =
677     // TODO: enum instead of bool for the last argument
678     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
679                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
680   if (!GetOperations()->IsDone() || aHSeq.IsNull())
681     return aSeq._retn();
682
683   Standard_Integer aLength = aHSeq->Length();
684   aSeq->length(aLength);
685   for (Standard_Integer i = 1; i <= aLength; i++)
686     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
687
688   return aSeq._retn();
689 }
690
691 //=============================================================================
692 /*!
693  *  SubShapeAllIDs
694  */
695 //=============================================================================
696 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
697                                                             const CORBA::Long     theShapeType,
698                                                             const CORBA::Boolean  isSorted)
699 {
700   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
701
702   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
703   if (aShape.IsNull()) return aSeq._retn();
704
705   Handle(TColStd_HSequenceOfInteger) aHSeq =
706     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
707                                     GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
708   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
709
710   Standard_Integer aLength = aHSeq->Length();
711   aSeq->length(aLength);
712   for (Standard_Integer i = 1; i <= aLength; i++)
713     aSeq[i-1] = aHSeq->Value(i);
714
715   return aSeq._retn();
716 }
717
718 //=============================================================================
719 /*!
720  *  GetAllSubShapesIDs
721  */
722 //=============================================================================
723 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
724                                                                 const CORBA::Long     theShapeType,
725                                                                 const CORBA::Boolean  isSorted)
726 {
727   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
728
729   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
730   if (aShape.IsNull()) return aSeq._retn();
731
732   Handle(TColStd_HSequenceOfInteger) aHSeq =
733     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
734                                     GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
735   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
736
737   Standard_Integer aLength = aHSeq->Length();
738   aSeq->length(aLength);
739   for (Standard_Integer i = 1; i <= aLength; i++)
740     aSeq[i-1] = aHSeq->Value(i);
741
742   return aSeq._retn();
743 }
744
745 //=============================================================================
746 /*!
747  *  GetSubShape
748  */
749 //=============================================================================
750 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
751                                            (GEOM::GEOM_Object_ptr theMainShape,
752                                             const CORBA::Long     theID)
753 {
754   GEOM::GEOM_Object_var aGEOMObject;
755
756   //Set a not done flag
757   GetOperations()->SetNotDone();
758
759   //Get the reference objects
760   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
761   if (aShape.IsNull()) return aGEOMObject._retn();
762
763   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
764   if (!GetOperations()->IsDone() || anObject.IsNull())
765     return aGEOMObject._retn();
766
767   return GetObject(anObject);
768 }
769
770 //=============================================================================
771 /*!
772  *  MakeSubShapes
773  */
774 //=============================================================================
775 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
776                                                          const GEOM::ListOfLong& theIndices)
777 {
778   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
779   Standard_Integer i;
780
781   //Set a not done flag
782   GetOperations()->SetNotDone();
783
784   if (theIndices.length() < 1)
785     return aSeq._retn();
786
787   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
788   if (aShape.IsNull()) return aSeq._retn();
789
790   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
791   for (i = 0; i < theIndices.length(); i++)
792     anArray->SetValue(i+1, theIndices[i]);
793
794   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
795   if (!GetOperations()->IsDone() || aHSeq.IsNull())
796     return aSeq._retn();
797
798   Standard_Integer aLength = aHSeq->Length();
799   aSeq->length(aLength);
800   for (i = 0; i < aLength; i++)
801     aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
802
803   return aSeq._retn();
804 }
805
806 //=============================================================================
807 /*!
808  *  GetSubShapeIndex
809  */
810 //=============================================================================
811 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
812   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
813 {
814   //Get the reference shapes
815   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
816   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
817
818   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
819
820   //Get the unique ID of <theSubShape> inside <theMainShape>
821   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
822   if (!GetOperations()->IsDone())
823     return -1;
824
825   return anID;
826 }
827
828 //=============================================================================
829 /*!
830  *  GetTopologyIndex
831  */
832 //=============================================================================
833 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
834   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
835 {
836   //Get the reference shapes
837   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
838   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
839
840   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
841
842   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
843   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
844   if (!GetOperations()->IsDone())
845     return -1;
846
847   return anID;
848 }
849
850 //=============================================================================
851 /*!
852  *  GetShapeTypeString
853  */
854 //=============================================================================
855 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
856 {
857   //Get the reference shape
858   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
859   if (aShape.IsNull()) return NULL;
860
861   // Get shape parameters
862   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
863   return CORBA::string_dup(aDescription.ToCString());
864 }
865
866 //=============================================================================
867 /*!
868  *  NumberOfFaces
869  */
870 //=============================================================================
871 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
872 {
873   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
874 }
875
876 //=============================================================================
877 /*!
878  *  NumberOfEdges
879  */
880 //=============================================================================
881 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
882 {
883   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
884 }
885
886 //=============================================================================
887 /*!
888  *  NumberOfSubShapes
889  */
890 //=============================================================================
891 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
892                                                          const CORBA::Long     theShapeType)
893 {
894   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
895   if (aShape.IsNull()) return -1;
896
897   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
898   if (!GetOperations()->IsDone()) return -1;
899
900   return aNb;
901 }
902
903 //=============================================================================
904 /*!
905  *  ChangeOrientation
906  */
907 //=============================================================================
908 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
909                                                 (GEOM::GEOM_Object_ptr theShape)
910 {
911   GEOM::GEOM_Object_var aGEOMObject;
912
913   //Set a not done flag
914   GetOperations()->SetNotDone();
915
916   //Get the reference objects
917   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
918   if (aShape.IsNull()) return aGEOMObject._retn();
919
920   //Create the Solid
921   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
922   if (!GetOperations()->IsDone() || anObject.IsNull())
923     return aGEOMObject._retn();
924
925   return GetObject(anObject);
926 }
927
928 //=============================================================================
929 /*!
930  *  GetFreeFacesIDs
931  */
932 //=============================================================================
933 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
934 {
935   //Set a not done flag
936   GetOperations()->SetNotDone();
937
938   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
939
940   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
941   if (aShape.IsNull()) return aSeq._retn();
942
943   Handle(TColStd_HSequenceOfInteger) aHSeq =
944     GetOperations()->GetFreeFacesIDs(aShape);
945   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
946
947   Standard_Integer aLength = aHSeq->Length();
948   aSeq->length(aLength);
949   for (Standard_Integer i = 1; i <= aLength; i++)
950     aSeq[i-1] = aHSeq->Value(i);
951
952   return aSeq._retn();
953 }
954
955 //=============================================================================
956 /*!
957  *  GetSharedShapes
958  */
959 //=============================================================================
960 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
961                                           (GEOM::GEOM_Object_ptr theShape1,
962                                            GEOM::GEOM_Object_ptr theShape2,
963                                            const CORBA::Long     theShapeType)
964 {
965   //Set a not done flag
966   GetOperations()->SetNotDone();
967
968   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
969
970   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
971   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
972
973   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
974
975   Handle(TColStd_HSequenceOfTransient) aHSeq =
976     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
977   if (!GetOperations()->IsDone() || aHSeq.IsNull())
978     return aSeq._retn();
979
980   Standard_Integer aLength = aHSeq->Length();
981   aSeq->length(aLength);
982   for (Standard_Integer i = 1; i <= aLength; i++)
983     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
984
985   return aSeq._retn();
986 }
987
988 //=============================================================================
989 /*!
990  *  GetSharedShapesMulti
991  */
992 //=============================================================================
993 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
994                                           (const GEOM::ListOfGO& theShapes,
995                                            const CORBA::Long     theShapeType)
996 {
997   //Set a not done flag
998   GetOperations()->SetNotDone();
999
1000   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1001
1002   //Get the shapes
1003   std::list<Handle(GEOM_Object)> aShapes;
1004   int aLen = theShapes.length();
1005   for (int ind = 0; ind < aLen; ind++) {
1006     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
1007     if (aSh.IsNull()) return aSeq._retn();
1008     aShapes.push_back(aSh);
1009   }
1010
1011   Handle(TColStd_HSequenceOfTransient) aHSeq =
1012     GetOperations()->GetSharedShapes(aShapes, theShapeType);
1013   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1014     return aSeq._retn();
1015
1016   Standard_Integer aLength = aHSeq->Length();
1017   aSeq->length(aLength);
1018   for (Standard_Integer i = 1; i <= aLength; i++)
1019     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1020
1021   return aSeq._retn();
1022 }
1023
1024 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1025 {
1026   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1027
1028   switch (theState) {
1029   case GEOM::ST_ON:
1030     aState = GEOMAlgo_ST_ON;
1031     break;
1032   case GEOM::ST_OUT:
1033     aState = GEOMAlgo_ST_OUT;
1034     break;
1035   case GEOM::ST_ONOUT:
1036     aState = GEOMAlgo_ST_ONOUT;
1037     break;
1038   case GEOM::ST_IN:
1039     aState = GEOMAlgo_ST_IN;
1040     break;
1041   case GEOM::ST_ONIN:
1042     aState = GEOMAlgo_ST_ONIN;
1043     break;
1044   default:
1045     break;
1046   }
1047
1048   return aState;
1049 }
1050
1051 //=============================================================================
1052 /*!
1053  *  GetShapesOnPlane
1054  */
1055 //=============================================================================
1056 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1057                                                 (GEOM::GEOM_Object_ptr   theShape,
1058                                                  const CORBA::Long       theShapeType,
1059                                                  GEOM::GEOM_Object_ptr   theAx1,
1060                                                  const GEOM::shape_state theState)
1061 {
1062   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1063
1064   //Set a not done flag
1065   GetOperations()->SetNotDone();
1066
1067   //Get the reference objects
1068   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1069   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1070
1071   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1072
1073   //Get Shapes On Plane
1074   Handle(TColStd_HSequenceOfTransient) aHSeq =
1075     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1076   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1077     return aSeq._retn();
1078
1079   Standard_Integer aLength = aHSeq->Length();
1080   aSeq->length(aLength);
1081   for (Standard_Integer i = 1; i <= aLength; i++)
1082     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1083
1084   return aSeq._retn();
1085 }
1086
1087 //=============================================================================
1088 /*!
1089  *  GetShapesOnPlaneWithLocation
1090  */
1091 //=============================================================================
1092 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1093                                                 (GEOM::GEOM_Object_ptr   theShape,
1094                                                  const CORBA::Long       theShapeType,
1095                                                  GEOM::GEOM_Object_ptr   theAx1,
1096                                                  GEOM::GEOM_Object_ptr   thePnt,
1097                                                  const GEOM::shape_state theState)
1098 {
1099   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1100
1101   //Set a not done flag
1102   GetOperations()->SetNotDone();
1103
1104   //Get the reference objects
1105   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1106   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1107   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1108
1109   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1110
1111   //Get Shapes On Plane
1112   Handle(TColStd_HSequenceOfTransient) aHSeq =
1113     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1114   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1115     return aSeq._retn();
1116
1117   Standard_Integer aLength = aHSeq->Length();
1118   aSeq->length(aLength);
1119   for (Standard_Integer i = 1; i <= aLength; i++)
1120     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1121
1122   return aSeq._retn();
1123 }
1124
1125 //=============================================================================
1126 /*!
1127  *  GetShapesOnCylinder
1128  */
1129 //=============================================================================
1130 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1131                                                 (GEOM::GEOM_Object_ptr   theShape,
1132                                                  const CORBA::Long       theShapeType,
1133                                                  GEOM::GEOM_Object_ptr   theAxis,
1134                                                  const CORBA::Double     theRadius,
1135                                                  const GEOM::shape_state theState)
1136 {
1137   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1138
1139   //Set a not done flag
1140   GetOperations()->SetNotDone();
1141
1142   //Get the reference objects
1143   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1144   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1145
1146   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1147
1148   //Get Shapes On Cylinder
1149   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1150     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1151   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1152     return aSeq._retn();
1153
1154   Standard_Integer aLength = aHSeq->Length();
1155   aSeq->length(aLength);
1156   for (Standard_Integer i = 1; i <= aLength; i++)
1157     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1158
1159   return aSeq._retn();
1160 }
1161
1162 //=============================================================================
1163 /*!
1164  *  GetShapesOnCylinderWithLocation
1165  */
1166 //=============================================================================
1167 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1168                                                 (GEOM::GEOM_Object_ptr   theShape,
1169                                                  const CORBA::Long       theShapeType,
1170                                                  GEOM::GEOM_Object_ptr   theAxis,
1171                                                  GEOM::GEOM_Object_ptr   thePnt,
1172                                                  const CORBA::Double     theRadius,
1173                                                  const GEOM::shape_state theState)
1174 {
1175   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1176
1177   //Set a not done flag
1178   GetOperations()->SetNotDone();
1179
1180   //Get the reference objects
1181   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1182   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1183   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1184
1185   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1186
1187   //Get Shapes On Cylinder
1188   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1189     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1190   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1191     return aSeq._retn();
1192
1193   Standard_Integer aLength = aHSeq->Length();
1194   aSeq->length(aLength);
1195   for (Standard_Integer i = 1; i <= aLength; i++)
1196     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1197
1198   return aSeq._retn();
1199 }
1200
1201 //=============================================================================
1202 /*!
1203  *  GetShapesOnSphere
1204  */
1205 //=============================================================================
1206 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1207                                                 (GEOM::GEOM_Object_ptr   theShape,
1208                                                  const CORBA::Long       theShapeType,
1209                                                  GEOM::GEOM_Object_ptr   theCenter,
1210                                                  const CORBA::Double     theRadius,
1211                                                  const GEOM::shape_state theState)
1212 {
1213   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1214
1215   //Set a not done flag
1216   GetOperations()->SetNotDone();
1217
1218   //Get the reference objects
1219   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1220   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1221
1222   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1223
1224   //Get Shapes On Sphere
1225   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1226     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1227   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1228     return aSeq._retn();
1229
1230   Standard_Integer aLength = aHSeq->Length();
1231   aSeq->length(aLength);
1232   for (Standard_Integer i = 1; i <= aLength; i++)
1233     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1234
1235   return aSeq._retn();
1236 }
1237
1238 //=============================================================================
1239 /*!
1240  *  GetShapesOnQuadrangle
1241  */
1242 //=============================================================================
1243 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1244                                                 (GEOM::GEOM_Object_ptr theShape,
1245                                                  CORBA::Long           theShapeType,
1246                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1247                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1248                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1249                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1250                                                  GEOM::shape_state     theState)
1251 {
1252   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1253
1254   //Set a not done flag
1255   GetOperations()->SetNotDone();
1256
1257   //Get the reference objects
1258   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1259   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1260   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1261   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1262   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1263
1264   if (aShape.IsNull() ||
1265       aTopLeftPoint.IsNull() ||
1266       aTopRigthPoint.IsNull() ||
1267       aBottomLeftPoint.IsNull() ||
1268       aBottomRigthPoint.IsNull())
1269     return aSeq._retn();
1270
1271   //Get Shapes On Quadrangle
1272   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1273     (aShape, theShapeType,
1274      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1275      ShapeState(theState));
1276   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1277     return aSeq._retn();
1278
1279   Standard_Integer aLength = aHSeq->Length();
1280   aSeq->length(aLength);
1281   for (Standard_Integer i = 1; i <= aLength; i++)
1282     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1283
1284   return aSeq._retn();
1285 }
1286
1287 //=============================================================================
1288 /*!
1289  *  GetShapesOnPlaneIDs
1290  */
1291 //=============================================================================
1292 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1293                                                 (GEOM::GEOM_Object_ptr   theShape,
1294                                                  const CORBA::Long       theShapeType,
1295                                                  GEOM::GEOM_Object_ptr   theAx1,
1296                                                  const GEOM::shape_state theState)
1297 {
1298   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1299
1300   //Set a not done flag
1301   GetOperations()->SetNotDone();
1302
1303   //Get the reference objects
1304   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1305   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1306
1307   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1308
1309   //Get Shapes On Plane
1310   Handle(TColStd_HSequenceOfInteger) aHSeq =
1311     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1312   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1313     return aSeq._retn();
1314
1315   Standard_Integer aLength = aHSeq->Length();
1316   aSeq->length(aLength);
1317   for (Standard_Integer i = 1; i <= aLength; i++)
1318     aSeq[i-1] = aHSeq->Value(i);
1319
1320   return aSeq._retn();
1321 }
1322
1323 //=============================================================================
1324 /*!
1325  *  GetShapesOnPlaneWithLocationIDs
1326  */
1327 //=============================================================================
1328 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1329                                                 (GEOM::GEOM_Object_ptr   theShape,
1330                                                  const CORBA::Long       theShapeType,
1331                                                  GEOM::GEOM_Object_ptr   theAx1,
1332                                                  GEOM::GEOM_Object_ptr   thePnt,
1333                                                  const GEOM::shape_state theState)
1334 {
1335   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1336
1337   //Set a not done flag
1338   GetOperations()->SetNotDone();
1339
1340   //Get the reference objects
1341   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1342   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1343   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1344
1345   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1346
1347   //Get Shapes On Plane
1348   Handle(TColStd_HSequenceOfInteger) aHSeq =
1349     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1350                                                      anAx1, anPnt, ShapeState(theState));
1351   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1352     return aSeq._retn();
1353
1354   Standard_Integer aLength = aHSeq->Length();
1355   aSeq->length(aLength);
1356   for (Standard_Integer i = 1; i <= aLength; i++)
1357     aSeq[i-1] = aHSeq->Value(i);
1358
1359   return aSeq._retn();
1360 }
1361
1362 //=============================================================================
1363 /*!
1364  *  GetShapesOnCylinderIDs
1365  */
1366 //=============================================================================
1367 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1368                                                 (GEOM::GEOM_Object_ptr   theShape,
1369                                                  const CORBA::Long       theShapeType,
1370                                                  GEOM::GEOM_Object_ptr   theAxis,
1371                                                  const CORBA::Double     theRadius,
1372                                                  const GEOM::shape_state theState)
1373 {
1374   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1375
1376   //Set a not done flag
1377   GetOperations()->SetNotDone();
1378
1379   //Get the reference objects
1380   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1381   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1382
1383   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1384
1385   //Get Shapes On Cylinder
1386   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1387     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1388   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1389     return aSeq._retn();
1390
1391   Standard_Integer aLength = aHSeq->Length();
1392   aSeq->length(aLength);
1393   for (Standard_Integer i = 1; i <= aLength; i++)
1394     aSeq[i-1] = aHSeq->Value(i);
1395
1396   return aSeq._retn();
1397 }
1398
1399 //=============================================================================
1400 /*!
1401  *  GetShapesOnCylinderWithLocationIDs
1402  */
1403 //=============================================================================
1404 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1405                                                 (GEOM::GEOM_Object_ptr   theShape,
1406                                                  const CORBA::Long       theShapeType,
1407                                                  GEOM::GEOM_Object_ptr   theAxis,
1408                                                  GEOM::GEOM_Object_ptr   thePnt,
1409                                                  const CORBA::Double     theRadius,
1410                                                  const GEOM::shape_state theState)
1411 {
1412   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1413
1414   //Set a not done flag
1415   GetOperations()->SetNotDone();
1416
1417   //Get the reference objects
1418   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1419   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1420   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1421
1422   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1423
1424   //Get Shapes On Cylinder
1425   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1426     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1427   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1428     return aSeq._retn();
1429
1430   Standard_Integer aLength = aHSeq->Length();
1431   aSeq->length(aLength);
1432   for (Standard_Integer i = 1; i <= aLength; i++)
1433     aSeq[i-1] = aHSeq->Value(i);
1434
1435   return aSeq._retn();
1436 }
1437
1438 //=============================================================================
1439 /*!
1440  *  GetShapesOnSphereIDs
1441  */
1442 //=============================================================================
1443 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1444                                                 (GEOM::GEOM_Object_ptr   theShape,
1445                                                  const CORBA::Long       theShapeType,
1446                                                  GEOM::GEOM_Object_ptr   theCenter,
1447                                                  const CORBA::Double     theRadius,
1448                                                  const GEOM::shape_state theState)
1449 {
1450   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1451
1452   //Set a not done flag
1453   GetOperations()->SetNotDone();
1454
1455   //Get the reference objects
1456   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1457   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1458
1459   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1460
1461   //Get Shapes On Sphere
1462   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1463     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1464   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1465     return aSeq._retn();
1466
1467   Standard_Integer aLength = aHSeq->Length();
1468   aSeq->length(aLength);
1469   for (Standard_Integer i = 1; i <= aLength; i++)
1470     aSeq[i-1] = aHSeq->Value(i);
1471
1472   return aSeq._retn();
1473 }
1474
1475 //=============================================================================
1476 /*!
1477  *  GetShapesOnQuadrangleIDs
1478  */
1479 //=============================================================================
1480 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1481                                                 (GEOM::GEOM_Object_ptr theShape,
1482                                                  CORBA::Long           theShapeType,
1483                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1484                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1485                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1486                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1487                                                  GEOM::shape_state     theState)
1488 {
1489   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1490
1491   //Set a not done flag
1492   GetOperations()->SetNotDone();
1493
1494   //Get the reference objects
1495   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1496   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1497   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1498   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1499   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1500
1501   if (aShape.IsNull() ||
1502       aTopLeftPoint.IsNull() ||
1503       aTopRigthPoint.IsNull() ||
1504       aBottomLeftPoint.IsNull() ||
1505       aBottomRigthPoint.IsNull() )
1506     return aSeq._retn();
1507
1508   //Get Shapes On Quadrangle
1509   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1510     (aShape, theShapeType,
1511      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1512      ShapeState(theState));
1513   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1514     return aSeq._retn();
1515
1516   Standard_Integer aLength = aHSeq->Length();
1517   aSeq->length(aLength);
1518   for (Standard_Integer i = 1; i <= aLength; i++)
1519     aSeq[i-1] = aHSeq->Value(i);
1520
1521   return aSeq._retn();
1522 }
1523
1524 //=============================================================================
1525 /*!
1526  *  GetShapesOnBox
1527  */
1528 //=============================================================================
1529 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1530                                                 (GEOM::GEOM_Object_ptr theBox,
1531                                                  GEOM::GEOM_Object_ptr theShape,
1532                                                  CORBA::Long           theShapeType,
1533                                                  GEOM::shape_state     theState)
1534 {
1535   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1536
1537   //Set a not done flag
1538   GetOperations()->SetNotDone();
1539
1540   //Get the reference objects
1541   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1542   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1543
1544   if (aShape.IsNull() || aBox.IsNull() )
1545     return aSeq._retn();
1546
1547   //Get Shapes On Box
1548   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1549     (aBox,aShape, theShapeType,ShapeState(theState));
1550   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1551     return aSeq._retn();
1552
1553   Standard_Integer aLength = aHSeq->Length();
1554   aSeq->length(aLength);
1555   for (Standard_Integer i = 1; i <= aLength; i++)
1556     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1557
1558   return aSeq._retn();
1559 }
1560
1561 //=============================================================================
1562 /*!
1563  *  GetShapesOnQuadrangleIDs
1564  */
1565 //=============================================================================
1566 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1567                                                 (GEOM::GEOM_Object_ptr theBox,
1568                                                  GEOM::GEOM_Object_ptr theShape,
1569                                                  CORBA::Long           theShapeType,
1570                                                  GEOM::shape_state     theState)
1571 {
1572   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1573
1574   //Set a not done flag
1575   GetOperations()->SetNotDone();
1576
1577   //Get the reference objects
1578   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1579   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1580
1581   if (aShape.IsNull() || aBox.IsNull() )
1582     return aSeq._retn();
1583
1584   //Get Shapes On Box
1585   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1586     (aBox,aShape, theShapeType,ShapeState(theState));
1587   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1588     return aSeq._retn();
1589
1590   Standard_Integer aLength = aHSeq->Length();
1591   aSeq->length(aLength);
1592   for (Standard_Integer i = 1; i <= aLength; i++)
1593     aSeq[i-1] = aHSeq->Value(i);
1594
1595   return aSeq._retn();
1596 }
1597
1598
1599 //=============================================================================
1600 /*!
1601  *  GetShapesOnShape
1602  */
1603 //=============================================================================
1604 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1605                                            (GEOM::GEOM_Object_ptr theCheckShape,
1606                                             GEOM::GEOM_Object_ptr theShape,
1607                                             CORBA::Short          theShapeType,
1608                                             GEOM::shape_state     theState)
1609 {
1610   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1611
1612   //Set a not done flag
1613   GetOperations()->SetNotDone();
1614
1615   //Get the reference objects
1616   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1617   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1618
1619   if (aShape.IsNull() || aCheckShape.IsNull() )
1620     return aSeq._retn();
1621
1622   //Get Shapes On Shape
1623   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1624     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1625
1626   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1627     return aSeq._retn();
1628
1629   Standard_Integer aLength = aHSeq->Length();
1630   aSeq->length(aLength);
1631   for (Standard_Integer i = 1; i <= aLength; i++)
1632     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1633
1634   return aSeq._retn();
1635 }
1636
1637
1638 //=============================================================================
1639 /*!
1640  *  GetShapesOnShapeAsCompound
1641  */
1642 //=============================================================================
1643 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1644                                            (GEOM::GEOM_Object_ptr theCheckShape,
1645                                             GEOM::GEOM_Object_ptr theShape,
1646                                             CORBA::Short          theShapeType,
1647                                             GEOM::shape_state     theState)
1648 {
1649   GEOM::GEOM_Object_var aGEOMObject;
1650
1651   //Set a not done flag
1652   GetOperations()->SetNotDone();
1653
1654   //Get the reference objects
1655   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1656   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1657
1658   if (aShape.IsNull() || aCheckShape.IsNull() )
1659     return aGEOMObject._retn();
1660
1661   //Get Shapes On Shape
1662   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1663     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1664
1665   if (anObject.IsNull())
1666     return aGEOMObject._retn();
1667
1668   return GetObject(anObject);
1669 }
1670
1671
1672 //=============================================================================
1673 /*!
1674  *  GetShapesOnShapeIDs
1675  */
1676 //=============================================================================
1677 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1678                                            (GEOM::GEOM_Object_ptr theCheckShape,
1679                                             GEOM::GEOM_Object_ptr theShape,
1680                                             CORBA::Short          theShapeType,
1681                                             GEOM::shape_state     theState)
1682 {
1683   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1684
1685   //Set a not done flag
1686   GetOperations()->SetNotDone();
1687
1688   //Get the reference objects
1689   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1690   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1691
1692   if (aShape.IsNull() || aCheckShape.IsNull() )
1693     return aSeq._retn();
1694
1695   //Get Shapes On Shape
1696   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1697     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1698   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1699     return aSeq._retn();
1700
1701   Standard_Integer aLength = aHSeq->Length();
1702   aSeq->length(aLength);
1703   for (Standard_Integer i = 1; i <= aLength; i++)
1704     aSeq[i-1] = aHSeq->Value(i);
1705
1706   return aSeq._retn();
1707 }
1708
1709
1710 //=============================================================================
1711 /*!
1712  *  GetInPlace
1713  */
1714 //=============================================================================
1715 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1716                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1717                                            GEOM::GEOM_Object_ptr theShapeWhat)
1718 {
1719   GEOM::GEOM_Object_var aGEOMObject;
1720
1721   //Set a not done flag
1722   GetOperations()->SetNotDone();
1723
1724   //Get the reference objects
1725   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1726   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1727
1728   if (aShapeWhere.IsNull() ||
1729       aShapeWhat.IsNull()) return aGEOMObject._retn();
1730
1731   //Get Shapes in place of aShapeWhat
1732   Handle(GEOM_Object) anObject =
1733     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1734   if (!GetOperations()->IsDone() || anObject.IsNull())
1735     return aGEOMObject._retn();
1736
1737   return GetObject(anObject);
1738 }
1739
1740 //=============================================================================
1741 /*!
1742  *  GetInPlaceByHistory
1743  */
1744 //=============================================================================
1745 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1746                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1747                                            GEOM::GEOM_Object_ptr theShapeWhat)
1748 {
1749   GEOM::GEOM_Object_var aGEOMObject;
1750
1751   //Set a not done flag
1752   GetOperations()->SetNotDone();
1753
1754   //Get the reference objects
1755   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1756   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1757
1758   if (aShapeWhere.IsNull() ||
1759       aShapeWhat.IsNull()) return aGEOMObject._retn();
1760
1761   //Get Shapes in place of aShapeWhat
1762   Handle(GEOM_Object) anObject =
1763     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1764   if (!GetOperations()->IsDone() || anObject.IsNull())
1765     return aGEOMObject._retn();
1766
1767   return GetObject(anObject);
1768 }
1769
1770 //=============================================================================
1771 /*!
1772  *  GetSame
1773  */
1774 //=============================================================================
1775 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1776                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1777                                            GEOM::GEOM_Object_ptr theShapeWhat)
1778 {
1779   GEOM::GEOM_Object_var aGEOMObject;
1780
1781   //Set a not done flag
1782   GetOperations()->SetNotDone();
1783
1784   //Get the reference objects
1785   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1786   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1787
1788   if (aShapeWhere.IsNull() ||
1789       aShapeWhat.IsNull()) return aGEOMObject._retn();
1790
1791   //Get Shapes in place of aShapeWhat
1792   Handle(GEOM_Object) anObject =
1793     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1794   if (!GetOperations()->IsDone() || anObject.IsNull())
1795     return aGEOMObject._retn();
1796
1797   return GetObject(anObject);
1798 }