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