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