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