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