Salome HOME
0022746: [EDF] Improvement of Glue Faces and Glue Edges operations
[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   int aLen = theShapes.length();
1051   for (int ind = 0; ind < aLen; ind++) {
1052     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
1053     if (aSh.IsNull()) return aSeq._retn();
1054     aShapes.push_back(aSh);
1055   }
1056
1057   Handle(TColStd_HSequenceOfTransient) aHSeq =
1058     GetOperations()->GetSharedShapes(aShapes, theShapeType);
1059   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1060     return aSeq._retn();
1061
1062   Standard_Integer aLength = aHSeq->Length();
1063   aSeq->length(aLength);
1064   for (Standard_Integer i = 1; i <= aLength; i++)
1065     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1066
1067   return aSeq._retn();
1068 }
1069
1070 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1071 {
1072   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1073
1074   switch (theState) {
1075   case GEOM::ST_ON:
1076     aState = GEOMAlgo_ST_ON;
1077     break;
1078   case GEOM::ST_OUT:
1079     aState = GEOMAlgo_ST_OUT;
1080     break;
1081   case GEOM::ST_ONOUT:
1082     aState = GEOMAlgo_ST_ONOUT;
1083     break;
1084   case GEOM::ST_IN:
1085     aState = GEOMAlgo_ST_IN;
1086     break;
1087   case GEOM::ST_ONIN:
1088     aState = GEOMAlgo_ST_ONIN;
1089     break;
1090   default:
1091     break;
1092   }
1093
1094   return aState;
1095 }
1096
1097 //=============================================================================
1098 /*!
1099  *  GetShapesOnPlane
1100  */
1101 //=============================================================================
1102 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1103                                                 (GEOM::GEOM_Object_ptr   theShape,
1104                                                  const CORBA::Long       theShapeType,
1105                                                  GEOM::GEOM_Object_ptr   theAx1,
1106                                                  const GEOM::shape_state theState)
1107 {
1108   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1109
1110   //Set a not done flag
1111   GetOperations()->SetNotDone();
1112
1113   //Get the reference objects
1114   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1115   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1116
1117   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1118
1119   //Get Shapes On Plane
1120   Handle(TColStd_HSequenceOfTransient) aHSeq =
1121     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1122   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1123     return aSeq._retn();
1124
1125   Standard_Integer aLength = aHSeq->Length();
1126   aSeq->length(aLength);
1127   for (Standard_Integer i = 1; i <= aLength; i++)
1128     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1129
1130   return aSeq._retn();
1131 }
1132
1133 //=============================================================================
1134 /*!
1135  *  GetShapesOnPlaneWithLocation
1136  */
1137 //=============================================================================
1138 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1139                                                 (GEOM::GEOM_Object_ptr   theShape,
1140                                                  const CORBA::Long       theShapeType,
1141                                                  GEOM::GEOM_Object_ptr   theAx1,
1142                                                  GEOM::GEOM_Object_ptr   thePnt,
1143                                                  const GEOM::shape_state theState)
1144 {
1145   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1146
1147   //Set a not done flag
1148   GetOperations()->SetNotDone();
1149
1150   //Get the reference objects
1151   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1152   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1153   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1154
1155   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1156
1157   //Get Shapes On Plane
1158   Handle(TColStd_HSequenceOfTransient) aHSeq =
1159     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1160   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1161     return aSeq._retn();
1162
1163   Standard_Integer aLength = aHSeq->Length();
1164   aSeq->length(aLength);
1165   for (Standard_Integer i = 1; i <= aLength; i++)
1166     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1167
1168   return aSeq._retn();
1169 }
1170
1171 //=============================================================================
1172 /*!
1173  *  GetShapesOnCylinder
1174  */
1175 //=============================================================================
1176 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1177                                                 (GEOM::GEOM_Object_ptr   theShape,
1178                                                  const CORBA::Long       theShapeType,
1179                                                  GEOM::GEOM_Object_ptr   theAxis,
1180                                                  const CORBA::Double     theRadius,
1181                                                  const GEOM::shape_state theState)
1182 {
1183   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1184
1185   //Set a not done flag
1186   GetOperations()->SetNotDone();
1187
1188   //Get the reference objects
1189   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1190   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1191
1192   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1193
1194   //Get Shapes On Cylinder
1195   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1196     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1197   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1198     return aSeq._retn();
1199
1200   Standard_Integer aLength = aHSeq->Length();
1201   aSeq->length(aLength);
1202   for (Standard_Integer i = 1; i <= aLength; i++)
1203     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1204
1205   return aSeq._retn();
1206 }
1207
1208 //=============================================================================
1209 /*!
1210  *  GetShapesOnCylinderWithLocation
1211  */
1212 //=============================================================================
1213 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1214                                                 (GEOM::GEOM_Object_ptr   theShape,
1215                                                  const CORBA::Long       theShapeType,
1216                                                  GEOM::GEOM_Object_ptr   theAxis,
1217                                                  GEOM::GEOM_Object_ptr   thePnt,
1218                                                  const CORBA::Double     theRadius,
1219                                                  const GEOM::shape_state theState)
1220 {
1221   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1222
1223   //Set a not done flag
1224   GetOperations()->SetNotDone();
1225
1226   //Get the reference objects
1227   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1228   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1229   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1230
1231   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1232
1233   //Get Shapes On Cylinder
1234   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1235     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1236   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1237     return aSeq._retn();
1238
1239   Standard_Integer aLength = aHSeq->Length();
1240   aSeq->length(aLength);
1241   for (Standard_Integer i = 1; i <= aLength; i++)
1242     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1243
1244   return aSeq._retn();
1245 }
1246
1247 //=============================================================================
1248 /*!
1249  *  GetShapesOnSphere
1250  */
1251 //=============================================================================
1252 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1253                                                 (GEOM::GEOM_Object_ptr   theShape,
1254                                                  const CORBA::Long       theShapeType,
1255                                                  GEOM::GEOM_Object_ptr   theCenter,
1256                                                  const CORBA::Double     theRadius,
1257                                                  const GEOM::shape_state theState)
1258 {
1259   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1260
1261   //Set a not done flag
1262   GetOperations()->SetNotDone();
1263
1264   //Get the reference objects
1265   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1266   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1267
1268   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1269
1270   //Get Shapes On Sphere
1271   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1272     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1273   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1274     return aSeq._retn();
1275
1276   Standard_Integer aLength = aHSeq->Length();
1277   aSeq->length(aLength);
1278   for (Standard_Integer i = 1; i <= aLength; i++)
1279     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1280
1281   return aSeq._retn();
1282 }
1283
1284 //=============================================================================
1285 /*!
1286  *  GetShapesOnQuadrangle
1287  */
1288 //=============================================================================
1289 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1290                                                 (GEOM::GEOM_Object_ptr theShape,
1291                                                  CORBA::Long           theShapeType,
1292                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1293                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1294                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1295                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1296                                                  GEOM::shape_state     theState)
1297 {
1298   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1299
1300   //Set a not done flag
1301   GetOperations()->SetNotDone();
1302
1303   //Get the reference objects
1304   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1305   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1306   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1307   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1308   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1309
1310   if (aShape.IsNull() ||
1311       aTopLeftPoint.IsNull() ||
1312       aTopRigthPoint.IsNull() ||
1313       aBottomLeftPoint.IsNull() ||
1314       aBottomRigthPoint.IsNull())
1315     return aSeq._retn();
1316
1317   //Get Shapes On Quadrangle
1318   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1319     (aShape, theShapeType,
1320      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1321      ShapeState(theState));
1322   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1323     return aSeq._retn();
1324
1325   Standard_Integer aLength = aHSeq->Length();
1326   aSeq->length(aLength);
1327   for (Standard_Integer i = 1; i <= aLength; i++)
1328     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1329
1330   return aSeq._retn();
1331 }
1332
1333 //=============================================================================
1334 /*!
1335  *  GetShapesOnPlaneIDs
1336  */
1337 //=============================================================================
1338 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1339                                                 (GEOM::GEOM_Object_ptr   theShape,
1340                                                  const CORBA::Long       theShapeType,
1341                                                  GEOM::GEOM_Object_ptr   theAx1,
1342                                                  const GEOM::shape_state theState)
1343 {
1344   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1345
1346   //Set a not done flag
1347   GetOperations()->SetNotDone();
1348
1349   //Get the reference objects
1350   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1351   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1352
1353   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1354
1355   //Get Shapes On Plane
1356   Handle(TColStd_HSequenceOfInteger) aHSeq =
1357     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1358   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1359     return aSeq._retn();
1360
1361   Standard_Integer aLength = aHSeq->Length();
1362   aSeq->length(aLength);
1363   for (Standard_Integer i = 1; i <= aLength; i++)
1364     aSeq[i-1] = aHSeq->Value(i);
1365
1366   return aSeq._retn();
1367 }
1368
1369 //=============================================================================
1370 /*!
1371  *  GetShapesOnPlaneWithLocationIDs
1372  */
1373 //=============================================================================
1374 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1375                                                 (GEOM::GEOM_Object_ptr   theShape,
1376                                                  const CORBA::Long       theShapeType,
1377                                                  GEOM::GEOM_Object_ptr   theAx1,
1378                                                  GEOM::GEOM_Object_ptr   thePnt,
1379                                                  const GEOM::shape_state theState)
1380 {
1381   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1382
1383   //Set a not done flag
1384   GetOperations()->SetNotDone();
1385
1386   //Get the reference objects
1387   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1388   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1389   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1390
1391   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1392
1393   //Get Shapes On Plane
1394   Handle(TColStd_HSequenceOfInteger) aHSeq =
1395     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1396                                                      anAx1, anPnt, ShapeState(theState));
1397   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1398     return aSeq._retn();
1399
1400   Standard_Integer aLength = aHSeq->Length();
1401   aSeq->length(aLength);
1402   for (Standard_Integer i = 1; i <= aLength; i++)
1403     aSeq[i-1] = aHSeq->Value(i);
1404
1405   return aSeq._retn();
1406 }
1407
1408 //=============================================================================
1409 /*!
1410  *  GetShapesOnCylinderIDs
1411  */
1412 //=============================================================================
1413 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1414                                                 (GEOM::GEOM_Object_ptr   theShape,
1415                                                  const CORBA::Long       theShapeType,
1416                                                  GEOM::GEOM_Object_ptr   theAxis,
1417                                                  const CORBA::Double     theRadius,
1418                                                  const GEOM::shape_state theState)
1419 {
1420   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1421
1422   //Set a not done flag
1423   GetOperations()->SetNotDone();
1424
1425   //Get the reference objects
1426   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1427   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1428
1429   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1430
1431   //Get Shapes On Cylinder
1432   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1433     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1434   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1435     return aSeq._retn();
1436
1437   Standard_Integer aLength = aHSeq->Length();
1438   aSeq->length(aLength);
1439   for (Standard_Integer i = 1; i <= aLength; i++)
1440     aSeq[i-1] = aHSeq->Value(i);
1441
1442   return aSeq._retn();
1443 }
1444
1445 //=============================================================================
1446 /*!
1447  *  GetShapesOnCylinderWithLocationIDs
1448  */
1449 //=============================================================================
1450 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1451                                                 (GEOM::GEOM_Object_ptr   theShape,
1452                                                  const CORBA::Long       theShapeType,
1453                                                  GEOM::GEOM_Object_ptr   theAxis,
1454                                                  GEOM::GEOM_Object_ptr   thePnt,
1455                                                  const CORBA::Double     theRadius,
1456                                                  const GEOM::shape_state theState)
1457 {
1458   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1459
1460   //Set a not done flag
1461   GetOperations()->SetNotDone();
1462
1463   //Get the reference objects
1464   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1465   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1466   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1467
1468   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1469
1470   //Get Shapes On Cylinder
1471   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1472     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1473   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1474     return aSeq._retn();
1475
1476   Standard_Integer aLength = aHSeq->Length();
1477   aSeq->length(aLength);
1478   for (Standard_Integer i = 1; i <= aLength; i++)
1479     aSeq[i-1] = aHSeq->Value(i);
1480
1481   return aSeq._retn();
1482 }
1483
1484 //=============================================================================
1485 /*!
1486  *  GetShapesOnSphereIDs
1487  */
1488 //=============================================================================
1489 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1490                                                 (GEOM::GEOM_Object_ptr   theShape,
1491                                                  const CORBA::Long       theShapeType,
1492                                                  GEOM::GEOM_Object_ptr   theCenter,
1493                                                  const CORBA::Double     theRadius,
1494                                                  const GEOM::shape_state theState)
1495 {
1496   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1497
1498   //Set a not done flag
1499   GetOperations()->SetNotDone();
1500
1501   //Get the reference objects
1502   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1503   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1504
1505   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1506
1507   //Get Shapes On Sphere
1508   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1509     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1510   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1511     return aSeq._retn();
1512
1513   Standard_Integer aLength = aHSeq->Length();
1514   aSeq->length(aLength);
1515   for (Standard_Integer i = 1; i <= aLength; i++)
1516     aSeq[i-1] = aHSeq->Value(i);
1517
1518   return aSeq._retn();
1519 }
1520
1521 //=============================================================================
1522 /*!
1523  *  GetShapesOnQuadrangleIDs
1524  */
1525 //=============================================================================
1526 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1527                                                 (GEOM::GEOM_Object_ptr theShape,
1528                                                  CORBA::Long           theShapeType,
1529                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1530                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1531                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1532                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1533                                                  GEOM::shape_state     theState)
1534 {
1535   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1536
1537   //Set a not done flag
1538   GetOperations()->SetNotDone();
1539
1540   //Get the reference objects
1541   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1542   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1543   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1544   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1545   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1546
1547   if (aShape.IsNull() ||
1548       aTopLeftPoint.IsNull() ||
1549       aTopRigthPoint.IsNull() ||
1550       aBottomLeftPoint.IsNull() ||
1551       aBottomRigthPoint.IsNull() )
1552     return aSeq._retn();
1553
1554   //Get Shapes On Quadrangle
1555   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1556     (aShape, theShapeType,
1557      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1558      ShapeState(theState));
1559   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1560     return aSeq._retn();
1561
1562   Standard_Integer aLength = aHSeq->Length();
1563   aSeq->length(aLength);
1564   for (Standard_Integer i = 1; i <= aLength; i++)
1565     aSeq[i-1] = aHSeq->Value(i);
1566
1567   return aSeq._retn();
1568 }
1569
1570 //=============================================================================
1571 /*!
1572  *  GetShapesOnBox
1573  */
1574 //=============================================================================
1575 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1576                                                 (GEOM::GEOM_Object_ptr theBox,
1577                                                  GEOM::GEOM_Object_ptr theShape,
1578                                                  CORBA::Long           theShapeType,
1579                                                  GEOM::shape_state     theState)
1580 {
1581   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1582
1583   //Set a not done flag
1584   GetOperations()->SetNotDone();
1585
1586   //Get the reference objects
1587   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1588   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1589
1590   if (aShape.IsNull() || aBox.IsNull() )
1591     return aSeq._retn();
1592
1593   //Get Shapes On Box
1594   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1595     (aBox,aShape, theShapeType,ShapeState(theState));
1596   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1597     return aSeq._retn();
1598
1599   Standard_Integer aLength = aHSeq->Length();
1600   aSeq->length(aLength);
1601   for (Standard_Integer i = 1; i <= aLength; i++)
1602     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1603
1604   return aSeq._retn();
1605 }
1606
1607 //=============================================================================
1608 /*!
1609  *  GetShapesOnQuadrangleIDs
1610  */
1611 //=============================================================================
1612 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1613                                                 (GEOM::GEOM_Object_ptr theBox,
1614                                                  GEOM::GEOM_Object_ptr theShape,
1615                                                  CORBA::Long           theShapeType,
1616                                                  GEOM::shape_state     theState)
1617 {
1618   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1619
1620   //Set a not done flag
1621   GetOperations()->SetNotDone();
1622
1623   //Get the reference objects
1624   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1625   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1626
1627   if (aShape.IsNull() || aBox.IsNull() )
1628     return aSeq._retn();
1629
1630   //Get Shapes On Box
1631   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1632     (aBox,aShape, theShapeType,ShapeState(theState));
1633   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1634     return aSeq._retn();
1635
1636   Standard_Integer aLength = aHSeq->Length();
1637   aSeq->length(aLength);
1638   for (Standard_Integer i = 1; i <= aLength; i++)
1639     aSeq[i-1] = aHSeq->Value(i);
1640
1641   return aSeq._retn();
1642 }
1643
1644
1645 //=============================================================================
1646 /*!
1647  *  GetShapesOnShape
1648  */
1649 //=============================================================================
1650 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1651                                            (GEOM::GEOM_Object_ptr theCheckShape,
1652                                             GEOM::GEOM_Object_ptr theShape,
1653                                             CORBA::Short          theShapeType,
1654                                             GEOM::shape_state     theState)
1655 {
1656   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1657
1658   //Set a not done flag
1659   GetOperations()->SetNotDone();
1660
1661   //Get the reference objects
1662   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1663   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1664
1665   if (aShape.IsNull() || aCheckShape.IsNull() )
1666     return aSeq._retn();
1667
1668   //Get Shapes On Shape
1669   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1670     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1671
1672   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1673     return aSeq._retn();
1674
1675   Standard_Integer aLength = aHSeq->Length();
1676   aSeq->length(aLength);
1677   for (Standard_Integer i = 1; i <= aLength; i++)
1678     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1679
1680   return aSeq._retn();
1681 }
1682
1683
1684 //=============================================================================
1685 /*!
1686  *  GetShapesOnShapeAsCompound
1687  */
1688 //=============================================================================
1689 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1690                                            (GEOM::GEOM_Object_ptr theCheckShape,
1691                                             GEOM::GEOM_Object_ptr theShape,
1692                                             CORBA::Short          theShapeType,
1693                                             GEOM::shape_state     theState)
1694 {
1695   GEOM::GEOM_Object_var aGEOMObject;
1696
1697   //Set a not done flag
1698   GetOperations()->SetNotDone();
1699
1700   //Get the reference objects
1701   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1702   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1703
1704   if (aShape.IsNull() || aCheckShape.IsNull() )
1705     return aGEOMObject._retn();
1706
1707   //Get Shapes On Shape
1708   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1709     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1710
1711   if (anObject.IsNull())
1712     return aGEOMObject._retn();
1713
1714   return GetObject(anObject);
1715 }
1716
1717
1718 //=============================================================================
1719 /*!
1720  *  GetShapesOnShapeIDs
1721  */
1722 //=============================================================================
1723 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1724                                            (GEOM::GEOM_Object_ptr theCheckShape,
1725                                             GEOM::GEOM_Object_ptr theShape,
1726                                             CORBA::Short          theShapeType,
1727                                             GEOM::shape_state     theState)
1728 {
1729   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1730
1731   //Set a not done flag
1732   GetOperations()->SetNotDone();
1733
1734   //Get the reference objects
1735   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1736   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1737
1738   if (aShape.IsNull() || aCheckShape.IsNull() )
1739     return aSeq._retn();
1740
1741   //Get Shapes On Shape
1742   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1743     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1744   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1745     return aSeq._retn();
1746
1747   Standard_Integer aLength = aHSeq->Length();
1748   aSeq->length(aLength);
1749   for (Standard_Integer i = 1; i <= aLength; i++)
1750     aSeq[i-1] = aHSeq->Value(i);
1751
1752   return aSeq._retn();
1753 }
1754
1755
1756 //=============================================================================
1757 /*!
1758  *  GetInPlace
1759  */
1760 //=============================================================================
1761 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1762                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1763                                            GEOM::GEOM_Object_ptr theShapeWhat)
1764 {
1765   GEOM::GEOM_Object_var aGEOMObject;
1766
1767   //Set a not done flag
1768   GetOperations()->SetNotDone();
1769
1770   //Get the reference objects
1771   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1772   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1773
1774   if (aShapeWhere.IsNull() ||
1775       aShapeWhat.IsNull()) return aGEOMObject._retn();
1776
1777   //Get Shapes in place of aShapeWhat
1778   Handle(GEOM_Object) anObject =
1779     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1780   if (!GetOperations()->IsDone() || anObject.IsNull())
1781     return aGEOMObject._retn();
1782
1783   return GetObject(anObject);
1784 }
1785
1786 //=============================================================================
1787 /*!
1788  *  GetInPlaceOld
1789  */
1790 //=============================================================================
1791 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1792                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1793                                            GEOM::GEOM_Object_ptr theShapeWhat)
1794 {
1795   GEOM::GEOM_Object_var aGEOMObject;
1796
1797   //Set a not done flag
1798   GetOperations()->SetNotDone();
1799
1800   //Get the reference objects
1801   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1802   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1803
1804   if (aShapeWhere.IsNull() ||
1805       aShapeWhat.IsNull()) return aGEOMObject._retn();
1806
1807   //Get Shapes in place of aShapeWhat
1808   Handle(GEOM_Object) anObject =
1809     GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1810   if (!GetOperations()->IsDone() || anObject.IsNull())
1811     return aGEOMObject._retn();
1812
1813   return GetObject(anObject);
1814 }
1815
1816 //=============================================================================
1817 /*!
1818  *  GetInPlaceByHistory
1819  */
1820 //=============================================================================
1821 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1822                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1823                                            GEOM::GEOM_Object_ptr theShapeWhat)
1824 {
1825   GEOM::GEOM_Object_var aGEOMObject;
1826
1827   //Set a not done flag
1828   GetOperations()->SetNotDone();
1829
1830   //Get the reference objects
1831   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1832   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1833
1834   if (aShapeWhere.IsNull() ||
1835       aShapeWhat.IsNull()) return aGEOMObject._retn();
1836
1837   //Get Shapes in place of aShapeWhat
1838   Handle(GEOM_Object) anObject =
1839     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1840   if (!GetOperations()->IsDone() || anObject.IsNull())
1841     return aGEOMObject._retn();
1842
1843   return GetObject(anObject);
1844 }
1845
1846 //=============================================================================
1847 /*!
1848  *  GetSame
1849  */
1850 //=============================================================================
1851 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1852                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1853                                            GEOM::GEOM_Object_ptr theShapeWhat)
1854 {
1855   GEOM::GEOM_Object_var aGEOMObject;
1856
1857   //Set a not done flag
1858   GetOperations()->SetNotDone();
1859
1860   //Get the reference objects
1861   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1862   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1863
1864   if (aShapeWhere.IsNull() ||
1865       aShapeWhat.IsNull()) return aGEOMObject._retn();
1866
1867   //Get Shapes in place of aShapeWhat
1868   Handle(GEOM_Object) anObject =
1869     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1870   if (!GetOperations()->IsDone() || anObject.IsNull())
1871     return aGEOMObject._retn();
1872
1873   return GetObject(anObject);
1874 }
1875
1876 //=============================================================================
1877 /*!
1878  *  GetSameIDs
1879  */
1880 //=============================================================================
1881 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1882                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1883                                            GEOM::GEOM_Object_ptr theShapeWhat) {
1884   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1885
1886   //Get the reference objects
1887   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1888   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1889
1890   if (aShapeWhere.IsNull() ||
1891       aShapeWhat.IsNull()) return aSeq._retn();
1892
1893
1894   Handle(TColStd_HSequenceOfInteger) aHSeq =
1895     GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
1896
1897   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1898
1899   Standard_Integer aLength = aHSeq->Length();
1900   aSeq->length(aLength);
1901   for (Standard_Integer i = 1; i <= aLength; i++)
1902     aSeq[i-1] = aHSeq->Value(i);
1903
1904   return aSeq._retn();
1905 }