Salome HOME
310111aaa864daf96a8f939de445d7d7977c0da4
[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
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   if (!GetOperations()->IsDone() || aHSeq.IsNull())
487     return aSeq._retn();
488
489   Standard_Integer aLength = aHSeq->Length();
490   aSeq->length(aLength);
491   for (Standard_Integer i = 1; i <= aLength; i++)
492     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
493
494   return aSeq._retn();
495 }
496
497 //=============================================================================
498 /*!
499  *  SubShapeAllIDs
500  */
501 //=============================================================================
502 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
503                                                             const CORBA::Long     theShapeType,
504                                                             const CORBA::Boolean  isSorted)
505 {
506   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
507
508   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
509   if (aShape.IsNull()) return aSeq._retn();
510
511   Handle(TColStd_HSequenceOfInteger) aHSeq =
512     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
513   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
514
515   Standard_Integer aLength = aHSeq->Length();
516   aSeq->length(aLength);
517   for (Standard_Integer i = 1; i <= aLength; i++)
518     aSeq[i-1] = aHSeq->Value(i);
519
520   return aSeq._retn();
521 }
522
523 //=============================================================================
524 /*!
525  *  GetSubShape
526  */
527 //=============================================================================
528 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
529                                            (GEOM::GEOM_Object_ptr theMainShape,
530                                             const CORBA::Long     theID)
531 {
532   GEOM::GEOM_Object_var aGEOMObject;
533
534   //Set a not done flag
535   GetOperations()->SetNotDone();
536
537   //Get the reference objects
538   Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
539   if (aShape.IsNull()) return aGEOMObject._retn();
540
541   Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
542   if (!GetOperations()->IsDone() || anObject.IsNull())
543     return aGEOMObject._retn();
544
545   return GetObject(anObject);
546 }
547
548 //=============================================================================
549 /*!
550  *  GetSubShapeIndex
551  */
552 //=============================================================================
553 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
554   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
555 {
556   //Get the reference shapes
557   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
558   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
559
560   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
561
562   //Get the unique ID of <theSubShape> inside <theMainShape>
563   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
564   if (!GetOperations()->IsDone())
565     return -1;
566
567   return anID;
568 }
569
570 //=============================================================================
571 /*!
572  *  GetTopologyIndex
573  */
574 //=============================================================================
575 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
576   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
577 {
578   //Get the reference shapes
579   Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
580   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
581
582   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
583
584   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
585   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
586   if (!GetOperations()->IsDone())
587     return -1;
588
589   return anID;
590 }
591
592 //=============================================================================
593 /*!
594  *  GetShapeTypeString
595  */
596 //=============================================================================
597 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
598 {
599   //Get the reference shape
600   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
601   if (aShape.IsNull()) return NULL;
602
603   // Get shape parameters
604   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
605   return CORBA::string_dup(aDescription.ToCString());
606 }
607
608 //=============================================================================
609 /*!
610  *  NumberOfFaces
611  */
612 //=============================================================================
613 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
614 {
615   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
616 }
617
618 //=============================================================================
619 /*!
620  *  NumberOfEdges
621  */
622 //=============================================================================
623 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
624 {
625   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
626 }
627
628 //=============================================================================
629 /*!
630  *  NumberOfSubShapes
631  */
632 //=============================================================================
633 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
634                                                          const CORBA::Long     theShapeType)
635 {
636   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
637   if (aShape.IsNull()) return -1;
638
639   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
640   if (!GetOperations()->IsDone()) return -1;
641
642   return aNb;
643 }
644
645 //=============================================================================
646 /*!
647  *  ChangeOrientation
648  */
649 //=============================================================================
650 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
651                                                 (GEOM::GEOM_Object_ptr theShape)
652 {
653   GEOM::GEOM_Object_var aGEOMObject;
654
655   //Set a not done flag
656   GetOperations()->SetNotDone();
657
658   //Get the reference objects
659   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
660   if (aShape.IsNull()) return aGEOMObject._retn();
661
662   //Create the Solid
663   Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
664   if (!GetOperations()->IsDone() || anObject.IsNull())
665     return aGEOMObject._retn();
666
667   return GetObject(anObject);
668 }
669
670 //=============================================================================
671 /*!
672  *  GetFreeFacesIDs
673  */
674 //=============================================================================
675 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
676 {
677   //Set a not done flag
678   GetOperations()->SetNotDone();
679
680   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
681
682   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
683   if (aShape.IsNull()) return aSeq._retn();
684
685   Handle(TColStd_HSequenceOfInteger) aHSeq =
686     GetOperations()->GetFreeFacesIDs(aShape);
687   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
688
689   Standard_Integer aLength = aHSeq->Length();
690   aSeq->length(aLength);
691   for (Standard_Integer i = 1; i <= aLength; i++)
692     aSeq[i-1] = aHSeq->Value(i);
693
694   return aSeq._retn();
695 }
696
697 //=============================================================================
698 /*!
699  *  GetSharedShapes
700  */
701 //=============================================================================
702 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
703                                           (GEOM::GEOM_Object_ptr theShape1,
704                                            GEOM::GEOM_Object_ptr theShape2,
705                                            const CORBA::Long     theShapeType)
706 {
707   //Set a not done flag
708   GetOperations()->SetNotDone();
709
710   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
711
712   Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
713   Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
714
715   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
716
717   Handle(TColStd_HSequenceOfTransient) aHSeq =
718     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
719   if (!GetOperations()->IsDone() || aHSeq.IsNull())
720     return aSeq._retn();
721
722   Standard_Integer aLength = aHSeq->Length();
723   aSeq->length(aLength);
724   for (Standard_Integer i = 1; i <= aLength; i++)
725     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
726
727   return aSeq._retn();
728 }
729
730 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
731 {
732   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
733
734   switch (theState) {
735   case GEOM::ST_ON:
736     aState = GEOMAlgo_ST_ON;
737     break;
738   case GEOM::ST_OUT:
739     aState = GEOMAlgo_ST_OUT;
740     break;
741   case GEOM::ST_ONOUT:
742     aState = GEOMAlgo_ST_ONOUT;
743     break;
744   case GEOM::ST_IN:
745     aState = GEOMAlgo_ST_IN;
746     break;
747   case GEOM::ST_ONIN:
748     aState = GEOMAlgo_ST_ONIN;
749     break;
750   default:
751     break;
752   }
753
754   return aState;
755 }
756
757 //=============================================================================
758 /*!
759  *  GetShapesOnPlane
760  */
761 //=============================================================================
762 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
763                                                 (GEOM::GEOM_Object_ptr   theShape,
764                                                  const CORBA::Long       theShapeType,
765                                                  GEOM::GEOM_Object_ptr   theAx1,
766                                                  const GEOM::shape_state theState)
767 {
768   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
769
770   //Set a not done flag
771   GetOperations()->SetNotDone();
772
773   //Get the reference objects
774   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
775   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
776
777   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
778
779   //Get Shapes On Plane
780   Handle(TColStd_HSequenceOfTransient) aHSeq =
781     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
782   if (!GetOperations()->IsDone() || aHSeq.IsNull())
783     return aSeq._retn();
784
785   Standard_Integer aLength = aHSeq->Length();
786   aSeq->length(aLength);
787   for (Standard_Integer i = 1; i <= aLength; i++)
788     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
789
790   return aSeq._retn();
791 }
792
793 //=============================================================================
794 /*!
795  *  GetShapesOnPlaneWithLocation
796  */
797 //=============================================================================
798 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
799                                                 (GEOM::GEOM_Object_ptr   theShape,
800                                                  const CORBA::Long       theShapeType,
801                                                  GEOM::GEOM_Object_ptr   theAx1,
802                                                  GEOM::GEOM_Object_ptr   thePnt,
803                                                  const GEOM::shape_state theState)
804 {
805   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
806
807   //Set a not done flag
808   GetOperations()->SetNotDone();
809
810   //Get the reference objects
811   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
812   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
813   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
814
815   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
816
817   //Get Shapes On Plane
818   Handle(TColStd_HSequenceOfTransient) aHSeq =
819     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
820   if (!GetOperations()->IsDone() || aHSeq.IsNull())
821     return aSeq._retn();
822
823   Standard_Integer aLength = aHSeq->Length();
824   aSeq->length(aLength);
825   for (Standard_Integer i = 1; i <= aLength; i++)
826     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
827
828   return aSeq._retn();
829 }
830
831 //=============================================================================
832 /*!
833  *  GetShapesOnCylinder
834  */
835 //=============================================================================
836 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
837                                                 (GEOM::GEOM_Object_ptr   theShape,
838                                                  const CORBA::Long       theShapeType,
839                                                  GEOM::GEOM_Object_ptr   theAxis,
840                                                  const CORBA::Double     theRadius,
841                                                  const GEOM::shape_state theState)
842 {
843   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
844
845   //Set a not done flag
846   GetOperations()->SetNotDone();
847
848   //Get the reference objects
849   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
850   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
851
852   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
853
854   //Get Shapes On Cylinder
855   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
856     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
857   if (!GetOperations()->IsDone() || aHSeq.IsNull())
858     return aSeq._retn();
859
860   Standard_Integer aLength = aHSeq->Length();
861   aSeq->length(aLength);
862   for (Standard_Integer i = 1; i <= aLength; i++)
863     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
864
865   return aSeq._retn();
866 }
867
868 //=============================================================================
869 /*!
870  *  GetShapesOnCylinderWithLocation
871  */
872 //=============================================================================
873 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
874                                                 (GEOM::GEOM_Object_ptr   theShape,
875                                                  const CORBA::Long       theShapeType,
876                                                  GEOM::GEOM_Object_ptr   theAxis,
877                                                  GEOM::GEOM_Object_ptr   thePnt,
878                                                  const CORBA::Double     theRadius,
879                                                  const GEOM::shape_state theState)
880 {
881   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
882
883   //Set a not done flag
884   GetOperations()->SetNotDone();
885
886   //Get the reference objects
887   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
888   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
889   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
890
891   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
892
893   //Get Shapes On Cylinder
894   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
895     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
896   if (!GetOperations()->IsDone() || aHSeq.IsNull())
897     return aSeq._retn();
898
899   Standard_Integer aLength = aHSeq->Length();
900   aSeq->length(aLength);
901   for (Standard_Integer i = 1; i <= aLength; i++)
902     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
903
904   return aSeq._retn();
905 }
906
907 //=============================================================================
908 /*!
909  *  GetShapesOnSphere
910  */
911 //=============================================================================
912 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
913                                                 (GEOM::GEOM_Object_ptr   theShape,
914                                                  const CORBA::Long       theShapeType,
915                                                  GEOM::GEOM_Object_ptr   theCenter,
916                                                  const CORBA::Double     theRadius,
917                                                  const GEOM::shape_state theState)
918 {
919   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
920
921   //Set a not done flag
922   GetOperations()->SetNotDone();
923
924   //Get the reference objects
925   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
926   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
927
928   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
929
930   //Get Shapes On Sphere
931   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
932     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
933   if (!GetOperations()->IsDone() || aHSeq.IsNull())
934     return aSeq._retn();
935
936   Standard_Integer aLength = aHSeq->Length();
937   aSeq->length(aLength);
938   for (Standard_Integer i = 1; i <= aLength; i++)
939     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
940
941   return aSeq._retn();
942 }
943
944 //=============================================================================
945 /*!
946  *  GetShapesOnQuadrangle
947  */
948 //=============================================================================
949 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
950                                                 (GEOM::GEOM_Object_ptr theShape,
951                                                  CORBA::Long           theShapeType,
952                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
953                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
954                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
955                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
956                                                  GEOM::shape_state     theState)
957 {
958   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
959
960   //Set a not done flag
961   GetOperations()->SetNotDone();
962
963   //Get the reference objects
964   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
965   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
966   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
967   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
968   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
969
970   if (aShape.IsNull() ||
971       aTopLeftPoint.IsNull() ||
972       aTopRigthPoint.IsNull() ||
973       aBottomLeftPoint.IsNull() ||
974       aBottomRigthPoint.IsNull())
975     return aSeq._retn();
976
977   //Get Shapes On Quadrangle
978   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
979     (aShape, theShapeType,
980      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
981      ShapeState(theState));
982   if (!GetOperations()->IsDone() || aHSeq.IsNull())
983     return aSeq._retn();
984
985   Standard_Integer aLength = aHSeq->Length();
986   aSeq->length(aLength);
987   for (Standard_Integer i = 1; i <= aLength; i++)
988     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
989
990   return aSeq._retn();
991 }
992
993 //=============================================================================
994 /*!
995  *  GetShapesOnPlaneIDs
996  */
997 //=============================================================================
998 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
999                                                 (GEOM::GEOM_Object_ptr   theShape,
1000                                                  const CORBA::Long       theShapeType,
1001                                                  GEOM::GEOM_Object_ptr   theAx1,
1002                                                  const GEOM::shape_state theState)
1003 {
1004   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1005
1006   //Set a not done flag
1007   GetOperations()->SetNotDone();
1008
1009   //Get the reference objects
1010   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1011   Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1012
1013   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1014
1015   //Get Shapes On Plane
1016   Handle(TColStd_HSequenceOfInteger) aHSeq =
1017     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, 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] = aHSeq->Value(i);
1025
1026   return aSeq._retn();
1027 }
1028
1029 //=============================================================================
1030 /*!
1031  *  GetShapesOnPlaneWithLocationIDs
1032  */
1033 //=============================================================================
1034 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1035                                                 (GEOM::GEOM_Object_ptr   theShape,
1036                                                  const CORBA::Long       theShapeType,
1037                                                  GEOM::GEOM_Object_ptr   theAx1,
1038                                                  GEOM::GEOM_Object_ptr   thePnt,
1039                                                  const GEOM::shape_state theState)
1040 {
1041   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
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) anAx1 = GetObjectImpl(theAx1);
1049   Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1050
1051   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1052
1053   //Get Shapes On Plane
1054   Handle(TColStd_HSequenceOfInteger) aHSeq =
1055     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1056                                                      anAx1, anPnt, ShapeState(theState));
1057   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1058     return aSeq._retn();
1059
1060   Standard_Integer aLength = aHSeq->Length();
1061   aSeq->length(aLength);
1062   for (Standard_Integer i = 1; i <= aLength; i++)
1063     aSeq[i-1] = aHSeq->Value(i);
1064
1065   return aSeq._retn();
1066 }
1067
1068 //=============================================================================
1069 /*!
1070  *  GetShapesOnCylinderIDs
1071  */
1072 //=============================================================================
1073 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1074                                                 (GEOM::GEOM_Object_ptr   theShape,
1075                                                  const CORBA::Long       theShapeType,
1076                                                  GEOM::GEOM_Object_ptr   theAxis,
1077                                                  const CORBA::Double     theRadius,
1078                                                  const GEOM::shape_state theState)
1079 {
1080   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
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) anAxis = GetObjectImpl(theAxis);
1088
1089   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1090
1091   //Get Shapes On Cylinder
1092   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1093     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1094   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1095     return aSeq._retn();
1096
1097   Standard_Integer aLength = aHSeq->Length();
1098   aSeq->length(aLength);
1099   for (Standard_Integer i = 1; i <= aLength; i++)
1100     aSeq[i-1] = aHSeq->Value(i);
1101
1102   return aSeq._retn();
1103 }
1104
1105 //=============================================================================
1106 /*!
1107  *  GetShapesOnCylinderWithLocationIDs
1108  */
1109 //=============================================================================
1110 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1111                                                 (GEOM::GEOM_Object_ptr   theShape,
1112                                                  const CORBA::Long       theShapeType,
1113                                                  GEOM::GEOM_Object_ptr   theAxis,
1114                                                  GEOM::GEOM_Object_ptr   thePnt,
1115                                                  const CORBA::Double     theRadius,
1116                                                  const GEOM::shape_state theState)
1117 {
1118   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1119
1120   //Set a not done flag
1121   GetOperations()->SetNotDone();
1122
1123   //Get the reference objects
1124   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1125   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1126   Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1127
1128   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1129
1130   //Get Shapes On Cylinder
1131   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1132     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1133   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1134     return aSeq._retn();
1135
1136   Standard_Integer aLength = aHSeq->Length();
1137   aSeq->length(aLength);
1138   for (Standard_Integer i = 1; i <= aLength; i++)
1139     aSeq[i-1] = aHSeq->Value(i);
1140
1141   return aSeq._retn();
1142 }
1143
1144 //=============================================================================
1145 /*!
1146  *  GetShapesOnSphereIDs
1147  */
1148 //=============================================================================
1149 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1150                                                 (GEOM::GEOM_Object_ptr   theShape,
1151                                                  const CORBA::Long       theShapeType,
1152                                                  GEOM::GEOM_Object_ptr   theCenter,
1153                                                  const CORBA::Double     theRadius,
1154                                                  const GEOM::shape_state theState)
1155 {
1156   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1157
1158   //Set a not done flag
1159   GetOperations()->SetNotDone();
1160
1161   //Get the reference objects
1162   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1163   Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1164
1165   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1166
1167   //Get Shapes On Sphere
1168   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1169     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1170   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1171     return aSeq._retn();
1172
1173   Standard_Integer aLength = aHSeq->Length();
1174   aSeq->length(aLength);
1175   for (Standard_Integer i = 1; i <= aLength; i++)
1176     aSeq[i-1] = aHSeq->Value(i);
1177
1178   return aSeq._retn();
1179 }
1180
1181 //=============================================================================
1182 /*!
1183  *  GetShapesOnQuadrangleIDs
1184  */
1185 //=============================================================================
1186 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1187                                                 (GEOM::GEOM_Object_ptr theShape,
1188                                                  CORBA::Long           theShapeType,
1189                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1190                                                  GEOM::GEOM_Object_ptr theTopRigthPoint,
1191                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1192                                                  GEOM::GEOM_Object_ptr theBottomRigthPoint,
1193                                                  GEOM::shape_state     theState)
1194 {
1195   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1196
1197   //Set a not done flag
1198   GetOperations()->SetNotDone();
1199
1200   //Get the reference objects
1201   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1202   Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1203   Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1204   Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1205   Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1206
1207   if (aShape.IsNull() ||
1208       aTopLeftPoint.IsNull() ||
1209       aTopRigthPoint.IsNull() ||
1210       aBottomLeftPoint.IsNull() ||
1211       aBottomRigthPoint.IsNull() )
1212     return aSeq._retn();
1213
1214   //Get Shapes On Quadrangle
1215   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1216     (aShape, theShapeType,
1217      aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1218      ShapeState(theState));
1219   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1220     return aSeq._retn();
1221
1222   Standard_Integer aLength = aHSeq->Length();
1223   aSeq->length(aLength);
1224   for (Standard_Integer i = 1; i <= aLength; i++)
1225     aSeq[i-1] = aHSeq->Value(i);
1226
1227   return aSeq._retn();
1228 }
1229
1230 //=============================================================================
1231 /*!
1232  *  GetShapesOnBox
1233  */
1234 //=============================================================================
1235 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1236                                                 (GEOM::GEOM_Object_ptr theBox,
1237                                                  GEOM::GEOM_Object_ptr theShape,
1238                                                  CORBA::Long           theShapeType,
1239                                                  GEOM::shape_state     theState)
1240 {
1241   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1242
1243   //Set a not done flag
1244   GetOperations()->SetNotDone();
1245
1246   //Get the reference objects
1247   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1248   Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1249
1250   if (aShape.IsNull() || aBox.IsNull() )
1251     return aSeq._retn();
1252
1253   //Get Shapes On Box
1254   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1255     (aBox,aShape, theShapeType,ShapeState(theState));
1256   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1257     return aSeq._retn();
1258
1259   Standard_Integer aLength = aHSeq->Length();
1260   aSeq->length(aLength);
1261   for (Standard_Integer i = 1; i <= aLength; i++)
1262     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1263
1264   return aSeq._retn();
1265 }
1266
1267 //=============================================================================
1268 /*!
1269  *  GetShapesOnQuadrangleIDs
1270  */
1271 //=============================================================================
1272 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1273                                                 (GEOM::GEOM_Object_ptr theBox,
1274                                                  GEOM::GEOM_Object_ptr theShape,
1275                                                  CORBA::Long           theShapeType,
1276                                                  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) aBox = GetObjectImpl(theBox);
1286
1287   if (aShape.IsNull() || aBox.IsNull() )
1288     return aSeq._retn();
1289
1290   //Get Shapes On Box
1291   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1292     (aBox,aShape, theShapeType,ShapeState(theState));
1293   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1294     return aSeq._retn();
1295
1296   Standard_Integer aLength = aHSeq->Length();
1297   aSeq->length(aLength);
1298   for (Standard_Integer i = 1; i <= aLength; i++)
1299     aSeq[i-1] = aHSeq->Value(i);
1300
1301   return aSeq._retn();
1302 }
1303
1304
1305 //=============================================================================
1306 /*!
1307  *  GetShapesOnShape
1308  */
1309 //=============================================================================
1310 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1311                                            (GEOM::GEOM_Object_ptr theCheckShape,
1312                                             GEOM::GEOM_Object_ptr theShape,
1313                                             CORBA::Short          theShapeType,
1314                                             GEOM::shape_state     theState)
1315 {
1316   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1317
1318   //Set a not done flag
1319   GetOperations()->SetNotDone();
1320
1321   //Get the reference objects
1322   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1323   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1324
1325   if (aShape.IsNull() || aCheckShape.IsNull() )
1326     return aSeq._retn();
1327
1328   //Get Shapes On Shape
1329   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1330     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1331
1332   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1333     return aSeq._retn();
1334
1335   Standard_Integer aLength = aHSeq->Length();
1336   aSeq->length(aLength);
1337   for (Standard_Integer i = 1; i <= aLength; i++)
1338     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1339
1340   return aSeq._retn();
1341 }
1342
1343
1344 //=============================================================================
1345 /*!
1346  *  GetShapesOnShapeAsCompound
1347  */
1348 //=============================================================================
1349 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1350                                            (GEOM::GEOM_Object_ptr theCheckShape,
1351                                             GEOM::GEOM_Object_ptr theShape,
1352                                             CORBA::Short          theShapeType,
1353                                             GEOM::shape_state     theState)
1354 {
1355   GEOM::GEOM_Object_var aGEOMObject;
1356
1357   //Set a not done flag
1358   GetOperations()->SetNotDone();
1359
1360   //Get the reference objects
1361   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1362   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1363
1364   if (aShape.IsNull() || aCheckShape.IsNull() )
1365     return aGEOMObject._retn();
1366
1367   //Get Shapes On Shape
1368   Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1369     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1370
1371   if (anObject.IsNull())
1372     return aGEOMObject._retn();
1373
1374   return GetObject(anObject);
1375 }
1376
1377
1378 //=============================================================================
1379 /*!
1380  *  GetShapesOnShapeIDs
1381  */
1382 //=============================================================================
1383 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1384                                            (GEOM::GEOM_Object_ptr theCheckShape,
1385                                             GEOM::GEOM_Object_ptr theShape,
1386                                             CORBA::Short          theShapeType,
1387                                             GEOM::shape_state     theState)
1388 {
1389   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1390
1391   //Set a not done flag
1392   GetOperations()->SetNotDone();
1393
1394   //Get the reference objects
1395   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1396   Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1397
1398   if (aShape.IsNull() || aCheckShape.IsNull() )
1399     return aSeq._retn();
1400
1401   //Get Shapes On Shape
1402   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1403     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1404   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1405     return aSeq._retn();
1406
1407   Standard_Integer aLength = aHSeq->Length();
1408   aSeq->length(aLength);
1409   for (Standard_Integer i = 1; i <= aLength; i++)
1410     aSeq[i-1] = aHSeq->Value(i);
1411
1412   return aSeq._retn();
1413 }
1414
1415
1416 //=============================================================================
1417 /*!
1418  *  GetInPlace
1419  */
1420 //=============================================================================
1421 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1422                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1423                                            GEOM::GEOM_Object_ptr theShapeWhat)
1424 {
1425   GEOM::GEOM_Object_var aGEOMObject;
1426
1427   //Set a not done flag
1428   GetOperations()->SetNotDone();
1429
1430   //Get the reference objects
1431   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1432   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1433
1434   if (aShapeWhere.IsNull() ||
1435       aShapeWhat.IsNull()) return aGEOMObject._retn();
1436
1437   //Get Shapes in place of aShapeWhat
1438   Handle(GEOM_Object) anObject =
1439     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1440   if (!GetOperations()->IsDone() || anObject.IsNull())
1441     return aGEOMObject._retn();
1442
1443   return GetObject(anObject);
1444 }
1445
1446 //=============================================================================
1447 /*!
1448  *  GetInPlaceByHistory
1449  */
1450 //=============================================================================
1451 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1452                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1453                                            GEOM::GEOM_Object_ptr theShapeWhat)
1454 {
1455   GEOM::GEOM_Object_var aGEOMObject;
1456
1457   //Set a not done flag
1458   GetOperations()->SetNotDone();
1459
1460   //Get the reference objects
1461   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1462   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1463
1464   if (aShapeWhere.IsNull() ||
1465       aShapeWhat.IsNull()) return aGEOMObject._retn();
1466
1467   //Get Shapes in place of aShapeWhat
1468   Handle(GEOM_Object) anObject =
1469     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1470   if (!GetOperations()->IsDone() || anObject.IsNull())
1471     return aGEOMObject._retn();
1472
1473   return GetObject(anObject);
1474 }
1475
1476 //=============================================================================
1477 /*!
1478  *  GetSame
1479  */
1480 //=============================================================================
1481 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1482                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1483                                            GEOM::GEOM_Object_ptr theShapeWhat)
1484 {
1485   GEOM::GEOM_Object_var aGEOMObject;
1486
1487   //Set a not done flag
1488   GetOperations()->SetNotDone();
1489
1490   //Get the reference objects
1491   Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1492   Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1493
1494   if (aShapeWhere.IsNull() ||
1495       aShapeWhat.IsNull()) return aGEOMObject._retn();
1496
1497   //Get Shapes in place of aShapeWhat
1498   Handle(GEOM_Object) anObject =
1499     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1500   if (!GetOperations()->IsDone() || anObject.IsNull())
1501     return aGEOMObject._retn();
1502
1503   return GetObject(anObject);
1504 }