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