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