Salome HOME
Copyrights update 2015.
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_IShapesOperations_i.hh"
26
27 #include "utilities.h"
28 #include "OpUtil.hxx"
29 #include "Utils_ExceptHandlers.hxx"
30
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
33
34 #include <TopAbs.hxx>
35 #include <TColStd_HSequenceOfTransient.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
37
38 //=============================================================================
39 /*!
40  *   constructor:
41  */
42 //=============================================================================
43 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
44                                                     GEOM::GEOM_Gen_ptr theEngine,
45                                                     ::GEOMImpl_IShapesOperations* theImpl)
46 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
47 {
48   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
49 }
50
51 //=============================================================================
52 /*!
53  *  destructor
54  */
55 //=============================================================================
56 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
57 {
58   MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
59 }
60
61
62 //=============================================================================
63 /*!
64  *  MakeEdge
65  */
66 //=============================================================================
67 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
68                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
69 {
70   GEOM::GEOM_Object_var aGEOMObject;
71
72   //Set a not done flag
73   GetOperations()->SetNotDone();
74
75   //Get the reference points
76   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
77   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
78
79   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
80
81   //Create the Edge
82   Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
83   if (!GetOperations()->IsDone() || anObject.IsNull())
84     return aGEOMObject._retn();
85
86   return GetObject(anObject);
87 }
88
89 //=============================================================================
90 /*!
91  *  MakeEdgeOnCurveByLength
92  */
93 //=============================================================================
94 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
95                   (GEOM::GEOM_Object_ptr theCurve,
96                    CORBA::Double         theLength,
97                    GEOM::GEOM_Object_ptr theStartPoint)
98 {
99   GEOM::GEOM_Object_var aGEOMObject;
100
101   //Set a not done flag
102   GetOperations()->SetNotDone();
103
104   //Get the reference curve
105   Handle(GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
106   if (aRefCurve.IsNull()) return aGEOMObject._retn();
107
108   //Get the reference point (can be NULL)
109   Handle(GEOM_Object) aRefPoint;
110   if (!CORBA::is_nil(theStartPoint)) {
111     aRefPoint = GetObjectImpl(theStartPoint);
112   }
113
114   //Create the point
115   Handle(GEOM_Object) anObject =
116     GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
117   if (!GetOperations()->IsDone() || anObject.IsNull())
118     return aGEOMObject._retn();
119
120   return GetObject(anObject);
121 }
122
123 //=============================================================================
124 /*!
125  *  MakeEdgeWire
126  */
127 //=============================================================================
128 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
129                       (GEOM::GEOM_Object_ptr theWire,
130                        const CORBA::Double theLinearTolerance,
131                        const CORBA::Double theAngularTolerance)
132 {
133   GEOM::GEOM_Object_var aGEOMObject;
134
135   //Set a not done flag
136   GetOperations()->SetNotDone();
137
138   //Get the source wire
139   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
140
141   if (aWire.IsNull()) return aGEOMObject._retn();
142
143   //Create the Edge
144   Handle(GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
145   if (!GetOperations()->IsDone() || anObject.IsNull())
146     return aGEOMObject._retn();
147
148   return GetObject(anObject);
149 }
150
151 //=============================================================================
152 /*!
153  *  MakeWire
154  */
155 //=============================================================================
156 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
157                            (const GEOM::ListOfGO& theEdgesAndWires,
158                             const CORBA::Double   theTolerance)
159 {
160   GEOM::GEOM_Object_var aGEOMObject;
161
162   //Set a not done flag
163   GetOperations()->SetNotDone();
164
165   int ind, aLen;
166   std::list<Handle(GEOM_Object)> aShapes;
167
168   //Get the shapes
169   aLen = theEdgesAndWires.length();
170   for (ind = 0; ind < aLen; ind++) {
171     Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
172     if (aSh.IsNull()) return aGEOMObject._retn();
173     aShapes.push_back(aSh);
174   }
175
176   // Make Solid
177   Handle(GEOM_Object) anObject =
178     GetOperations()->MakeWire(aShapes, theTolerance);
179   if (!GetOperations()->IsDone() || anObject.IsNull())
180     return aGEOMObject._retn();
181
182   return GetObject(anObject);
183 }
184
185 //=============================================================================
186 /*!
187  *  MakeFace
188  */
189 //=============================================================================
190 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
191                       (GEOM::GEOM_Object_ptr theWire,
192                        const CORBA::Boolean  isPlanarWanted)
193 {
194   GEOM::GEOM_Object_var aGEOMObject;
195
196   //Set a not done flag
197   GetOperations()->SetNotDone();
198
199   //Get the reference wire
200   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
201   if (aWire.IsNull()) return aGEOMObject._retn();
202
203   //Create the Face
204   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
205   //if (!GetOperations()->IsDone() || anObject.IsNull())
206   // enable warning status
207   if (anObject.IsNull())
208     return aGEOMObject._retn();
209
210   return GetObject(anObject);
211 }
212
213 //=============================================================================
214 /*!
215  *  MakeFaceWires
216  */
217 //=============================================================================
218 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
219                                          (const GEOM::ListOfGO& theWires,
220                                           const CORBA::Boolean  isPlanarWanted)
221 {
222   GEOM::GEOM_Object_var aGEOMObject;
223
224   //Set a not done flag
225   GetOperations()->SetNotDone();
226
227   int ind, aLen;
228   std::list<Handle(GEOM_Object)> aShapes;
229
230   //Get the shapes
231   aLen = theWires.length();
232   for (ind = 0; ind < aLen; ind++) {
233     Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
234     if (aSh.IsNull()) return aGEOMObject._retn();
235     aShapes.push_back(aSh);
236   }
237
238   // Make Face
239   Handle(GEOM_Object) anObject =
240     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
241   //if (!GetOperations()->IsDone() || anObject.IsNull())
242   // enable warning status
243   if (anObject.IsNull())
244     return aGEOMObject._retn();
245
246   return GetObject(anObject);
247 }
248
249 //=============================================================================
250 /*!
251  *  MakeFaceFromSurface
252  */
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceFromSurface
255                                   (GEOM::GEOM_Object_ptr theFace,
256                                    GEOM::GEOM_Object_ptr theWire)
257 {
258   GEOM::GEOM_Object_var aGEOMObject;
259
260   //Set a not done flag
261   GetOperations()->SetNotDone();
262
263   //Get the reference face and wire
264   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
265   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
266
267   if (aFace.IsNull() || aWire.IsNull()) {
268     return aGEOMObject._retn();
269   }
270
271   //Create the Face
272   Handle(GEOM_Object) anObject =
273     GetOperations()->MakeFaceFromSurface(aFace, aWire);
274
275   if (anObject.IsNull()) {
276     return aGEOMObject._retn();
277   }
278
279   return GetObject(anObject);
280 }
281
282 //=============================================================================
283 /*!
284  *  MakeFaceWithConstraints
285  */
286 //=============================================================================
287 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWithConstraints
288                                                 (const GEOM::ListOfGO& theConstraints)
289 {
290   GEOM::GEOM_Object_var aGEOMObject;
291
292   //Set a not done flag
293   GetOperations()->SetNotDone();
294
295   //Get the shapes
296   std::list<Handle(GEOM_Object)> aConstraints;
297   for( int ind = 0; ind < theConstraints.length(); ind++ ) {
298     Handle(GEOM_Object) anObject = GetObjectImpl( theConstraints[ind] );
299     aConstraints.push_back(anObject);
300   }
301
302   // Make Face
303   Handle(GEOM_Object) anObject =
304     GetOperations()->MakeFaceWithConstraints( aConstraints );
305
306   // enable warning status
307   if (anObject.IsNull())
308     return aGEOMObject._retn();
309
310   return GetObject(anObject);
311 }
312
313 //=============================================================================
314 /*!
315  *  MakeShell
316  */
317 //=============================================================================
318 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
319                                       (const GEOM::ListOfGO& theFacesAndShells)
320 {
321   GEOM::GEOM_Object_var aGEOMObject;
322
323   //Set a not done flag
324   GetOperations()->SetNotDone();
325
326   int ind, aLen;
327   std::list<Handle(GEOM_Object)> aShapes;
328
329   //Get the shapes
330   aLen = theFacesAndShells.length();
331   for (ind = 0; ind < aLen; ind++) {
332     Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
333     if (aSh.IsNull()) return aGEOMObject._retn();
334     aShapes.push_back(aSh);
335   }
336
337   // Make Solid
338   Handle(GEOM_Object) anObject =
339     GetOperations()->MakeShell(aShapes);
340   if (!GetOperations()->IsDone() || anObject.IsNull())
341     return aGEOMObject._retn();
342
343   return GetObject(anObject);
344 }
345
346 //=============================================================================
347 /*!
348  *  MakeSolidShell
349  */
350 //=============================================================================
351 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
352                                                 (GEOM::GEOM_Object_ptr theShell)
353 {
354   GEOM::GEOM_Object_var aGEOMObject;
355
356   //Set a not done flag
357   GetOperations()->SetNotDone();
358
359   //Get the reference objects
360   Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
361   if (aShell.IsNull()) return aGEOMObject._retn();
362
363   std::list<Handle(GEOM_Object)> aShapes;
364   aShapes.push_back(aShell);
365
366   //Create the Solid
367   Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
368   if (!GetOperations()->IsDone() || anObject.IsNull())
369     return aGEOMObject._retn();
370
371   return GetObject(anObject);
372 }
373
374 //=============================================================================
375 /*!
376  *  MakeSolidShells
377  */
378 //=============================================================================
379 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
380                                       (const GEOM::ListOfGO& theShells)
381 {
382   GEOM::GEOM_Object_var aGEOMObject;
383
384   //Set a not done flag
385   GetOperations()->SetNotDone();
386
387   int ind, aLen;
388   std::list<Handle(GEOM_Object)> aShapes;
389
390   //Get the shapes
391   aLen = theShells.length();
392   for (ind = 0; ind < aLen; ind++) {
393     Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
394     if (aSh.IsNull()) return aGEOMObject._retn();
395     aShapes.push_back(aSh);
396   }
397
398   // Make Solid
399   Handle(GEOM_Object) anObject =
400     GetOperations()->MakeSolidShells(aShapes);
401   if (!GetOperations()->IsDone() || anObject.IsNull())
402     return aGEOMObject._retn();
403
404   return GetObject(anObject);
405 }
406
407 //=============================================================================
408 /*!
409  *  MakeCompound
410  */
411 //=============================================================================
412 GEOM::GEOM_Object_ptr
413 GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
414 {
415   GEOM::GEOM_Object_var aGEOMObject;
416
417   //Set a not done flag
418   GetOperations()->SetNotDone();
419
420   int ind, aLen;
421   std::list<Handle(GEOM_Object)> aShapes;
422
423   //Get the shapes
424   aLen = theShapes.length();
425   for (ind = 0; ind < aLen; ind++) {
426     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
427     if (aSh.IsNull()) return aGEOMObject._retn();
428     aShapes.push_back(aSh);
429   }
430
431   // Make Solid
432   Handle(GEOM_Object) anObject =
433     GetOperations()->MakeCompound(aShapes);
434   if (!GetOperations()->IsDone() || anObject.IsNull())
435     return aGEOMObject._retn();
436
437   return GetObject(anObject);
438 }
439
440 //=============================================================================
441 /*!
442  *  MakeSolidFromConnectedFaces
443  */
444 //=============================================================================
445 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidFromConnectedFaces
446                                       (const GEOM::ListOfGO& theFacesOrShells,
447                                        const CORBA::Boolean  isIntersect)
448 {
449   GEOM::GEOM_Object_var aGEOMObject;
450
451   //Set a not done flag
452   GetOperations()->SetNotDone();
453
454   int ind, aLen;
455   std::list<Handle(GEOM_Object)> aShapes;
456
457   //Get the shapes
458   aLen = theFacesOrShells.length();
459   for (ind = 0; ind < aLen; ind++) {
460     Handle(GEOM_Object) aSh = GetObjectImpl(theFacesOrShells[ind]);
461     if (aSh.IsNull()) return aGEOMObject._retn();
462     aShapes.push_back(aSh);
463   }
464
465   // Make Solid
466   Handle(GEOM_Object) anObject =
467     GetOperations()->MakeSolidFromConnectedFaces(aShapes, isIntersect);
468   if (!GetOperations()->IsDone() || anObject.IsNull())
469     return aGEOMObject._retn();
470
471   return GetObject(anObject);
472 }
473
474 //=============================================================================
475 /*!
476  *  MakeGlueFaces
477  */
478 //=============================================================================
479 GEOM::GEOM_Object_ptr
480 GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
481                                          CORBA::Double         theTolerance,
482                                          CORBA::Boolean  doKeepNonSolids)
483 {
484   GEOM::GEOM_Object_var aGEOMObject;
485
486   //Set a not done flag
487   GetOperations()->SetNotDone();
488
489   //Get the reference objects
490   std::list< Handle(GEOM_Object) > aShapes;
491   if (! GetListOfObjectsImpl( theShapes, aShapes ))
492     return aGEOMObject._retn();
493
494   //Perform the gluing
495   Handle(GEOM_Object) anObject =
496     GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
497   //if (!GetOperations()->IsDone() || anObject.IsNull())
498   // to allow warning
499   if (anObject.IsNull())
500     return aGEOMObject._retn();
501
502   return GetObject(anObject);
503 }
504
505 //=============================================================================
506 /*!
507  *  GetGlueFaces
508  */
509 //=============================================================================
510 GEOM::ListOfGO*
511 GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
512                                         const CORBA::Double   theTolerance)
513 {
514   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
515
516   //Set a not done flag
517   GetOperations()->SetNotDone();
518
519   //Get the reference objects
520   std::list< Handle(GEOM_Object) > aShapes;
521   if (! GetListOfObjectsImpl( theShapes, aShapes ))
522     return aSeq._retn();
523
524   Handle(TColStd_HSequenceOfTransient) aHSeq =
525     GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
526
527   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
528   // to allow warning
529   if(aHSeq.IsNull())
530     return aSeq._retn();
531
532   Standard_Integer aLength = aHSeq->Length();
533   aSeq->length(aLength);
534   for (Standard_Integer i = 1; i <= aLength; i++)
535     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
536
537   return aSeq._retn();
538 }
539
540 //=============================================================================
541 /*!
542  *  MakeGlueFacesByList
543  */
544 //=============================================================================
545 GEOM::GEOM_Object_ptr
546 GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
547                                                CORBA::Double         theTolerance,
548                                                const GEOM::ListOfGO& theFaces,
549                                                CORBA::Boolean        doKeepNonSolids,
550                                                CORBA::Boolean        doGlueAllEdges)
551 {
552   GEOM::GEOM_Object_var aGEOMObject;
553
554   //Set a not done flag
555   GetOperations()->SetNotDone();
556
557   //Get the reference objects
558   std::list< Handle(GEOM_Object) > aShapes;
559   if (! GetListOfObjectsImpl( theShapes, aShapes ))
560     return aGEOMObject._retn();
561
562   //Get the shapes
563   std::list<Handle(GEOM_Object)> aFaces;
564   if (! GetListOfObjectsImpl( theFaces, aFaces ))
565     return aGEOMObject._retn();
566
567   //Perform the gluing
568   Handle(GEOM_Object) anObject =
569     GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
570                                          doKeepNonSolids, doGlueAllEdges);
571   //if (!GetOperations()->IsDone() || anObject.IsNull())
572   // to allow warning
573   if (anObject.IsNull())
574     return aGEOMObject._retn();
575
576   return GetObject(anObject);
577 }
578
579 //=============================================================================
580 /*!
581  *  MakeGlueEdges
582  */
583 //=============================================================================
584 GEOM::GEOM_Object_ptr
585 GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
586                                          CORBA::Double         theTolerance)
587 {
588   GEOM::GEOM_Object_var aGEOMObject;
589
590   //Set a not done flag
591   GetOperations()->SetNotDone();
592
593   //Get the reference objects
594   std::list< Handle(GEOM_Object) > aShapes;
595   if (! GetListOfObjectsImpl( theShapes, aShapes ))
596     return aGEOMObject._retn();
597
598   //Perform the gluing
599   Handle(GEOM_Object) anObject =
600     GetOperations()->MakeGlueEdges(aShapes, theTolerance);
601   //if (!GetOperations()->IsDone() || anObject.IsNull())
602   // to allow warning
603   if (anObject.IsNull())
604     return aGEOMObject._retn();
605
606   return GetObject(anObject);
607 }
608
609 //=============================================================================
610 /*!
611  *  GetGlueEdges
612  */
613 //=============================================================================
614 GEOM::ListOfGO*
615 GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
616                                         const CORBA::Double   theTolerance)
617 {
618   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
619
620   //Set a not done flag
621   GetOperations()->SetNotDone();
622
623   //Get the reference objects
624   std::list< Handle(GEOM_Object) > aShapes;
625   if (! GetListOfObjectsImpl( theShapes, aShapes ))
626     return aSeq._retn();
627
628   Handle(TColStd_HSequenceOfTransient) aHSeq =
629     GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
630
631   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
632   // to allow warning
633   if (aHSeq.IsNull())
634     return aSeq._retn();
635
636   Standard_Integer aLength = aHSeq->Length();
637   aSeq->length(aLength);
638   for (Standard_Integer i = 1; i <= aLength; i++)
639     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
640
641   return aSeq._retn();
642 }
643
644 //=============================================================================
645 /*!
646  *  MakeGlueEdgesByList
647  */
648 //=============================================================================
649 GEOM::GEOM_Object_ptr
650 GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
651                                                CORBA::Double         theTolerance,
652                                                const GEOM::ListOfGO& theEdges)
653 {
654   GEOM::GEOM_Object_var aGEOMObject;
655
656   //Set a not done flag
657   GetOperations()->SetNotDone();
658
659   //Get the reference objects
660   std::list< Handle(GEOM_Object) > aShapes;
661   if (! GetListOfObjectsImpl( theShapes, aShapes ))
662     return aGEOMObject._retn();
663
664   //Get the shapes
665   std::list<Handle(GEOM_Object)> anEdges;
666   if (! GetListOfObjectsImpl( theEdges, anEdges ))
667     return aGEOMObject._retn();
668
669   //Perform the gluing
670   Handle(GEOM_Object) anObject =
671     GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
672   //if (!GetOperations()->IsDone() || anObject.IsNull())
673   // to allow warning
674   if (anObject.IsNull())
675     return aGEOMObject._retn();
676
677   return GetObject(anObject);
678 }
679
680 //=============================================================================
681 /*!
682  *  GetExistingSubObjects
683  */
684 //=============================================================================
685 GEOM::ListOfGO*
686 GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
687                                                  CORBA::Boolean        theGroupsOnly)
688 {
689   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
690
691   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
692   if (aShape.IsNull()) return aSeq._retn();
693
694   Handle(TColStd_HSequenceOfTransient) aHSeq =
695     GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
696   if (!GetOperations()->IsDone() || aHSeq.IsNull())
697     return aSeq._retn();
698
699   Standard_Integer aLength = aHSeq->Length();
700   aSeq->length(aLength);
701   for (Standard_Integer i = 1; i <= aLength; i++)
702     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
703
704   return aSeq._retn();
705 }
706
707 //=============================================================================
708 /*!
709  *  MakeExplode (including theShape itself, bad sorting)
710  */
711 //=============================================================================
712 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
713                                                        const CORBA::Long     theShapeType,
714                                                        const CORBA::Boolean  isSorted)
715 {
716   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
717
718   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
719   if (aShape.IsNull()) return aSeq._retn();
720
721   Handle(TColStd_HSequenceOfTransient) aHSeq =
722     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
723                                  GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
724   if (!GetOperations()->IsDone() || aHSeq.IsNull())
725     return aSeq._retn();
726
727   Standard_Integer aLength = aHSeq->Length();
728   aSeq->length(aLength);
729   for (Standard_Integer i = 1; i <= aLength; i++)
730     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
731
732   return aSeq._retn();
733 }
734
735 //=============================================================================
736 /*!
737  *  MakeAllSubShapes (including theShape itself, good sorting)
738  */
739 //=============================================================================
740 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
741                                                             const CORBA::Long     theShapeType,
742                                                             const CORBA::Boolean  isSorted)
743 {
744   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
745
746   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
747   if (aShape.IsNull()) return aSeq._retn();
748
749   Handle(TColStd_HSequenceOfTransient) aHSeq =
750     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
751                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
752   if (!GetOperations()->IsDone() || aHSeq.IsNull())
753     return aSeq._retn();
754
755   Standard_Integer aLength = aHSeq->Length();
756   aSeq->length(aLength);
757   for (Standard_Integer i = 1; i <= aLength; i++)
758     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
759
760   return aSeq._retn();
761 }
762
763 //=============================================================================
764 /*!
765  *  ExtractSubShapes (excluding theShape itself, good sorting)
766  */
767 //=============================================================================
768 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
769                                                             const CORBA::Long     theShapeType,
770                                                             const CORBA::Boolean  isSorted)
771 {
772   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
773
774   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
775   if (aShape.IsNull()) return aSeq._retn();
776
777   Handle(TColStd_HSequenceOfTransient) aHSeq =
778     // TODO: enum instead of bool for the last argument
779     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
780                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
781   if (!GetOperations()->IsDone() || aHSeq.IsNull())
782     return aSeq._retn();
783
784   Standard_Integer aLength = aHSeq->Length();
785   aSeq->length(aLength);
786   for (Standard_Integer i = 1; i <= aLength; i++)
787     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
788
789   return aSeq._retn();
790 }
791
792 //=============================================================================
793 /*!
794  *  SubShapeAllIDs
795  */
796 //=============================================================================
797 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
798                                                             const CORBA::Long     theShapeType,
799                                                             const CORBA::Boolean  isSorted)
800 {
801   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
802
803   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
804   if (aShape.IsNull()) return aSeq._retn();
805
806   Handle(TColStd_HSequenceOfInteger) aHSeq =
807     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
808                                     GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
809   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
810
811   Standard_Integer aLength = aHSeq->Length();
812   aSeq->length(aLength);
813   for (Standard_Integer i = 1; i <= aLength; i++)
814     aSeq[i-1] = aHSeq->Value(i);
815
816   return aSeq._retn();
817 }
818
819 //=============================================================================
820 /*!
821  *  GetAllSubShapesIDs
822  */
823 //=============================================================================
824 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
825                                                                 const CORBA::Long     theShapeType,
826                                                                 const CORBA::Boolean  isSorted)
827 {
828   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
829
830   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
831   if (aShape.IsNull()) return aSeq._retn();
832
833   Handle(TColStd_HSequenceOfInteger) aHSeq =
834     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
835                                     GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
836   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
837
838   Standard_Integer aLength = aHSeq->Length();
839   aSeq->length(aLength);
840   for (Standard_Integer i = 1; i <= aLength; i++)
841     aSeq[i-1] = aHSeq->Value(i);
842
843   return aSeq._retn();
844 }
845
846 //=============================================================================
847 /*!
848  *  GetSubShape
849  */
850 //=============================================================================
851 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
852                                            (GEOM::GEOM_Object_ptr theMainShape,
853                                             const CORBA::Long     theID)
854 {
855   GEOM::GEOM_Object_var aGEOMObject;
856
857   //Set a not done flag
858   GetOperations()->SetNotDone();
859
860   //Get the reference objects
861   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
862   if (aShape.IsNull()) return aGEOMObject._retn();
863
864   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
865   if (!GetOperations()->IsDone() || anObject.IsNull())
866     return aGEOMObject._retn();
867
868   return GetObject(anObject);
869 }
870
871 //=============================================================================
872 /*!
873  *  MakeSubShapes
874  */
875 //=============================================================================
876 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
877                                                          const GEOM::ListOfLong& theIndices)
878 {
879   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
880   Standard_Integer i;
881
882   //Set a not done flag
883   GetOperations()->SetNotDone();
884
885   if (theIndices.length() < 1)
886     return aSeq._retn();
887
888   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
889   if (aShape.IsNull()) return aSeq._retn();
890
891   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
892   for (i = 0; i < theIndices.length(); i++)
893     anArray->SetValue(i+1, theIndices[i]);
894
895   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
896   if (!GetOperations()->IsDone() || aHSeq.IsNull())
897     return aSeq._retn();
898
899   Standard_Integer aLength = aHSeq->Length();
900   aSeq->length(aLength);
901   for (i = 0; i < aLength; i++)
902     aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
903
904   return aSeq._retn();
905 }
906
907 //=============================================================================
908 /*!
909  *  GetSubShapeIndex
910  */
911 //=============================================================================
912 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
913   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
914 {
915   //Get the reference shapes
916   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
917   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
918
919   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
920
921   //Get the unique ID of <theSubShape> inside <theMainShape>
922   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
923   if (!GetOperations()->IsDone())
924     return -1;
925
926   return anID;
927 }
928
929 //=============================================================================
930 /*!
931  *  GetSubShapesIndices
932  */
933 //=============================================================================
934 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
935   (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
936 {
937   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
938   
939   //Get the reference main shape
940   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape); 
941   if (aMainShapeRef.IsNull()) return aSeq._retn();
942       
943   //Get the subshapes
944   std::list<Handle(GEOM_Object)> aShapes;
945   int aLen = theSubShapes.length();
946   for (int ind = 0; ind < aLen; ind++) {
947     Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
948     if (aSh.IsNull())
949     {
950       MESSAGE("NULL shape")
951       return aSeq._retn();
952     }
953     aShapes.push_back(aSh);
954   }
955
956   //Get the IDs of <theSubShapes> inside <theMainShape>
957   Handle(TColStd_HSequenceOfInteger) aHSeq = 
958   GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
959   
960   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
961
962   Standard_Integer aLength = aHSeq->Length();
963   aSeq->length(aLength);
964   
965   for (Standard_Integer i = 1; i <= aLength; i++)
966     aSeq[i-1] = aHSeq->Value(i);
967
968   return aSeq._retn();
969 }
970
971
972 //=============================================================================
973 /*!
974  *  GetTopologyIndex
975  */
976 //=============================================================================
977 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
978   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
979 {
980   //Get the reference shapes
981   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
982   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
983
984   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
985
986   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
987   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
988   if (!GetOperations()->IsDone())
989     return -1;
990
991   return anID;
992 }
993
994 //=============================================================================
995 /*!
996  *  GetShapeTypeString
997  */
998 //=============================================================================
999 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
1000 {
1001   //Get the reference shape
1002   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1003   if (aShape.IsNull()) return NULL;
1004
1005   // Get shape parameters
1006   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
1007   return CORBA::string_dup(aDescription.ToCString());
1008 }
1009
1010 //=============================================================================
1011 /*!
1012  *  IsSubShapeBelongsTo
1013  */
1014 //=============================================================================
1015 CORBA::Boolean GEOM_IShapesOperations_i::IsSubShapeBelongsTo( GEOM::GEOM_Object_ptr theSubObject,
1016                                                               const CORBA::Long theSubObjectIndex,
1017                                                               GEOM::GEOM_Object_ptr theObject,
1018                                                               const CORBA::Long theObjectIndex)
1019 {
1020   Handle(GEOM_Object) aSubObject = GetObjectImpl( theSubObject );
1021   Handle(GEOM_Object) anObject = GetObjectImpl( theObject );
1022   if( anObject.IsNull() || aSubObject.IsNull() )
1023     return false;
1024
1025   // Get parameters
1026   return GetOperations()->IsSubShapeBelongsTo( aSubObject, theSubObjectIndex, anObject, theObjectIndex );
1027 }
1028
1029 //=============================================================================
1030 /*!
1031  *  NumberOfFaces
1032  */
1033 //=============================================================================
1034 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
1035 {
1036   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
1037 }
1038
1039 //=============================================================================
1040 /*!
1041  *  NumberOfEdges
1042  */
1043 //=============================================================================
1044 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
1045 {
1046   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
1047 }
1048
1049 //=============================================================================
1050 /*!
1051  *  NumberOfSubShapes
1052  */
1053 //=============================================================================
1054 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
1055                                                          const CORBA::Long     theShapeType)
1056 {
1057   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1058   if (aShape.IsNull()) return -1;
1059
1060   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
1061   if (!GetOperations()->IsDone()) return -1;
1062
1063   return aNb;
1064 }
1065
1066 //=============================================================================
1067 /*!
1068  *  ChangeOrientation
1069  */
1070 //=============================================================================
1071 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
1072                                                 (GEOM::GEOM_Object_ptr theShape)
1073 {
1074   GEOM::GEOM_Object_var aGEOMObject;
1075
1076   //Set a not done flag
1077   GetOperations()->SetNotDone();
1078
1079   //Get the reference objects
1080   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1081   if (aShape.IsNull()) return aGEOMObject._retn();
1082
1083   //Create the Solid
1084   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
1085   if (!GetOperations()->IsDone() || anObject.IsNull())
1086     return aGEOMObject._retn();
1087
1088   return GetObject(anObject);
1089 }
1090
1091 //=============================================================================
1092 /*!
1093  *  GetFreeFacesIDs
1094  */
1095 //=============================================================================
1096 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
1097 {
1098   //Set a not done flag
1099   GetOperations()->SetNotDone();
1100
1101   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1102
1103   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1104   if (aShape.IsNull()) return aSeq._retn();
1105
1106   Handle(TColStd_HSequenceOfInteger) aHSeq =
1107     GetOperations()->GetFreeFacesIDs(aShape);
1108   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1109
1110   Standard_Integer aLength = aHSeq->Length();
1111   aSeq->length(aLength);
1112   for (Standard_Integer i = 1; i <= aLength; i++)
1113     aSeq[i-1] = aHSeq->Value(i);
1114
1115   return aSeq._retn();
1116 }
1117
1118 //=============================================================================
1119 /*!
1120  *  GetSharedShapes
1121  */
1122 //=============================================================================
1123 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1124                                           (GEOM::GEOM_Object_ptr theShape1,
1125                                            GEOM::GEOM_Object_ptr theShape2,
1126                                            const CORBA::Long     theShapeType)
1127 {
1128   //Set a not done flag
1129   GetOperations()->SetNotDone();
1130
1131   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1132
1133   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1134   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1135
1136   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1137
1138   Handle(TColStd_HSequenceOfTransient) aHSeq =
1139     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1140   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1141     return aSeq._retn();
1142
1143   Standard_Integer aLength = aHSeq->Length();
1144   aSeq->length(aLength);
1145   for (Standard_Integer i = 1; i <= aLength; i++)
1146     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1147
1148   return aSeq._retn();
1149 }
1150
1151 //=============================================================================
1152 /*!
1153  *  GetSharedShapesMulti
1154  */
1155 //=============================================================================
1156 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1157                                           (const GEOM::ListOfGO& theShapes,
1158                                            const CORBA::Long     theShapeType,
1159                                            CORBA::Boolean        theMultiShare)
1160 {
1161   //Set a not done flag
1162   GetOperations()->SetNotDone();
1163
1164   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1165
1166   //Get the shapes
1167   std::list<Handle(GEOM_Object)> aShapes;
1168   if (! GetListOfObjectsImpl( theShapes, aShapes ))
1169     return aSeq._retn();
1170
1171   Handle(TColStd_HSequenceOfTransient) aHSeq =
1172     GetOperations()->GetSharedShapes(aShapes, theShapeType, theMultiShare);
1173   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1174     return aSeq._retn();
1175
1176   Standard_Integer aLength = aHSeq->Length();
1177   aSeq->length(aLength);
1178   for (Standard_Integer i = 1; i <= aLength; i++)
1179     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1180
1181   return aSeq._retn();
1182 }
1183
1184 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1185 {
1186   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1187
1188   switch (theState) {
1189   case GEOM::ST_ON:
1190     aState = GEOMAlgo_ST_ON;
1191     break;
1192   case GEOM::ST_OUT:
1193     aState = GEOMAlgo_ST_OUT;
1194     break;
1195   case GEOM::ST_ONOUT:
1196     aState = GEOMAlgo_ST_ONOUT;
1197     break;
1198   case GEOM::ST_IN:
1199     aState = GEOMAlgo_ST_IN;
1200     break;
1201   case GEOM::ST_ONIN:
1202     aState = GEOMAlgo_ST_ONIN;
1203     break;
1204   default:
1205     break;
1206   }
1207
1208   return aState;
1209 }
1210
1211 //=============================================================================
1212 /*!
1213  *  GetShapesOnPlane
1214  */
1215 //=============================================================================
1216 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1217                                                 (GEOM::GEOM_Object_ptr   theShape,
1218                                                  const CORBA::Long       theShapeType,
1219                                                  GEOM::GEOM_Object_ptr   theAx1,
1220                                                  const GEOM::shape_state theState)
1221 {
1222   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1223
1224   //Set a not done flag
1225   GetOperations()->SetNotDone();
1226
1227   //Get the reference objects
1228   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1229   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1230
1231   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1232
1233   //Get Shapes On Plane
1234   Handle(TColStd_HSequenceOfTransient) aHSeq =
1235     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1236   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1237     return aSeq._retn();
1238
1239   Standard_Integer aLength = aHSeq->Length();
1240   aSeq->length(aLength);
1241   for (Standard_Integer i = 1; i <= aLength; i++)
1242     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1243
1244   return aSeq._retn();
1245 }
1246
1247 //=============================================================================
1248 /*!
1249  *  GetShapesOnPlaneWithLocation
1250  */
1251 //=============================================================================
1252 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1253                                                 (GEOM::GEOM_Object_ptr   theShape,
1254                                                  const CORBA::Long       theShapeType,
1255                                                  GEOM::GEOM_Object_ptr   theAx1,
1256                                                  GEOM::GEOM_Object_ptr   thePnt,
1257                                                  const GEOM::shape_state theState)
1258 {
1259   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1260
1261   //Set a not done flag
1262   GetOperations()->SetNotDone();
1263
1264   //Get the reference objects
1265   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1266   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1267   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1268
1269   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1270
1271   //Get Shapes On Plane
1272   Handle(TColStd_HSequenceOfTransient) aHSeq =
1273     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1274   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1275     return aSeq._retn();
1276
1277   Standard_Integer aLength = aHSeq->Length();
1278   aSeq->length(aLength);
1279   for (Standard_Integer i = 1; i <= aLength; i++)
1280     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1281
1282   return aSeq._retn();
1283 }
1284
1285 //=============================================================================
1286 /*!
1287  *  GetShapesOnCylinder
1288  */
1289 //=============================================================================
1290 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1291                                                 (GEOM::GEOM_Object_ptr   theShape,
1292                                                  const CORBA::Long       theShapeType,
1293                                                  GEOM::GEOM_Object_ptr   theAxis,
1294                                                  const CORBA::Double     theRadius,
1295                                                  const GEOM::shape_state theState)
1296 {
1297   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1298
1299   //Set a not done flag
1300   GetOperations()->SetNotDone();
1301
1302   //Get the reference objects
1303   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1304   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1305
1306   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1307
1308   //Get Shapes On Cylinder
1309   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1310     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1311   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1312     return aSeq._retn();
1313
1314   Standard_Integer aLength = aHSeq->Length();
1315   aSeq->length(aLength);
1316   for (Standard_Integer i = 1; i <= aLength; i++)
1317     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1318
1319   return aSeq._retn();
1320 }
1321
1322 //=============================================================================
1323 /*!
1324  *  GetShapesOnCylinderWithLocation
1325  */
1326 //=============================================================================
1327 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1328                                                 (GEOM::GEOM_Object_ptr   theShape,
1329                                                  const CORBA::Long       theShapeType,
1330                                                  GEOM::GEOM_Object_ptr   theAxis,
1331                                                  GEOM::GEOM_Object_ptr   thePnt,
1332                                                  const CORBA::Double     theRadius,
1333                                                  const GEOM::shape_state theState)
1334 {
1335   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1336
1337   //Set a not done flag
1338   GetOperations()->SetNotDone();
1339
1340   //Get the reference objects
1341   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1342   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1343   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1344
1345   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1346
1347   //Get Shapes On Cylinder
1348   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1349     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1350   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1351     return aSeq._retn();
1352
1353   Standard_Integer aLength = aHSeq->Length();
1354   aSeq->length(aLength);
1355   for (Standard_Integer i = 1; i <= aLength; i++)
1356     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1357
1358   return aSeq._retn();
1359 }
1360
1361 //=============================================================================
1362 /*!
1363  *  GetShapesOnSphere
1364  */
1365 //=============================================================================
1366 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1367                                                 (GEOM::GEOM_Object_ptr   theShape,
1368                                                  const CORBA::Long       theShapeType,
1369                                                  GEOM::GEOM_Object_ptr   theCenter,
1370                                                  const CORBA::Double     theRadius,
1371                                                  const GEOM::shape_state theState)
1372 {
1373   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1374
1375   //Set a not done flag
1376   GetOperations()->SetNotDone();
1377
1378   //Get the reference objects
1379   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1380   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1381
1382   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1383
1384   //Get Shapes On Sphere
1385   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1386     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1387   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1388     return aSeq._retn();
1389
1390   Standard_Integer aLength = aHSeq->Length();
1391   aSeq->length(aLength);
1392   for (Standard_Integer i = 1; i <= aLength; i++)
1393     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1394
1395   return aSeq._retn();
1396 }
1397
1398 //=============================================================================
1399 /*!
1400  *  GetShapesOnQuadrangle
1401  */
1402 //=============================================================================
1403 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1404                                                 (GEOM::GEOM_Object_ptr theShape,
1405                                                  CORBA::Long           theShapeType,
1406                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1407                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1408                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1409                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1410                                                  GEOM::shape_state     theState)
1411 {
1412   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1413
1414   //Set a not done flag
1415   GetOperations()->SetNotDone();
1416
1417   //Get the reference objects
1418   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1419   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1420   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1421   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1422   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1423
1424   if (aShape.IsNull() ||
1425       aTopLeftPoint.IsNull() ||
1426       aTopRigthPoint.IsNull() ||
1427       aBottomLeftPoint.IsNull() ||
1428       aBottomRigthPoint.IsNull())
1429     return aSeq._retn();
1430
1431   //Get Shapes On Quadrangle
1432   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1433     (aShape, theShapeType,
1434      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1435      ShapeState(theState));
1436   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1437     return aSeq._retn();
1438
1439   Standard_Integer aLength = aHSeq->Length();
1440   aSeq->length(aLength);
1441   for (Standard_Integer i = 1; i <= aLength; i++)
1442     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1443
1444   return aSeq._retn();
1445 }
1446
1447 //=============================================================================
1448 /*!
1449  *  GetShapesOnPlaneIDs
1450  */
1451 //=============================================================================
1452 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1453                                                 (GEOM::GEOM_Object_ptr   theShape,
1454                                                  const CORBA::Long       theShapeType,
1455                                                  GEOM::GEOM_Object_ptr   theAx1,
1456                                                  const GEOM::shape_state theState)
1457 {
1458   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1459
1460   //Set a not done flag
1461   GetOperations()->SetNotDone();
1462
1463   //Get the reference objects
1464   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1465   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1466
1467   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1468
1469   //Get Shapes On Plane
1470   Handle(TColStd_HSequenceOfInteger) aHSeq =
1471     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1472   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1473     return aSeq._retn();
1474
1475   Standard_Integer aLength = aHSeq->Length();
1476   aSeq->length(aLength);
1477   for (Standard_Integer i = 1; i <= aLength; i++)
1478     aSeq[i-1] = aHSeq->Value(i);
1479
1480   return aSeq._retn();
1481 }
1482
1483 //=============================================================================
1484 /*!
1485  *  GetShapesOnPlaneWithLocationIDs
1486  */
1487 //=============================================================================
1488 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1489                                                 (GEOM::GEOM_Object_ptr   theShape,
1490                                                  const CORBA::Long       theShapeType,
1491                                                  GEOM::GEOM_Object_ptr   theAx1,
1492                                                  GEOM::GEOM_Object_ptr   thePnt,
1493                                                  const GEOM::shape_state theState)
1494 {
1495   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1496
1497   //Set a not done flag
1498   GetOperations()->SetNotDone();
1499
1500   //Get the reference objects
1501   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1502   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1503   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1504
1505   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1506
1507   //Get Shapes On Plane
1508   Handle(TColStd_HSequenceOfInteger) aHSeq =
1509     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1510                                                      anAx1, anPnt, ShapeState(theState));
1511   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1512     return aSeq._retn();
1513
1514   Standard_Integer aLength = aHSeq->Length();
1515   aSeq->length(aLength);
1516   for (Standard_Integer i = 1; i <= aLength; i++)
1517     aSeq[i-1] = aHSeq->Value(i);
1518
1519   return aSeq._retn();
1520 }
1521
1522 //=============================================================================
1523 /*!
1524  *  GetShapesOnCylinderIDs
1525  */
1526 //=============================================================================
1527 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1528                                                 (GEOM::GEOM_Object_ptr   theShape,
1529                                                  const CORBA::Long       theShapeType,
1530                                                  GEOM::GEOM_Object_ptr   theAxis,
1531                                                  const CORBA::Double     theRadius,
1532                                                  const GEOM::shape_state theState)
1533 {
1534   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1535
1536   //Set a not done flag
1537   GetOperations()->SetNotDone();
1538
1539   //Get the reference objects
1540   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1541   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1542
1543   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1544
1545   //Get Shapes On Cylinder
1546   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1547     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1548   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1549     return aSeq._retn();
1550
1551   Standard_Integer aLength = aHSeq->Length();
1552   aSeq->length(aLength);
1553   for (Standard_Integer i = 1; i <= aLength; i++)
1554     aSeq[i-1] = aHSeq->Value(i);
1555
1556   return aSeq._retn();
1557 }
1558
1559 //=============================================================================
1560 /*!
1561  *  GetShapesOnCylinderWithLocationIDs
1562  */
1563 //=============================================================================
1564 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1565                                                 (GEOM::GEOM_Object_ptr   theShape,
1566                                                  const CORBA::Long       theShapeType,
1567                                                  GEOM::GEOM_Object_ptr   theAxis,
1568                                                  GEOM::GEOM_Object_ptr   thePnt,
1569                                                  const CORBA::Double     theRadius,
1570                                                  const GEOM::shape_state theState)
1571 {
1572   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1573
1574   //Set a not done flag
1575   GetOperations()->SetNotDone();
1576
1577   //Get the reference objects
1578   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1579   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1580   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1581
1582   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1583
1584   //Get Shapes On Cylinder
1585   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1586     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1587   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1588     return aSeq._retn();
1589
1590   Standard_Integer aLength = aHSeq->Length();
1591   aSeq->length(aLength);
1592   for (Standard_Integer i = 1; i <= aLength; i++)
1593     aSeq[i-1] = aHSeq->Value(i);
1594
1595   return aSeq._retn();
1596 }
1597
1598 //=============================================================================
1599 /*!
1600  *  GetShapesOnSphereIDs
1601  */
1602 //=============================================================================
1603 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1604                                                 (GEOM::GEOM_Object_ptr   theShape,
1605                                                  const CORBA::Long       theShapeType,
1606                                                  GEOM::GEOM_Object_ptr   theCenter,
1607                                                  const CORBA::Double     theRadius,
1608                                                  const GEOM::shape_state theState)
1609 {
1610   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1611
1612   //Set a not done flag
1613   GetOperations()->SetNotDone();
1614
1615   //Get the reference objects
1616   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1617   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1618
1619   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1620
1621   //Get Shapes On Sphere
1622   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1623     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1624   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1625     return aSeq._retn();
1626
1627   Standard_Integer aLength = aHSeq->Length();
1628   aSeq->length(aLength);
1629   for (Standard_Integer i = 1; i <= aLength; i++)
1630     aSeq[i-1] = aHSeq->Value(i);
1631
1632   return aSeq._retn();
1633 }
1634
1635 //=============================================================================
1636 /*!
1637  *  GetShapesOnQuadrangleIDs
1638  */
1639 //=============================================================================
1640 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1641                                                 (GEOM::GEOM_Object_ptr theShape,
1642                                                  CORBA::Long           theShapeType,
1643                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1644                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1645                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1646                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1647                                                  GEOM::shape_state     theState)
1648 {
1649   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1650
1651   //Set a not done flag
1652   GetOperations()->SetNotDone();
1653
1654   //Get the reference objects
1655   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1656   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1657   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1658   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1659   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1660
1661   if (aShape.IsNull() ||
1662       aTopLeftPoint.IsNull() ||
1663       aTopRigthPoint.IsNull() ||
1664       aBottomLeftPoint.IsNull() ||
1665       aBottomRigthPoint.IsNull() )
1666     return aSeq._retn();
1667
1668   //Get Shapes On Quadrangle
1669   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1670     (aShape, theShapeType,
1671      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1672      ShapeState(theState));
1673   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1674     return aSeq._retn();
1675
1676   Standard_Integer aLength = aHSeq->Length();
1677   aSeq->length(aLength);
1678   for (Standard_Integer i = 1; i <= aLength; i++)
1679     aSeq[i-1] = aHSeq->Value(i);
1680
1681   return aSeq._retn();
1682 }
1683
1684 //=============================================================================
1685 /*!
1686  *  GetShapesOnBox
1687  */
1688 //=============================================================================
1689 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1690                                                 (GEOM::GEOM_Object_ptr theBox,
1691                                                  GEOM::GEOM_Object_ptr theShape,
1692                                                  CORBA::Long           theShapeType,
1693                                                  GEOM::shape_state     theState)
1694 {
1695   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1696
1697   //Set a not done flag
1698   GetOperations()->SetNotDone();
1699
1700   //Get the reference objects
1701   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1702   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1703
1704   if (aShape.IsNull() || aBox.IsNull() )
1705     return aSeq._retn();
1706
1707   //Get Shapes On Box
1708   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1709     (aBox,aShape, theShapeType,ShapeState(theState));
1710   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1711     return aSeq._retn();
1712
1713   Standard_Integer aLength = aHSeq->Length();
1714   aSeq->length(aLength);
1715   for (Standard_Integer i = 1; i <= aLength; i++)
1716     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1717
1718   return aSeq._retn();
1719 }
1720
1721 //=============================================================================
1722 /*!
1723  *  GetShapesOnQuadrangleIDs
1724  */
1725 //=============================================================================
1726 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1727                                                 (GEOM::GEOM_Object_ptr theBox,
1728                                                  GEOM::GEOM_Object_ptr theShape,
1729                                                  CORBA::Long           theShapeType,
1730                                                  GEOM::shape_state     theState)
1731 {
1732   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1733
1734   //Set a not done flag
1735   GetOperations()->SetNotDone();
1736
1737   //Get the reference objects
1738   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1739   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1740
1741   if (aShape.IsNull() || aBox.IsNull() )
1742     return aSeq._retn();
1743
1744   //Get Shapes On Box
1745   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1746     (aBox,aShape, theShapeType,ShapeState(theState));
1747   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1748     return aSeq._retn();
1749
1750   Standard_Integer aLength = aHSeq->Length();
1751   aSeq->length(aLength);
1752   for (Standard_Integer i = 1; i <= aLength; i++)
1753     aSeq[i-1] = aHSeq->Value(i);
1754
1755   return aSeq._retn();
1756 }
1757
1758
1759 //=============================================================================
1760 /*!
1761  *  GetShapesOnShape
1762  */
1763 //=============================================================================
1764 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1765                                            (GEOM::GEOM_Object_ptr theCheckShape,
1766                                             GEOM::GEOM_Object_ptr theShape,
1767                                             CORBA::Short          theShapeType,
1768                                             GEOM::shape_state     theState)
1769 {
1770   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1771
1772   //Set a not done flag
1773   GetOperations()->SetNotDone();
1774
1775   //Get the reference objects
1776   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1777   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1778
1779   if (aShape.IsNull() || aCheckShape.IsNull() )
1780     return aSeq._retn();
1781
1782   //Get Shapes On Shape
1783   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1784     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1785
1786   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1787     return aSeq._retn();
1788
1789   Standard_Integer aLength = aHSeq->Length();
1790   aSeq->length(aLength);
1791   for (Standard_Integer i = 1; i <= aLength; i++)
1792     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1793
1794   return aSeq._retn();
1795 }
1796
1797
1798 //=============================================================================
1799 /*!
1800  *  GetShapesOnShapeAsCompound
1801  */
1802 //=============================================================================
1803 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1804                                            (GEOM::GEOM_Object_ptr theCheckShape,
1805                                             GEOM::GEOM_Object_ptr theShape,
1806                                             CORBA::Short          theShapeType,
1807                                             GEOM::shape_state     theState)
1808 {
1809   GEOM::GEOM_Object_var aGEOMObject;
1810
1811   //Set a not done flag
1812   GetOperations()->SetNotDone();
1813
1814   //Get the reference objects
1815   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1816   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1817
1818   if (aShape.IsNull() || aCheckShape.IsNull() )
1819     return aGEOMObject._retn();
1820
1821   //Get Shapes On Shape
1822   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1823     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1824
1825   if (anObject.IsNull())
1826     return aGEOMObject._retn();
1827
1828   return GetObject(anObject);
1829 }
1830
1831
1832 //=============================================================================
1833 /*!
1834  *  GetShapesOnShapeIDs
1835  */
1836 //=============================================================================
1837 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1838                                            (GEOM::GEOM_Object_ptr theCheckShape,
1839                                             GEOM::GEOM_Object_ptr theShape,
1840                                             CORBA::Short          theShapeType,
1841                                             GEOM::shape_state     theState)
1842 {
1843   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1844
1845   //Set a not done flag
1846   GetOperations()->SetNotDone();
1847
1848   //Get the reference objects
1849   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1850   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1851
1852   if (aShape.IsNull() || aCheckShape.IsNull() )
1853     return aSeq._retn();
1854
1855   //Get Shapes On Shape
1856   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1857     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1858   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1859     return aSeq._retn();
1860
1861   Standard_Integer aLength = aHSeq->Length();
1862   aSeq->length(aLength);
1863   for (Standard_Integer i = 1; i <= aLength; i++)
1864     aSeq[i-1] = aHSeq->Value(i);
1865
1866   return aSeq._retn();
1867 }
1868
1869
1870 //=============================================================================
1871 /*!
1872  *  GetInPlace
1873  */
1874 //=============================================================================
1875 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1876                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1877                                            GEOM::GEOM_Object_ptr theShapeWhat)
1878 {
1879   GEOM::GEOM_Object_var aGEOMObject;
1880
1881   //Set a not done flag
1882   GetOperations()->SetNotDone();
1883
1884   //Get the reference objects
1885   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1886   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1887
1888   if (aShapeWhere.IsNull() ||
1889       aShapeWhat.IsNull()) return aGEOMObject._retn();
1890
1891   //Get Shapes in place of aShapeWhat
1892   Handle(GEOM_Object) anObject =
1893     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1894   if (!GetOperations()->IsDone() || anObject.IsNull())
1895     return aGEOMObject._retn();
1896
1897   return GetObject(anObject);
1898 }
1899
1900 //=============================================================================
1901 /*!
1902  *  GetInPlaceOld
1903  */
1904 //=============================================================================
1905 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1906                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1907                                            GEOM::GEOM_Object_ptr theShapeWhat)
1908 {
1909   GEOM::GEOM_Object_var aGEOMObject;
1910
1911   //Set a not done flag
1912   GetOperations()->SetNotDone();
1913
1914   //Get the reference objects
1915   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1916   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1917
1918   if (aShapeWhere.IsNull() ||
1919       aShapeWhat.IsNull()) return aGEOMObject._retn();
1920
1921   //Get Shapes in place of aShapeWhat
1922   Handle(GEOM_Object) anObject =
1923     GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1924   if (!GetOperations()->IsDone() || anObject.IsNull())
1925     return aGEOMObject._retn();
1926
1927   return GetObject(anObject);
1928 }
1929
1930 //=============================================================================
1931 /*!
1932  *  GetInPlaceByHistory
1933  */
1934 //=============================================================================
1935 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1936                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1937                                            GEOM::GEOM_Object_ptr theShapeWhat)
1938 {
1939   GEOM::GEOM_Object_var aGEOMObject;
1940
1941   //Set a not done flag
1942   GetOperations()->SetNotDone();
1943
1944   //Get the reference objects
1945   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1946   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1947
1948   if (aShapeWhere.IsNull() ||
1949       aShapeWhat.IsNull()) return aGEOMObject._retn();
1950
1951   //Get Shapes in place of aShapeWhat
1952   Handle(GEOM_Object) anObject =
1953     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1954   if (!GetOperations()->IsDone() || anObject.IsNull())
1955     return aGEOMObject._retn();
1956
1957   return GetObject(anObject);
1958 }
1959
1960 //=============================================================================
1961 /*!
1962  *  GetSame
1963  */
1964 //=============================================================================
1965 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1966                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1967                                            GEOM::GEOM_Object_ptr theShapeWhat)
1968 {
1969   GEOM::GEOM_Object_var aGEOMObject;
1970
1971   //Set a not done flag
1972   GetOperations()->SetNotDone();
1973
1974   //Get the reference objects
1975   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1976   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1977
1978   if (aShapeWhere.IsNull() ||
1979       aShapeWhat.IsNull()) return aGEOMObject._retn();
1980
1981   //Get Shapes in place of aShapeWhat
1982   Handle(GEOM_Object) anObject =
1983     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1984   if (!GetOperations()->IsDone() || anObject.IsNull())
1985     return aGEOMObject._retn();
1986
1987   return GetObject(anObject);
1988 }
1989
1990 //=============================================================================
1991 /*!
1992  *  GetSameIDs
1993  */
1994 //=============================================================================
1995 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1996                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1997                                            GEOM::GEOM_Object_ptr theShapeWhat) {
1998   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1999
2000   //Get the reference objects
2001   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2002   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2003
2004   if (aShapeWhere.IsNull() ||
2005       aShapeWhat.IsNull()) return aSeq._retn();
2006
2007
2008   Handle(TColStd_HSequenceOfInteger) aHSeq =
2009     GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
2010
2011   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
2012
2013   Standard_Integer aLength = aHSeq->Length();
2014   aSeq->length(aLength);
2015   for (Standard_Integer i = 1; i <= aLength; i++)
2016     aSeq[i-1] = aHSeq->Value(i);
2017
2018   return aSeq._retn();
2019 }
2020
2021 //=============================================================================
2022 /*!
2023  *  ExtendEdge
2024  */
2025 //=============================================================================
2026 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendEdge
2027                                   (GEOM::GEOM_Object_ptr theEdge,
2028                                    CORBA::Double         theMin,
2029                                    CORBA::Double         theMax)
2030 {
2031   GEOM::GEOM_Object_var aGEOMObject;
2032
2033   //Set a not done flag
2034   GetOperations()->SetNotDone();
2035
2036   //Get the reference objects
2037   Handle(GEOM_Object) anEdge = GetObjectImpl(theEdge);
2038
2039   if (anEdge.IsNull()) {
2040     return aGEOMObject._retn();
2041   }
2042
2043   //Get Shapes in place of aShapeWhat
2044   Handle(GEOM_Object) aNewEdge =
2045     GetOperations()->ExtendEdge(anEdge, theMin, theMax);
2046
2047   if (!GetOperations()->IsDone() || aNewEdge.IsNull()) {
2048     return aGEOMObject._retn();
2049   }
2050
2051   return GetObject(aNewEdge);
2052 }
2053
2054 //=============================================================================
2055 /*!
2056  *  ExtendFace
2057  */
2058 //=============================================================================
2059 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
2060                                   (GEOM::GEOM_Object_ptr theFace,
2061                                    CORBA::Double         theUMin,
2062                                    CORBA::Double         theUMax,
2063                                    CORBA::Double         theVMin,
2064                                    CORBA::Double         theVMax)
2065 {
2066   GEOM::GEOM_Object_var aGEOMObject;
2067
2068   //Set a not done flag
2069   GetOperations()->SetNotDone();
2070
2071   //Get the reference objects
2072   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
2073
2074   if (aFace.IsNull()) {
2075     return aGEOMObject._retn();
2076   }
2077
2078   //Get Shapes in place of aShapeWhat
2079   Handle(GEOM_Object) aNewFace =
2080     GetOperations()->ExtendFace(aFace, theUMin, theUMax, theVMin, theVMax);
2081
2082   if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2083     return aGEOMObject._retn();
2084   }
2085
2086   return GetObject(aNewFace);
2087 }
2088
2089 //=============================================================================
2090 /*!
2091  *  MakeSurfaceFromFace
2092  */
2093 //=============================================================================
2094 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
2095                                   (GEOM::GEOM_Object_ptr theFace)
2096 {
2097   GEOM::GEOM_Object_var aGEOMObject;
2098
2099   //Set a not done flag
2100   GetOperations()->SetNotDone();
2101
2102   //Get the reference object
2103   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
2104
2105   if (aFace.IsNull()) {
2106     return aGEOMObject._retn();
2107   }
2108
2109   //Get Shapes in place of aShapeWhat
2110   Handle(GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
2111
2112   if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2113     return aGEOMObject._retn();
2114   }
2115
2116   return GetObject(aNewFace);
2117 }
2118
2119 //=============================================================================
2120 /*!
2121  *  GetSubShapeEdgeSorted
2122  */
2123 //=============================================================================
2124 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapeEdgeSorted
2125                                         (GEOM::GEOM_Object_ptr theShape,
2126                                          GEOM::GEOM_Object_ptr theStartPoint)
2127 {
2128   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
2129
2130   //Set a not done flag
2131   GetOperations()->SetNotDone();
2132
2133   //Get the reference objects
2134   Handle(GEOM_Object) aShape      = GetObjectImpl(theShape);
2135   Handle(GEOM_Object) aStartPoint = GetObjectImpl(theStartPoint);
2136
2137   if (aShape.IsNull() || aStartPoint.IsNull()) {
2138     return aSeq._retn();
2139   }
2140
2141   //Get Shapes On Shape
2142   Handle(TColStd_HSequenceOfTransient) aHSeq =
2143       GetOperations()->GetSubShapeEdgeSorted(aShape, aStartPoint);
2144
2145   if (!GetOperations()->IsDone() || aHSeq.IsNull())
2146     return aSeq._retn();
2147
2148   const Standard_Integer aLength = aHSeq->Length();
2149   Standard_Integer       i;
2150
2151   aSeq->length(aLength);
2152
2153   for (i = 1; i <= aLength; i++) {
2154     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
2155   }
2156
2157   return aSeq._retn();
2158 }