]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_I/GEOM_IShapesOperations_i.cc
Salome HOME
Mantis issues 0020939(GetSharedShapes) and 0020842(AllSorted meaning).
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 //  Copyright (C) 2007-2010  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.
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 #include <Standard_Stream.hxx>
23
24 #include "GEOM_IShapesOperations_i.hh"
25
26 #include "utilities.h"
27 #include "OpUtil.hxx"
28 #include "Utils_ExceptHandlers.hxx"
29
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
32
33 #include <TopAbs.hxx>
34 #include <TColStd_HSequenceOfTransient.hxx>
35 #include <TColStd_HArray1OfInteger.hxx>
36
37 //=============================================================================
38 /*!
39  *   constructor:
40  */
41 //=============================================================================
42 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
43                                                     GEOM::GEOM_Gen_ptr theEngine,
44                                                     ::GEOMImpl_IShapesOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
46 {
47   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
48 }
49
50 //=============================================================================
51 /*!
52  *  destructor
53  */
54 //=============================================================================
55 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
56 {
57   MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
58 }
59
60
61 //=============================================================================
62 /*!
63  *  MakeEdge
64  */
65 //=============================================================================
66 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
67                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
68 {
69   GEOM::GEOM_Object_var aGEOMObject;
70
71   //Set a not done flag
72   GetOperations()->SetNotDone();
73
74   //Get the reference points
75   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
76   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
77
78   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
79
80   //Create the Edge
81   Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
82   if (!GetOperations()->IsDone() || anObject.IsNull())
83     return aGEOMObject._retn();
84
85   return GetObject(anObject);
86 }
87
88 //=============================================================================
89 /*!
90  *  MakeWire
91  */
92 //=============================================================================
93 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
94                            (const GEOM::ListOfGO& theEdgesAndWires,
95                             const CORBA::Double   theTolerance)
96 {
97   GEOM::GEOM_Object_var aGEOMObject;
98
99   //Set a not done flag
100   GetOperations()->SetNotDone();
101
102   int ind, aLen;
103   std::list<Handle(GEOM_Object)> aShapes;
104
105   //Get the shapes
106   aLen = theEdgesAndWires.length();
107   for (ind = 0; ind < aLen; ind++) {
108     Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
109     if (aSh.IsNull()) return aGEOMObject._retn();
110     aShapes.push_back(aSh);
111   }
112
113   // Make Solid
114   Handle(GEOM_Object) anObject =
115     GetOperations()->MakeWire(aShapes, theTolerance);
116   if (!GetOperations()->IsDone() || anObject.IsNull())
117     return aGEOMObject._retn();
118
119   return GetObject(anObject);
120 }
121
122 //=============================================================================
123 /*!
124  *  MakeFace
125  */
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
128                       (GEOM::GEOM_Object_ptr theWire,
129                        const CORBA::Boolean  isPlanarWanted)
130 {
131   GEOM::GEOM_Object_var aGEOMObject;
132
133   //Set a not done flag
134   GetOperations()->SetNotDone();
135
136   //Get the reference wire
137   Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
138   if (aWire.IsNull()) return aGEOMObject._retn();
139
140   //Create the Face
141   Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
142   if (!GetOperations()->IsDone() || anObject.IsNull())
143     return aGEOMObject._retn();
144
145   return GetObject(anObject);
146 }
147
148 //=============================================================================
149 /*!
150  *  MakeFaceWires
151  */
152 //=============================================================================
153 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
154                                          (const GEOM::ListOfGO& theWires,
155                                           const CORBA::Boolean  isPlanarWanted)
156 {
157   GEOM::GEOM_Object_var aGEOMObject;
158
159   //Set a not done flag
160   GetOperations()->SetNotDone();
161
162   int ind, aLen;
163   std::list<Handle(GEOM_Object)> aShapes;
164
165   //Get the shapes
166   aLen = theWires.length();
167   for (ind = 0; ind < aLen; ind++) {
168     Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
169     if (aSh.IsNull()) return aGEOMObject._retn();
170     aShapes.push_back(aSh);
171   }
172
173   // Make Face
174   Handle(GEOM_Object) anObject =
175     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
176   if (!GetOperations()->IsDone() || anObject.IsNull())
177     return aGEOMObject._retn();
178
179   return GetObject(anObject);
180 }
181
182 //=============================================================================
183 /*!
184  *  MakeShell
185  */
186 //=============================================================================
187 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
188                                       (const GEOM::ListOfGO& theFacesAndShells)
189 {
190   GEOM::GEOM_Object_var aGEOMObject;
191
192   //Set a not done flag
193   GetOperations()->SetNotDone();
194
195   int ind, aLen;
196   std::list<Handle(GEOM_Object)> aShapes;
197
198   //Get the shapes
199   aLen = theFacesAndShells.length();
200   for (ind = 0; ind < aLen; ind++) {
201     Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
202     if (aSh.IsNull()) return aGEOMObject._retn();
203     aShapes.push_back(aSh);
204   }
205
206   // Make Solid
207   Handle(GEOM_Object) anObject =
208     GetOperations()->MakeShell(aShapes);
209   if (!GetOperations()->IsDone() || anObject.IsNull())
210     return aGEOMObject._retn();
211
212   return GetObject(anObject);
213 }
214
215 //=============================================================================
216 /*!
217  *  MakeSolidShell
218  */
219 //=============================================================================
220 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
221                                                 (GEOM::GEOM_Object_ptr theShell)
222 {
223   GEOM::GEOM_Object_var aGEOMObject;
224
225   //Set a not done flag
226   GetOperations()->SetNotDone();
227
228   //Get the reference objects
229   Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
230   if (aShell.IsNull()) return aGEOMObject._retn();
231
232   //Create the Solid
233   Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
234   if (!GetOperations()->IsDone() || anObject.IsNull())
235     return aGEOMObject._retn();
236
237   return GetObject(anObject);
238 }
239
240 //=============================================================================
241 /*!
242  *  MakeSolidShells
243  */
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
246                                       (const GEOM::ListOfGO& theShells)
247 {
248   GEOM::GEOM_Object_var aGEOMObject;
249
250   //Set a not done flag
251   GetOperations()->SetNotDone();
252
253   int ind, aLen;
254   std::list<Handle(GEOM_Object)> aShapes;
255
256   //Get the shapes
257   aLen = theShells.length();
258   for (ind = 0; ind < aLen; ind++) {
259     Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
260     if (aSh.IsNull()) return aGEOMObject._retn();
261     aShapes.push_back(aSh);
262   }
263
264   // Make Solid
265   Handle(GEOM_Object) anObject =
266     GetOperations()->MakeSolidShells(aShapes);
267   if (!GetOperations()->IsDone() || anObject.IsNull())
268     return aGEOMObject._retn();
269
270   return GetObject(anObject);
271 }
272
273 //=============================================================================
274 /*!
275  *  MakeCompound
276  */
277 //=============================================================================
278 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
279                                       (const GEOM::ListOfGO& theShapes)
280 {
281   GEOM::GEOM_Object_var aGEOMObject;
282
283   //Set a not done flag
284   GetOperations()->SetNotDone();
285
286   int ind, aLen;
287   std::list<Handle(GEOM_Object)> aShapes;
288
289   //Get the shapes
290   aLen = theShapes.length();
291   for (ind = 0; ind < aLen; ind++) {
292     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
293     if (aSh.IsNull()) return aGEOMObject._retn();
294     aShapes.push_back(aSh);
295   }
296
297   // Make Solid
298   Handle(GEOM_Object) anObject =
299     GetOperations()->MakeCompound(aShapes);
300   if (!GetOperations()->IsDone() || anObject.IsNull())
301     return aGEOMObject._retn();
302
303   return GetObject(anObject);
304 }
305
306 //=============================================================================
307 /*!
308  *  MakeGlueFaces
309  */
310 //=============================================================================
311 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
312                                            (GEOM::GEOM_Object_ptr theShape,
313                                             CORBA::Double   theTolerance,
314                                             CORBA::Boolean  doKeepNonSolids)
315 {
316   GEOM::GEOM_Object_var aGEOMObject;
317
318   //Set a not done flag
319   GetOperations()->SetNotDone();
320
321   //Get the reference objects
322   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
323   if (aShape.IsNull()) return aGEOMObject._retn();
324
325   //Perform the gluing
326   Handle(GEOM_Object) anObject =
327     GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
328   //if (!GetOperations()->IsDone() || anObject.IsNull())
329   // to allow warning
330   if (anObject.IsNull())
331     return aGEOMObject._retn();
332
333   return GetObject(anObject);
334 }
335
336
337 //=============================================================================
338 /*!
339  *  GetGlueFaces
340  */
341 //=============================================================================
342 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
343                                            (GEOM::GEOM_Object_ptr theShape,
344                                             const CORBA::Double   theTolerance)
345 {
346   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
347
348   //Set a not done flag
349   GetOperations()->SetNotDone();
350
351   //Get the reference objects
352   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
353   if (aShape.IsNull()) return aSeq._retn();
354
355   Handle(TColStd_HSequenceOfTransient) aHSeq =
356     GetOperations()->GetGlueFaces(aShape, theTolerance);
357
358   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
359   // to allow warning
360   if(aHSeq.IsNull())
361     return aSeq._retn();
362
363   Standard_Integer aLength = aHSeq->Length();
364   aSeq->length(aLength);
365   for (Standard_Integer i = 1; i <= aLength; i++)
366     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
367
368   return aSeq._retn();
369 }
370
371
372 //=============================================================================
373 /*!
374  *  MakeGlueFacesByList
375  */
376 //=============================================================================
377 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
378                                            (GEOM::GEOM_Object_ptr theShape,
379                                             CORBA::Double   theTolerance,
380                                             const GEOM::ListOfGO& theFaces,
381                                             CORBA::Boolean  doKeepNonSolids)
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) aShape = GetObjectImpl(theShape);
390   if (aShape.IsNull()) return aGEOMObject._retn();
391
392   int ind, aLen;
393   std::list<Handle(GEOM_Object)> aFaces;
394   //Get the shapes
395   aLen = theFaces.length();
396   for (ind = 0; ind < aLen; ind++) {
397     Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
398     if (aSh.IsNull()) return aGEOMObject._retn();
399     aFaces.push_back(aSh);
400   }
401
402   //Perform the gluing
403   Handle(GEOM_Object) anObject =
404     GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
405   //if (!GetOperations()->IsDone() || anObject.IsNull())
406   // to allow warning
407   if (anObject.IsNull())
408     return aGEOMObject._retn();
409
410   return GetObject(anObject);
411 }
412
413 //=============================================================================
414 /*!
415  *  MakeExplode
416  */
417 //=============================================================================
418 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
419                                                        const CORBA::Long     theShapeType,
420                                                        const CORBA::Boolean  isSorted)
421 {
422   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
423
424   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
425   if (aShape.IsNull()) return aSeq._retn();
426
427   Handle(TColStd_HSequenceOfTransient) aHSeq =
428     GetOperations()->MakeExplode(aShape, theShapeType, isSorted, Standard_True);
429   if (!GetOperations()->IsDone() || aHSeq.IsNull())
430     return aSeq._retn();
431
432   Standard_Integer aLength = aHSeq->Length();
433   aSeq->length(aLength);
434   for (Standard_Integer i = 1; i <= aLength; i++)
435     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
436
437   return aSeq._retn();
438 }
439
440 //=============================================================================
441 /*!
442  *  MakeAllSubShapes
443  */
444 //=============================================================================
445 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
446                                                             const CORBA::Long     theShapeType,
447                                                             const CORBA::Boolean  isSorted)
448 {
449   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
450
451   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
452   if (aShape.IsNull()) return aSeq._retn();
453
454   Handle(TColStd_HSequenceOfTransient) aHSeq =
455     GetOperations()->MakeExplode(aShape, theShapeType, isSorted, Standard_False);
456   if (!GetOperations()->IsDone() || aHSeq.IsNull())
457     return aSeq._retn();
458
459   Standard_Integer aLength = aHSeq->Length();
460   aSeq->length(aLength);
461   for (Standard_Integer i = 1; i <= aLength; i++)
462     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
463
464   return aSeq._retn();
465 }
466
467 //=============================================================================
468 /*!
469  *  SubShapeAllIDs
470  */
471 //=============================================================================
472 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
473                                                             const CORBA::Long     theShapeType,
474                                                             const CORBA::Boolean  isSorted)
475 {
476   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
477
478   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
479   if (aShape.IsNull()) return aSeq._retn();
480
481   Handle(TColStd_HSequenceOfInteger) aHSeq =
482     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted, Standard_True);
483   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
484
485   Standard_Integer aLength = aHSeq->Length();
486   aSeq->length(aLength);
487   for (Standard_Integer i = 1; i <= aLength; i++)
488     aSeq[i-1] = aHSeq->Value(i);
489
490   return aSeq._retn();
491 }
492
493 //=============================================================================
494 /*!
495  *  GetAllSubShapesIDs
496  */
497 //=============================================================================
498 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
499                                                                 const CORBA::Long     theShapeType,
500                                                                 const CORBA::Boolean  isSorted)
501 {
502   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
503
504   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
505   if (aShape.IsNull()) return aSeq._retn();
506
507   Handle(TColStd_HSequenceOfInteger) aHSeq =
508     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted, Standard_False);
509   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
510
511   Standard_Integer aLength = aHSeq->Length();
512   aSeq->length(aLength);
513   for (Standard_Integer i = 1; i <= aLength; i++)
514     aSeq[i-1] = aHSeq->Value(i);
515
516   return aSeq._retn();
517 }
518
519 //=============================================================================
520 /*!
521  *  GetSubShape
522  */
523 //=============================================================================
524 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
525                                            (GEOM::GEOM_Object_ptr theMainShape,
526                                             const CORBA::Long     theID)
527 {
528   GEOM::GEOM_Object_var aGEOMObject;
529
530   //Set a not done flag
531   GetOperations()->SetNotDone();
532
533   //Get the reference objects
534   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
535   if (aShape.IsNull()) return aGEOMObject._retn();
536
537   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
538   if (!GetOperations()->IsDone() || anObject.IsNull())
539     return aGEOMObject._retn();
540
541   return GetObject(anObject);
542 }
543
544 //=============================================================================
545 /*!
546  *  GetSubShapeIndex
547  */
548 //=============================================================================
549 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
550   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
551 {
552   //Get the reference shapes
553   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
554   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
555
556   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
557
558   //Get the unique ID of <theSubShape> inside <theMainShape>
559   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
560   if (!GetOperations()->IsDone())
561     return -1;
562
563   return anID;
564 }
565
566 //=============================================================================
567 /*!
568  *  GetTopologyIndex
569  */
570 //=============================================================================
571 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
572   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
573 {
574   //Get the reference shapes
575   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
576   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
577
578   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
579
580   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
581   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
582   if (!GetOperations()->IsDone())
583     return -1;
584
585   return anID;
586 }
587
588 //=============================================================================
589 /*!
590  *  GetShapeTypeString
591  */
592 //=============================================================================
593 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
594 {
595   //Get the reference shape
596   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
597   if (aShape.IsNull()) return NULL;
598
599   // Get shape parameters
600   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
601   return CORBA::string_dup(aDescription.ToCString());
602 }
603
604 //=============================================================================
605 /*!
606  *  NumberOfFaces
607  */
608 //=============================================================================
609 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
610 {
611   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
612 }
613
614 //=============================================================================
615 /*!
616  *  NumberOfEdges
617  */
618 //=============================================================================
619 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
620 {
621   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
622 }
623
624 //=============================================================================
625 /*!
626  *  NumberOfSubShapes
627  */
628 //=============================================================================
629 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
630                                                          const CORBA::Long     theShapeType)
631 {
632   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
633   if (aShape.IsNull()) return -1;
634
635   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
636   if (!GetOperations()->IsDone()) return -1;
637
638   return aNb;
639 }
640
641 //=============================================================================
642 /*!
643  *  ChangeOrientation
644  */
645 //=============================================================================
646 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
647                                                 (GEOM::GEOM_Object_ptr theShape)
648 {
649   GEOM::GEOM_Object_var aGEOMObject;
650
651   //Set a not done flag
652   GetOperations()->SetNotDone();
653
654   //Get the reference objects
655   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
656   if (aShape.IsNull()) return aGEOMObject._retn();
657
658   //Create the Solid
659   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
660   if (!GetOperations()->IsDone() || anObject.IsNull())
661     return aGEOMObject._retn();
662
663   return GetObject(anObject);
664 }
665
666 //=============================================================================
667 /*!
668  *  GetFreeFacesIDs
669  */
670 //=============================================================================
671 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
672 {
673   //Set a not done flag
674   GetOperations()->SetNotDone();
675
676   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
677
678   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
679   if (aShape.IsNull()) return aSeq._retn();
680
681   Handle(TColStd_HSequenceOfInteger) aHSeq =
682     GetOperations()->GetFreeFacesIDs(aShape);
683   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
684
685   Standard_Integer aLength = aHSeq->Length();
686   aSeq->length(aLength);
687   for (Standard_Integer i = 1; i <= aLength; i++)
688     aSeq[i-1] = aHSeq->Value(i);
689
690   return aSeq._retn();
691 }
692
693 //=============================================================================
694 /*!
695  *  GetSharedShapes
696  */
697 //=============================================================================
698 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
699                                           (GEOM::GEOM_Object_ptr theShape1,
700                                            GEOM::GEOM_Object_ptr theShape2,
701                                            const CORBA::Long     theShapeType)
702 {
703   //Set a not done flag
704   GetOperations()->SetNotDone();
705
706   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
707
708   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
709   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
710
711   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
712
713   Handle(TColStd_HSequenceOfTransient) aHSeq =
714     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
715   if (!GetOperations()->IsDone() || aHSeq.IsNull())
716     return aSeq._retn();
717
718   Standard_Integer aLength = aHSeq->Length();
719   aSeq->length(aLength);
720   for (Standard_Integer i = 1; i <= aLength; i++)
721     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
722
723   return aSeq._retn();
724 }
725
726 //=============================================================================
727 /*!
728  *  GetSharedShapesMulti
729  */
730 //=============================================================================
731 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
732                                           (const GEOM::ListOfGO& theShapes,
733                                            const CORBA::Long     theShapeType)
734 {
735   //Set a not done flag
736   GetOperations()->SetNotDone();
737
738   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
739
740   //Get the shapes
741   std::list<Handle(GEOM_Object)> aShapes;
742   int aLen = theShapes.length();
743   for (int ind = 0; ind < aLen; ind++) {
744     Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
745     if (aSh.IsNull()) return aSeq._retn();
746     aShapes.push_back(aSh);
747   }
748
749   Handle(TColStd_HSequenceOfTransient) aHSeq =
750     GetOperations()->GetSharedShapes(aShapes, theShapeType);
751   if (!GetOperations()->IsDone() || aHSeq.IsNull())
752     return aSeq._retn();
753
754   Standard_Integer aLength = aHSeq->Length();
755   aSeq->length(aLength);
756   for (Standard_Integer i = 1; i <= aLength; i++)
757     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
758
759   return aSeq._retn();
760 }
761
762 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
763 {
764   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
765
766   switch (theState) {
767   case GEOM::ST_ON:
768     aState = GEOMAlgo_ST_ON;
769     break;
770   case GEOM::ST_OUT:
771     aState = GEOMAlgo_ST_OUT;
772     break;
773   case GEOM::ST_ONOUT:
774     aState = GEOMAlgo_ST_ONOUT;
775     break;
776   case GEOM::ST_IN:
777     aState = GEOMAlgo_ST_IN;
778     break;
779   case GEOM::ST_ONIN:
780     aState = GEOMAlgo_ST_ONIN;
781     break;
782   default:
783     break;
784   }
785
786   return aState;
787 }
788
789 //=============================================================================
790 /*!
791  *  GetShapesOnPlane
792  */
793 //=============================================================================
794 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
795                                                 (GEOM::GEOM_Object_ptr   theShape,
796                                                  const CORBA::Long       theShapeType,
797                                                  GEOM::GEOM_Object_ptr   theAx1,
798                                                  const GEOM::shape_state theState)
799 {
800   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
801
802   //Set a not done flag
803   GetOperations()->SetNotDone();
804
805   //Get the reference objects
806   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
807   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
808
809   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
810
811   //Get Shapes On Plane
812   Handle(TColStd_HSequenceOfTransient) aHSeq =
813     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
814   if (!GetOperations()->IsDone() || aHSeq.IsNull())
815     return aSeq._retn();
816
817   Standard_Integer aLength = aHSeq->Length();
818   aSeq->length(aLength);
819   for (Standard_Integer i = 1; i <= aLength; i++)
820     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
821
822   return aSeq._retn();
823 }
824
825 //=============================================================================
826 /*!
827  *  GetShapesOnPlaneWithLocation
828  */
829 //=============================================================================
830 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
831                                                 (GEOM::GEOM_Object_ptr   theShape,
832                                                  const CORBA::Long       theShapeType,
833                                                  GEOM::GEOM_Object_ptr   theAx1,
834                                                  GEOM::GEOM_Object_ptr   thePnt,
835                                                  const GEOM::shape_state theState)
836 {
837   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
838
839   //Set a not done flag
840   GetOperations()->SetNotDone();
841
842   //Get the reference objects
843   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
844   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
845   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
846
847   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
848
849   //Get Shapes On Plane
850   Handle(TColStd_HSequenceOfTransient) aHSeq =
851     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
852   if (!GetOperations()->IsDone() || aHSeq.IsNull())
853     return aSeq._retn();
854
855   Standard_Integer aLength = aHSeq->Length();
856   aSeq->length(aLength);
857   for (Standard_Integer i = 1; i <= aLength; i++)
858     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
859
860   return aSeq._retn();
861 }
862
863 //=============================================================================
864 /*!
865  *  GetShapesOnCylinder
866  */
867 //=============================================================================
868 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
869                                                 (GEOM::GEOM_Object_ptr   theShape,
870                                                  const CORBA::Long       theShapeType,
871                                                  GEOM::GEOM_Object_ptr   theAxis,
872                                                  const CORBA::Double     theRadius,
873                                                  const GEOM::shape_state theState)
874 {
875   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
876
877   //Set a not done flag
878   GetOperations()->SetNotDone();
879
880   //Get the reference objects
881   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
882   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
883
884   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
885
886   //Get Shapes On Cylinder
887   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
888     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
889   if (!GetOperations()->IsDone() || aHSeq.IsNull())
890     return aSeq._retn();
891
892   Standard_Integer aLength = aHSeq->Length();
893   aSeq->length(aLength);
894   for (Standard_Integer i = 1; i <= aLength; i++)
895     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
896
897   return aSeq._retn();
898 }
899
900 //=============================================================================
901 /*!
902  *  GetShapesOnCylinderWithLocation
903  */
904 //=============================================================================
905 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
906                                                 (GEOM::GEOM_Object_ptr   theShape,
907                                                  const CORBA::Long       theShapeType,
908                                                  GEOM::GEOM_Object_ptr   theAxis,
909                                                  GEOM::GEOM_Object_ptr   thePnt,
910                                                  const CORBA::Double     theRadius,
911                                                  const GEOM::shape_state theState)
912 {
913   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
914
915   //Set a not done flag
916   GetOperations()->SetNotDone();
917
918   //Get the reference objects
919   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
920   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
921   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
922
923   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
924
925   //Get Shapes On Cylinder
926   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
927     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
928   if (!GetOperations()->IsDone() || aHSeq.IsNull())
929     return aSeq._retn();
930
931   Standard_Integer aLength = aHSeq->Length();
932   aSeq->length(aLength);
933   for (Standard_Integer i = 1; i <= aLength; i++)
934     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
935
936   return aSeq._retn();
937 }
938
939 //=============================================================================
940 /*!
941  *  GetShapesOnSphere
942  */
943 //=============================================================================
944 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
945                                                 (GEOM::GEOM_Object_ptr   theShape,
946                                                  const CORBA::Long       theShapeType,
947                                                  GEOM::GEOM_Object_ptr   theCenter,
948                                                  const CORBA::Double     theRadius,
949                                                  const GEOM::shape_state theState)
950 {
951   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
952
953   //Set a not done flag
954   GetOperations()->SetNotDone();
955
956   //Get the reference objects
957   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
958   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
959
960   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
961
962   //Get Shapes On Sphere
963   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
964     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
965   if (!GetOperations()->IsDone() || aHSeq.IsNull())
966     return aSeq._retn();
967
968   Standard_Integer aLength = aHSeq->Length();
969   aSeq->length(aLength);
970   for (Standard_Integer i = 1; i <= aLength; i++)
971     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
972
973   return aSeq._retn();
974 }
975
976 //=============================================================================
977 /*!
978  *  GetShapesOnQuadrangle
979  */
980 //=============================================================================
981 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
982                                                 (GEOM::GEOM_Object_ptr theShape,
983                                                  CORBA::Long           theShapeType,
984                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
985                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
986                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
987                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
988                                                  GEOM::shape_state     theState)
989 {
990   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
991
992   //Set a not done flag
993   GetOperations()->SetNotDone();
994
995   //Get the reference objects
996   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
997   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
998   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
999   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1000   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1001
1002   if (aShape.IsNull() ||
1003       aTopLeftPoint.IsNull() ||
1004       aTopRigthPoint.IsNull() ||
1005       aBottomLeftPoint.IsNull() ||
1006       aBottomRigthPoint.IsNull())
1007     return aSeq._retn();
1008
1009   //Get Shapes On Quadrangle
1010   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1011     (aShape, theShapeType,
1012      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1013      ShapeState(theState));
1014   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1015     return aSeq._retn();
1016
1017   Standard_Integer aLength = aHSeq->Length();
1018   aSeq->length(aLength);
1019   for (Standard_Integer i = 1; i <= aLength; i++)
1020     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1021
1022   return aSeq._retn();
1023 }
1024
1025 //=============================================================================
1026 /*!
1027  *  GetShapesOnPlaneIDs
1028  */
1029 //=============================================================================
1030 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1031                                                 (GEOM::GEOM_Object_ptr   theShape,
1032                                                  const CORBA::Long       theShapeType,
1033                                                  GEOM::GEOM_Object_ptr   theAx1,
1034                                                  const GEOM::shape_state theState)
1035 {
1036   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1037
1038   //Set a not done flag
1039   GetOperations()->SetNotDone();
1040
1041   //Get the reference objects
1042   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1043   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1044
1045   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1046
1047   //Get Shapes On Plane
1048   Handle(TColStd_HSequenceOfInteger) aHSeq =
1049     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1050   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1051     return aSeq._retn();
1052
1053   Standard_Integer aLength = aHSeq->Length();
1054   aSeq->length(aLength);
1055   for (Standard_Integer i = 1; i <= aLength; i++)
1056     aSeq[i-1] = aHSeq->Value(i);
1057
1058   return aSeq._retn();
1059 }
1060
1061 //=============================================================================
1062 /*!
1063  *  GetShapesOnPlaneWithLocationIDs
1064  */
1065 //=============================================================================
1066 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1067                                                 (GEOM::GEOM_Object_ptr   theShape,
1068                                                  const CORBA::Long       theShapeType,
1069                                                  GEOM::GEOM_Object_ptr   theAx1,
1070                                                  GEOM::GEOM_Object_ptr   thePnt,
1071                                                  const GEOM::shape_state theState)
1072 {
1073   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1074
1075   //Set a not done flag
1076   GetOperations()->SetNotDone();
1077
1078   //Get the reference objects
1079   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1080   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1081   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1082
1083   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1084
1085   //Get Shapes On Plane
1086   Handle(TColStd_HSequenceOfInteger) aHSeq =
1087     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1088                                                      anAx1, anPnt, ShapeState(theState));
1089   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1090     return aSeq._retn();
1091
1092   Standard_Integer aLength = aHSeq->Length();
1093   aSeq->length(aLength);
1094   for (Standard_Integer i = 1; i <= aLength; i++)
1095     aSeq[i-1] = aHSeq->Value(i);
1096
1097   return aSeq._retn();
1098 }
1099
1100 //=============================================================================
1101 /*!
1102  *  GetShapesOnCylinderIDs
1103  */
1104 //=============================================================================
1105 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1106                                                 (GEOM::GEOM_Object_ptr   theShape,
1107                                                  const CORBA::Long       theShapeType,
1108                                                  GEOM::GEOM_Object_ptr   theAxis,
1109                                                  const CORBA::Double     theRadius,
1110                                                  const GEOM::shape_state theState)
1111 {
1112   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1113
1114   //Set a not done flag
1115   GetOperations()->SetNotDone();
1116
1117   //Get the reference objects
1118   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1119   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1120
1121   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1122
1123   //Get Shapes On Cylinder
1124   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1125     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1126   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1127     return aSeq._retn();
1128
1129   Standard_Integer aLength = aHSeq->Length();
1130   aSeq->length(aLength);
1131   for (Standard_Integer i = 1; i <= aLength; i++)
1132     aSeq[i-1] = aHSeq->Value(i);
1133
1134   return aSeq._retn();
1135 }
1136
1137 //=============================================================================
1138 /*!
1139  *  GetShapesOnCylinderWithLocationIDs
1140  */
1141 //=============================================================================
1142 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1143                                                 (GEOM::GEOM_Object_ptr   theShape,
1144                                                  const CORBA::Long       theShapeType,
1145                                                  GEOM::GEOM_Object_ptr   theAxis,
1146                                                  GEOM::GEOM_Object_ptr   thePnt,
1147                                                  const CORBA::Double     theRadius,
1148                                                  const GEOM::shape_state theState)
1149 {
1150   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1151
1152   //Set a not done flag
1153   GetOperations()->SetNotDone();
1154
1155   //Get the reference objects
1156   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1157   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1158   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1159
1160   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1161
1162   //Get Shapes On Cylinder
1163   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1164     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1165   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1166     return aSeq._retn();
1167
1168   Standard_Integer aLength = aHSeq->Length();
1169   aSeq->length(aLength);
1170   for (Standard_Integer i = 1; i <= aLength; i++)
1171     aSeq[i-1] = aHSeq->Value(i);
1172
1173   return aSeq._retn();
1174 }
1175
1176 //=============================================================================
1177 /*!
1178  *  GetShapesOnSphereIDs
1179  */
1180 //=============================================================================
1181 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1182                                                 (GEOM::GEOM_Object_ptr   theShape,
1183                                                  const CORBA::Long       theShapeType,
1184                                                  GEOM::GEOM_Object_ptr   theCenter,
1185                                                  const CORBA::Double     theRadius,
1186                                                  const GEOM::shape_state theState)
1187 {
1188   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1189
1190   //Set a not done flag
1191   GetOperations()->SetNotDone();
1192
1193   //Get the reference objects
1194   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1195   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1196
1197   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1198
1199   //Get Shapes On Sphere
1200   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1201     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
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] = aHSeq->Value(i);
1209
1210   return aSeq._retn();
1211 }
1212
1213 //=============================================================================
1214 /*!
1215  *  GetShapesOnQuadrangleIDs
1216  */
1217 //=============================================================================
1218 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1219                                                 (GEOM::GEOM_Object_ptr theShape,
1220                                                  CORBA::Long           theShapeType,
1221                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1222                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1223                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1224                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1225                                                  GEOM::shape_state     theState)
1226 {
1227   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1228
1229   //Set a not done flag
1230   GetOperations()->SetNotDone();
1231
1232   //Get the reference objects
1233   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1234   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1235   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1236   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1237   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1238
1239   if (aShape.IsNull() ||
1240       aTopLeftPoint.IsNull() ||
1241       aTopRigthPoint.IsNull() ||
1242       aBottomLeftPoint.IsNull() ||
1243       aBottomRigthPoint.IsNull() )
1244     return aSeq._retn();
1245
1246   //Get Shapes On Quadrangle
1247   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1248     (aShape, theShapeType,
1249      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1250      ShapeState(theState));
1251   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1252     return aSeq._retn();
1253
1254   Standard_Integer aLength = aHSeq->Length();
1255   aSeq->length(aLength);
1256   for (Standard_Integer i = 1; i <= aLength; i++)
1257     aSeq[i-1] = aHSeq->Value(i);
1258
1259   return aSeq._retn();
1260 }
1261
1262 //=============================================================================
1263 /*!
1264  *  GetShapesOnBox
1265  */
1266 //=============================================================================
1267 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1268                                                 (GEOM::GEOM_Object_ptr theBox,
1269                                                  GEOM::GEOM_Object_ptr theShape,
1270                                                  CORBA::Long           theShapeType,
1271                                                  GEOM::shape_state     theState)
1272 {
1273   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1274
1275   //Set a not done flag
1276   GetOperations()->SetNotDone();
1277
1278   //Get the reference objects
1279   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1280   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1281
1282   if (aShape.IsNull() || aBox.IsNull() )
1283     return aSeq._retn();
1284
1285   //Get Shapes On Box
1286   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1287     (aBox,aShape, theShapeType,ShapeState(theState));
1288   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1289     return aSeq._retn();
1290
1291   Standard_Integer aLength = aHSeq->Length();
1292   aSeq->length(aLength);
1293   for (Standard_Integer i = 1; i <= aLength; i++)
1294     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1295
1296   return aSeq._retn();
1297 }
1298
1299 //=============================================================================
1300 /*!
1301  *  GetShapesOnQuadrangleIDs
1302  */
1303 //=============================================================================
1304 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1305                                                 (GEOM::GEOM_Object_ptr theBox,
1306                                                  GEOM::GEOM_Object_ptr theShape,
1307                                                  CORBA::Long           theShapeType,
1308                                                  GEOM::shape_state     theState)
1309 {
1310   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1311
1312   //Set a not done flag
1313   GetOperations()->SetNotDone();
1314
1315   //Get the reference objects
1316   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1317   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1318
1319   if (aShape.IsNull() || aBox.IsNull() )
1320     return aSeq._retn();
1321
1322   //Get Shapes On Box
1323   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1324     (aBox,aShape, theShapeType,ShapeState(theState));
1325   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1326     return aSeq._retn();
1327
1328   Standard_Integer aLength = aHSeq->Length();
1329   aSeq->length(aLength);
1330   for (Standard_Integer i = 1; i <= aLength; i++)
1331     aSeq[i-1] = aHSeq->Value(i);
1332
1333   return aSeq._retn();
1334 }
1335
1336
1337 //=============================================================================
1338 /*!
1339  *  GetShapesOnShape
1340  */
1341 //=============================================================================
1342 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1343                                            (GEOM::GEOM_Object_ptr theCheckShape,
1344                                             GEOM::GEOM_Object_ptr theShape,
1345                                             CORBA::Short          theShapeType,
1346                                             GEOM::shape_state     theState)
1347 {
1348   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1349
1350   //Set a not done flag
1351   GetOperations()->SetNotDone();
1352
1353   //Get the reference objects
1354   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1355   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1356
1357   if (aShape.IsNull() || aCheckShape.IsNull() )
1358     return aSeq._retn();
1359
1360   //Get Shapes On Shape
1361   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1362     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1363
1364   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1365     return aSeq._retn();
1366
1367   Standard_Integer aLength = aHSeq->Length();
1368   aSeq->length(aLength);
1369   for (Standard_Integer i = 1; i <= aLength; i++)
1370     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1371
1372   return aSeq._retn();
1373 }
1374
1375
1376 //=============================================================================
1377 /*!
1378  *  GetShapesOnShapeAsCompound
1379  */
1380 //=============================================================================
1381 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1382                                            (GEOM::GEOM_Object_ptr theCheckShape,
1383                                             GEOM::GEOM_Object_ptr theShape,
1384                                             CORBA::Short          theShapeType,
1385                                             GEOM::shape_state     theState)
1386 {
1387   GEOM::GEOM_Object_var aGEOMObject;
1388
1389   //Set a not done flag
1390   GetOperations()->SetNotDone();
1391
1392   //Get the reference objects
1393   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1394   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1395
1396   if (aShape.IsNull() || aCheckShape.IsNull() )
1397     return aGEOMObject._retn();
1398
1399   //Get Shapes On Shape
1400   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1401     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1402
1403   if (anObject.IsNull())
1404     return aGEOMObject._retn();
1405
1406   return GetObject(anObject);
1407 }
1408
1409
1410 //=============================================================================
1411 /*!
1412  *  GetShapesOnShapeIDs
1413  */
1414 //=============================================================================
1415 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1416                                            (GEOM::GEOM_Object_ptr theCheckShape,
1417                                             GEOM::GEOM_Object_ptr theShape,
1418                                             CORBA::Short          theShapeType,
1419                                             GEOM::shape_state     theState)
1420 {
1421   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1422
1423   //Set a not done flag
1424   GetOperations()->SetNotDone();
1425
1426   //Get the reference objects
1427   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1428   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1429
1430   if (aShape.IsNull() || aCheckShape.IsNull() )
1431     return aSeq._retn();
1432
1433   //Get Shapes On Shape
1434   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1435     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1436   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1437     return aSeq._retn();
1438
1439   Standard_Integer aLength = aHSeq->Length();
1440   aSeq->length(aLength);
1441   for (Standard_Integer i = 1; i <= aLength; i++)
1442     aSeq[i-1] = aHSeq->Value(i);
1443
1444   return aSeq._retn();
1445 }
1446
1447
1448 //=============================================================================
1449 /*!
1450  *  GetInPlace
1451  */
1452 //=============================================================================
1453 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1454                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1455                                            GEOM::GEOM_Object_ptr theShapeWhat)
1456 {
1457   GEOM::GEOM_Object_var aGEOMObject;
1458
1459   //Set a not done flag
1460   GetOperations()->SetNotDone();
1461
1462   //Get the reference objects
1463   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1464   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1465
1466   if (aShapeWhere.IsNull() ||
1467       aShapeWhat.IsNull()) return aGEOMObject._retn();
1468
1469   //Get Shapes in place of aShapeWhat
1470   Handle(GEOM_Object) anObject =
1471     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1472   if (!GetOperations()->IsDone() || anObject.IsNull())
1473     return aGEOMObject._retn();
1474
1475   return GetObject(anObject);
1476 }
1477
1478 //=============================================================================
1479 /*!
1480  *  GetInPlaceByHistory
1481  */
1482 //=============================================================================
1483 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1484                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1485                                            GEOM::GEOM_Object_ptr theShapeWhat)
1486 {
1487   GEOM::GEOM_Object_var aGEOMObject;
1488
1489   //Set a not done flag
1490   GetOperations()->SetNotDone();
1491
1492   //Get the reference objects
1493   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1494   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1495
1496   if (aShapeWhere.IsNull() ||
1497       aShapeWhat.IsNull()) return aGEOMObject._retn();
1498
1499   //Get Shapes in place of aShapeWhat
1500   Handle(GEOM_Object) anObject =
1501     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1502   if (!GetOperations()->IsDone() || anObject.IsNull())
1503     return aGEOMObject._retn();
1504
1505   return GetObject(anObject);
1506 }
1507
1508 //=============================================================================
1509 /*!
1510  *  GetSame
1511  */
1512 //=============================================================================
1513 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1514                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1515                                            GEOM::GEOM_Object_ptr theShapeWhat)
1516 {
1517   GEOM::GEOM_Object_var aGEOMObject;
1518
1519   //Set a not done flag
1520   GetOperations()->SetNotDone();
1521
1522   //Get the reference objects
1523   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1524   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1525
1526   if (aShapeWhere.IsNull() ||
1527       aShapeWhat.IsNull()) return aGEOMObject._retn();
1528
1529   //Get Shapes in place of aShapeWhat
1530   Handle(GEOM_Object) anObject =
1531     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1532   if (!GetOperations()->IsDone() || anObject.IsNull())
1533     return aGEOMObject._retn();
1534
1535   return GetObject(anObject);
1536 }