Salome HOME
0022759: [EDF] Creation of a surface from several edges
[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  *  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 {
1160   //Set a not done flag
1161   GetOperations()->SetNotDone();
1162
1163   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1164
1165   //Get the shapes
1166   std::list<Handle(GEOM_Object)> aShapes;
1167   if (! GetListOfObjectsImpl( theShapes, aShapes ))
1168     return aSeq._retn();
1169
1170   Handle(TColStd_HSequenceOfTransient) aHSeq =
1171     GetOperations()->GetSharedShapes(aShapes, theShapeType);
1172   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1173     return aSeq._retn();
1174
1175   Standard_Integer aLength = aHSeq->Length();
1176   aSeq->length(aLength);
1177   for (Standard_Integer i = 1; i <= aLength; i++)
1178     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1179
1180   return aSeq._retn();
1181 }
1182
1183 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1184 {
1185   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1186
1187   switch (theState) {
1188   case GEOM::ST_ON:
1189     aState = GEOMAlgo_ST_ON;
1190     break;
1191   case GEOM::ST_OUT:
1192     aState = GEOMAlgo_ST_OUT;
1193     break;
1194   case GEOM::ST_ONOUT:
1195     aState = GEOMAlgo_ST_ONOUT;
1196     break;
1197   case GEOM::ST_IN:
1198     aState = GEOMAlgo_ST_IN;
1199     break;
1200   case GEOM::ST_ONIN:
1201     aState = GEOMAlgo_ST_ONIN;
1202     break;
1203   default:
1204     break;
1205   }
1206
1207   return aState;
1208 }
1209
1210 //=============================================================================
1211 /*!
1212  *  GetShapesOnPlane
1213  */
1214 //=============================================================================
1215 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1216                                                 (GEOM::GEOM_Object_ptr   theShape,
1217                                                  const CORBA::Long       theShapeType,
1218                                                  GEOM::GEOM_Object_ptr   theAx1,
1219                                                  const GEOM::shape_state theState)
1220 {
1221   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1222
1223   //Set a not done flag
1224   GetOperations()->SetNotDone();
1225
1226   //Get the reference objects
1227   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1228   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1229
1230   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1231
1232   //Get Shapes On Plane
1233   Handle(TColStd_HSequenceOfTransient) aHSeq =
1234     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1235   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1236     return aSeq._retn();
1237
1238   Standard_Integer aLength = aHSeq->Length();
1239   aSeq->length(aLength);
1240   for (Standard_Integer i = 1; i <= aLength; i++)
1241     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1242
1243   return aSeq._retn();
1244 }
1245
1246 //=============================================================================
1247 /*!
1248  *  GetShapesOnPlaneWithLocation
1249  */
1250 //=============================================================================
1251 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1252                                                 (GEOM::GEOM_Object_ptr   theShape,
1253                                                  const CORBA::Long       theShapeType,
1254                                                  GEOM::GEOM_Object_ptr   theAx1,
1255                                                  GEOM::GEOM_Object_ptr   thePnt,
1256                                                  const GEOM::shape_state theState)
1257 {
1258   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1259
1260   //Set a not done flag
1261   GetOperations()->SetNotDone();
1262
1263   //Get the reference objects
1264   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1265   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1266   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1267
1268   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1269
1270   //Get Shapes On Plane
1271   Handle(TColStd_HSequenceOfTransient) aHSeq =
1272     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1273   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1274     return aSeq._retn();
1275
1276   Standard_Integer aLength = aHSeq->Length();
1277   aSeq->length(aLength);
1278   for (Standard_Integer i = 1; i <= aLength; i++)
1279     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1280
1281   return aSeq._retn();
1282 }
1283
1284 //=============================================================================
1285 /*!
1286  *  GetShapesOnCylinder
1287  */
1288 //=============================================================================
1289 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1290                                                 (GEOM::GEOM_Object_ptr   theShape,
1291                                                  const CORBA::Long       theShapeType,
1292                                                  GEOM::GEOM_Object_ptr   theAxis,
1293                                                  const CORBA::Double     theRadius,
1294                                                  const GEOM::shape_state theState)
1295 {
1296   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1297
1298   //Set a not done flag
1299   GetOperations()->SetNotDone();
1300
1301   //Get the reference objects
1302   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1303   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1304
1305   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1306
1307   //Get Shapes On Cylinder
1308   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1309     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1310   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1311     return aSeq._retn();
1312
1313   Standard_Integer aLength = aHSeq->Length();
1314   aSeq->length(aLength);
1315   for (Standard_Integer i = 1; i <= aLength; i++)
1316     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1317
1318   return aSeq._retn();
1319 }
1320
1321 //=============================================================================
1322 /*!
1323  *  GetShapesOnCylinderWithLocation
1324  */
1325 //=============================================================================
1326 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1327                                                 (GEOM::GEOM_Object_ptr   theShape,
1328                                                  const CORBA::Long       theShapeType,
1329                                                  GEOM::GEOM_Object_ptr   theAxis,
1330                                                  GEOM::GEOM_Object_ptr   thePnt,
1331                                                  const CORBA::Double     theRadius,
1332                                                  const GEOM::shape_state theState)
1333 {
1334   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1335
1336   //Set a not done flag
1337   GetOperations()->SetNotDone();
1338
1339   //Get the reference objects
1340   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1341   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1342   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1343
1344   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1345
1346   //Get Shapes On Cylinder
1347   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1348     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1349   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1350     return aSeq._retn();
1351
1352   Standard_Integer aLength = aHSeq->Length();
1353   aSeq->length(aLength);
1354   for (Standard_Integer i = 1; i <= aLength; i++)
1355     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1356
1357   return aSeq._retn();
1358 }
1359
1360 //=============================================================================
1361 /*!
1362  *  GetShapesOnSphere
1363  */
1364 //=============================================================================
1365 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1366                                                 (GEOM::GEOM_Object_ptr   theShape,
1367                                                  const CORBA::Long       theShapeType,
1368                                                  GEOM::GEOM_Object_ptr   theCenter,
1369                                                  const CORBA::Double     theRadius,
1370                                                  const GEOM::shape_state theState)
1371 {
1372   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1373
1374   //Set a not done flag
1375   GetOperations()->SetNotDone();
1376
1377   //Get the reference objects
1378   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1379   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1380
1381   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1382
1383   //Get Shapes On Sphere
1384   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1385     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1386   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1387     return aSeq._retn();
1388
1389   Standard_Integer aLength = aHSeq->Length();
1390   aSeq->length(aLength);
1391   for (Standard_Integer i = 1; i <= aLength; i++)
1392     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1393
1394   return aSeq._retn();
1395 }
1396
1397 //=============================================================================
1398 /*!
1399  *  GetShapesOnQuadrangle
1400  */
1401 //=============================================================================
1402 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1403                                                 (GEOM::GEOM_Object_ptr theShape,
1404                                                  CORBA::Long           theShapeType,
1405                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1406                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1407                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1408                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1409                                                  GEOM::shape_state     theState)
1410 {
1411   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1412
1413   //Set a not done flag
1414   GetOperations()->SetNotDone();
1415
1416   //Get the reference objects
1417   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1418   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1419   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1420   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1421   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1422
1423   if (aShape.IsNull() ||
1424       aTopLeftPoint.IsNull() ||
1425       aTopRigthPoint.IsNull() ||
1426       aBottomLeftPoint.IsNull() ||
1427       aBottomRigthPoint.IsNull())
1428     return aSeq._retn();
1429
1430   //Get Shapes On Quadrangle
1431   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1432     (aShape, theShapeType,
1433      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1434      ShapeState(theState));
1435   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1436     return aSeq._retn();
1437
1438   Standard_Integer aLength = aHSeq->Length();
1439   aSeq->length(aLength);
1440   for (Standard_Integer i = 1; i <= aLength; i++)
1441     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1442
1443   return aSeq._retn();
1444 }
1445
1446 //=============================================================================
1447 /*!
1448  *  GetShapesOnPlaneIDs
1449  */
1450 //=============================================================================
1451 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1452                                                 (GEOM::GEOM_Object_ptr   theShape,
1453                                                  const CORBA::Long       theShapeType,
1454                                                  GEOM::GEOM_Object_ptr   theAx1,
1455                                                  const GEOM::shape_state theState)
1456 {
1457   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1458
1459   //Set a not done flag
1460   GetOperations()->SetNotDone();
1461
1462   //Get the reference objects
1463   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1464   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1465
1466   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1467
1468   //Get Shapes On Plane
1469   Handle(TColStd_HSequenceOfInteger) aHSeq =
1470     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1471   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1472     return aSeq._retn();
1473
1474   Standard_Integer aLength = aHSeq->Length();
1475   aSeq->length(aLength);
1476   for (Standard_Integer i = 1; i <= aLength; i++)
1477     aSeq[i-1] = aHSeq->Value(i);
1478
1479   return aSeq._retn();
1480 }
1481
1482 //=============================================================================
1483 /*!
1484  *  GetShapesOnPlaneWithLocationIDs
1485  */
1486 //=============================================================================
1487 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1488                                                 (GEOM::GEOM_Object_ptr   theShape,
1489                                                  const CORBA::Long       theShapeType,
1490                                                  GEOM::GEOM_Object_ptr   theAx1,
1491                                                  GEOM::GEOM_Object_ptr   thePnt,
1492                                                  const GEOM::shape_state theState)
1493 {
1494   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1495
1496   //Set a not done flag
1497   GetOperations()->SetNotDone();
1498
1499   //Get the reference objects
1500   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1501   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1502   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1503
1504   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1505
1506   //Get Shapes On Plane
1507   Handle(TColStd_HSequenceOfInteger) aHSeq =
1508     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1509                                                      anAx1, anPnt, ShapeState(theState));
1510   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1511     return aSeq._retn();
1512
1513   Standard_Integer aLength = aHSeq->Length();
1514   aSeq->length(aLength);
1515   for (Standard_Integer i = 1; i <= aLength; i++)
1516     aSeq[i-1] = aHSeq->Value(i);
1517
1518   return aSeq._retn();
1519 }
1520
1521 //=============================================================================
1522 /*!
1523  *  GetShapesOnCylinderIDs
1524  */
1525 //=============================================================================
1526 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1527                                                 (GEOM::GEOM_Object_ptr   theShape,
1528                                                  const CORBA::Long       theShapeType,
1529                                                  GEOM::GEOM_Object_ptr   theAxis,
1530                                                  const CORBA::Double     theRadius,
1531                                                  const GEOM::shape_state theState)
1532 {
1533   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1534
1535   //Set a not done flag
1536   GetOperations()->SetNotDone();
1537
1538   //Get the reference objects
1539   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1540   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1541
1542   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1543
1544   //Get Shapes On Cylinder
1545   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1546     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1547   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1548     return aSeq._retn();
1549
1550   Standard_Integer aLength = aHSeq->Length();
1551   aSeq->length(aLength);
1552   for (Standard_Integer i = 1; i <= aLength; i++)
1553     aSeq[i-1] = aHSeq->Value(i);
1554
1555   return aSeq._retn();
1556 }
1557
1558 //=============================================================================
1559 /*!
1560  *  GetShapesOnCylinderWithLocationIDs
1561  */
1562 //=============================================================================
1563 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1564                                                 (GEOM::GEOM_Object_ptr   theShape,
1565                                                  const CORBA::Long       theShapeType,
1566                                                  GEOM::GEOM_Object_ptr   theAxis,
1567                                                  GEOM::GEOM_Object_ptr   thePnt,
1568                                                  const CORBA::Double     theRadius,
1569                                                  const GEOM::shape_state theState)
1570 {
1571   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1572
1573   //Set a not done flag
1574   GetOperations()->SetNotDone();
1575
1576   //Get the reference objects
1577   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1578   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1579   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1580
1581   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1582
1583   //Get Shapes On Cylinder
1584   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1585     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1586   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1587     return aSeq._retn();
1588
1589   Standard_Integer aLength = aHSeq->Length();
1590   aSeq->length(aLength);
1591   for (Standard_Integer i = 1; i <= aLength; i++)
1592     aSeq[i-1] = aHSeq->Value(i);
1593
1594   return aSeq._retn();
1595 }
1596
1597 //=============================================================================
1598 /*!
1599  *  GetShapesOnSphereIDs
1600  */
1601 //=============================================================================
1602 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1603                                                 (GEOM::GEOM_Object_ptr   theShape,
1604                                                  const CORBA::Long       theShapeType,
1605                                                  GEOM::GEOM_Object_ptr   theCenter,
1606                                                  const CORBA::Double     theRadius,
1607                                                  const GEOM::shape_state theState)
1608 {
1609   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1610
1611   //Set a not done flag
1612   GetOperations()->SetNotDone();
1613
1614   //Get the reference objects
1615   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1616   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1617
1618   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1619
1620   //Get Shapes On Sphere
1621   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1622     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1623   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1624     return aSeq._retn();
1625
1626   Standard_Integer aLength = aHSeq->Length();
1627   aSeq->length(aLength);
1628   for (Standard_Integer i = 1; i <= aLength; i++)
1629     aSeq[i-1] = aHSeq->Value(i);
1630
1631   return aSeq._retn();
1632 }
1633
1634 //=============================================================================
1635 /*!
1636  *  GetShapesOnQuadrangleIDs
1637  */
1638 //=============================================================================
1639 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1640                                                 (GEOM::GEOM_Object_ptr theShape,
1641                                                  CORBA::Long           theShapeType,
1642                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1643                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1644                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1645                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1646                                                  GEOM::shape_state     theState)
1647 {
1648   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1649
1650   //Set a not done flag
1651   GetOperations()->SetNotDone();
1652
1653   //Get the reference objects
1654   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1655   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1656   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1657   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1658   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1659
1660   if (aShape.IsNull() ||
1661       aTopLeftPoint.IsNull() ||
1662       aTopRigthPoint.IsNull() ||
1663       aBottomLeftPoint.IsNull() ||
1664       aBottomRigthPoint.IsNull() )
1665     return aSeq._retn();
1666
1667   //Get Shapes On Quadrangle
1668   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1669     (aShape, theShapeType,
1670      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1671      ShapeState(theState));
1672   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1673     return aSeq._retn();
1674
1675   Standard_Integer aLength = aHSeq->Length();
1676   aSeq->length(aLength);
1677   for (Standard_Integer i = 1; i <= aLength; i++)
1678     aSeq[i-1] = aHSeq->Value(i);
1679
1680   return aSeq._retn();
1681 }
1682
1683 //=============================================================================
1684 /*!
1685  *  GetShapesOnBox
1686  */
1687 //=============================================================================
1688 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1689                                                 (GEOM::GEOM_Object_ptr theBox,
1690                                                  GEOM::GEOM_Object_ptr theShape,
1691                                                  CORBA::Long           theShapeType,
1692                                                  GEOM::shape_state     theState)
1693 {
1694   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1695
1696   //Set a not done flag
1697   GetOperations()->SetNotDone();
1698
1699   //Get the reference objects
1700   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1701   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1702
1703   if (aShape.IsNull() || aBox.IsNull() )
1704     return aSeq._retn();
1705
1706   //Get Shapes On Box
1707   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1708     (aBox,aShape, theShapeType,ShapeState(theState));
1709   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1710     return aSeq._retn();
1711
1712   Standard_Integer aLength = aHSeq->Length();
1713   aSeq->length(aLength);
1714   for (Standard_Integer i = 1; i <= aLength; i++)
1715     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1716
1717   return aSeq._retn();
1718 }
1719
1720 //=============================================================================
1721 /*!
1722  *  GetShapesOnQuadrangleIDs
1723  */
1724 //=============================================================================
1725 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1726                                                 (GEOM::GEOM_Object_ptr theBox,
1727                                                  GEOM::GEOM_Object_ptr theShape,
1728                                                  CORBA::Long           theShapeType,
1729                                                  GEOM::shape_state     theState)
1730 {
1731   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1732
1733   //Set a not done flag
1734   GetOperations()->SetNotDone();
1735
1736   //Get the reference objects
1737   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1738   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1739
1740   if (aShape.IsNull() || aBox.IsNull() )
1741     return aSeq._retn();
1742
1743   //Get Shapes On Box
1744   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1745     (aBox,aShape, theShapeType,ShapeState(theState));
1746   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1747     return aSeq._retn();
1748
1749   Standard_Integer aLength = aHSeq->Length();
1750   aSeq->length(aLength);
1751   for (Standard_Integer i = 1; i <= aLength; i++)
1752     aSeq[i-1] = aHSeq->Value(i);
1753
1754   return aSeq._retn();
1755 }
1756
1757
1758 //=============================================================================
1759 /*!
1760  *  GetShapesOnShape
1761  */
1762 //=============================================================================
1763 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1764                                            (GEOM::GEOM_Object_ptr theCheckShape,
1765                                             GEOM::GEOM_Object_ptr theShape,
1766                                             CORBA::Short          theShapeType,
1767                                             GEOM::shape_state     theState)
1768 {
1769   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1770
1771   //Set a not done flag
1772   GetOperations()->SetNotDone();
1773
1774   //Get the reference objects
1775   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1776   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1777
1778   if (aShape.IsNull() || aCheckShape.IsNull() )
1779     return aSeq._retn();
1780
1781   //Get Shapes On Shape
1782   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1783     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1784
1785   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1786     return aSeq._retn();
1787
1788   Standard_Integer aLength = aHSeq->Length();
1789   aSeq->length(aLength);
1790   for (Standard_Integer i = 1; i <= aLength; i++)
1791     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1792
1793   return aSeq._retn();
1794 }
1795
1796
1797 //=============================================================================
1798 /*!
1799  *  GetShapesOnShapeAsCompound
1800  */
1801 //=============================================================================
1802 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1803                                            (GEOM::GEOM_Object_ptr theCheckShape,
1804                                             GEOM::GEOM_Object_ptr theShape,
1805                                             CORBA::Short          theShapeType,
1806                                             GEOM::shape_state     theState)
1807 {
1808   GEOM::GEOM_Object_var aGEOMObject;
1809
1810   //Set a not done flag
1811   GetOperations()->SetNotDone();
1812
1813   //Get the reference objects
1814   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1815   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1816
1817   if (aShape.IsNull() || aCheckShape.IsNull() )
1818     return aGEOMObject._retn();
1819
1820   //Get Shapes On Shape
1821   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1822     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1823
1824   if (anObject.IsNull())
1825     return aGEOMObject._retn();
1826
1827   return GetObject(anObject);
1828 }
1829
1830
1831 //=============================================================================
1832 /*!
1833  *  GetShapesOnShapeIDs
1834  */
1835 //=============================================================================
1836 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1837                                            (GEOM::GEOM_Object_ptr theCheckShape,
1838                                             GEOM::GEOM_Object_ptr theShape,
1839                                             CORBA::Short          theShapeType,
1840                                             GEOM::shape_state     theState)
1841 {
1842   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1843
1844   //Set a not done flag
1845   GetOperations()->SetNotDone();
1846
1847   //Get the reference objects
1848   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1849   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1850
1851   if (aShape.IsNull() || aCheckShape.IsNull() )
1852     return aSeq._retn();
1853
1854   //Get Shapes On Shape
1855   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1856     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1857   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1858     return aSeq._retn();
1859
1860   Standard_Integer aLength = aHSeq->Length();
1861   aSeq->length(aLength);
1862   for (Standard_Integer i = 1; i <= aLength; i++)
1863     aSeq[i-1] = aHSeq->Value(i);
1864
1865   return aSeq._retn();
1866 }
1867
1868
1869 //=============================================================================
1870 /*!
1871  *  GetInPlace
1872  */
1873 //=============================================================================
1874 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1875                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1876                                            GEOM::GEOM_Object_ptr theShapeWhat)
1877 {
1878   GEOM::GEOM_Object_var aGEOMObject;
1879
1880   //Set a not done flag
1881   GetOperations()->SetNotDone();
1882
1883   //Get the reference objects
1884   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1885   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1886
1887   if (aShapeWhere.IsNull() ||
1888       aShapeWhat.IsNull()) return aGEOMObject._retn();
1889
1890   //Get Shapes in place of aShapeWhat
1891   Handle(GEOM_Object) anObject =
1892     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1893   if (!GetOperations()->IsDone() || anObject.IsNull())
1894     return aGEOMObject._retn();
1895
1896   return GetObject(anObject);
1897 }
1898
1899 //=============================================================================
1900 /*!
1901  *  GetInPlaceOld
1902  */
1903 //=============================================================================
1904 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1905                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1906                                            GEOM::GEOM_Object_ptr theShapeWhat)
1907 {
1908   GEOM::GEOM_Object_var aGEOMObject;
1909
1910   //Set a not done flag
1911   GetOperations()->SetNotDone();
1912
1913   //Get the reference objects
1914   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1915   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1916
1917   if (aShapeWhere.IsNull() ||
1918       aShapeWhat.IsNull()) return aGEOMObject._retn();
1919
1920   //Get Shapes in place of aShapeWhat
1921   Handle(GEOM_Object) anObject =
1922     GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1923   if (!GetOperations()->IsDone() || anObject.IsNull())
1924     return aGEOMObject._retn();
1925
1926   return GetObject(anObject);
1927 }
1928
1929 //=============================================================================
1930 /*!
1931  *  GetInPlaceByHistory
1932  */
1933 //=============================================================================
1934 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1935                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1936                                            GEOM::GEOM_Object_ptr theShapeWhat)
1937 {
1938   GEOM::GEOM_Object_var aGEOMObject;
1939
1940   //Set a not done flag
1941   GetOperations()->SetNotDone();
1942
1943   //Get the reference objects
1944   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1945   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1946
1947   if (aShapeWhere.IsNull() ||
1948       aShapeWhat.IsNull()) return aGEOMObject._retn();
1949
1950   //Get Shapes in place of aShapeWhat
1951   Handle(GEOM_Object) anObject =
1952     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1953   if (!GetOperations()->IsDone() || anObject.IsNull())
1954     return aGEOMObject._retn();
1955
1956   return GetObject(anObject);
1957 }
1958
1959 //=============================================================================
1960 /*!
1961  *  GetSame
1962  */
1963 //=============================================================================
1964 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1965                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1966                                            GEOM::GEOM_Object_ptr theShapeWhat)
1967 {
1968   GEOM::GEOM_Object_var aGEOMObject;
1969
1970   //Set a not done flag
1971   GetOperations()->SetNotDone();
1972
1973   //Get the reference objects
1974   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1975   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1976
1977   if (aShapeWhere.IsNull() ||
1978       aShapeWhat.IsNull()) return aGEOMObject._retn();
1979
1980   //Get Shapes in place of aShapeWhat
1981   Handle(GEOM_Object) anObject =
1982     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1983   if (!GetOperations()->IsDone() || anObject.IsNull())
1984     return aGEOMObject._retn();
1985
1986   return GetObject(anObject);
1987 }
1988
1989 //=============================================================================
1990 /*!
1991  *  GetSameIDs
1992  */
1993 //=============================================================================
1994 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1995                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1996                                            GEOM::GEOM_Object_ptr theShapeWhat) {
1997   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1998
1999   //Get the reference objects
2000   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2001   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2002
2003   if (aShapeWhere.IsNull() ||
2004       aShapeWhat.IsNull()) return aSeq._retn();
2005
2006
2007   Handle(TColStd_HSequenceOfInteger) aHSeq =
2008     GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
2009
2010   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
2011
2012   Standard_Integer aLength = aHSeq->Length();
2013   aSeq->length(aLength);
2014   for (Standard_Integer i = 1; i <= aLength; i++)
2015     aSeq[i-1] = aHSeq->Value(i);
2016
2017   return aSeq._retn();
2018 }
2019
2020 //=============================================================================
2021 /*!
2022  *  ExtendEdge
2023  */
2024 //=============================================================================
2025 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendEdge
2026                                   (GEOM::GEOM_Object_ptr theEdge,
2027                                    CORBA::Double         theMin,
2028                                    CORBA::Double         theMax)
2029 {
2030   GEOM::GEOM_Object_var aGEOMObject;
2031
2032   //Set a not done flag
2033   GetOperations()->SetNotDone();
2034
2035   //Get the reference objects
2036   Handle(GEOM_Object) anEdge = GetObjectImpl(theEdge);
2037
2038   if (anEdge.IsNull()) {
2039     return aGEOMObject._retn();
2040   }
2041
2042   //Get Shapes in place of aShapeWhat
2043   Handle(GEOM_Object) aNewEdge =
2044     GetOperations()->ExtendEdge(anEdge, theMin, theMax);
2045
2046   if (!GetOperations()->IsDone() || aNewEdge.IsNull()) {
2047     return aGEOMObject._retn();
2048   }
2049
2050   return GetObject(aNewEdge);
2051 }
2052
2053 //=============================================================================
2054 /*!
2055  *  ExtendFace
2056  */
2057 //=============================================================================
2058 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
2059                                   (GEOM::GEOM_Object_ptr theFace,
2060                                    CORBA::Double         theUMin,
2061                                    CORBA::Double         theUMax,
2062                                    CORBA::Double         theVMin,
2063                                    CORBA::Double         theVMax)
2064 {
2065   GEOM::GEOM_Object_var aGEOMObject;
2066
2067   //Set a not done flag
2068   GetOperations()->SetNotDone();
2069
2070   //Get the reference objects
2071   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
2072
2073   if (aFace.IsNull()) {
2074     return aGEOMObject._retn();
2075   }
2076
2077   //Get Shapes in place of aShapeWhat
2078   Handle(GEOM_Object) aNewFace =
2079     GetOperations()->ExtendFace(aFace, theUMin, theUMax, theVMin, theVMax);
2080
2081   if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2082     return aGEOMObject._retn();
2083   }
2084
2085   return GetObject(aNewFace);
2086 }
2087
2088 //=============================================================================
2089 /*!
2090  *  MakeSurfaceFromFace
2091  */
2092 //=============================================================================
2093 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
2094                                   (GEOM::GEOM_Object_ptr theFace)
2095 {
2096   GEOM::GEOM_Object_var aGEOMObject;
2097
2098   //Set a not done flag
2099   GetOperations()->SetNotDone();
2100
2101   //Get the reference object
2102   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
2103
2104   if (aFace.IsNull()) {
2105     return aGEOMObject._retn();
2106   }
2107
2108   //Get Shapes in place of aShapeWhat
2109   Handle(GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
2110
2111   if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2112     return aGEOMObject._retn();
2113   }
2114
2115   return GetObject(aNewFace);
2116 }