Salome HOME
0022686: [CEA 1268] Explode a shape into edges sorted in a row from a starting point
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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  *  GetSubShapesIndices
837  */
838 //=============================================================================
839 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
840   (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
841 {
842   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
843   
844   //Get the reference main shape
845   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape); 
846   if (aMainShapeRef.IsNull()) return aSeq._retn();
847       
848   //Get the subshapes
849   std::list<Handle(GEOM_Object)> aShapes;
850   int aLen = theSubShapes.length();
851   for (int ind = 0; ind < aLen; ind++) {
852     Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
853     if (aSh.IsNull())
854     {
855       MESSAGE("NULL shape")
856       return aSeq._retn();
857     }
858     aShapes.push_back(aSh);
859   }
860
861   //Get the IDs of <theSubShapes> inside <theMainShape>
862   Handle(TColStd_HSequenceOfInteger) aHSeq = 
863   GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
864   
865   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
866
867   Standard_Integer aLength = aHSeq->Length();
868   aSeq->length(aLength);
869   
870   for (Standard_Integer i = 1; i <= aLength; i++)
871     aSeq[i-1] = aHSeq->Value(i);
872
873   return aSeq._retn();
874 }
875
876
877 //=============================================================================
878 /*!
879  *  GetTopologyIndex
880  */
881 //=============================================================================
882 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
883   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
884 {
885   //Get the reference shapes
886   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
887   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
888
889   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
890
891   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
892   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
893   if (!GetOperations()->IsDone())
894     return -1;
895
896   return anID;
897 }
898
899 //=============================================================================
900 /*!
901  *  GetShapeTypeString
902  */
903 //=============================================================================
904 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
905 {
906   //Get the reference shape
907   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
908   if (aShape.IsNull()) return NULL;
909
910   // Get shape parameters
911   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
912   return CORBA::string_dup(aDescription.ToCString());
913 }
914
915 //=============================================================================
916 /*!
917  *  NumberOfFaces
918  */
919 //=============================================================================
920 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
921 {
922   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
923 }
924
925 //=============================================================================
926 /*!
927  *  NumberOfEdges
928  */
929 //=============================================================================
930 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
931 {
932   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
933 }
934
935 //=============================================================================
936 /*!
937  *  NumberOfSubShapes
938  */
939 //=============================================================================
940 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
941                                                          const CORBA::Long     theShapeType)
942 {
943   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
944   if (aShape.IsNull()) return -1;
945
946   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
947   if (!GetOperations()->IsDone()) return -1;
948
949   return aNb;
950 }
951
952 //=============================================================================
953 /*!
954  *  ChangeOrientation
955  */
956 //=============================================================================
957 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
958                                                 (GEOM::GEOM_Object_ptr theShape)
959 {
960   GEOM::GEOM_Object_var aGEOMObject;
961
962   //Set a not done flag
963   GetOperations()->SetNotDone();
964
965   //Get the reference objects
966   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
967   if (aShape.IsNull()) return aGEOMObject._retn();
968
969   //Create the Solid
970   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
971   if (!GetOperations()->IsDone() || anObject.IsNull())
972     return aGEOMObject._retn();
973
974   return GetObject(anObject);
975 }
976
977 //=============================================================================
978 /*!
979  *  GetFreeFacesIDs
980  */
981 //=============================================================================
982 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
983 {
984   //Set a not done flag
985   GetOperations()->SetNotDone();
986
987   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
988
989   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
990   if (aShape.IsNull()) return aSeq._retn();
991
992   Handle(TColStd_HSequenceOfInteger) aHSeq =
993     GetOperations()->GetFreeFacesIDs(aShape);
994   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
995
996   Standard_Integer aLength = aHSeq->Length();
997   aSeq->length(aLength);
998   for (Standard_Integer i = 1; i <= aLength; i++)
999     aSeq[i-1] = aHSeq->Value(i);
1000
1001   return aSeq._retn();
1002 }
1003
1004 //=============================================================================
1005 /*!
1006  *  GetSharedShapes
1007  */
1008 //=============================================================================
1009 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1010                                           (GEOM::GEOM_Object_ptr theShape1,
1011                                            GEOM::GEOM_Object_ptr theShape2,
1012                                            const CORBA::Long     theShapeType)
1013 {
1014   //Set a not done flag
1015   GetOperations()->SetNotDone();
1016
1017   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1018
1019   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1020   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1021
1022   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1023
1024   Handle(TColStd_HSequenceOfTransient) aHSeq =
1025     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1026   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1027     return aSeq._retn();
1028
1029   Standard_Integer aLength = aHSeq->Length();
1030   aSeq->length(aLength);
1031   for (Standard_Integer i = 1; i <= aLength; i++)
1032     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1033
1034   return aSeq._retn();
1035 }
1036
1037 //=============================================================================
1038 /*!
1039  *  GetSharedShapesMulti
1040  */
1041 //=============================================================================
1042 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1043                                           (const GEOM::ListOfGO& theShapes,
1044                                            const CORBA::Long     theShapeType)
1045 {
1046   //Set a not done flag
1047   GetOperations()->SetNotDone();
1048
1049   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1050
1051   //Get the shapes
1052   std::list<Handle(GEOM_Object)> aShapes;
1053   int aLen = theShapes.length();
1054   for (int ind = 0; ind < aLen; ind++) {
1055     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
1056     if (aSh.IsNull()) return aSeq._retn();
1057     aShapes.push_back(aSh);
1058   }
1059
1060   Handle(TColStd_HSequenceOfTransient) aHSeq =
1061     GetOperations()->GetSharedShapes(aShapes, theShapeType);
1062   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1063     return aSeq._retn();
1064
1065   Standard_Integer aLength = aHSeq->Length();
1066   aSeq->length(aLength);
1067   for (Standard_Integer i = 1; i <= aLength; i++)
1068     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1069
1070   return aSeq._retn();
1071 }
1072
1073 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1074 {
1075   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1076
1077   switch (theState) {
1078   case GEOM::ST_ON:
1079     aState = GEOMAlgo_ST_ON;
1080     break;
1081   case GEOM::ST_OUT:
1082     aState = GEOMAlgo_ST_OUT;
1083     break;
1084   case GEOM::ST_ONOUT:
1085     aState = GEOMAlgo_ST_ONOUT;
1086     break;
1087   case GEOM::ST_IN:
1088     aState = GEOMAlgo_ST_IN;
1089     break;
1090   case GEOM::ST_ONIN:
1091     aState = GEOMAlgo_ST_ONIN;
1092     break;
1093   default:
1094     break;
1095   }
1096
1097   return aState;
1098 }
1099
1100 //=============================================================================
1101 /*!
1102  *  GetShapesOnPlane
1103  */
1104 //=============================================================================
1105 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1106                                                 (GEOM::GEOM_Object_ptr   theShape,
1107                                                  const CORBA::Long       theShapeType,
1108                                                  GEOM::GEOM_Object_ptr   theAx1,
1109                                                  const GEOM::shape_state theState)
1110 {
1111   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1112
1113   //Set a not done flag
1114   GetOperations()->SetNotDone();
1115
1116   //Get the reference objects
1117   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1118   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1119
1120   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1121
1122   //Get Shapes On Plane
1123   Handle(TColStd_HSequenceOfTransient) aHSeq =
1124     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1125   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1126     return aSeq._retn();
1127
1128   Standard_Integer aLength = aHSeq->Length();
1129   aSeq->length(aLength);
1130   for (Standard_Integer i = 1; i <= aLength; i++)
1131     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1132
1133   return aSeq._retn();
1134 }
1135
1136 //=============================================================================
1137 /*!
1138  *  GetShapesOnPlaneWithLocation
1139  */
1140 //=============================================================================
1141 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1142                                                 (GEOM::GEOM_Object_ptr   theShape,
1143                                                  const CORBA::Long       theShapeType,
1144                                                  GEOM::GEOM_Object_ptr   theAx1,
1145                                                  GEOM::GEOM_Object_ptr   thePnt,
1146                                                  const GEOM::shape_state theState)
1147 {
1148   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1149
1150   //Set a not done flag
1151   GetOperations()->SetNotDone();
1152
1153   //Get the reference objects
1154   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1155   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1156   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1157
1158   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1159
1160   //Get Shapes On Plane
1161   Handle(TColStd_HSequenceOfTransient) aHSeq =
1162     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1163   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1164     return aSeq._retn();
1165
1166   Standard_Integer aLength = aHSeq->Length();
1167   aSeq->length(aLength);
1168   for (Standard_Integer i = 1; i <= aLength; i++)
1169     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1170
1171   return aSeq._retn();
1172 }
1173
1174 //=============================================================================
1175 /*!
1176  *  GetShapesOnCylinder
1177  */
1178 //=============================================================================
1179 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1180                                                 (GEOM::GEOM_Object_ptr   theShape,
1181                                                  const CORBA::Long       theShapeType,
1182                                                  GEOM::GEOM_Object_ptr   theAxis,
1183                                                  const CORBA::Double     theRadius,
1184                                                  const GEOM::shape_state theState)
1185 {
1186   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1187
1188   //Set a not done flag
1189   GetOperations()->SetNotDone();
1190
1191   //Get the reference objects
1192   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1193   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1194
1195   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1196
1197   //Get Shapes On Cylinder
1198   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1199     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1200   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1201     return aSeq._retn();
1202
1203   Standard_Integer aLength = aHSeq->Length();
1204   aSeq->length(aLength);
1205   for (Standard_Integer i = 1; i <= aLength; i++)
1206     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1207
1208   return aSeq._retn();
1209 }
1210
1211 //=============================================================================
1212 /*!
1213  *  GetShapesOnCylinderWithLocation
1214  */
1215 //=============================================================================
1216 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1217                                                 (GEOM::GEOM_Object_ptr   theShape,
1218                                                  const CORBA::Long       theShapeType,
1219                                                  GEOM::GEOM_Object_ptr   theAxis,
1220                                                  GEOM::GEOM_Object_ptr   thePnt,
1221                                                  const CORBA::Double     theRadius,
1222                                                  const GEOM::shape_state theState)
1223 {
1224   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1225
1226   //Set a not done flag
1227   GetOperations()->SetNotDone();
1228
1229   //Get the reference objects
1230   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1231   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1232   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1233
1234   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1235
1236   //Get Shapes On Cylinder
1237   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1238     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1239   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1240     return aSeq._retn();
1241
1242   Standard_Integer aLength = aHSeq->Length();
1243   aSeq->length(aLength);
1244   for (Standard_Integer i = 1; i <= aLength; i++)
1245     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1246
1247   return aSeq._retn();
1248 }
1249
1250 //=============================================================================
1251 /*!
1252  *  GetShapesOnSphere
1253  */
1254 //=============================================================================
1255 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1256                                                 (GEOM::GEOM_Object_ptr   theShape,
1257                                                  const CORBA::Long       theShapeType,
1258                                                  GEOM::GEOM_Object_ptr   theCenter,
1259                                                  const CORBA::Double     theRadius,
1260                                                  const GEOM::shape_state theState)
1261 {
1262   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1263
1264   //Set a not done flag
1265   GetOperations()->SetNotDone();
1266
1267   //Get the reference objects
1268   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1269   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1270
1271   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1272
1273   //Get Shapes On Sphere
1274   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1275     (aShape, theShapeType, aCenter, theRadius, 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  *  GetShapesOnQuadrangle
1290  */
1291 //=============================================================================
1292 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1293                                                 (GEOM::GEOM_Object_ptr theShape,
1294                                                  CORBA::Long           theShapeType,
1295                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1296                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1297                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1298                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1299                                                  GEOM::shape_state     theState)
1300 {
1301   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1302
1303   //Set a not done flag
1304   GetOperations()->SetNotDone();
1305
1306   //Get the reference objects
1307   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1308   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1309   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1310   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1311   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1312
1313   if (aShape.IsNull() ||
1314       aTopLeftPoint.IsNull() ||
1315       aTopRigthPoint.IsNull() ||
1316       aBottomLeftPoint.IsNull() ||
1317       aBottomRigthPoint.IsNull())
1318     return aSeq._retn();
1319
1320   //Get Shapes On Quadrangle
1321   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1322     (aShape, theShapeType,
1323      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1324      ShapeState(theState));
1325   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1326     return aSeq._retn();
1327
1328   Standard_Integer aLength = aHSeq->Length();
1329   aSeq->length(aLength);
1330   for (Standard_Integer i = 1; i <= aLength; i++)
1331     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1332
1333   return aSeq._retn();
1334 }
1335
1336 //=============================================================================
1337 /*!
1338  *  GetShapesOnPlaneIDs
1339  */
1340 //=============================================================================
1341 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1342                                                 (GEOM::GEOM_Object_ptr   theShape,
1343                                                  const CORBA::Long       theShapeType,
1344                                                  GEOM::GEOM_Object_ptr   theAx1,
1345                                                  const GEOM::shape_state theState)
1346 {
1347   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1348
1349   //Set a not done flag
1350   GetOperations()->SetNotDone();
1351
1352   //Get the reference objects
1353   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1354   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1355
1356   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1357
1358   //Get Shapes On Plane
1359   Handle(TColStd_HSequenceOfInteger) aHSeq =
1360     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1361   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1362     return aSeq._retn();
1363
1364   Standard_Integer aLength = aHSeq->Length();
1365   aSeq->length(aLength);
1366   for (Standard_Integer i = 1; i <= aLength; i++)
1367     aSeq[i-1] = aHSeq->Value(i);
1368
1369   return aSeq._retn();
1370 }
1371
1372 //=============================================================================
1373 /*!
1374  *  GetShapesOnPlaneWithLocationIDs
1375  */
1376 //=============================================================================
1377 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1378                                                 (GEOM::GEOM_Object_ptr   theShape,
1379                                                  const CORBA::Long       theShapeType,
1380                                                  GEOM::GEOM_Object_ptr   theAx1,
1381                                                  GEOM::GEOM_Object_ptr   thePnt,
1382                                                  const GEOM::shape_state theState)
1383 {
1384   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1385
1386   //Set a not done flag
1387   GetOperations()->SetNotDone();
1388
1389   //Get the reference objects
1390   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1391   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1392   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1393
1394   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1395
1396   //Get Shapes On Plane
1397   Handle(TColStd_HSequenceOfInteger) aHSeq =
1398     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1399                                                      anAx1, anPnt, ShapeState(theState));
1400   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1401     return aSeq._retn();
1402
1403   Standard_Integer aLength = aHSeq->Length();
1404   aSeq->length(aLength);
1405   for (Standard_Integer i = 1; i <= aLength; i++)
1406     aSeq[i-1] = aHSeq->Value(i);
1407
1408   return aSeq._retn();
1409 }
1410
1411 //=============================================================================
1412 /*!
1413  *  GetShapesOnCylinderIDs
1414  */
1415 //=============================================================================
1416 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1417                                                 (GEOM::GEOM_Object_ptr   theShape,
1418                                                  const CORBA::Long       theShapeType,
1419                                                  GEOM::GEOM_Object_ptr   theAxis,
1420                                                  const CORBA::Double     theRadius,
1421                                                  const GEOM::shape_state theState)
1422 {
1423   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1424
1425   //Set a not done flag
1426   GetOperations()->SetNotDone();
1427
1428   //Get the reference objects
1429   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1430   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1431
1432   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1433
1434   //Get Shapes On Cylinder
1435   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1436     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1437   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1438     return aSeq._retn();
1439
1440   Standard_Integer aLength = aHSeq->Length();
1441   aSeq->length(aLength);
1442   for (Standard_Integer i = 1; i <= aLength; i++)
1443     aSeq[i-1] = aHSeq->Value(i);
1444
1445   return aSeq._retn();
1446 }
1447
1448 //=============================================================================
1449 /*!
1450  *  GetShapesOnCylinderWithLocationIDs
1451  */
1452 //=============================================================================
1453 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1454                                                 (GEOM::GEOM_Object_ptr   theShape,
1455                                                  const CORBA::Long       theShapeType,
1456                                                  GEOM::GEOM_Object_ptr   theAxis,
1457                                                  GEOM::GEOM_Object_ptr   thePnt,
1458                                                  const CORBA::Double     theRadius,
1459                                                  const GEOM::shape_state theState)
1460 {
1461   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1462
1463   //Set a not done flag
1464   GetOperations()->SetNotDone();
1465
1466   //Get the reference objects
1467   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1468   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1469   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1470
1471   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1472
1473   //Get Shapes On Cylinder
1474   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1475     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1476   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1477     return aSeq._retn();
1478
1479   Standard_Integer aLength = aHSeq->Length();
1480   aSeq->length(aLength);
1481   for (Standard_Integer i = 1; i <= aLength; i++)
1482     aSeq[i-1] = aHSeq->Value(i);
1483
1484   return aSeq._retn();
1485 }
1486
1487 //=============================================================================
1488 /*!
1489  *  GetShapesOnSphereIDs
1490  */
1491 //=============================================================================
1492 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1493                                                 (GEOM::GEOM_Object_ptr   theShape,
1494                                                  const CORBA::Long       theShapeType,
1495                                                  GEOM::GEOM_Object_ptr   theCenter,
1496                                                  const CORBA::Double     theRadius,
1497                                                  const GEOM::shape_state theState)
1498 {
1499   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1500
1501   //Set a not done flag
1502   GetOperations()->SetNotDone();
1503
1504   //Get the reference objects
1505   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1506   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1507
1508   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1509
1510   //Get Shapes On Sphere
1511   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1512     (aShape, theShapeType, aCenter, theRadius, 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  *  GetShapesOnQuadrangleIDs
1527  */
1528 //=============================================================================
1529 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1530                                                 (GEOM::GEOM_Object_ptr theShape,
1531                                                  CORBA::Long           theShapeType,
1532                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1533                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1534                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1535                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1536                                                  GEOM::shape_state     theState)
1537 {
1538   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1539
1540   //Set a not done flag
1541   GetOperations()->SetNotDone();
1542
1543   //Get the reference objects
1544   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1545   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1546   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1547   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1548   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1549
1550   if (aShape.IsNull() ||
1551       aTopLeftPoint.IsNull() ||
1552       aTopRigthPoint.IsNull() ||
1553       aBottomLeftPoint.IsNull() ||
1554       aBottomRigthPoint.IsNull() )
1555     return aSeq._retn();
1556
1557   //Get Shapes On Quadrangle
1558   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1559     (aShape, theShapeType,
1560      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1561      ShapeState(theState));
1562   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1563     return aSeq._retn();
1564
1565   Standard_Integer aLength = aHSeq->Length();
1566   aSeq->length(aLength);
1567   for (Standard_Integer i = 1; i <= aLength; i++)
1568     aSeq[i-1] = aHSeq->Value(i);
1569
1570   return aSeq._retn();
1571 }
1572
1573 //=============================================================================
1574 /*!
1575  *  GetShapesOnBox
1576  */
1577 //=============================================================================
1578 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1579                                                 (GEOM::GEOM_Object_ptr theBox,
1580                                                  GEOM::GEOM_Object_ptr theShape,
1581                                                  CORBA::Long           theShapeType,
1582                                                  GEOM::shape_state     theState)
1583 {
1584   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1585
1586   //Set a not done flag
1587   GetOperations()->SetNotDone();
1588
1589   //Get the reference objects
1590   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1591   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1592
1593   if (aShape.IsNull() || aBox.IsNull() )
1594     return aSeq._retn();
1595
1596   //Get Shapes On Box
1597   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1598     (aBox,aShape, theShapeType,ShapeState(theState));
1599   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1600     return aSeq._retn();
1601
1602   Standard_Integer aLength = aHSeq->Length();
1603   aSeq->length(aLength);
1604   for (Standard_Integer i = 1; i <= aLength; i++)
1605     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1606
1607   return aSeq._retn();
1608 }
1609
1610 //=============================================================================
1611 /*!
1612  *  GetShapesOnQuadrangleIDs
1613  */
1614 //=============================================================================
1615 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1616                                                 (GEOM::GEOM_Object_ptr theBox,
1617                                                  GEOM::GEOM_Object_ptr theShape,
1618                                                  CORBA::Long           theShapeType,
1619                                                  GEOM::shape_state     theState)
1620 {
1621   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1622
1623   //Set a not done flag
1624   GetOperations()->SetNotDone();
1625
1626   //Get the reference objects
1627   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1628   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1629
1630   if (aShape.IsNull() || aBox.IsNull() )
1631     return aSeq._retn();
1632
1633   //Get Shapes On Box
1634   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1635     (aBox,aShape, theShapeType,ShapeState(theState));
1636   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1637     return aSeq._retn();
1638
1639   Standard_Integer aLength = aHSeq->Length();
1640   aSeq->length(aLength);
1641   for (Standard_Integer i = 1; i <= aLength; i++)
1642     aSeq[i-1] = aHSeq->Value(i);
1643
1644   return aSeq._retn();
1645 }
1646
1647
1648 //=============================================================================
1649 /*!
1650  *  GetShapesOnShape
1651  */
1652 //=============================================================================
1653 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1654                                            (GEOM::GEOM_Object_ptr theCheckShape,
1655                                             GEOM::GEOM_Object_ptr theShape,
1656                                             CORBA::Short          theShapeType,
1657                                             GEOM::shape_state     theState)
1658 {
1659   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1660
1661   //Set a not done flag
1662   GetOperations()->SetNotDone();
1663
1664   //Get the reference objects
1665   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1666   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1667
1668   if (aShape.IsNull() || aCheckShape.IsNull() )
1669     return aSeq._retn();
1670
1671   //Get Shapes On Shape
1672   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1673     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1674
1675   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1676     return aSeq._retn();
1677
1678   Standard_Integer aLength = aHSeq->Length();
1679   aSeq->length(aLength);
1680   for (Standard_Integer i = 1; i <= aLength; i++)
1681     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1682
1683   return aSeq._retn();
1684 }
1685
1686
1687 //=============================================================================
1688 /*!
1689  *  GetShapesOnShapeAsCompound
1690  */
1691 //=============================================================================
1692 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1693                                            (GEOM::GEOM_Object_ptr theCheckShape,
1694                                             GEOM::GEOM_Object_ptr theShape,
1695                                             CORBA::Short          theShapeType,
1696                                             GEOM::shape_state     theState)
1697 {
1698   GEOM::GEOM_Object_var aGEOMObject;
1699
1700   //Set a not done flag
1701   GetOperations()->SetNotDone();
1702
1703   //Get the reference objects
1704   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1705   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1706
1707   if (aShape.IsNull() || aCheckShape.IsNull() )
1708     return aGEOMObject._retn();
1709
1710   //Get Shapes On Shape
1711   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1712     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1713
1714   if (anObject.IsNull())
1715     return aGEOMObject._retn();
1716
1717   return GetObject(anObject);
1718 }
1719
1720
1721 //=============================================================================
1722 /*!
1723  *  GetShapesOnShapeIDs
1724  */
1725 //=============================================================================
1726 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1727                                            (GEOM::GEOM_Object_ptr theCheckShape,
1728                                             GEOM::GEOM_Object_ptr theShape,
1729                                             CORBA::Short          theShapeType,
1730                                             GEOM::shape_state     theState)
1731 {
1732   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1733
1734   //Set a not done flag
1735   GetOperations()->SetNotDone();
1736
1737   //Get the reference objects
1738   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1739   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1740
1741   if (aShape.IsNull() || aCheckShape.IsNull() )
1742     return aSeq._retn();
1743
1744   //Get Shapes On Shape
1745   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1746     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1747   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1748     return aSeq._retn();
1749
1750   Standard_Integer aLength = aHSeq->Length();
1751   aSeq->length(aLength);
1752   for (Standard_Integer i = 1; i <= aLength; i++)
1753     aSeq[i-1] = aHSeq->Value(i);
1754
1755   return aSeq._retn();
1756 }
1757
1758
1759 //=============================================================================
1760 /*!
1761  *  GetInPlace
1762  */
1763 //=============================================================================
1764 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1765                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1766                                            GEOM::GEOM_Object_ptr theShapeWhat)
1767 {
1768   GEOM::GEOM_Object_var aGEOMObject;
1769
1770   //Set a not done flag
1771   GetOperations()->SetNotDone();
1772
1773   //Get the reference objects
1774   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1775   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1776
1777   if (aShapeWhere.IsNull() ||
1778       aShapeWhat.IsNull()) return aGEOMObject._retn();
1779
1780   //Get Shapes in place of aShapeWhat
1781   Handle(GEOM_Object) anObject =
1782     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1783   if (!GetOperations()->IsDone() || anObject.IsNull())
1784     return aGEOMObject._retn();
1785
1786   return GetObject(anObject);
1787 }
1788
1789 //=============================================================================
1790 /*!
1791  *  GetInPlaceOld
1792  */
1793 //=============================================================================
1794 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1795                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1796                                            GEOM::GEOM_Object_ptr theShapeWhat)
1797 {
1798   GEOM::GEOM_Object_var aGEOMObject;
1799
1800   //Set a not done flag
1801   GetOperations()->SetNotDone();
1802
1803   //Get the reference objects
1804   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1805   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1806
1807   if (aShapeWhere.IsNull() ||
1808       aShapeWhat.IsNull()) return aGEOMObject._retn();
1809
1810   //Get Shapes in place of aShapeWhat
1811   Handle(GEOM_Object) anObject =
1812     GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1813   if (!GetOperations()->IsDone() || anObject.IsNull())
1814     return aGEOMObject._retn();
1815
1816   return GetObject(anObject);
1817 }
1818
1819 //=============================================================================
1820 /*!
1821  *  GetInPlaceByHistory
1822  */
1823 //=============================================================================
1824 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1825                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1826                                            GEOM::GEOM_Object_ptr theShapeWhat)
1827 {
1828   GEOM::GEOM_Object_var aGEOMObject;
1829
1830   //Set a not done flag
1831   GetOperations()->SetNotDone();
1832
1833   //Get the reference objects
1834   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1835   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1836
1837   if (aShapeWhere.IsNull() ||
1838       aShapeWhat.IsNull()) return aGEOMObject._retn();
1839
1840   //Get Shapes in place of aShapeWhat
1841   Handle(GEOM_Object) anObject =
1842     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1843   if (!GetOperations()->IsDone() || anObject.IsNull())
1844     return aGEOMObject._retn();
1845
1846   return GetObject(anObject);
1847 }
1848
1849 //=============================================================================
1850 /*!
1851  *  GetSame
1852  */
1853 //=============================================================================
1854 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1855                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1856                                            GEOM::GEOM_Object_ptr theShapeWhat)
1857 {
1858   GEOM::GEOM_Object_var aGEOMObject;
1859
1860   //Set a not done flag
1861   GetOperations()->SetNotDone();
1862
1863   //Get the reference objects
1864   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1865   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1866
1867   if (aShapeWhere.IsNull() ||
1868       aShapeWhat.IsNull()) return aGEOMObject._retn();
1869
1870   //Get Shapes in place of aShapeWhat
1871   Handle(GEOM_Object) anObject =
1872     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1873   if (!GetOperations()->IsDone() || anObject.IsNull())
1874     return aGEOMObject._retn();
1875
1876   return GetObject(anObject);
1877 }
1878
1879 //=============================================================================
1880 /*!
1881  *  GetSameIDs
1882  */
1883 //=============================================================================
1884 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1885                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1886                                            GEOM::GEOM_Object_ptr theShapeWhat) {
1887   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1888
1889   //Get the reference objects
1890   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1891   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1892
1893   if (aShapeWhere.IsNull() ||
1894       aShapeWhat.IsNull()) return aSeq._retn();
1895
1896
1897   Handle(TColStd_HSequenceOfInteger) aHSeq =
1898     GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
1899
1900   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1901
1902   Standard_Integer aLength = aHSeq->Length();
1903   aSeq->length(aLength);
1904   for (Standard_Integer i = 1; i <= aLength; i++)
1905     aSeq[i-1] = aHSeq->Value(i);
1906
1907   return aSeq._retn();
1908 }
1909
1910 //=============================================================================
1911 /*!
1912  *  GetSubShapeEdgeSorted
1913  */
1914 //=============================================================================
1915 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapeEdgeSorted
1916                                         (GEOM::GEOM_Object_ptr theShape,
1917                                          GEOM::GEOM_Object_ptr theStartPoint)
1918 {
1919   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1920
1921   //Set a not done flag
1922   GetOperations()->SetNotDone();
1923
1924   //Get the reference objects
1925   Handle(GEOM_Object) aShape      = GetObjectImpl(theShape);
1926   Handle(GEOM_Object) aStartPoint = GetObjectImpl(theStartPoint);
1927
1928   if (aShape.IsNull() || aStartPoint.IsNull()) {
1929     return aSeq._retn();
1930   }
1931
1932   //Get Shapes On Shape
1933   Handle(TColStd_HSequenceOfTransient) aHSeq =
1934       GetOperations()->GetSubShapeEdgeSorted(aShape, aStartPoint);
1935
1936   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1937     return aSeq._retn();
1938
1939   const Standard_Integer aLength = aHSeq->Length();
1940   Standard_Integer       i;
1941
1942   aSeq->length(aLength);
1943
1944   for (i = 1; i <= aLength; i++) {
1945     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1946   }
1947
1948   return aSeq._retn();
1949 }