Salome HOME
0022747: [EDF] Improvement of Get Shared Shapes operation
[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
349 GEOM_IShapesOperations_i::MakeCompound (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
382 GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
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   std::list< Handle(GEOM_Object) > aShapes;
393   if (! GetListOfObjectsImpl( theShapes, aShapes ))
394     return aGEOMObject._retn();
395
396   //Perform the gluing
397   Handle(GEOM_Object) anObject =
398     GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
399   //if (!GetOperations()->IsDone() || anObject.IsNull())
400   // to allow warning
401   if (anObject.IsNull())
402     return aGEOMObject._retn();
403
404   return GetObject(anObject);
405 }
406
407 //=============================================================================
408 /*!
409  *  GetGlueFaces
410  */
411 //=============================================================================
412 GEOM::ListOfGO*
413 GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
414                                         const CORBA::Double   theTolerance)
415 {
416   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
417
418   //Set a not done flag
419   GetOperations()->SetNotDone();
420
421   //Get the reference objects
422   std::list< Handle(GEOM_Object) > aShapes;
423   if (! GetListOfObjectsImpl( theShapes, aShapes ))
424     return aSeq._retn();
425
426   Handle(TColStd_HSequenceOfTransient) aHSeq =
427     GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
428
429   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
430   // to allow warning
431   if(aHSeq.IsNull())
432     return aSeq._retn();
433
434   Standard_Integer aLength = aHSeq->Length();
435   aSeq->length(aLength);
436   for (Standard_Integer i = 1; i <= aLength; i++)
437     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
438
439   return aSeq._retn();
440 }
441
442 //=============================================================================
443 /*!
444  *  MakeGlueFacesByList
445  */
446 //=============================================================================
447 GEOM::GEOM_Object_ptr
448 GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
449                                                CORBA::Double         theTolerance,
450                                                const GEOM::ListOfGO& theFaces,
451                                                CORBA::Boolean        doKeepNonSolids,
452                                                CORBA::Boolean        doGlueAllEdges)
453 {
454   GEOM::GEOM_Object_var aGEOMObject;
455
456   //Set a not done flag
457   GetOperations()->SetNotDone();
458
459   //Get the reference objects
460   std::list< Handle(GEOM_Object) > aShapes;
461   if (! GetListOfObjectsImpl( theShapes, aShapes ))
462     return aGEOMObject._retn();
463
464   //Get the shapes
465   std::list<Handle(GEOM_Object)> aFaces;
466   if (! GetListOfObjectsImpl( theFaces, aFaces ))
467     return aGEOMObject._retn();
468
469   //Perform the gluing
470   Handle(GEOM_Object) anObject =
471     GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
472                                          doKeepNonSolids, doGlueAllEdges);
473   //if (!GetOperations()->IsDone() || anObject.IsNull())
474   // to allow warning
475   if (anObject.IsNull())
476     return aGEOMObject._retn();
477
478   return GetObject(anObject);
479 }
480
481 //=============================================================================
482 /*!
483  *  MakeGlueEdges
484  */
485 //=============================================================================
486 GEOM::GEOM_Object_ptr
487 GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
488                                          CORBA::Double         theTolerance)
489 {
490   GEOM::GEOM_Object_var aGEOMObject;
491
492   //Set a not done flag
493   GetOperations()->SetNotDone();
494
495   //Get the reference objects
496   std::list< Handle(GEOM_Object) > aShapes;
497   if (! GetListOfObjectsImpl( theShapes, aShapes ))
498     return aGEOMObject._retn();
499
500   //Perform the gluing
501   Handle(GEOM_Object) anObject =
502     GetOperations()->MakeGlueEdges(aShapes, theTolerance);
503   //if (!GetOperations()->IsDone() || anObject.IsNull())
504   // to allow warning
505   if (anObject.IsNull())
506     return aGEOMObject._retn();
507
508   return GetObject(anObject);
509 }
510
511 //=============================================================================
512 /*!
513  *  GetGlueEdges
514  */
515 //=============================================================================
516 GEOM::ListOfGO*
517 GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
518                                         const CORBA::Double   theTolerance)
519 {
520   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
521
522   //Set a not done flag
523   GetOperations()->SetNotDone();
524
525   //Get the reference objects
526   std::list< Handle(GEOM_Object) > aShapes;
527   if (! GetListOfObjectsImpl( theShapes, aShapes ))
528     return aSeq._retn();
529
530   Handle(TColStd_HSequenceOfTransient) aHSeq =
531     GetOperations()->GetGlueShapes(aShapes, 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
552 GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
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   std::list< Handle(GEOM_Object) > aShapes;
563   if (! GetListOfObjectsImpl( theShapes, aShapes ))
564     return aGEOMObject._retn();
565
566   //Get the shapes
567   std::list<Handle(GEOM_Object)> anEdges;
568   if (! GetListOfObjectsImpl( theEdges, anEdges ))
569     return aGEOMObject._retn();
570
571   //Perform the gluing
572   Handle(GEOM_Object) anObject =
573     GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
574   //if (!GetOperations()->IsDone() || anObject.IsNull())
575   // to allow warning
576   if (anObject.IsNull())
577     return aGEOMObject._retn();
578
579   return GetObject(anObject);
580 }
581
582 //=============================================================================
583 /*!
584  *  GetExistingSubObjects
585  */
586 //=============================================================================
587 GEOM::ListOfGO*
588 GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
589                                                  CORBA::Boolean        theGroupsOnly)
590 {
591   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
592
593   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
594   if (aShape.IsNull()) return aSeq._retn();
595
596   Handle(TColStd_HSequenceOfTransient) aHSeq =
597     GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
598   if (!GetOperations()->IsDone() || aHSeq.IsNull())
599     return aSeq._retn();
600
601   Standard_Integer aLength = aHSeq->Length();
602   aSeq->length(aLength);
603   for (Standard_Integer i = 1; i <= aLength; i++)
604     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
605
606   return aSeq._retn();
607 }
608
609 //=============================================================================
610 /*!
611  *  MakeExplode (including theShape itself, bad sorting)
612  */
613 //=============================================================================
614 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
615                                                        const CORBA::Long     theShapeType,
616                                                        const CORBA::Boolean  isSorted)
617 {
618   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
619
620   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
621   if (aShape.IsNull()) return aSeq._retn();
622
623   Handle(TColStd_HSequenceOfTransient) aHSeq =
624     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
625                                  GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
626   if (!GetOperations()->IsDone() || aHSeq.IsNull())
627     return aSeq._retn();
628
629   Standard_Integer aLength = aHSeq->Length();
630   aSeq->length(aLength);
631   for (Standard_Integer i = 1; i <= aLength; i++)
632     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
633
634   return aSeq._retn();
635 }
636
637 //=============================================================================
638 /*!
639  *  MakeAllSubShapes (including theShape itself, good sorting)
640  */
641 //=============================================================================
642 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
643                                                             const CORBA::Long     theShapeType,
644                                                             const CORBA::Boolean  isSorted)
645 {
646   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
647
648   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
649   if (aShape.IsNull()) return aSeq._retn();
650
651   Handle(TColStd_HSequenceOfTransient) aHSeq =
652     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
653                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
654   if (!GetOperations()->IsDone() || aHSeq.IsNull())
655     return aSeq._retn();
656
657   Standard_Integer aLength = aHSeq->Length();
658   aSeq->length(aLength);
659   for (Standard_Integer i = 1; i <= aLength; i++)
660     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
661
662   return aSeq._retn();
663 }
664
665 //=============================================================================
666 /*!
667  *  ExtractSubShapes (excluding theShape itself, good sorting)
668  */
669 //=============================================================================
670 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
671                                                             const CORBA::Long     theShapeType,
672                                                             const CORBA::Boolean  isSorted)
673 {
674   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
675
676   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
677   if (aShape.IsNull()) return aSeq._retn();
678
679   Handle(TColStd_HSequenceOfTransient) aHSeq =
680     // TODO: enum instead of bool for the last argument
681     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
682                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
683   if (!GetOperations()->IsDone() || aHSeq.IsNull())
684     return aSeq._retn();
685
686   Standard_Integer aLength = aHSeq->Length();
687   aSeq->length(aLength);
688   for (Standard_Integer i = 1; i <= aLength; i++)
689     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
690
691   return aSeq._retn();
692 }
693
694 //=============================================================================
695 /*!
696  *  SubShapeAllIDs
697  */
698 //=============================================================================
699 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
700                                                             const CORBA::Long     theShapeType,
701                                                             const CORBA::Boolean  isSorted)
702 {
703   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
704
705   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
706   if (aShape.IsNull()) return aSeq._retn();
707
708   Handle(TColStd_HSequenceOfInteger) aHSeq =
709     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
710                                     GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
711   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
712
713   Standard_Integer aLength = aHSeq->Length();
714   aSeq->length(aLength);
715   for (Standard_Integer i = 1; i <= aLength; i++)
716     aSeq[i-1] = aHSeq->Value(i);
717
718   return aSeq._retn();
719 }
720
721 //=============================================================================
722 /*!
723  *  GetAllSubShapesIDs
724  */
725 //=============================================================================
726 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
727                                                                 const CORBA::Long     theShapeType,
728                                                                 const CORBA::Boolean  isSorted)
729 {
730   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
731
732   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
733   if (aShape.IsNull()) return aSeq._retn();
734
735   Handle(TColStd_HSequenceOfInteger) aHSeq =
736     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
737                                     GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
738   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
739
740   Standard_Integer aLength = aHSeq->Length();
741   aSeq->length(aLength);
742   for (Standard_Integer i = 1; i <= aLength; i++)
743     aSeq[i-1] = aHSeq->Value(i);
744
745   return aSeq._retn();
746 }
747
748 //=============================================================================
749 /*!
750  *  GetSubShape
751  */
752 //=============================================================================
753 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
754                                            (GEOM::GEOM_Object_ptr theMainShape,
755                                             const CORBA::Long     theID)
756 {
757   GEOM::GEOM_Object_var aGEOMObject;
758
759   //Set a not done flag
760   GetOperations()->SetNotDone();
761
762   //Get the reference objects
763   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
764   if (aShape.IsNull()) return aGEOMObject._retn();
765
766   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
767   if (!GetOperations()->IsDone() || anObject.IsNull())
768     return aGEOMObject._retn();
769
770   return GetObject(anObject);
771 }
772
773 //=============================================================================
774 /*!
775  *  MakeSubShapes
776  */
777 //=============================================================================
778 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
779                                                          const GEOM::ListOfLong& theIndices)
780 {
781   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
782   Standard_Integer i;
783
784   //Set a not done flag
785   GetOperations()->SetNotDone();
786
787   if (theIndices.length() < 1)
788     return aSeq._retn();
789
790   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
791   if (aShape.IsNull()) return aSeq._retn();
792
793   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
794   for (i = 0; i < theIndices.length(); i++)
795     anArray->SetValue(i+1, theIndices[i]);
796
797   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
798   if (!GetOperations()->IsDone() || aHSeq.IsNull())
799     return aSeq._retn();
800
801   Standard_Integer aLength = aHSeq->Length();
802   aSeq->length(aLength);
803   for (i = 0; i < aLength; i++)
804     aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
805
806   return aSeq._retn();
807 }
808
809 //=============================================================================
810 /*!
811  *  GetSubShapeIndex
812  */
813 //=============================================================================
814 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
815   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
816 {
817   //Get the reference shapes
818   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
819   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
820
821   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
822
823   //Get the unique ID of <theSubShape> inside <theMainShape>
824   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
825   if (!GetOperations()->IsDone())
826     return -1;
827
828   return anID;
829 }
830
831 //=============================================================================
832 /*!
833  *  GetSubShapesIndices
834  */
835 //=============================================================================
836 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
837   (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
838 {
839   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
840   
841   //Get the reference main shape
842   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape); 
843   if (aMainShapeRef.IsNull()) return aSeq._retn();
844       
845   //Get the subshapes
846   std::list<Handle(GEOM_Object)> aShapes;
847   int aLen = theSubShapes.length();
848   for (int ind = 0; ind < aLen; ind++) {
849     Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
850     if (aSh.IsNull())
851     {
852       MESSAGE("NULL shape")
853       return aSeq._retn();
854     }
855     aShapes.push_back(aSh);
856   }
857
858   //Get the IDs of <theSubShapes> inside <theMainShape>
859   Handle(TColStd_HSequenceOfInteger) aHSeq = 
860   GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
861   
862   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
863
864   Standard_Integer aLength = aHSeq->Length();
865   aSeq->length(aLength);
866   
867   for (Standard_Integer i = 1; i <= aLength; i++)
868     aSeq[i-1] = aHSeq->Value(i);
869
870   return aSeq._retn();
871 }
872
873
874 //=============================================================================
875 /*!
876  *  GetTopologyIndex
877  */
878 //=============================================================================
879 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
880   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
881 {
882   //Get the reference shapes
883   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
884   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
885
886   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
887
888   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
889   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
890   if (!GetOperations()->IsDone())
891     return -1;
892
893   return anID;
894 }
895
896 //=============================================================================
897 /*!
898  *  GetShapeTypeString
899  */
900 //=============================================================================
901 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
902 {
903   //Get the reference shape
904   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
905   if (aShape.IsNull()) return NULL;
906
907   // Get shape parameters
908   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
909   return CORBA::string_dup(aDescription.ToCString());
910 }
911
912 //=============================================================================
913 /*!
914  *  NumberOfFaces
915  */
916 //=============================================================================
917 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
918 {
919   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
920 }
921
922 //=============================================================================
923 /*!
924  *  NumberOfEdges
925  */
926 //=============================================================================
927 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
928 {
929   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
930 }
931
932 //=============================================================================
933 /*!
934  *  NumberOfSubShapes
935  */
936 //=============================================================================
937 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
938                                                          const CORBA::Long     theShapeType)
939 {
940   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
941   if (aShape.IsNull()) return -1;
942
943   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
944   if (!GetOperations()->IsDone()) return -1;
945
946   return aNb;
947 }
948
949 //=============================================================================
950 /*!
951  *  ChangeOrientation
952  */
953 //=============================================================================
954 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
955                                                 (GEOM::GEOM_Object_ptr theShape)
956 {
957   GEOM::GEOM_Object_var aGEOMObject;
958
959   //Set a not done flag
960   GetOperations()->SetNotDone();
961
962   //Get the reference objects
963   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
964   if (aShape.IsNull()) return aGEOMObject._retn();
965
966   //Create the Solid
967   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
968   if (!GetOperations()->IsDone() || anObject.IsNull())
969     return aGEOMObject._retn();
970
971   return GetObject(anObject);
972 }
973
974 //=============================================================================
975 /*!
976  *  GetFreeFacesIDs
977  */
978 //=============================================================================
979 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
980 {
981   //Set a not done flag
982   GetOperations()->SetNotDone();
983
984   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
985
986   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
987   if (aShape.IsNull()) return aSeq._retn();
988
989   Handle(TColStd_HSequenceOfInteger) aHSeq =
990     GetOperations()->GetFreeFacesIDs(aShape);
991   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
992
993   Standard_Integer aLength = aHSeq->Length();
994   aSeq->length(aLength);
995   for (Standard_Integer i = 1; i <= aLength; i++)
996     aSeq[i-1] = aHSeq->Value(i);
997
998   return aSeq._retn();
999 }
1000
1001 //=============================================================================
1002 /*!
1003  *  GetSharedShapes
1004  */
1005 //=============================================================================
1006 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1007                                           (GEOM::GEOM_Object_ptr theShape1,
1008                                            GEOM::GEOM_Object_ptr theShape2,
1009                                            const CORBA::Long     theShapeType)
1010 {
1011   //Set a not done flag
1012   GetOperations()->SetNotDone();
1013
1014   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1015
1016   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1017   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1018
1019   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1020
1021   Handle(TColStd_HSequenceOfTransient) aHSeq =
1022     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1023   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1024     return aSeq._retn();
1025
1026   Standard_Integer aLength = aHSeq->Length();
1027   aSeq->length(aLength);
1028   for (Standard_Integer i = 1; i <= aLength; i++)
1029     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1030
1031   return aSeq._retn();
1032 }
1033
1034 //=============================================================================
1035 /*!
1036  *  GetSharedShapesMulti
1037  */
1038 //=============================================================================
1039 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1040                                           (const GEOM::ListOfGO& theShapes,
1041                                            const CORBA::Long     theShapeType)
1042 {
1043   //Set a not done flag
1044   GetOperations()->SetNotDone();
1045
1046   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1047
1048   //Get the shapes
1049   std::list<Handle(GEOM_Object)> aShapes;
1050   if (! GetListOfObjectsImpl( theShapes, aShapes ))
1051     return aSeq._retn();
1052
1053   Handle(TColStd_HSequenceOfTransient) aHSeq =
1054     GetOperations()->GetSharedShapes(aShapes, theShapeType);
1055   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1056     return aSeq._retn();
1057
1058   Standard_Integer aLength = aHSeq->Length();
1059   aSeq->length(aLength);
1060   for (Standard_Integer i = 1; i <= aLength; i++)
1061     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1062
1063   return aSeq._retn();
1064 }
1065
1066 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1067 {
1068   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1069
1070   switch (theState) {
1071   case GEOM::ST_ON:
1072     aState = GEOMAlgo_ST_ON;
1073     break;
1074   case GEOM::ST_OUT:
1075     aState = GEOMAlgo_ST_OUT;
1076     break;
1077   case GEOM::ST_ONOUT:
1078     aState = GEOMAlgo_ST_ONOUT;
1079     break;
1080   case GEOM::ST_IN:
1081     aState = GEOMAlgo_ST_IN;
1082     break;
1083   case GEOM::ST_ONIN:
1084     aState = GEOMAlgo_ST_ONIN;
1085     break;
1086   default:
1087     break;
1088   }
1089
1090   return aState;
1091 }
1092
1093 //=============================================================================
1094 /*!
1095  *  GetShapesOnPlane
1096  */
1097 //=============================================================================
1098 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1099                                                 (GEOM::GEOM_Object_ptr   theShape,
1100                                                  const CORBA::Long       theShapeType,
1101                                                  GEOM::GEOM_Object_ptr   theAx1,
1102                                                  const GEOM::shape_state theState)
1103 {
1104   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1105
1106   //Set a not done flag
1107   GetOperations()->SetNotDone();
1108
1109   //Get the reference objects
1110   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1111   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1112
1113   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1114
1115   //Get Shapes On Plane
1116   Handle(TColStd_HSequenceOfTransient) aHSeq =
1117     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1118   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1119     return aSeq._retn();
1120
1121   Standard_Integer aLength = aHSeq->Length();
1122   aSeq->length(aLength);
1123   for (Standard_Integer i = 1; i <= aLength; i++)
1124     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1125
1126   return aSeq._retn();
1127 }
1128
1129 //=============================================================================
1130 /*!
1131  *  GetShapesOnPlaneWithLocation
1132  */
1133 //=============================================================================
1134 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1135                                                 (GEOM::GEOM_Object_ptr   theShape,
1136                                                  const CORBA::Long       theShapeType,
1137                                                  GEOM::GEOM_Object_ptr   theAx1,
1138                                                  GEOM::GEOM_Object_ptr   thePnt,
1139                                                  const GEOM::shape_state theState)
1140 {
1141   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1142
1143   //Set a not done flag
1144   GetOperations()->SetNotDone();
1145
1146   //Get the reference objects
1147   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1148   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1149   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1150
1151   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1152
1153   //Get Shapes On Plane
1154   Handle(TColStd_HSequenceOfTransient) aHSeq =
1155     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1156   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1157     return aSeq._retn();
1158
1159   Standard_Integer aLength = aHSeq->Length();
1160   aSeq->length(aLength);
1161   for (Standard_Integer i = 1; i <= aLength; i++)
1162     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1163
1164   return aSeq._retn();
1165 }
1166
1167 //=============================================================================
1168 /*!
1169  *  GetShapesOnCylinder
1170  */
1171 //=============================================================================
1172 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1173                                                 (GEOM::GEOM_Object_ptr   theShape,
1174                                                  const CORBA::Long       theShapeType,
1175                                                  GEOM::GEOM_Object_ptr   theAxis,
1176                                                  const CORBA::Double     theRadius,
1177                                                  const GEOM::shape_state theState)
1178 {
1179   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1180
1181   //Set a not done flag
1182   GetOperations()->SetNotDone();
1183
1184   //Get the reference objects
1185   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1186   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1187
1188   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1189
1190   //Get Shapes On Cylinder
1191   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1192     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1193   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1194     return aSeq._retn();
1195
1196   Standard_Integer aLength = aHSeq->Length();
1197   aSeq->length(aLength);
1198   for (Standard_Integer i = 1; i <= aLength; i++)
1199     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1200
1201   return aSeq._retn();
1202 }
1203
1204 //=============================================================================
1205 /*!
1206  *  GetShapesOnCylinderWithLocation
1207  */
1208 //=============================================================================
1209 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1210                                                 (GEOM::GEOM_Object_ptr   theShape,
1211                                                  const CORBA::Long       theShapeType,
1212                                                  GEOM::GEOM_Object_ptr   theAxis,
1213                                                  GEOM::GEOM_Object_ptr   thePnt,
1214                                                  const CORBA::Double     theRadius,
1215                                                  const GEOM::shape_state theState)
1216 {
1217   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1218
1219   //Set a not done flag
1220   GetOperations()->SetNotDone();
1221
1222   //Get the reference objects
1223   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1224   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1225   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1226
1227   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1228
1229   //Get Shapes On Cylinder
1230   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1231     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1232   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1233     return aSeq._retn();
1234
1235   Standard_Integer aLength = aHSeq->Length();
1236   aSeq->length(aLength);
1237   for (Standard_Integer i = 1; i <= aLength; i++)
1238     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1239
1240   return aSeq._retn();
1241 }
1242
1243 //=============================================================================
1244 /*!
1245  *  GetShapesOnSphere
1246  */
1247 //=============================================================================
1248 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1249                                                 (GEOM::GEOM_Object_ptr   theShape,
1250                                                  const CORBA::Long       theShapeType,
1251                                                  GEOM::GEOM_Object_ptr   theCenter,
1252                                                  const CORBA::Double     theRadius,
1253                                                  const GEOM::shape_state theState)
1254 {
1255   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1256
1257   //Set a not done flag
1258   GetOperations()->SetNotDone();
1259
1260   //Get the reference objects
1261   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1262   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1263
1264   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1265
1266   //Get Shapes On Sphere
1267   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1268     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1269   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1270     return aSeq._retn();
1271
1272   Standard_Integer aLength = aHSeq->Length();
1273   aSeq->length(aLength);
1274   for (Standard_Integer i = 1; i <= aLength; i++)
1275     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1276
1277   return aSeq._retn();
1278 }
1279
1280 //=============================================================================
1281 /*!
1282  *  GetShapesOnQuadrangle
1283  */
1284 //=============================================================================
1285 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1286                                                 (GEOM::GEOM_Object_ptr theShape,
1287                                                  CORBA::Long           theShapeType,
1288                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1289                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1290                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1291                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1292                                                  GEOM::shape_state     theState)
1293 {
1294   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1295
1296   //Set a not done flag
1297   GetOperations()->SetNotDone();
1298
1299   //Get the reference objects
1300   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1301   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1302   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1303   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1304   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1305
1306   if (aShape.IsNull() ||
1307       aTopLeftPoint.IsNull() ||
1308       aTopRigthPoint.IsNull() ||
1309       aBottomLeftPoint.IsNull() ||
1310       aBottomRigthPoint.IsNull())
1311     return aSeq._retn();
1312
1313   //Get Shapes On Quadrangle
1314   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1315     (aShape, theShapeType,
1316      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1317      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] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1325
1326   return aSeq._retn();
1327 }
1328
1329 //=============================================================================
1330 /*!
1331  *  GetShapesOnPlaneIDs
1332  */
1333 //=============================================================================
1334 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1335                                                 (GEOM::GEOM_Object_ptr   theShape,
1336                                                  const CORBA::Long       theShapeType,
1337                                                  GEOM::GEOM_Object_ptr   theAx1,
1338                                                  const GEOM::shape_state theState)
1339 {
1340   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1341
1342   //Set a not done flag
1343   GetOperations()->SetNotDone();
1344
1345   //Get the reference objects
1346   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1347   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1348
1349   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1350
1351   //Get Shapes On Plane
1352   Handle(TColStd_HSequenceOfInteger) aHSeq =
1353     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1354   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1355     return aSeq._retn();
1356
1357   Standard_Integer aLength = aHSeq->Length();
1358   aSeq->length(aLength);
1359   for (Standard_Integer i = 1; i <= aLength; i++)
1360     aSeq[i-1] = aHSeq->Value(i);
1361
1362   return aSeq._retn();
1363 }
1364
1365 //=============================================================================
1366 /*!
1367  *  GetShapesOnPlaneWithLocationIDs
1368  */
1369 //=============================================================================
1370 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1371                                                 (GEOM::GEOM_Object_ptr   theShape,
1372                                                  const CORBA::Long       theShapeType,
1373                                                  GEOM::GEOM_Object_ptr   theAx1,
1374                                                  GEOM::GEOM_Object_ptr   thePnt,
1375                                                  const GEOM::shape_state theState)
1376 {
1377   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1378
1379   //Set a not done flag
1380   GetOperations()->SetNotDone();
1381
1382   //Get the reference objects
1383   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1384   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1385   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1386
1387   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1388
1389   //Get Shapes On Plane
1390   Handle(TColStd_HSequenceOfInteger) aHSeq =
1391     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1392                                                      anAx1, anPnt, ShapeState(theState));
1393   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1394     return aSeq._retn();
1395
1396   Standard_Integer aLength = aHSeq->Length();
1397   aSeq->length(aLength);
1398   for (Standard_Integer i = 1; i <= aLength; i++)
1399     aSeq[i-1] = aHSeq->Value(i);
1400
1401   return aSeq._retn();
1402 }
1403
1404 //=============================================================================
1405 /*!
1406  *  GetShapesOnCylinderIDs
1407  */
1408 //=============================================================================
1409 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1410                                                 (GEOM::GEOM_Object_ptr   theShape,
1411                                                  const CORBA::Long       theShapeType,
1412                                                  GEOM::GEOM_Object_ptr   theAxis,
1413                                                  const CORBA::Double     theRadius,
1414                                                  const GEOM::shape_state theState)
1415 {
1416   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1417
1418   //Set a not done flag
1419   GetOperations()->SetNotDone();
1420
1421   //Get the reference objects
1422   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1423   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1424
1425   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1426
1427   //Get Shapes On Cylinder
1428   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1429     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1430   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1431     return aSeq._retn();
1432
1433   Standard_Integer aLength = aHSeq->Length();
1434   aSeq->length(aLength);
1435   for (Standard_Integer i = 1; i <= aLength; i++)
1436     aSeq[i-1] = aHSeq->Value(i);
1437
1438   return aSeq._retn();
1439 }
1440
1441 //=============================================================================
1442 /*!
1443  *  GetShapesOnCylinderWithLocationIDs
1444  */
1445 //=============================================================================
1446 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1447                                                 (GEOM::GEOM_Object_ptr   theShape,
1448                                                  const CORBA::Long       theShapeType,
1449                                                  GEOM::GEOM_Object_ptr   theAxis,
1450                                                  GEOM::GEOM_Object_ptr   thePnt,
1451                                                  const CORBA::Double     theRadius,
1452                                                  const GEOM::shape_state theState)
1453 {
1454   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1455
1456   //Set a not done flag
1457   GetOperations()->SetNotDone();
1458
1459   //Get the reference objects
1460   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1461   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1462   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1463
1464   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1465
1466   //Get Shapes On Cylinder
1467   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1468     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1469   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1470     return aSeq._retn();
1471
1472   Standard_Integer aLength = aHSeq->Length();
1473   aSeq->length(aLength);
1474   for (Standard_Integer i = 1; i <= aLength; i++)
1475     aSeq[i-1] = aHSeq->Value(i);
1476
1477   return aSeq._retn();
1478 }
1479
1480 //=============================================================================
1481 /*!
1482  *  GetShapesOnSphereIDs
1483  */
1484 //=============================================================================
1485 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1486                                                 (GEOM::GEOM_Object_ptr   theShape,
1487                                                  const CORBA::Long       theShapeType,
1488                                                  GEOM::GEOM_Object_ptr   theCenter,
1489                                                  const CORBA::Double     theRadius,
1490                                                  const GEOM::shape_state theState)
1491 {
1492   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1493
1494   //Set a not done flag
1495   GetOperations()->SetNotDone();
1496
1497   //Get the reference objects
1498   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1499   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1500
1501   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1502
1503   //Get Shapes On Sphere
1504   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1505     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1506   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1507     return aSeq._retn();
1508
1509   Standard_Integer aLength = aHSeq->Length();
1510   aSeq->length(aLength);
1511   for (Standard_Integer i = 1; i <= aLength; i++)
1512     aSeq[i-1] = aHSeq->Value(i);
1513
1514   return aSeq._retn();
1515 }
1516
1517 //=============================================================================
1518 /*!
1519  *  GetShapesOnQuadrangleIDs
1520  */
1521 //=============================================================================
1522 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1523                                                 (GEOM::GEOM_Object_ptr theShape,
1524                                                  CORBA::Long           theShapeType,
1525                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1526                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1527                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1528                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1529                                                  GEOM::shape_state     theState)
1530 {
1531   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1532
1533   //Set a not done flag
1534   GetOperations()->SetNotDone();
1535
1536   //Get the reference objects
1537   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1538   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1539   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1540   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1541   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1542
1543   if (aShape.IsNull() ||
1544       aTopLeftPoint.IsNull() ||
1545       aTopRigthPoint.IsNull() ||
1546       aBottomLeftPoint.IsNull() ||
1547       aBottomRigthPoint.IsNull() )
1548     return aSeq._retn();
1549
1550   //Get Shapes On Quadrangle
1551   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1552     (aShape, theShapeType,
1553      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1554      ShapeState(theState));
1555   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1556     return aSeq._retn();
1557
1558   Standard_Integer aLength = aHSeq->Length();
1559   aSeq->length(aLength);
1560   for (Standard_Integer i = 1; i <= aLength; i++)
1561     aSeq[i-1] = aHSeq->Value(i);
1562
1563   return aSeq._retn();
1564 }
1565
1566 //=============================================================================
1567 /*!
1568  *  GetShapesOnBox
1569  */
1570 //=============================================================================
1571 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1572                                                 (GEOM::GEOM_Object_ptr theBox,
1573                                                  GEOM::GEOM_Object_ptr theShape,
1574                                                  CORBA::Long           theShapeType,
1575                                                  GEOM::shape_state     theState)
1576 {
1577   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1578
1579   //Set a not done flag
1580   GetOperations()->SetNotDone();
1581
1582   //Get the reference objects
1583   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1584   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1585
1586   if (aShape.IsNull() || aBox.IsNull() )
1587     return aSeq._retn();
1588
1589   //Get Shapes On Box
1590   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1591     (aBox,aShape, theShapeType,ShapeState(theState));
1592   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1593     return aSeq._retn();
1594
1595   Standard_Integer aLength = aHSeq->Length();
1596   aSeq->length(aLength);
1597   for (Standard_Integer i = 1; i <= aLength; i++)
1598     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1599
1600   return aSeq._retn();
1601 }
1602
1603 //=============================================================================
1604 /*!
1605  *  GetShapesOnQuadrangleIDs
1606  */
1607 //=============================================================================
1608 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1609                                                 (GEOM::GEOM_Object_ptr theBox,
1610                                                  GEOM::GEOM_Object_ptr theShape,
1611                                                  CORBA::Long           theShapeType,
1612                                                  GEOM::shape_state     theState)
1613 {
1614   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1615
1616   //Set a not done flag
1617   GetOperations()->SetNotDone();
1618
1619   //Get the reference objects
1620   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1621   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1622
1623   if (aShape.IsNull() || aBox.IsNull() )
1624     return aSeq._retn();
1625
1626   //Get Shapes On Box
1627   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1628     (aBox,aShape, theShapeType,ShapeState(theState));
1629   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1630     return aSeq._retn();
1631
1632   Standard_Integer aLength = aHSeq->Length();
1633   aSeq->length(aLength);
1634   for (Standard_Integer i = 1; i <= aLength; i++)
1635     aSeq[i-1] = aHSeq->Value(i);
1636
1637   return aSeq._retn();
1638 }
1639
1640
1641 //=============================================================================
1642 /*!
1643  *  GetShapesOnShape
1644  */
1645 //=============================================================================
1646 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1647                                            (GEOM::GEOM_Object_ptr theCheckShape,
1648                                             GEOM::GEOM_Object_ptr theShape,
1649                                             CORBA::Short          theShapeType,
1650                                             GEOM::shape_state     theState)
1651 {
1652   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1653
1654   //Set a not done flag
1655   GetOperations()->SetNotDone();
1656
1657   //Get the reference objects
1658   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1659   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1660
1661   if (aShape.IsNull() || aCheckShape.IsNull() )
1662     return aSeq._retn();
1663
1664   //Get Shapes On Shape
1665   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1666     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1667
1668   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1669     return aSeq._retn();
1670
1671   Standard_Integer aLength = aHSeq->Length();
1672   aSeq->length(aLength);
1673   for (Standard_Integer i = 1; i <= aLength; i++)
1674     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1675
1676   return aSeq._retn();
1677 }
1678
1679
1680 //=============================================================================
1681 /*!
1682  *  GetShapesOnShapeAsCompound
1683  */
1684 //=============================================================================
1685 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1686                                            (GEOM::GEOM_Object_ptr theCheckShape,
1687                                             GEOM::GEOM_Object_ptr theShape,
1688                                             CORBA::Short          theShapeType,
1689                                             GEOM::shape_state     theState)
1690 {
1691   GEOM::GEOM_Object_var aGEOMObject;
1692
1693   //Set a not done flag
1694   GetOperations()->SetNotDone();
1695
1696   //Get the reference objects
1697   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1698   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1699
1700   if (aShape.IsNull() || aCheckShape.IsNull() )
1701     return aGEOMObject._retn();
1702
1703   //Get Shapes On Shape
1704   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1705     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1706
1707   if (anObject.IsNull())
1708     return aGEOMObject._retn();
1709
1710   return GetObject(anObject);
1711 }
1712
1713
1714 //=============================================================================
1715 /*!
1716  *  GetShapesOnShapeIDs
1717  */
1718 //=============================================================================
1719 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1720                                            (GEOM::GEOM_Object_ptr theCheckShape,
1721                                             GEOM::GEOM_Object_ptr theShape,
1722                                             CORBA::Short          theShapeType,
1723                                             GEOM::shape_state     theState)
1724 {
1725   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1726
1727   //Set a not done flag
1728   GetOperations()->SetNotDone();
1729
1730   //Get the reference objects
1731   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1732   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1733
1734   if (aShape.IsNull() || aCheckShape.IsNull() )
1735     return aSeq._retn();
1736
1737   //Get Shapes On Shape
1738   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1739     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1740   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1741     return aSeq._retn();
1742
1743   Standard_Integer aLength = aHSeq->Length();
1744   aSeq->length(aLength);
1745   for (Standard_Integer i = 1; i <= aLength; i++)
1746     aSeq[i-1] = aHSeq->Value(i);
1747
1748   return aSeq._retn();
1749 }
1750
1751
1752 //=============================================================================
1753 /*!
1754  *  GetInPlace
1755  */
1756 //=============================================================================
1757 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1758                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1759                                            GEOM::GEOM_Object_ptr theShapeWhat)
1760 {
1761   GEOM::GEOM_Object_var aGEOMObject;
1762
1763   //Set a not done flag
1764   GetOperations()->SetNotDone();
1765
1766   //Get the reference objects
1767   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1768   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1769
1770   if (aShapeWhere.IsNull() ||
1771       aShapeWhat.IsNull()) return aGEOMObject._retn();
1772
1773   //Get Shapes in place of aShapeWhat
1774   Handle(GEOM_Object) anObject =
1775     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1776   if (!GetOperations()->IsDone() || anObject.IsNull())
1777     return aGEOMObject._retn();
1778
1779   return GetObject(anObject);
1780 }
1781
1782 //=============================================================================
1783 /*!
1784  *  GetInPlaceOld
1785  */
1786 //=============================================================================
1787 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1788                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1789                                            GEOM::GEOM_Object_ptr theShapeWhat)
1790 {
1791   GEOM::GEOM_Object_var aGEOMObject;
1792
1793   //Set a not done flag
1794   GetOperations()->SetNotDone();
1795
1796   //Get the reference objects
1797   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1798   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1799
1800   if (aShapeWhere.IsNull() ||
1801       aShapeWhat.IsNull()) return aGEOMObject._retn();
1802
1803   //Get Shapes in place of aShapeWhat
1804   Handle(GEOM_Object) anObject =
1805     GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1806   if (!GetOperations()->IsDone() || anObject.IsNull())
1807     return aGEOMObject._retn();
1808
1809   return GetObject(anObject);
1810 }
1811
1812 //=============================================================================
1813 /*!
1814  *  GetInPlaceByHistory
1815  */
1816 //=============================================================================
1817 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1818                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1819                                            GEOM::GEOM_Object_ptr theShapeWhat)
1820 {
1821   GEOM::GEOM_Object_var aGEOMObject;
1822
1823   //Set a not done flag
1824   GetOperations()->SetNotDone();
1825
1826   //Get the reference objects
1827   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1828   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1829
1830   if (aShapeWhere.IsNull() ||
1831       aShapeWhat.IsNull()) return aGEOMObject._retn();
1832
1833   //Get Shapes in place of aShapeWhat
1834   Handle(GEOM_Object) anObject =
1835     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1836   if (!GetOperations()->IsDone() || anObject.IsNull())
1837     return aGEOMObject._retn();
1838
1839   return GetObject(anObject);
1840 }
1841
1842 //=============================================================================
1843 /*!
1844  *  GetSame
1845  */
1846 //=============================================================================
1847 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1848                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1849                                            GEOM::GEOM_Object_ptr theShapeWhat)
1850 {
1851   GEOM::GEOM_Object_var aGEOMObject;
1852
1853   //Set a not done flag
1854   GetOperations()->SetNotDone();
1855
1856   //Get the reference objects
1857   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1858   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1859
1860   if (aShapeWhere.IsNull() ||
1861       aShapeWhat.IsNull()) return aGEOMObject._retn();
1862
1863   //Get Shapes in place of aShapeWhat
1864   Handle(GEOM_Object) anObject =
1865     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1866   if (!GetOperations()->IsDone() || anObject.IsNull())
1867     return aGEOMObject._retn();
1868
1869   return GetObject(anObject);
1870 }
1871
1872 //=============================================================================
1873 /*!
1874  *  GetSameIDs
1875  */
1876 //=============================================================================
1877 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1878                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1879                                            GEOM::GEOM_Object_ptr theShapeWhat) {
1880   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1881
1882   //Get the reference objects
1883   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1884   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1885
1886   if (aShapeWhere.IsNull() ||
1887       aShapeWhat.IsNull()) return aSeq._retn();
1888
1889
1890   Handle(TColStd_HSequenceOfInteger) aHSeq =
1891     GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
1892
1893   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1894
1895   Standard_Integer aLength = aHSeq->Length();
1896   aSeq->length(aLength);
1897   for (Standard_Integer i = 1; i <= aLength; i++)
1898     aSeq[i-1] = aHSeq->Value(i);
1899
1900   return aSeq._retn();
1901 }