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