Salome HOME
7a0fff924cda77b0124ad9cd63a8a7a8a753376c
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 //  Copyright (C) 2007-2008  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 #include <Standard_Stream.hxx>
23
24 #include "GEOM_IShapesOperations_i.hh"
25
26 #include "utilities.h"
27 #include "OpUtil.hxx"
28 #include "Utils_ExceptHandlers.hxx"
29
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
32
33 #include <TopAbs.hxx>
34 #include <TColStd_HSequenceOfTransient.hxx>
35 #include <TColStd_HArray1OfInteger.hxx>
36
37 //=============================================================================
38 /*!
39  *   constructor:
40  */
41 //=============================================================================
42 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
43                                                     GEOM::GEOM_Gen_ptr theEngine,
44                                                     ::GEOMImpl_IShapesOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
46 {
47   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
48 }
49
50 //=============================================================================
51 /*!
52  *  destructor
53  */
54 //=============================================================================
55 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
56 {
57   MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
58 }
59
60
61 //=============================================================================
62 /*!
63  *  MakeEdge
64  */
65 //=============================================================================
66 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
67                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
68 {
69   GEOM::GEOM_Object_var aGEOMObject;
70
71   //Set a not done flag
72   GetOperations()->SetNotDone();
73
74   //Get the reference points
75   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
76   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
77
78   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
79
80   //Create the Edge
81   Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
82   if (!GetOperations()->IsDone() || anObject.IsNull())
83     return aGEOMObject._retn();
84
85   return GetObject(anObject);
86 }
87
88 //=============================================================================
89 /*!
90  *  MakeWire
91  */
92 //=============================================================================
93 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
94                            (const GEOM::ListOfGO& theEdgesAndWires,
95                             const CORBA::Double   theTolerance)
96 {
97   GEOM::GEOM_Object_var aGEOMObject;
98
99   //Set a not done flag
100   GetOperations()->SetNotDone();
101
102   int ind, aLen;
103   std::list<Handle(GEOM_Object)> aShapes;
104
105   //Get the shapes
106   aLen = theEdgesAndWires.length();
107   for (ind = 0; ind < aLen; ind++) {
108     Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
109     if (aSh.IsNull()) return aGEOMObject._retn();
110     aShapes.push_back(aSh);
111   }
112
113   // Make Solid
114   Handle(GEOM_Object) anObject =
115     GetOperations()->MakeWire(aShapes, theTolerance);
116   if (!GetOperations()->IsDone() || anObject.IsNull())
117     return aGEOMObject._retn();
118
119   return GetObject(anObject);
120 }
121
122 //=============================================================================
123 /*!
124  *  MakeFace
125  */
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
128                       (GEOM::GEOM_Object_ptr theWire,
129                        const CORBA::Boolean  isPlanarWanted)
130 {
131   GEOM::GEOM_Object_var aGEOMObject;
132
133   //Set a not done flag
134   GetOperations()->SetNotDone();
135
136   //Get the reference wire
137   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
138   if (aWire.IsNull()) return aGEOMObject._retn();
139
140   //Create the Face
141   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
142   if (!GetOperations()->IsDone() || anObject.IsNull())
143     return aGEOMObject._retn();
144
145   return GetObject(anObject);
146 }
147
148 //=============================================================================
149 /*!
150  *  MakeFaceWires
151  */
152 //=============================================================================
153 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
154                                          (const GEOM::ListOfGO& theWires,
155                                           const CORBA::Boolean  isPlanarWanted)
156 {
157   GEOM::GEOM_Object_var aGEOMObject;
158
159   //Set a not done flag
160   GetOperations()->SetNotDone();
161
162   int ind, aLen;
163   std::list<Handle(GEOM_Object)> aShapes;
164
165   //Get the shapes
166   aLen = theWires.length();
167   for (ind = 0; ind < aLen; ind++) {
168     Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
169     if (aSh.IsNull()) return aGEOMObject._retn();
170     aShapes.push_back(aSh);
171   }
172
173   // Make Face
174   Handle(GEOM_Object) anObject =
175     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
176   if (!GetOperations()->IsDone() || anObject.IsNull())
177     return aGEOMObject._retn();
178
179   return GetObject(anObject);
180 }
181
182 //=============================================================================
183 /*!
184  *  MakeShell
185  */
186 //=============================================================================
187 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
188                                       (const GEOM::ListOfGO& theFacesAndShells)
189 {
190   GEOM::GEOM_Object_var aGEOMObject;
191
192   //Set a not done flag
193   GetOperations()->SetNotDone();
194
195   int ind, aLen;
196   std::list<Handle(GEOM_Object)> aShapes;
197
198   //Get the shapes
199   aLen = theFacesAndShells.length();
200   for (ind = 0; ind < aLen; ind++) {
201     Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
202     if (aSh.IsNull()) return aGEOMObject._retn();
203     aShapes.push_back(aSh);
204   }
205
206   // Make Solid
207   Handle(GEOM_Object) anObject =
208     GetOperations()->MakeShell(aShapes);
209   if (!GetOperations()->IsDone() || anObject.IsNull())
210     return aGEOMObject._retn();
211
212   return GetObject(anObject);
213 }
214
215 //=============================================================================
216 /*!
217  *  MakeSolidShell
218  */
219 //=============================================================================
220 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
221                                                 (GEOM::GEOM_Object_ptr theShell)
222 {
223   GEOM::GEOM_Object_var aGEOMObject;
224
225   //Set a not done flag
226   GetOperations()->SetNotDone();
227
228   //Get the reference objects
229   Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
230   if (aShell.IsNull()) return aGEOMObject._retn();
231
232   //Create the Solid
233   Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
234   if (!GetOperations()->IsDone() || anObject.IsNull())
235     return aGEOMObject._retn();
236
237   return GetObject(anObject);
238 }
239
240 //=============================================================================
241 /*!
242  *  MakeSolidShells
243  */
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
246                                       (const GEOM::ListOfGO& theShells)
247 {
248   GEOM::GEOM_Object_var aGEOMObject;
249
250   //Set a not done flag
251   GetOperations()->SetNotDone();
252
253   int ind, aLen;
254   std::list<Handle(GEOM_Object)> aShapes;
255
256   //Get the shapes
257   aLen = theShells.length();
258   for (ind = 0; ind < aLen; ind++) {
259     Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
260     if (aSh.IsNull()) return aGEOMObject._retn();
261     aShapes.push_back(aSh);
262   }
263
264   // Make Solid
265   Handle(GEOM_Object) anObject =
266     GetOperations()->MakeSolidShells(aShapes);
267   if (!GetOperations()->IsDone() || anObject.IsNull())
268     return aGEOMObject._retn();
269
270   return GetObject(anObject);
271 }
272
273 //=============================================================================
274 /*!
275  *  MakeCompound
276  */
277 //=============================================================================
278 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
279                                       (const GEOM::ListOfGO& theShapes)
280 {
281   GEOM::GEOM_Object_var aGEOMObject;
282
283   //Set a not done flag
284   GetOperations()->SetNotDone();
285
286   int ind, aLen;
287   std::list<Handle(GEOM_Object)> aShapes;
288
289   //Get the shapes
290   aLen = theShapes.length();
291   for (ind = 0; ind < aLen; ind++) {
292     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
293     if (aSh.IsNull()) return aGEOMObject._retn();
294     aShapes.push_back(aSh);
295   }
296
297   // Make Solid
298   Handle(GEOM_Object) anObject =
299     GetOperations()->MakeCompound(aShapes);
300   if (!GetOperations()->IsDone() || anObject.IsNull())
301     return aGEOMObject._retn();
302
303   return GetObject(anObject);
304 }
305
306 //=============================================================================
307 /*!
308  *  MakeGlueFaces
309  */
310 //=============================================================================
311 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
312                                            (GEOM::GEOM_Object_ptr theShape,
313                                             CORBA::Double   theTolerance,
314                                             CORBA::Boolean  doKeepNonSolids)
315 {
316   GEOM::GEOM_Object_var aGEOMObject;
317
318   //Set a not done flag
319   GetOperations()->SetNotDone();
320
321   //Get the reference objects
322   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
323   if (aShape.IsNull()) return aGEOMObject._retn();
324
325   //Perform the gluing
326   Handle(GEOM_Object) anObject =
327     GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
328   //if (!GetOperations()->IsDone() || anObject.IsNull())
329   // to allow warning
330   if (anObject.IsNull())
331     return aGEOMObject._retn();
332
333   return GetObject(anObject);
334 }
335
336
337 //=============================================================================
338 /*!
339  *  GetGlueFaces
340  */
341 //=============================================================================
342 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
343                                            (GEOM::GEOM_Object_ptr theShape,
344                                             const CORBA::Double   theTolerance)
345 {
346   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
347
348   //Set a not done flag
349   GetOperations()->SetNotDone();
350
351   //Get the reference objects
352   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
353   if (aShape.IsNull()) return aSeq._retn();
354
355   Handle(TColStd_HSequenceOfTransient) aHSeq =
356     GetOperations()->GetGlueFaces(aShape, theTolerance);
357
358   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
359   // to allow warning
360   if(aHSeq.IsNull())
361     return aSeq._retn();
362
363   Standard_Integer aLength = aHSeq->Length();
364   aSeq->length(aLength);
365   for (Standard_Integer i = 1; i <= aLength; i++)
366     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
367
368   return aSeq._retn();
369 }
370
371
372 //=============================================================================
373 /*!
374  *  MakeGlueFacesByList
375  */
376 //=============================================================================
377 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
378                                            (GEOM::GEOM_Object_ptr theShape,
379                                             CORBA::Double   theTolerance,
380                                             const GEOM::ListOfGO& theFaces,
381                                             CORBA::Boolean  doKeepNonSolids)
382 {
383   GEOM::GEOM_Object_var aGEOMObject;
384
385   //Set a not done flag
386   GetOperations()->SetNotDone();
387
388   //Get the reference objects
389   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
390   if (aShape.IsNull()) return aGEOMObject._retn();
391
392   int ind, aLen;
393   std::list<Handle(GEOM_Object)> aFaces;
394   //Get the shapes
395   aLen = theFaces.length();
396   for (ind = 0; ind < aLen; ind++) {
397     Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
398     if (aSh.IsNull()) return aGEOMObject._retn();
399     aFaces.push_back(aSh);
400   }
401
402   //Perform the gluing
403   Handle(GEOM_Object) anObject =
404     GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
405   //if (!GetOperations()->IsDone() || anObject.IsNull())
406   // to allow warning
407   if (anObject.IsNull())
408     return aGEOMObject._retn();
409
410   return GetObject(anObject);
411 }
412
413
414 //=============================================================================
415 /*!
416  *  MakeExplode
417  */
418 //=============================================================================
419 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
420                                                        const CORBA::Long     theShapeType,
421                                                        const CORBA::Boolean  isSorted)
422 {
423   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
424
425   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
426   if (aShape.IsNull()) return aSeq._retn();
427
428   Handle(TColStd_HSequenceOfTransient) aHSeq =
429     GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
430   if (!GetOperations()->IsDone() || aHSeq.IsNull())
431     return aSeq._retn();
432
433   Standard_Integer aLength = aHSeq->Length();
434   aSeq->length(aLength);
435   for (Standard_Integer i = 1; i <= aLength; i++)
436     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
437
438   return aSeq._retn();
439 }
440
441 //=============================================================================
442 /*!
443  *  SubShapeAllIDs
444  */
445 //=============================================================================
446 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
447                                                             const CORBA::Long     theShapeType,
448                                                             const CORBA::Boolean  isSorted)
449 {
450   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
451
452   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
453   if (aShape.IsNull()) return aSeq._retn();
454
455   Handle(TColStd_HSequenceOfInteger) aHSeq =
456     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
457   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
458
459   Standard_Integer aLength = aHSeq->Length();
460   aSeq->length(aLength);
461   for (Standard_Integer i = 1; i <= aLength; i++)
462     aSeq[i-1] = aHSeq->Value(i);
463
464   return aSeq._retn();
465 }
466
467 //=============================================================================
468 /*!
469  *  GetSubShape
470  */
471 //=============================================================================
472 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
473                                            (GEOM::GEOM_Object_ptr theMainShape,
474                                             const CORBA::Long     theID)
475 {
476   GEOM::GEOM_Object_var aGEOMObject;
477
478   //Set a not done flag
479   GetOperations()->SetNotDone();
480
481   //Get the reference objects
482   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
483   if (aShape.IsNull()) return aGEOMObject._retn();
484
485   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
486   if (!GetOperations()->IsDone() || anObject.IsNull())
487     return aGEOMObject._retn();
488
489   return GetObject(anObject);
490 }
491
492 //=============================================================================
493 /*!
494  *  GetSubShapeIndex
495  */
496 //=============================================================================
497 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
498   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
499 {
500   //Get the reference shapes
501   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
502   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
503
504   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
505
506   //Get the unique ID of <theSubShape> inside <theMainShape>
507   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
508   if (!GetOperations()->IsDone())
509     return -1;
510
511   return anID;
512 }
513
514 //=============================================================================
515 /*!
516  *  GetTopologyIndex
517  */
518 //=============================================================================
519 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
520   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
521 {
522   //Get the reference shapes
523   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
524   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
525
526   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
527
528   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
529   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
530   if (!GetOperations()->IsDone())
531     return -1;
532
533   return anID;
534 }
535
536 //=============================================================================
537 /*!
538  *  GetShapeTypeString
539  */
540 //=============================================================================
541 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
542 {
543   //Get the reference shape
544   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
545   if (aShape.IsNull()) return NULL;
546
547   // Get shape parameters
548   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
549   return CORBA::string_dup(aDescription.ToCString());
550 }
551
552 //=============================================================================
553 /*!
554  *  NumberOfFaces
555  */
556 //=============================================================================
557 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
558 {
559   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
560 }
561
562 //=============================================================================
563 /*!
564  *  NumberOfEdges
565  */
566 //=============================================================================
567 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
568 {
569   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
570 }
571
572 //=============================================================================
573 /*!
574  *  NumberOfSubShapes
575  */
576 //=============================================================================
577 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
578                                                          const CORBA::Long     theShapeType)
579 {
580   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
581   if (aShape.IsNull()) return -1;
582
583   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
584   if (!GetOperations()->IsDone()) return -1;
585
586   return aNb;
587 }
588
589 //=============================================================================
590 /*!
591  *  ChangeOrientation
592  */
593 //=============================================================================
594 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
595                                                 (GEOM::GEOM_Object_ptr theShape)
596 {
597   GEOM::GEOM_Object_var aGEOMObject;
598
599   //Set a not done flag
600   GetOperations()->SetNotDone();
601
602   //Get the reference objects
603   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
604   if (aShape.IsNull()) return aGEOMObject._retn();
605
606   //Create the Solid
607   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
608   if (!GetOperations()->IsDone() || anObject.IsNull())
609     return aGEOMObject._retn();
610
611   return GetObject(anObject);
612 }
613
614 //=============================================================================
615 /*!
616  *  GetFreeFacesIDs
617  */
618 //=============================================================================
619 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
620 {
621   //Set a not done flag
622   GetOperations()->SetNotDone();
623
624   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
625
626   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
627   if (aShape.IsNull()) return aSeq._retn();
628
629   Handle(TColStd_HSequenceOfInteger) aHSeq =
630     GetOperations()->GetFreeFacesIDs(aShape);
631   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
632
633   Standard_Integer aLength = aHSeq->Length();
634   aSeq->length(aLength);
635   for (Standard_Integer i = 1; i <= aLength; i++)
636     aSeq[i-1] = aHSeq->Value(i);
637
638   return aSeq._retn();
639 }
640
641 //=============================================================================
642 /*!
643  *  GetSharedShapes
644  */
645 //=============================================================================
646 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
647                                           (GEOM::GEOM_Object_ptr theShape1,
648                                            GEOM::GEOM_Object_ptr theShape2,
649                                            const CORBA::Long     theShapeType)
650 {
651   //Set a not done flag
652   GetOperations()->SetNotDone();
653
654   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
655
656   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
657   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
658
659   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
660
661   Handle(TColStd_HSequenceOfTransient) aHSeq =
662     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
663   if (!GetOperations()->IsDone() || aHSeq.IsNull())
664     return aSeq._retn();
665
666   Standard_Integer aLength = aHSeq->Length();
667   aSeq->length(aLength);
668   for (Standard_Integer i = 1; i <= aLength; i++)
669     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
670
671   return aSeq._retn();
672 }
673
674 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
675 {
676   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
677
678   switch (theState) {
679   case GEOM::ST_ON:
680     aState = GEOMAlgo_ST_ON;
681     break;
682   case GEOM::ST_OUT:
683     aState = GEOMAlgo_ST_OUT;
684     break;
685   case GEOM::ST_ONOUT:
686     aState = GEOMAlgo_ST_ONOUT;
687     break;
688   case GEOM::ST_IN:
689     aState = GEOMAlgo_ST_IN;
690     break;
691   case GEOM::ST_ONIN:
692     aState = GEOMAlgo_ST_ONIN;
693     break;
694   default:
695     break;
696   }
697
698   return aState;
699 }
700
701 //=============================================================================
702 /*!
703  *  GetShapesOnPlane
704  */
705 //=============================================================================
706 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
707                                                 (GEOM::GEOM_Object_ptr   theShape,
708                                                  const CORBA::Long       theShapeType,
709                                                  GEOM::GEOM_Object_ptr   theAx1,
710                                                  const GEOM::shape_state theState)
711 {
712   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
713
714   //Set a not done flag
715   GetOperations()->SetNotDone();
716
717   //Get the reference objects
718   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
719   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
720
721   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
722
723   //Get Shapes On Plane
724   Handle(TColStd_HSequenceOfTransient) aHSeq =
725     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
726   if (!GetOperations()->IsDone() || aHSeq.IsNull())
727     return aSeq._retn();
728
729   Standard_Integer aLength = aHSeq->Length();
730   aSeq->length(aLength);
731   for (Standard_Integer i = 1; i <= aLength; i++)
732     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
733
734   return aSeq._retn();
735 }
736
737 //=============================================================================
738 /*!
739  *  GetShapesOnPlaneWithLocation
740  */
741 //=============================================================================
742 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
743                                                 (GEOM::GEOM_Object_ptr   theShape,
744                                                  const CORBA::Long       theShapeType,
745                                                  GEOM::GEOM_Object_ptr   theAx1,
746                                                  GEOM::GEOM_Object_ptr   thePnt,
747                                                  const GEOM::shape_state theState)
748 {
749   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
750
751   //Set a not done flag
752   GetOperations()->SetNotDone();
753
754   //Get the reference objects
755   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
756   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
757   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
758
759   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
760
761   //Get Shapes On Plane
762   Handle(TColStd_HSequenceOfTransient) aHSeq =
763     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
764   if (!GetOperations()->IsDone() || aHSeq.IsNull())
765     return aSeq._retn();
766
767   Standard_Integer aLength = aHSeq->Length();
768   aSeq->length(aLength);
769   for (Standard_Integer i = 1; i <= aLength; i++)
770     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
771
772   return aSeq._retn();
773 }
774
775 //=============================================================================
776 /*!
777  *  GetShapesOnCylinder
778  */
779 //=============================================================================
780 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
781                                                 (GEOM::GEOM_Object_ptr   theShape,
782                                                  const CORBA::Long       theShapeType,
783                                                  GEOM::GEOM_Object_ptr   theAxis,
784                                                  const CORBA::Double     theRadius,
785                                                  const GEOM::shape_state theState)
786 {
787   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
788
789   //Set a not done flag
790   GetOperations()->SetNotDone();
791
792   //Get the reference objects
793   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
794   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
795
796   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
797
798   //Get Shapes On Cylinder
799   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
800     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
801   if (!GetOperations()->IsDone() || aHSeq.IsNull())
802     return aSeq._retn();
803
804   Standard_Integer aLength = aHSeq->Length();
805   aSeq->length(aLength);
806   for (Standard_Integer i = 1; i <= aLength; i++)
807     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
808
809   return aSeq._retn();
810 }
811
812 //=============================================================================
813 /*!
814  *  GetShapesOnCylinderWithLocation
815  */
816 //=============================================================================
817 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
818                                                 (GEOM::GEOM_Object_ptr   theShape,
819                                                  const CORBA::Long       theShapeType,
820                                                  GEOM::GEOM_Object_ptr   theAxis,
821                                                  GEOM::GEOM_Object_ptr   thePnt,
822                                                  const CORBA::Double     theRadius,
823                                                  const GEOM::shape_state theState)
824 {
825   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
826
827   //Set a not done flag
828   GetOperations()->SetNotDone();
829
830   //Get the reference objects
831   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
832   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
833   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
834
835   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
836
837   //Get Shapes On Cylinder
838   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
839     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
840   if (!GetOperations()->IsDone() || aHSeq.IsNull())
841     return aSeq._retn();
842
843   Standard_Integer aLength = aHSeq->Length();
844   aSeq->length(aLength);
845   for (Standard_Integer i = 1; i <= aLength; i++)
846     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
847
848   return aSeq._retn();
849 }
850
851 //=============================================================================
852 /*!
853  *  GetShapesOnSphere
854  */
855 //=============================================================================
856 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
857                                                 (GEOM::GEOM_Object_ptr   theShape,
858                                                  const CORBA::Long       theShapeType,
859                                                  GEOM::GEOM_Object_ptr   theCenter,
860                                                  const CORBA::Double     theRadius,
861                                                  const GEOM::shape_state theState)
862 {
863   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
864
865   //Set a not done flag
866   GetOperations()->SetNotDone();
867
868   //Get the reference objects
869   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
870   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
871
872   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
873
874   //Get Shapes On Sphere
875   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
876     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
877   if (!GetOperations()->IsDone() || aHSeq.IsNull())
878     return aSeq._retn();
879
880   Standard_Integer aLength = aHSeq->Length();
881   aSeq->length(aLength);
882   for (Standard_Integer i = 1; i <= aLength; i++)
883     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
884
885   return aSeq._retn();
886 }
887
888 //=============================================================================
889 /*!
890  *  GetShapesOnQuadrangle
891  */
892 //=============================================================================
893 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
894                                                 (GEOM::GEOM_Object_ptr theShape,
895                                                  CORBA::Long           theShapeType,
896                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
897                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
898                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
899                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
900                                                  GEOM::shape_state     theState)
901 {
902   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
903
904   //Set a not done flag
905   GetOperations()->SetNotDone();
906
907   //Get the reference objects
908   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
909   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
910   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
911   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
912   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
913
914   if (aShape.IsNull() ||
915       aTopLeftPoint.IsNull() ||
916       aTopRigthPoint.IsNull() ||
917       aBottomLeftPoint.IsNull() ||
918       aBottomRigthPoint.IsNull())
919     return aSeq._retn();
920
921   //Get Shapes On Quadrangle
922   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
923     (aShape, theShapeType,
924      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
925      ShapeState(theState));
926   if (!GetOperations()->IsDone() || aHSeq.IsNull())
927     return aSeq._retn();
928
929   Standard_Integer aLength = aHSeq->Length();
930   aSeq->length(aLength);
931   for (Standard_Integer i = 1; i <= aLength; i++)
932     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
933
934   return aSeq._retn();
935 }
936
937 //=============================================================================
938 /*!
939  *  GetShapesOnPlaneIDs
940  */
941 //=============================================================================
942 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
943                                                 (GEOM::GEOM_Object_ptr   theShape,
944                                                  const CORBA::Long       theShapeType,
945                                                  GEOM::GEOM_Object_ptr   theAx1,
946                                                  const GEOM::shape_state theState)
947 {
948   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
949
950   //Set a not done flag
951   GetOperations()->SetNotDone();
952
953   //Get the reference objects
954   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
955   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
956
957   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
958
959   //Get Shapes On Plane
960   Handle(TColStd_HSequenceOfInteger) aHSeq =
961     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
962   if (!GetOperations()->IsDone() || aHSeq.IsNull())
963     return aSeq._retn();
964
965   Standard_Integer aLength = aHSeq->Length();
966   aSeq->length(aLength);
967   for (Standard_Integer i = 1; i <= aLength; i++)
968     aSeq[i-1] = aHSeq->Value(i);
969
970   return aSeq._retn();
971 }
972
973 //=============================================================================
974 /*!
975  *  GetShapesOnPlaneWithLocationIDs
976  */
977 //=============================================================================
978 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
979                                                 (GEOM::GEOM_Object_ptr   theShape,
980                                                  const CORBA::Long       theShapeType,
981                                                  GEOM::GEOM_Object_ptr   theAx1,
982                                                  GEOM::GEOM_Object_ptr   thePnt,
983                                                  const GEOM::shape_state theState)
984 {
985   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
986
987   //Set a not done flag
988   GetOperations()->SetNotDone();
989
990   //Get the reference objects
991   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
992   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
993   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
994
995   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
996
997   //Get Shapes On Plane
998   Handle(TColStd_HSequenceOfInteger) aHSeq =
999     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1000                                                      anAx1, anPnt, ShapeState(theState));
1001   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1002     return aSeq._retn();
1003
1004   Standard_Integer aLength = aHSeq->Length();
1005   aSeq->length(aLength);
1006   for (Standard_Integer i = 1; i <= aLength; i++)
1007     aSeq[i-1] = aHSeq->Value(i);
1008
1009   return aSeq._retn();
1010 }
1011
1012 //=============================================================================
1013 /*!
1014  *  GetShapesOnCylinderIDs
1015  */
1016 //=============================================================================
1017 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1018                                                 (GEOM::GEOM_Object_ptr   theShape,
1019                                                  const CORBA::Long       theShapeType,
1020                                                  GEOM::GEOM_Object_ptr   theAxis,
1021                                                  const CORBA::Double     theRadius,
1022                                                  const GEOM::shape_state theState)
1023 {
1024   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1025
1026   //Set a not done flag
1027   GetOperations()->SetNotDone();
1028
1029   //Get the reference objects
1030   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1031   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1032
1033   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1034
1035   //Get Shapes On Cylinder
1036   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1037     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1038   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1039     return aSeq._retn();
1040
1041   Standard_Integer aLength = aHSeq->Length();
1042   aSeq->length(aLength);
1043   for (Standard_Integer i = 1; i <= aLength; i++)
1044     aSeq[i-1] = aHSeq->Value(i);
1045
1046   return aSeq._retn();
1047 }
1048
1049 //=============================================================================
1050 /*!
1051  *  GetShapesOnCylinderWithLocationIDs
1052  */
1053 //=============================================================================
1054 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1055                                                 (GEOM::GEOM_Object_ptr   theShape,
1056                                                  const CORBA::Long       theShapeType,
1057                                                  GEOM::GEOM_Object_ptr   theAxis,
1058                                                  GEOM::GEOM_Object_ptr   thePnt,
1059                                                  const CORBA::Double     theRadius,
1060                                                  const GEOM::shape_state theState)
1061 {
1062   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1063
1064   //Set a not done flag
1065   GetOperations()->SetNotDone();
1066
1067   //Get the reference objects
1068   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1069   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1070   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1071
1072   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1073
1074   //Get Shapes On Cylinder
1075   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1076     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1077   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1078     return aSeq._retn();
1079
1080   Standard_Integer aLength = aHSeq->Length();
1081   aSeq->length(aLength);
1082   for (Standard_Integer i = 1; i <= aLength; i++)
1083     aSeq[i-1] = aHSeq->Value(i);
1084
1085   return aSeq._retn();
1086 }
1087
1088 //=============================================================================
1089 /*!
1090  *  GetShapesOnSphereIDs
1091  */
1092 //=============================================================================
1093 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1094                                                 (GEOM::GEOM_Object_ptr   theShape,
1095                                                  const CORBA::Long       theShapeType,
1096                                                  GEOM::GEOM_Object_ptr   theCenter,
1097                                                  const CORBA::Double     theRadius,
1098                                                  const GEOM::shape_state theState)
1099 {
1100   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1101
1102   //Set a not done flag
1103   GetOperations()->SetNotDone();
1104
1105   //Get the reference objects
1106   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1107   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1108
1109   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1110
1111   //Get Shapes On Sphere
1112   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1113     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1114   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1115     return aSeq._retn();
1116
1117   Standard_Integer aLength = aHSeq->Length();
1118   aSeq->length(aLength);
1119   for (Standard_Integer i = 1; i <= aLength; i++)
1120     aSeq[i-1] = aHSeq->Value(i);
1121
1122   return aSeq._retn();
1123 }
1124
1125 //=============================================================================
1126 /*!
1127  *  GetShapesOnQuadrangleIDs
1128  */
1129 //=============================================================================
1130 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1131                                                 (GEOM::GEOM_Object_ptr theShape,
1132                                                  CORBA::Long           theShapeType,
1133                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1134                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1135                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1136                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1137                                                  GEOM::shape_state     theState)
1138 {
1139   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
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) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1147   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1148   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1149   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1150
1151   if (aShape.IsNull() ||
1152       aTopLeftPoint.IsNull() ||
1153       aTopRigthPoint.IsNull() ||
1154       aBottomLeftPoint.IsNull() ||
1155       aBottomRigthPoint.IsNull() )
1156     return aSeq._retn();
1157
1158   //Get Shapes On Quadrangle
1159   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1160     (aShape, theShapeType,
1161      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1162      ShapeState(theState));
1163   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1164     return aSeq._retn();
1165
1166   Standard_Integer aLength = aHSeq->Length();
1167   aSeq->length(aLength);
1168   for (Standard_Integer i = 1; i <= aLength; i++)
1169     aSeq[i-1] = aHSeq->Value(i);
1170
1171   return aSeq._retn();
1172 }
1173
1174 //=============================================================================
1175 /*!
1176  *  GetShapesOnBox
1177  */
1178 //=============================================================================
1179 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1180                                                 (GEOM::GEOM_Object_ptr theBox,
1181                                                  GEOM::GEOM_Object_ptr theShape,
1182                                                  CORBA::Long           theShapeType,
1183                                                  GEOM::shape_state     theState)
1184 {
1185   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1186
1187   //Set a not done flag
1188   GetOperations()->SetNotDone();
1189
1190   //Get the reference objects
1191   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1192   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1193
1194   if (aShape.IsNull() || aBox.IsNull() )
1195     return aSeq._retn();
1196
1197   //Get Shapes On Box
1198   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1199     (aBox,aShape, theShapeType,ShapeState(theState));
1200   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1201     return aSeq._retn();
1202
1203   Standard_Integer aLength = aHSeq->Length();
1204   aSeq->length(aLength);
1205   for (Standard_Integer i = 1; i <= aLength; i++)
1206     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1207
1208   return aSeq._retn();
1209 }
1210
1211 //=============================================================================
1212 /*!
1213  *  GetShapesOnQuadrangleIDs
1214  */
1215 //=============================================================================
1216 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1217                                                 (GEOM::GEOM_Object_ptr theBox,
1218                                                  GEOM::GEOM_Object_ptr theShape,
1219                                                  CORBA::Long           theShapeType,
1220                                                  GEOM::shape_state     theState)
1221 {
1222   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1223
1224   //Set a not done flag
1225   GetOperations()->SetNotDone();
1226
1227   //Get the reference objects
1228   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1229   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1230
1231   if (aShape.IsNull() || aBox.IsNull() )
1232     return aSeq._retn();
1233
1234   //Get Shapes On Box
1235   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1236     (aBox,aShape, theShapeType,ShapeState(theState));
1237   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1238     return aSeq._retn();
1239
1240   Standard_Integer aLength = aHSeq->Length();
1241   aSeq->length(aLength);
1242   for (Standard_Integer i = 1; i <= aLength; i++)
1243     aSeq[i-1] = aHSeq->Value(i);
1244
1245   return aSeq._retn();
1246 }
1247
1248
1249 //=============================================================================
1250 /*!
1251  *  GetShapesOnShape
1252  */
1253 //=============================================================================
1254 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1255                                            (GEOM::GEOM_Object_ptr theCheckShape,
1256                                             GEOM::GEOM_Object_ptr theShape,
1257                                             CORBA::Short          theShapeType,
1258                                             GEOM::shape_state     theState)
1259 {
1260   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1261
1262   //Set a not done flag
1263   GetOperations()->SetNotDone();
1264
1265   //Get the reference objects
1266   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1267   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1268
1269   if (aShape.IsNull() || aCheckShape.IsNull() )
1270     return aSeq._retn();
1271
1272   //Get Shapes On Shape
1273   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1274     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1275
1276   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1277     return aSeq._retn();
1278
1279   Standard_Integer aLength = aHSeq->Length();
1280   aSeq->length(aLength);
1281   for (Standard_Integer i = 1; i <= aLength; i++)
1282     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1283
1284   return aSeq._retn();
1285 }
1286
1287
1288 //=============================================================================
1289 /*!
1290  *  GetShapesOnShapeAsCompound
1291  */
1292 //=============================================================================
1293 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1294                                            (GEOM::GEOM_Object_ptr theCheckShape,
1295                                             GEOM::GEOM_Object_ptr theShape,
1296                                             CORBA::Short          theShapeType,
1297                                             GEOM::shape_state     theState)
1298 {
1299   GEOM::GEOM_Object_var aGEOMObject;
1300
1301   //Set a not done flag
1302   GetOperations()->SetNotDone();
1303
1304   //Get the reference objects
1305   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1306   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1307
1308   if (aShape.IsNull() || aCheckShape.IsNull() )
1309     return aGEOMObject._retn();
1310
1311   //Get Shapes On Shape
1312   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1313     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1314
1315   if (anObject.IsNull())
1316     return aGEOMObject._retn();
1317
1318   return GetObject(anObject);
1319 }
1320
1321
1322 //=============================================================================
1323 /*!
1324  *  GetShapesOnShapeIDs
1325  */
1326 //=============================================================================
1327 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1328                                            (GEOM::GEOM_Object_ptr theCheckShape,
1329                                             GEOM::GEOM_Object_ptr theShape,
1330                                             CORBA::Short          theShapeType,
1331                                             GEOM::shape_state     theState)
1332 {
1333   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1334
1335   //Set a not done flag
1336   GetOperations()->SetNotDone();
1337
1338   //Get the reference objects
1339   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1340   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1341
1342   if (aShape.IsNull() || aCheckShape.IsNull() )
1343     return aSeq._retn();
1344
1345   //Get Shapes On Shape
1346   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1347     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1348   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1349     return aSeq._retn();
1350
1351   Standard_Integer aLength = aHSeq->Length();
1352   aSeq->length(aLength);
1353   for (Standard_Integer i = 1; i <= aLength; i++)
1354     aSeq[i-1] = aHSeq->Value(i);
1355
1356   return aSeq._retn();
1357 }
1358
1359
1360 //=============================================================================
1361 /*!
1362  *  GetInPlace
1363  */
1364 //=============================================================================
1365 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1366                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1367                                            GEOM::GEOM_Object_ptr theShapeWhat)
1368 {
1369   GEOM::GEOM_Object_var aGEOMObject;
1370
1371   //Set a not done flag
1372   GetOperations()->SetNotDone();
1373
1374   //Get the reference objects
1375   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1376   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1377
1378   if (aShapeWhere.IsNull() ||
1379       aShapeWhat.IsNull()) return aGEOMObject._retn();
1380
1381   //Get Shapes in place of aShapeWhat
1382   Handle(GEOM_Object) anObject =
1383     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1384   if (!GetOperations()->IsDone() || anObject.IsNull())
1385     return aGEOMObject._retn();
1386
1387   return GetObject(anObject);
1388 }
1389
1390 //=============================================================================
1391 /*!
1392  *  GetInPlaceByHistory
1393  */
1394 //=============================================================================
1395 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1396                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1397                                            GEOM::GEOM_Object_ptr theShapeWhat)
1398 {
1399   GEOM::GEOM_Object_var aGEOMObject;
1400
1401   //Set a not done flag
1402   GetOperations()->SetNotDone();
1403
1404   //Get the reference objects
1405   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1406   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1407
1408   if (aShapeWhere.IsNull() ||
1409       aShapeWhat.IsNull()) return aGEOMObject._retn();
1410
1411   //Get Shapes in place of aShapeWhat
1412   Handle(GEOM_Object) anObject =
1413     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1414   if (!GetOperations()->IsDone() || anObject.IsNull())
1415     return aGEOMObject._retn();
1416
1417   return GetObject(anObject);
1418 }
1419
1420 //=============================================================================
1421 /*!
1422  *  GetSame
1423  */
1424 //=============================================================================
1425 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1426                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1427                                            GEOM::GEOM_Object_ptr theShapeWhat)
1428 {
1429   GEOM::GEOM_Object_var aGEOMObject;
1430
1431   //Set a not done flag
1432   GetOperations()->SetNotDone();
1433
1434   //Get the reference objects
1435   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1436   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1437
1438   if (aShapeWhere.IsNull() ||
1439       aShapeWhat.IsNull()) return aGEOMObject._retn();
1440
1441   //Get Shapes in place of aShapeWhat
1442   Handle(GEOM_Object) anObject =
1443     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1444   if (!GetOperations()->IsDone() || anObject.IsNull())
1445     return aGEOMObject._retn();
1446
1447   return GetObject(anObject);
1448 }