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