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