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