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