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