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