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