Salome HOME
Unicode support
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_IShapesOperations_i.hh"
26
27 #include "utilities.h"
28 #include "OpUtil.hxx"
29 #include "Utils_ExceptHandlers.hxx"
30
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
33
34 #include <TopAbs.hxx>
35 #include <TColStd_HSequenceOfTransient.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
37
38 /**
39  * This function converts GEOM::comparison_condition type into
40  * GEOMUtils::ComparisonCondition type.
41  *
42  * \param theCondition the condition of GEOM::comparison_condition type
43  * \return the condition of GEOMUtils::ComparisonCondition type.
44  */
45 static GEOMUtils::ComparisonCondition ComparisonCondition
46                     (const GEOM::comparison_condition theCondition)
47 {
48   GEOMUtils::ComparisonCondition aResult = GEOMUtils::CC_GT;
49
50   switch (theCondition) {
51   case GEOM::CC_GE:
52     aResult = GEOMUtils::CC_GE;
53     break;
54   case GEOM::CC_LT:
55     aResult = GEOMUtils::CC_LT;
56     break;
57   case GEOM::CC_LE:
58     aResult = GEOMUtils::CC_LE;
59     break;
60   default:
61     break;
62   }
63
64   return aResult;
65 }
66
67 //=============================================================================
68 /*!
69  *   constructor:
70  */
71 //=============================================================================
72 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
73                                                     GEOM::GEOM_Gen_ptr theEngine,
74                                                     ::GEOMImpl_IShapesOperations* theImpl)
75 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
76 {
77   MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
78 }
79
80 //=============================================================================
81 /*!
82  *  destructor
83  */
84 //=============================================================================
85 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
86 {
87   MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
88 }
89
90
91 //=============================================================================
92 /*!
93  *  MakeEdge
94  */
95 //=============================================================================
96 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
97                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
98 {
99   GEOM::GEOM_Object_var aGEOMObject;
100
101   //Set a not done flag
102   GetOperations()->SetNotDone();
103
104   //Get the reference points
105   Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
106   Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
107
108   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
109
110   //Create the Edge
111   Handle(::GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
112   if (!GetOperations()->IsDone() || anObject.IsNull())
113     return aGEOMObject._retn();
114
115   return GetObject(anObject);
116 }
117
118 //=============================================================================
119 /*!
120  *  MakeEdgeOnCurveByLength
121  */
122 //=============================================================================
123 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
124                   (GEOM::GEOM_Object_ptr theCurve,
125                    CORBA::Double         theLength,
126                    GEOM::GEOM_Object_ptr theStartPoint)
127 {
128   GEOM::GEOM_Object_var aGEOMObject;
129
130   //Set a not done flag
131   GetOperations()->SetNotDone();
132
133   //Get the reference curve
134   Handle(::GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
135   if (aRefCurve.IsNull()) return aGEOMObject._retn();
136
137   //Get the reference point (can be NULL)
138   Handle(::GEOM_Object) aRefPoint;
139   if (!CORBA::is_nil(theStartPoint)) {
140     aRefPoint = GetObjectImpl(theStartPoint);
141   }
142
143   //Create the point
144   Handle(::GEOM_Object) anObject =
145     GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
146   if (!GetOperations()->IsDone() || anObject.IsNull())
147     return aGEOMObject._retn();
148
149   return GetObject(anObject);
150 }
151
152 //=============================================================================
153 /*!
154  *  MakeEdgeWire
155  */
156 //=============================================================================
157 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
158                       (GEOM::GEOM_Object_ptr theWire,
159                        const CORBA::Double theLinearTolerance,
160                        const CORBA::Double theAngularTolerance)
161 {
162   GEOM::GEOM_Object_var aGEOMObject;
163
164   //Set a not done flag
165   GetOperations()->SetNotDone();
166
167   //Get the source wire
168   Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
169
170   if (aWire.IsNull()) return aGEOMObject._retn();
171
172   //Create the Edge
173   Handle(::GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
174   if (!GetOperations()->IsDone() || anObject.IsNull())
175     return aGEOMObject._retn();
176
177   return GetObject(anObject);
178 }
179
180 //=============================================================================
181 /*!
182  *  MakeWire
183  */
184 //=============================================================================
185 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
186                            (const GEOM::ListOfGO& theEdgesAndWires,
187                             const CORBA::Double   theTolerance)
188 {
189   GEOM::GEOM_Object_var aGEOMObject;
190
191   //Set a not done flag
192   GetOperations()->SetNotDone();
193
194   int ind, aLen;
195   std::list<Handle(::GEOM_Object)> aShapes;
196
197   //Get the shapes
198   aLen = theEdgesAndWires.length();
199   for (ind = 0; ind < aLen; ind++) {
200     Handle(::GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
201     if (aSh.IsNull()) return aGEOMObject._retn();
202     aShapes.push_back(aSh);
203   }
204
205   // Make Solid
206   Handle(::GEOM_Object) anObject =
207     GetOperations()->MakeWire(aShapes, theTolerance);
208   if (!GetOperations()->IsDone() || anObject.IsNull())
209     return aGEOMObject._retn();
210
211   return GetObject(anObject);
212 }
213
214 //=============================================================================
215 /*!
216  *  MakeFace
217  */
218 //=============================================================================
219 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
220                       (GEOM::GEOM_Object_ptr theWire,
221                        const CORBA::Boolean  isPlanarWanted)
222 {
223   GEOM::GEOM_Object_var aGEOMObject;
224
225   //Set a not done flag
226   GetOperations()->SetNotDone();
227
228   //Get the reference wire
229   Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
230   if (aWire.IsNull()) return aGEOMObject._retn();
231
232   //Create the Face
233   Handle(::GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
234   //if (!GetOperations()->IsDone() || anObject.IsNull())
235   // enable warning status
236   if (anObject.IsNull())
237     return aGEOMObject._retn();
238
239   return GetObject(anObject);
240 }
241
242 //=============================================================================
243 /*!
244  *  MakeFaceWires
245  */
246 //=============================================================================
247 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
248                                          (const GEOM::ListOfGO& theWires,
249                                           const CORBA::Boolean  isPlanarWanted)
250 {
251   GEOM::GEOM_Object_var aGEOMObject;
252
253   //Set a not done flag
254   GetOperations()->SetNotDone();
255
256   int ind, aLen;
257   std::list<Handle(::GEOM_Object)> aShapes;
258
259   //Get the shapes
260   aLen = theWires.length();
261   for (ind = 0; ind < aLen; ind++) {
262     Handle(::GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
263     if (aSh.IsNull()) return aGEOMObject._retn();
264     aShapes.push_back(aSh);
265   }
266
267   // Make Face
268   Handle(::GEOM_Object) anObject =
269     GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
270   //if (!GetOperations()->IsDone() || anObject.IsNull())
271   // enable warning status
272   if (anObject.IsNull())
273     return aGEOMObject._retn();
274
275   return GetObject(anObject);
276 }
277
278 //=============================================================================
279 /*!
280  *  MakeFaceFromSurface
281  */
282 //=============================================================================
283 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceFromSurface
284                                   (GEOM::GEOM_Object_ptr theFace,
285                                    GEOM::GEOM_Object_ptr theWire)
286 {
287   GEOM::GEOM_Object_var aGEOMObject;
288
289   //Set a not done flag
290   GetOperations()->SetNotDone();
291
292   //Get the reference face and wire
293   Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
294   Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
295
296   if (aFace.IsNull() || aWire.IsNull()) {
297     return aGEOMObject._retn();
298   }
299
300   //Create the Face
301   Handle(::GEOM_Object) anObject =
302     GetOperations()->MakeFaceFromSurface(aFace, aWire);
303
304   if (anObject.IsNull()) {
305     return aGEOMObject._retn();
306   }
307
308   return GetObject(anObject);
309 }
310
311 //=============================================================================
312 /*!
313  *  MakeFaceWithConstraints
314  */
315 //=============================================================================
316 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWithConstraints
317                                                 (const GEOM::ListOfGO& theConstraints)
318 {
319   GEOM::GEOM_Object_var aGEOMObject;
320
321   //Set a not done flag
322   GetOperations()->SetNotDone();
323
324   //Get the shapes
325   std::list<Handle(::GEOM_Object)> aConstraints;
326   for( CORBA::ULong ind = 0; ind < theConstraints.length(); ind++ ) {
327     Handle(::GEOM_Object) anObject = GetObjectImpl( theConstraints[ind] );
328     aConstraints.push_back(anObject);
329   }
330
331   // Make Face
332   Handle(::GEOM_Object) anObject =
333     GetOperations()->MakeFaceWithConstraints( aConstraints );
334
335   // enable warning status
336   if (anObject.IsNull())
337     return aGEOMObject._retn();
338
339   return GetObject(anObject);
340 }
341
342 //=============================================================================
343 /*!
344  *  MakeShell
345  */
346 //=============================================================================
347 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
348                                       (const GEOM::ListOfGO& theFacesAndShells)
349 {
350   GEOM::GEOM_Object_var aGEOMObject;
351
352   //Set a not done flag
353   GetOperations()->SetNotDone();
354
355   int ind, aLen;
356   std::list<Handle(::GEOM_Object)> aShapes;
357
358   //Get the shapes
359   aLen = theFacesAndShells.length();
360   for (ind = 0; ind < aLen; ind++) {
361     Handle(::GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
362     if (aSh.IsNull()) return aGEOMObject._retn();
363     aShapes.push_back(aSh);
364   }
365
366   // Make Solid
367   Handle(::GEOM_Object) anObject =
368     GetOperations()->MakeShell(aShapes);
369   if (!GetOperations()->IsDone() || anObject.IsNull())
370     return aGEOMObject._retn();
371
372   return GetObject(anObject);
373 }
374
375 //=============================================================================
376 /*!
377  *  MakeSolidShell
378  */
379 //=============================================================================
380 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
381                                                 (GEOM::GEOM_Object_ptr theShell)
382 {
383   GEOM::GEOM_Object_var aGEOMObject;
384
385   //Set a not done flag
386   GetOperations()->SetNotDone();
387
388   //Get the reference objects
389   Handle(::GEOM_Object) aShell = GetObjectImpl(theShell);
390   if (aShell.IsNull()) return aGEOMObject._retn();
391
392   std::list<Handle(::GEOM_Object)> aShapes;
393   aShapes.push_back(aShell);
394
395   //Create the Solid
396   Handle(::GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
397   if (!GetOperations()->IsDone() || anObject.IsNull())
398     return aGEOMObject._retn();
399
400   return GetObject(anObject);
401 }
402
403 //=============================================================================
404 /*!
405  *  MakeSolidShells
406  */
407 //=============================================================================
408 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
409                                       (const GEOM::ListOfGO& theShells)
410 {
411   GEOM::GEOM_Object_var aGEOMObject;
412
413   //Set a not done flag
414   GetOperations()->SetNotDone();
415
416   int ind, aLen;
417   std::list<Handle(::GEOM_Object)> aShapes;
418
419   //Get the shapes
420   aLen = theShells.length();
421   for (ind = 0; ind < aLen; ind++) {
422     Handle(::GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
423     if (aSh.IsNull()) return aGEOMObject._retn();
424     aShapes.push_back(aSh);
425   }
426
427   // Make Solid
428   Handle(::GEOM_Object) anObject =
429     GetOperations()->MakeSolidShells(aShapes);
430   if (!GetOperations()->IsDone() || anObject.IsNull())
431     return aGEOMObject._retn();
432
433   return GetObject(anObject);
434 }
435
436 //=============================================================================
437 /*!
438  *  MakeCompound
439  */
440 //=============================================================================
441 GEOM::GEOM_Object_ptr
442 GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
443 {
444   GEOM::GEOM_Object_var aGEOMObject;
445
446   //Set a not done flag
447   GetOperations()->SetNotDone();
448
449   int ind, aLen;
450   std::list<Handle(::GEOM_Object)> aShapes;
451
452   //Get the shapes
453   aLen = theShapes.length();
454   for (ind = 0; ind < aLen; ind++) {
455     Handle(::GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
456     if (aSh.IsNull()) return aGEOMObject._retn();
457     aShapes.push_back(aSh);
458   }
459
460   // Make Solid
461   Handle(::GEOM_Object) anObject =
462     GetOperations()->MakeCompound(aShapes);
463   if (!GetOperations()->IsDone() || anObject.IsNull())
464     return aGEOMObject._retn();
465
466   return GetObject(anObject);
467 }
468
469 //=============================================================================
470 /*!
471  *  MakeSolidFromConnectedFaces
472  */
473 //=============================================================================
474 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidFromConnectedFaces
475                                       (const GEOM::ListOfGO& theFacesOrShells,
476                                        const CORBA::Boolean  isIntersect)
477 {
478   GEOM::GEOM_Object_var aGEOMObject;
479
480   //Set a not done flag
481   GetOperations()->SetNotDone();
482
483   int ind, aLen;
484   std::list<Handle(::GEOM_Object)> aShapes;
485
486   //Get the shapes
487   aLen = theFacesOrShells.length();
488   for (ind = 0; ind < aLen; ind++) {
489     ::Handle(::GEOM_Object) aSh = GetObjectImpl(theFacesOrShells[ind]);
490     if (aSh.IsNull()) return aGEOMObject._retn();
491     aShapes.push_back(aSh);
492   }
493
494   // Make Solid
495   Handle(::GEOM_Object) anObject =
496     GetOperations()->MakeSolidFromConnectedFaces(aShapes, isIntersect);
497   if (!GetOperations()->IsDone() || anObject.IsNull())
498     return aGEOMObject._retn();
499
500   return GetObject(anObject);
501 }
502
503 //=============================================================================
504 /*!
505  *  MakeGlueFaces
506  */
507 //=============================================================================
508 GEOM::GEOM_Object_ptr
509 GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
510                                          CORBA::Double         theTolerance,
511                                          CORBA::Boolean  doKeepNonSolids)
512 {
513   GEOM::GEOM_Object_var aGEOMObject;
514
515   //Set a not done flag
516   GetOperations()->SetNotDone();
517
518   //Get the reference objects
519   std::list< Handle(::GEOM_Object) > aShapes;
520   if (! GetListOfObjectsImpl( theShapes, aShapes ))
521     return aGEOMObject._retn();
522
523   //Perform the gluing
524   Handle(::GEOM_Object) anObject =
525     GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
526   //if (!GetOperations()->IsDone() || anObject.IsNull())
527   // to allow warning
528   if (anObject.IsNull())
529     return aGEOMObject._retn();
530
531   return GetObject(anObject);
532 }
533
534 //=============================================================================
535 /*!
536  *  GetGlueFaces
537  */
538 //=============================================================================
539 GEOM::ListOfGO*
540 GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
541                                         const CORBA::Double   theTolerance)
542 {
543   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
544
545   //Set a not done flag
546   GetOperations()->SetNotDone();
547
548   //Get the reference objects
549   std::list< Handle(::GEOM_Object) > aShapes;
550   if (! GetListOfObjectsImpl( theShapes, aShapes ))
551     return aSeq._retn();
552
553   Handle(TColStd_HSequenceOfTransient) aHSeq =
554     GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
555
556   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
557   // to allow warning
558   if(aHSeq.IsNull())
559     return aSeq._retn();
560
561   Standard_Integer aLength = aHSeq->Length();
562   aSeq->length(aLength);
563   for (Standard_Integer i = 1; i <= aLength; i++)
564     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
565
566   return aSeq._retn();
567 }
568
569 //=============================================================================
570 /*!
571  *  MakeGlueFacesByList
572  */
573 //=============================================================================
574 GEOM::GEOM_Object_ptr
575 GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
576                                                CORBA::Double         theTolerance,
577                                                const GEOM::ListOfGO& theFaces,
578                                                CORBA::Boolean        doKeepNonSolids,
579                                                CORBA::Boolean        doGlueAllEdges)
580 {
581   GEOM::GEOM_Object_var aGEOMObject;
582
583   //Set a not done flag
584   GetOperations()->SetNotDone();
585
586   //Get the reference objects
587   std::list< Handle(::GEOM_Object) > aShapes;
588   if (! GetListOfObjectsImpl( theShapes, aShapes ))
589     return aGEOMObject._retn();
590
591   //Get the shapes
592   std::list<Handle(::GEOM_Object)> aFaces;
593   if (! GetListOfObjectsImpl( theFaces, aFaces ))
594     return aGEOMObject._retn();
595
596   //Perform the gluing
597   Handle(::GEOM_Object) anObject =
598     GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
599                                          doKeepNonSolids, doGlueAllEdges);
600   //if (!GetOperations()->IsDone() || anObject.IsNull())
601   // to allow warning
602   if (anObject.IsNull())
603     return aGEOMObject._retn();
604
605   return GetObject(anObject);
606 }
607
608 //=============================================================================
609 /*!
610  *  MakeGlueEdges
611  */
612 //=============================================================================
613 GEOM::GEOM_Object_ptr
614 GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
615                                          CORBA::Double         theTolerance)
616 {
617   GEOM::GEOM_Object_var aGEOMObject;
618
619   //Set a not done flag
620   GetOperations()->SetNotDone();
621
622   //Get the reference objects
623   std::list< Handle(::GEOM_Object) > aShapes;
624   if (! GetListOfObjectsImpl( theShapes, aShapes ))
625     return aGEOMObject._retn();
626
627   //Perform the gluing
628   Handle(::GEOM_Object) anObject =
629     GetOperations()->MakeGlueEdges(aShapes, theTolerance);
630   //if (!GetOperations()->IsDone() || anObject.IsNull())
631   // to allow warning
632   if (anObject.IsNull())
633     return aGEOMObject._retn();
634
635   return GetObject(anObject);
636 }
637
638 //=============================================================================
639 /*!
640  *  GetGlueEdges
641  */
642 //=============================================================================
643 GEOM::ListOfGO*
644 GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
645                                         const CORBA::Double   theTolerance)
646 {
647   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
648
649   //Set a not done flag
650   GetOperations()->SetNotDone();
651
652   //Get the reference objects
653   std::list< Handle(::GEOM_Object) > aShapes;
654   if (! GetListOfObjectsImpl( theShapes, aShapes ))
655     return aSeq._retn();
656
657   Handle(TColStd_HSequenceOfTransient) aHSeq =
658     GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
659
660   //if (!GetOperations()->IsDone() || aHSeq.IsNull())
661   // to allow warning
662   if (aHSeq.IsNull())
663     return aSeq._retn();
664
665   Standard_Integer aLength = aHSeq->Length();
666   aSeq->length(aLength);
667   for (Standard_Integer i = 1; i <= aLength; i++)
668     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
669
670   return aSeq._retn();
671 }
672
673 //=============================================================================
674 /*!
675  *  MakeGlueEdgesByList
676  */
677 //=============================================================================
678 GEOM::GEOM_Object_ptr
679 GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
680                                                CORBA::Double         theTolerance,
681                                                const GEOM::ListOfGO& theEdges)
682 {
683   GEOM::GEOM_Object_var aGEOMObject;
684
685   //Set a not done flag
686   GetOperations()->SetNotDone();
687
688   //Get the reference objects
689   std::list< Handle(::GEOM_Object) > aShapes;
690   if (! GetListOfObjectsImpl( theShapes, aShapes ))
691     return aGEOMObject._retn();
692
693   //Get the shapes
694   std::list<Handle(::GEOM_Object)> anEdges;
695   if (! GetListOfObjectsImpl( theEdges, anEdges ))
696     return aGEOMObject._retn();
697
698   //Perform the gluing
699   Handle(::GEOM_Object) anObject =
700     GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
701   //if (!GetOperations()->IsDone() || anObject.IsNull())
702   // to allow warning
703   if (anObject.IsNull())
704     return aGEOMObject._retn();
705
706   return GetObject(anObject);
707 }
708
709 //=============================================================================
710 /*!
711  *  GetExistingSubObjects
712  */
713 //=============================================================================
714 GEOM::ListOfGO*
715 GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
716                                                  CORBA::Boolean        theGroupsOnly)
717 {
718   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
719
720   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
721   if (aShape.IsNull()) return aSeq._retn();
722
723   Handle(TColStd_HSequenceOfTransient) aHSeq =
724     GetOperations()->GetExistingSubObjects(aShape, (Standard_Boolean)theGroupsOnly);
725   if (!GetOperations()->IsDone() || aHSeq.IsNull())
726     return aSeq._retn();
727
728   Standard_Integer aLength = aHSeq->Length();
729   aSeq->length(aLength);
730   for (Standard_Integer i = 1; i <= aLength; i++)
731     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
732
733   return aSeq._retn();
734 }
735
736 //=============================================================================
737 /*!
738  *  MakeExplode (including theShape itself, bad sorting)
739  */
740 //=============================================================================
741 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
742                                                        const CORBA::Long     theShapeType,
743                                                        const CORBA::Boolean  isSorted)
744 {
745   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
746
747   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
748   if (aShape.IsNull()) return aSeq._retn();
749
750   Handle(TColStd_HSequenceOfTransient) aHSeq =
751     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
752                                  GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
753   if (!GetOperations()->IsDone() || aHSeq.IsNull())
754     return aSeq._retn();
755
756   Standard_Integer aLength = aHSeq->Length();
757   aSeq->length(aLength);
758   for (Standard_Integer i = 1; i <= aLength; i++)
759     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
760
761   return aSeq._retn();
762 }
763
764 //=============================================================================
765 /*!
766  *  MakeAllSubShapes (including theShape itself, good sorting)
767  */
768 //=============================================================================
769 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
770                                                             const CORBA::Long     theShapeType,
771                                                             const CORBA::Boolean  isSorted)
772 {
773   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
774
775   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
776   if (aShape.IsNull()) return aSeq._retn();
777
778   Handle(TColStd_HSequenceOfTransient) aHSeq =
779     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
780                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
781   if (!GetOperations()->IsDone() || aHSeq.IsNull())
782     return aSeq._retn();
783
784   Standard_Integer aLength = aHSeq->Length();
785   aSeq->length(aLength);
786   for (Standard_Integer i = 1; i <= aLength; i++)
787     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
788
789   return aSeq._retn();
790 }
791
792 //=============================================================================
793 /*!
794  *  ExtractSubShapes (excluding theShape itself, good sorting)
795  */
796 //=============================================================================
797 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
798                                                             const CORBA::Long     theShapeType,
799                                                             const CORBA::Boolean  isSorted)
800 {
801   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
802
803   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
804   if (aShape.IsNull()) return aSeq._retn();
805
806   Handle(TColStd_HSequenceOfTransient) aHSeq =
807     // TODO: enum instead of bool for the last argument
808     GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
809                                  GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
810   if (!GetOperations()->IsDone() || aHSeq.IsNull())
811     return aSeq._retn();
812
813   Standard_Integer aLength = aHSeq->Length();
814   aSeq->length(aLength);
815   for (Standard_Integer i = 1; i <= aLength; i++)
816     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
817
818   return aSeq._retn();
819 }
820
821 //=============================================================================
822 /*!
823  *  SubShapeAllIDs
824  */
825 //=============================================================================
826 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
827                                                             const CORBA::Long     theShapeType,
828                                                             const CORBA::Boolean  isSorted)
829 {
830   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
831
832   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
833   if (aShape.IsNull()) return aSeq._retn();
834
835   Handle(TColStd_HSequenceOfInteger) aHSeq =
836     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
837                                     GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
838   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
839
840   Standard_Integer aLength = aHSeq->Length();
841   aSeq->length(aLength);
842   for (Standard_Integer i = 1; i <= aLength; i++)
843     aSeq[i-1] = aHSeq->Value(i);
844
845   return aSeq._retn();
846 }
847
848 //=============================================================================
849 /*!
850  *  GetAllSubShapesIDs
851  */
852 //=============================================================================
853 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
854                                                                 const CORBA::Long     theShapeType,
855                                                                 const CORBA::Boolean  isSorted)
856 {
857   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
858
859   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
860   if (aShape.IsNull()) return aSeq._retn();
861
862   Handle(TColStd_HSequenceOfInteger) aHSeq =
863     GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
864                                     GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
865   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
866
867   Standard_Integer aLength = aHSeq->Length();
868   aSeq->length(aLength);
869   for (Standard_Integer i = 1; i <= aLength; i++)
870     aSeq[i-1] = aHSeq->Value(i);
871
872   return aSeq._retn();
873 }
874
875 //=============================================================================
876 /*!
877  *  GetSubShape
878  */
879 //=============================================================================
880 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
881                                            (GEOM::GEOM_Object_ptr theMainShape,
882                                             const CORBA::Long     theID)
883 {
884   GEOM::GEOM_Object_var aGEOMObject;
885
886   //Set a not done flag
887   GetOperations()->SetNotDone();
888
889   //Get the reference objects
890   Handle(::GEOM_Object) aShape = GetObjectImpl(theMainShape);
891   if (aShape.IsNull()) return aGEOMObject._retn();
892
893   Handle(::GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
894   if (!GetOperations()->IsDone() || anObject.IsNull())
895     return aGEOMObject._retn();
896
897   return GetObject(anObject);
898 }
899
900 //=============================================================================
901 /*!
902  *  MakeSubShapes
903  */
904 //=============================================================================
905 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
906                                                          const GEOM::ListOfLong& theIndices)
907 {
908   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
909
910   //Set a not done flag
911   GetOperations()->SetNotDone();
912
913   if (theIndices.length() < 1)
914     return aSeq._retn();
915
916   Handle(::GEOM_Object) aShape = GetObjectImpl(theMainShape);
917   if (aShape.IsNull()) return aSeq._retn();
918
919   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
920   for (CORBA::ULong i = 0; i < theIndices.length(); i++)
921     anArray->SetValue(i+1, theIndices[i]);
922
923   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
924   if (!GetOperations()->IsDone() || aHSeq.IsNull())
925     return aSeq._retn();
926
927   Standard_Integer aLength = aHSeq->Length();
928   aSeq->length(aLength);
929   for (int i = 0; i < aLength; i++)
930     aSeq[i] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i+1)));
931
932   return aSeq._retn();
933 }
934
935 //=============================================================================
936 /*!
937  *  GetSubShapeIndex
938  */
939 //=============================================================================
940 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
941   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
942 {
943   //Get the reference shapes
944   Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
945   Handle(::GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
946
947   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
948
949   //Get the unique ID of <theSubShape> inside <theMainShape>
950   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
951   if (!GetOperations()->IsDone())
952     return -1;
953
954   return anID;
955 }
956
957 //=============================================================================
958 /*!
959  *  GetSubShapesIndices
960  */
961 //=============================================================================
962 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
963   (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
964 {
965   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
966   
967   //Get the reference main shape
968   Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
969   if (aMainShapeRef.IsNull()) return aSeq._retn();
970       
971   //Get the subshapes
972   std::list<Handle(::GEOM_Object)> aShapes;
973   int aLen = theSubShapes.length();
974   for (int ind = 0; ind < aLen; ind++) {
975     Handle(::GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
976     if (aSh.IsNull())
977     {
978       MESSAGE("NULL shape")
979       return aSeq._retn();
980     }
981     aShapes.push_back(aSh);
982   }
983
984   //Get the IDs of <theSubShapes> inside <theMainShape>
985   Handle(TColStd_HSequenceOfInteger) aHSeq = 
986   GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
987   
988   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
989
990   Standard_Integer aLength = aHSeq->Length();
991   aSeq->length(aLength);
992   
993   for (Standard_Integer i = 1; i <= aLength; i++)
994     aSeq[i-1] = aHSeq->Value(i);
995
996   return aSeq._retn();
997 }
998
999
1000 //=============================================================================
1001 /*!
1002  *  GetTopologyIndex
1003  */
1004 //=============================================================================
1005 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
1006   (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
1007 {
1008   //Get the reference shapes
1009   Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
1010   Handle(::GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
1011
1012   if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
1013
1014   //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
1015   CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
1016   if (!GetOperations()->IsDone())
1017     return -1;
1018
1019   return anID;
1020 }
1021
1022 //=============================================================================
1023 /*!
1024  *  GetShapeTypeString
1025  */
1026 //=============================================================================
1027 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
1028 {
1029   //Get the reference shape
1030   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1031   if (aShape.IsNull()) return NULL;
1032
1033   // Get shape parameters
1034   TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
1035   return CORBA::string_dup(aDescription.ToCString());
1036 }
1037
1038 //=============================================================================
1039 /*!
1040  *  IsSubShapeBelongsTo
1041  */
1042 //=============================================================================
1043 CORBA::Boolean GEOM_IShapesOperations_i::IsSubShapeBelongsTo( GEOM::GEOM_Object_ptr theSubObject,
1044                                                               const CORBA::Long theSubObjectIndex,
1045                                                               GEOM::GEOM_Object_ptr theObject,
1046                                                               const CORBA::Long theObjectIndex)
1047 {
1048   Handle(::GEOM_Object) aSubObject = GetObjectImpl( theSubObject );
1049   Handle(::GEOM_Object) anObject = GetObjectImpl( theObject );
1050   if( anObject.IsNull() || aSubObject.IsNull() )
1051     return false;
1052
1053   // Get parameters
1054   return GetOperations()->IsSubShapeBelongsTo( aSubObject, theSubObjectIndex, anObject, theObjectIndex );
1055 }
1056
1057 //=============================================================================
1058 /*!
1059  *  NumberOfFaces
1060  */
1061 //=============================================================================
1062 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
1063 {
1064   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
1065 }
1066
1067 //=============================================================================
1068 /*!
1069  *  NumberOfEdges
1070  */
1071 //=============================================================================
1072 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
1073 {
1074   return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
1075 }
1076
1077 //=============================================================================
1078 /*!
1079  *  NumberOfSubShapes
1080  */
1081 //=============================================================================
1082 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
1083                                                          const CORBA::Long     theShapeType)
1084 {
1085   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1086   if (aShape.IsNull()) return -1;
1087
1088   CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
1089   if (!GetOperations()->IsDone()) return -1;
1090
1091   return aNb;
1092 }
1093
1094 //=============================================================================
1095 /*!
1096  *  ChangeOrientation
1097  */
1098 //=============================================================================
1099 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
1100                                                 (GEOM::GEOM_Object_ptr theShape)
1101 {
1102   GEOM::GEOM_Object_var aGEOMObject;
1103
1104   //Set a not done flag
1105   GetOperations()->SetNotDone();
1106
1107   //Get the reference objects
1108   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1109   if (aShape.IsNull()) return aGEOMObject._retn();
1110
1111   //Create the Solid
1112   Handle(::GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
1113   if (!GetOperations()->IsDone() || anObject.IsNull())
1114     return aGEOMObject._retn();
1115
1116   return GetObject(anObject);
1117 }
1118
1119 //=============================================================================
1120 /*!
1121  *  GetFreeFacesIDs
1122  */
1123 //=============================================================================
1124 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
1125 {
1126   //Set a not done flag
1127   GetOperations()->SetNotDone();
1128
1129   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1130
1131   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1132   if (aShape.IsNull()) return aSeq._retn();
1133
1134   Handle(TColStd_HSequenceOfInteger) aHSeq =
1135     GetOperations()->GetFreeFacesIDs(aShape);
1136   if (!GetOperations()->IsDone() || aHSeq.IsNull()) 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  *  GetSharedShapes
1149  */
1150 //=============================================================================
1151 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1152                                           (GEOM::GEOM_Object_ptr theShape1,
1153                                            GEOM::GEOM_Object_ptr theShape2,
1154                                            const CORBA::Long     theShapeType)
1155 {
1156   //Set a not done flag
1157   GetOperations()->SetNotDone();
1158
1159   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1160
1161   Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1162   Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1163
1164   if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1165
1166   Handle(TColStd_HSequenceOfTransient) aHSeq =
1167     GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1168   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1169     return aSeq._retn();
1170
1171   Standard_Integer aLength = aHSeq->Length();
1172   aSeq->length(aLength);
1173   for (Standard_Integer i = 1; i <= aLength; i++)
1174     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1175
1176   return aSeq._retn();
1177 }
1178
1179 //=============================================================================
1180 /*!
1181  *  GetSharedShapesMulti
1182  */
1183 //=============================================================================
1184 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1185                                           (const GEOM::ListOfGO& theShapes,
1186                                            const CORBA::Long     theShapeType,
1187                                            CORBA::Boolean        theMultiShare)
1188 {
1189   //Set a not done flag
1190   GetOperations()->SetNotDone();
1191
1192   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1193
1194   //Get the shapes
1195   std::list<Handle(::GEOM_Object)> aShapes;
1196   if (! GetListOfObjectsImpl( theShapes, aShapes ))
1197     return aSeq._retn();
1198
1199   Handle(TColStd_HSequenceOfTransient) aHSeq =
1200     GetOperations()->GetSharedShapes(aShapes, theShapeType, theMultiShare);
1201   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1202     return aSeq._retn();
1203
1204   Standard_Integer aLength = aHSeq->Length();
1205   aSeq->length(aLength);
1206   for (Standard_Integer i = 1; i <= aLength; i++)
1207     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1208
1209   return aSeq._retn();
1210 }
1211
1212 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1213 {
1214   GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1215
1216   switch (theState) {
1217   case GEOM::ST_ON:
1218     aState = GEOMAlgo_ST_ON;
1219     break;
1220   case GEOM::ST_OUT:
1221     aState = GEOMAlgo_ST_OUT;
1222     break;
1223   case GEOM::ST_ONOUT:
1224     aState = GEOMAlgo_ST_ONOUT;
1225     break;
1226   case GEOM::ST_IN:
1227     aState = GEOMAlgo_ST_IN;
1228     break;
1229   case GEOM::ST_ONIN:
1230     aState = GEOMAlgo_ST_ONIN;
1231     break;
1232   default:
1233     break;
1234   }
1235
1236   return aState;
1237 }
1238
1239 //=============================================================================
1240 /*!
1241  *  GetShapesOnPlane
1242  */
1243 //=============================================================================
1244 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1245                                                 (GEOM::GEOM_Object_ptr   theShape,
1246                                                  const CORBA::Long       theShapeType,
1247                                                  GEOM::GEOM_Object_ptr   theAx1,
1248                                                  const GEOM::shape_state theState)
1249 {
1250   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1251
1252   //Set a not done flag
1253   GetOperations()->SetNotDone();
1254
1255   //Get the reference objects
1256   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1257   Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1258
1259   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1260
1261   //Get Shapes On Plane
1262   Handle(TColStd_HSequenceOfTransient) aHSeq =
1263     GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1264   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1265     return aSeq._retn();
1266
1267   Standard_Integer aLength = aHSeq->Length();
1268   aSeq->length(aLength);
1269   for (Standard_Integer i = 1; i <= aLength; i++)
1270     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1271
1272   return aSeq._retn();
1273 }
1274
1275 //=============================================================================
1276 /*!
1277  *  GetShapesOnPlaneWithLocation
1278  */
1279 //=============================================================================
1280 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1281                                                 (GEOM::GEOM_Object_ptr   theShape,
1282                                                  const CORBA::Long       theShapeType,
1283                                                  GEOM::GEOM_Object_ptr   theAx1,
1284                                                  GEOM::GEOM_Object_ptr   thePnt,
1285                                                  const GEOM::shape_state theState)
1286 {
1287   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1288
1289   //Set a not done flag
1290   GetOperations()->SetNotDone();
1291
1292   //Get the reference objects
1293   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1294   Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1295   Handle(::GEOM_Object) anPnt = GetObjectImpl(thePnt);
1296
1297   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1298
1299   //Get Shapes On Plane
1300   Handle(TColStd_HSequenceOfTransient) aHSeq =
1301     GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1302   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1303     return aSeq._retn();
1304
1305   Standard_Integer aLength = aHSeq->Length();
1306   aSeq->length(aLength);
1307   for (Standard_Integer i = 1; i <= aLength; i++)
1308     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1309
1310   return aSeq._retn();
1311 }
1312
1313 //=============================================================================
1314 /*!
1315  *  GetShapesOnCylinder
1316  */
1317 //=============================================================================
1318 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1319                                                 (GEOM::GEOM_Object_ptr   theShape,
1320                                                  const CORBA::Long       theShapeType,
1321                                                  GEOM::GEOM_Object_ptr   theAxis,
1322                                                  const CORBA::Double     theRadius,
1323                                                  const GEOM::shape_state theState)
1324 {
1325   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1326
1327   //Set a not done flag
1328   GetOperations()->SetNotDone();
1329
1330   //Get the reference objects
1331   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1332   Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1333
1334   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1335
1336   //Get Shapes On Cylinder
1337   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1338     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1339   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1340     return aSeq._retn();
1341
1342   Standard_Integer aLength = aHSeq->Length();
1343   aSeq->length(aLength);
1344   for (Standard_Integer i = 1; i <= aLength; i++)
1345     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1346
1347   return aSeq._retn();
1348 }
1349
1350 //=============================================================================
1351 /*!
1352  *  GetShapesOnCylinderWithLocation
1353  */
1354 //=============================================================================
1355 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1356                                                 (GEOM::GEOM_Object_ptr   theShape,
1357                                                  const CORBA::Long       theShapeType,
1358                                                  GEOM::GEOM_Object_ptr   theAxis,
1359                                                  GEOM::GEOM_Object_ptr   thePnt,
1360                                                  const CORBA::Double     theRadius,
1361                                                  const GEOM::shape_state theState)
1362 {
1363   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1364
1365   //Set a not done flag
1366   GetOperations()->SetNotDone();
1367
1368   //Get the reference objects
1369   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1370   Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1371   Handle(::GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1372
1373   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1374
1375   //Get Shapes On Cylinder
1376   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1377     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1378   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1379     return aSeq._retn();
1380
1381   Standard_Integer aLength = aHSeq->Length();
1382   aSeq->length(aLength);
1383   for (Standard_Integer i = 1; i <= aLength; i++)
1384     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1385
1386   return aSeq._retn();
1387 }
1388
1389 //=============================================================================
1390 /*!
1391  *  GetShapesOnSphere
1392  */
1393 //=============================================================================
1394 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1395                                                 (GEOM::GEOM_Object_ptr   theShape,
1396                                                  const CORBA::Long       theShapeType,
1397                                                  GEOM::GEOM_Object_ptr   theCenter,
1398                                                  const CORBA::Double     theRadius,
1399                                                  const GEOM::shape_state theState)
1400 {
1401   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1402
1403   //Set a not done flag
1404   GetOperations()->SetNotDone();
1405
1406   //Get the reference objects
1407   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1408   Handle(::GEOM_Object) aCenter = GetObjectImpl(theCenter);
1409
1410   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1411
1412   //Get Shapes On Sphere
1413   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1414     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1415   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1416     return aSeq._retn();
1417
1418   Standard_Integer aLength = aHSeq->Length();
1419   aSeq->length(aLength);
1420   for (Standard_Integer i = 1; i <= aLength; i++)
1421     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1422
1423   return aSeq._retn();
1424 }
1425
1426 //=============================================================================
1427 /*!
1428  *  GetShapesOnQuadrangle
1429  */
1430 //=============================================================================
1431 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1432                                                 (GEOM::GEOM_Object_ptr theShape,
1433                                                  CORBA::Long           theShapeType,
1434                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1435                                                  GEOM::GEOM_Object_ptr theTopRightPoint,
1436                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1437                                                  GEOM::GEOM_Object_ptr theBottomRightPoint,
1438                                                  GEOM::shape_state     theState)
1439 {
1440   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1441
1442   //Set a not done flag
1443   GetOperations()->SetNotDone();
1444
1445   //Get the reference objects
1446   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1447   Handle(::GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1448   Handle(::GEOM_Object) aTopRightPoint = GetObjectImpl(theTopRightPoint);
1449   Handle(::GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1450   Handle(::GEOM_Object) aBottomRightPoint = GetObjectImpl(theBottomRightPoint);
1451
1452   if (aShape.IsNull() ||
1453       aTopLeftPoint.IsNull() ||
1454       aTopRightPoint.IsNull() ||
1455       aBottomLeftPoint.IsNull() ||
1456       aBottomRightPoint.IsNull())
1457     return aSeq._retn();
1458
1459   //Get Shapes On Quadrangle
1460   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1461     (aShape, theShapeType,
1462      aTopLeftPoint, aTopRightPoint, aBottomLeftPoint, aBottomRightPoint,
1463      ShapeState(theState));
1464   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1465     return aSeq._retn();
1466
1467   Standard_Integer aLength = aHSeq->Length();
1468   aSeq->length(aLength);
1469   for (Standard_Integer i = 1; i <= aLength; i++)
1470     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1471
1472   return aSeq._retn();
1473 }
1474
1475 //=============================================================================
1476 /*!
1477  *  GetShapesOnPlaneIDs
1478  */
1479 //=============================================================================
1480 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1481                                                 (GEOM::GEOM_Object_ptr   theShape,
1482                                                  const CORBA::Long       theShapeType,
1483                                                  GEOM::GEOM_Object_ptr   theAx1,
1484                                                  const GEOM::shape_state theState)
1485 {
1486   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1487
1488   //Set a not done flag
1489   GetOperations()->SetNotDone();
1490
1491   //Get the reference objects
1492   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1493   Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1494
1495   if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1496
1497   //Get Shapes On Plane
1498   Handle(TColStd_HSequenceOfInteger) aHSeq =
1499     GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1500   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1501     return aSeq._retn();
1502
1503   Standard_Integer aLength = aHSeq->Length();
1504   aSeq->length(aLength);
1505   for (Standard_Integer i = 1; i <= aLength; i++)
1506     aSeq[i-1] = aHSeq->Value(i);
1507
1508   return aSeq._retn();
1509 }
1510
1511 //=============================================================================
1512 /*!
1513  *  GetShapesOnPlaneWithLocationIDs
1514  */
1515 //=============================================================================
1516 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1517                                                 (GEOM::GEOM_Object_ptr   theShape,
1518                                                  const CORBA::Long       theShapeType,
1519                                                  GEOM::GEOM_Object_ptr   theAx1,
1520                                                  GEOM::GEOM_Object_ptr   thePnt,
1521                                                  const GEOM::shape_state theState)
1522 {
1523   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1524
1525   //Set a not done flag
1526   GetOperations()->SetNotDone();
1527
1528   //Get the reference objects
1529   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1530   Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1531   Handle(::GEOM_Object) anPnt = GetObjectImpl(thePnt);
1532
1533   if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1534
1535   //Get Shapes On Plane
1536   Handle(TColStd_HSequenceOfInteger) aHSeq =
1537     GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1538                                                      anAx1, anPnt, ShapeState(theState));
1539   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1540     return aSeq._retn();
1541
1542   Standard_Integer aLength = aHSeq->Length();
1543   aSeq->length(aLength);
1544   for (Standard_Integer i = 1; i <= aLength; i++)
1545     aSeq[i-1] = aHSeq->Value(i);
1546
1547   return aSeq._retn();
1548 }
1549
1550 //=============================================================================
1551 /*!
1552  *  GetShapesOnCylinderIDs
1553  */
1554 //=============================================================================
1555 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1556                                                 (GEOM::GEOM_Object_ptr   theShape,
1557                                                  const CORBA::Long       theShapeType,
1558                                                  GEOM::GEOM_Object_ptr   theAxis,
1559                                                  const CORBA::Double     theRadius,
1560                                                  const GEOM::shape_state theState)
1561 {
1562   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1563
1564   //Set a not done flag
1565   GetOperations()->SetNotDone();
1566
1567   //Get the reference objects
1568   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1569   Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1570
1571   if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1572
1573   //Get Shapes On Cylinder
1574   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1575     (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1576   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1577     return aSeq._retn();
1578
1579   Standard_Integer aLength = aHSeq->Length();
1580   aSeq->length(aLength);
1581   for (Standard_Integer i = 1; i <= aLength; i++)
1582     aSeq[i-1] = aHSeq->Value(i);
1583
1584   return aSeq._retn();
1585 }
1586
1587 //=============================================================================
1588 /*!
1589  *  GetShapesOnCylinderWithLocationIDs
1590  */
1591 //=============================================================================
1592 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1593                                                 (GEOM::GEOM_Object_ptr   theShape,
1594                                                  const CORBA::Long       theShapeType,
1595                                                  GEOM::GEOM_Object_ptr   theAxis,
1596                                                  GEOM::GEOM_Object_ptr   thePnt,
1597                                                  const CORBA::Double     theRadius,
1598                                                  const GEOM::shape_state theState)
1599 {
1600   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1601
1602   //Set a not done flag
1603   GetOperations()->SetNotDone();
1604
1605   //Get the reference objects
1606   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1607   Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1608   Handle(::GEOM_Object) aPnt   = GetObjectImpl(thePnt);
1609
1610   if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1611
1612   //Get Shapes On Cylinder
1613   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1614     (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1615   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1616     return aSeq._retn();
1617
1618   Standard_Integer aLength = aHSeq->Length();
1619   aSeq->length(aLength);
1620   for (Standard_Integer i = 1; i <= aLength; i++)
1621     aSeq[i-1] = aHSeq->Value(i);
1622
1623   return aSeq._retn();
1624 }
1625
1626 //=============================================================================
1627 /*!
1628  *  GetShapesOnSphereIDs
1629  */
1630 //=============================================================================
1631 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1632                                                 (GEOM::GEOM_Object_ptr   theShape,
1633                                                  const CORBA::Long       theShapeType,
1634                                                  GEOM::GEOM_Object_ptr   theCenter,
1635                                                  const CORBA::Double     theRadius,
1636                                                  const GEOM::shape_state theState)
1637 {
1638   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1639
1640   //Set a not done flag
1641   GetOperations()->SetNotDone();
1642
1643   //Get the reference objects
1644   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1645   Handle(::GEOM_Object) aCenter = GetObjectImpl(theCenter);
1646
1647   if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1648
1649   //Get Shapes On Sphere
1650   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1651     (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1652   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1653     return aSeq._retn();
1654
1655   Standard_Integer aLength = aHSeq->Length();
1656   aSeq->length(aLength);
1657   for (Standard_Integer i = 1; i <= aLength; i++)
1658     aSeq[i-1] = aHSeq->Value(i);
1659
1660   return aSeq._retn();
1661 }
1662
1663 //=============================================================================
1664 /*!
1665  *  GetShapesOnQuadrangleIDs
1666  */
1667 //=============================================================================
1668 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1669                                                 (GEOM::GEOM_Object_ptr theShape,
1670                                                  CORBA::Long           theShapeType,
1671                                                  GEOM::GEOM_Object_ptr theTopLeftPoint,
1672                                                  GEOM::GEOM_Object_ptr theTopRightPoint,
1673                                                  GEOM::GEOM_Object_ptr theBottomLeftPoint,
1674                                                  GEOM::GEOM_Object_ptr theBottomRightPoint,
1675                                                  GEOM::shape_state     theState)
1676 {
1677   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1678
1679   //Set a not done flag
1680   GetOperations()->SetNotDone();
1681
1682   //Get the reference objects
1683   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1684   Handle(::GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1685   Handle(::GEOM_Object) aTopRightPoint = GetObjectImpl(theTopRightPoint);
1686   Handle(::GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1687   Handle(::GEOM_Object) aBottomRightPoint = GetObjectImpl(theBottomRightPoint);
1688
1689   if (aShape.IsNull() ||
1690       aTopLeftPoint.IsNull() ||
1691       aTopRightPoint.IsNull() ||
1692       aBottomLeftPoint.IsNull() ||
1693       aBottomRightPoint.IsNull() )
1694     return aSeq._retn();
1695
1696   //Get Shapes On Quadrangle
1697   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1698     (aShape, theShapeType,
1699      aTopLeftPoint, aTopRightPoint, aBottomLeftPoint, aBottomRightPoint,
1700      ShapeState(theState));
1701   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1702     return aSeq._retn();
1703
1704   Standard_Integer aLength = aHSeq->Length();
1705   aSeq->length(aLength);
1706   for (Standard_Integer i = 1; i <= aLength; i++)
1707     aSeq[i-1] = aHSeq->Value(i);
1708
1709   return aSeq._retn();
1710 }
1711
1712 //=============================================================================
1713 /*!
1714  *  GetShapesOnBox
1715  */
1716 //=============================================================================
1717 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1718                                                 (GEOM::GEOM_Object_ptr theBox,
1719                                                  GEOM::GEOM_Object_ptr theShape,
1720                                                  CORBA::Long           theShapeType,
1721                                                  GEOM::shape_state     theState)
1722 {
1723   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1724
1725   //Set a not done flag
1726   GetOperations()->SetNotDone();
1727
1728   //Get the reference objects
1729   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1730   Handle(::GEOM_Object) aBox = GetObjectImpl(theBox);
1731
1732   if (aShape.IsNull() || aBox.IsNull() )
1733     return aSeq._retn();
1734
1735   //Get Shapes On Box
1736   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1737     (aBox,aShape, theShapeType,ShapeState(theState));
1738   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1739     return aSeq._retn();
1740
1741   Standard_Integer aLength = aHSeq->Length();
1742   aSeq->length(aLength);
1743   for (Standard_Integer i = 1; i <= aLength; i++)
1744     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1745
1746   return aSeq._retn();
1747 }
1748
1749 //=============================================================================
1750 /*!
1751  *  GetShapesOnQuadrangleIDs
1752  */
1753 //=============================================================================
1754 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1755                                                 (GEOM::GEOM_Object_ptr theBox,
1756                                                  GEOM::GEOM_Object_ptr theShape,
1757                                                  CORBA::Long           theShapeType,
1758                                                  GEOM::shape_state     theState)
1759 {
1760   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1761
1762   //Set a not done flag
1763   GetOperations()->SetNotDone();
1764
1765   //Get the reference objects
1766   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1767   Handle(::GEOM_Object) aBox = GetObjectImpl(theBox);
1768
1769   if (aShape.IsNull() || aBox.IsNull() )
1770     return aSeq._retn();
1771
1772   //Get Shapes On Box
1773   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1774     (aBox,aShape, theShapeType,ShapeState(theState));
1775   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1776     return aSeq._retn();
1777
1778   Standard_Integer aLength = aHSeq->Length();
1779   aSeq->length(aLength);
1780   for (Standard_Integer i = 1; i <= aLength; i++)
1781     aSeq[i-1] = aHSeq->Value(i);
1782
1783   return aSeq._retn();
1784 }
1785
1786
1787 //=============================================================================
1788 /*!
1789  *  GetShapesOnShape
1790  */
1791 //=============================================================================
1792 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1793                                            (GEOM::GEOM_Object_ptr theCheckShape,
1794                                             GEOM::GEOM_Object_ptr theShape,
1795                                             CORBA::Short          theShapeType,
1796                                             GEOM::shape_state     theState)
1797 {
1798   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1799
1800   //Set a not done flag
1801   GetOperations()->SetNotDone();
1802
1803   //Get the reference objects
1804   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1805   Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1806
1807   if (aShape.IsNull() || aCheckShape.IsNull() )
1808     return aSeq._retn();
1809
1810   //Get Shapes On Shape
1811   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1812     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1813
1814   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1815     return aSeq._retn();
1816
1817   Standard_Integer aLength = aHSeq->Length();
1818   aSeq->length(aLength);
1819   for (Standard_Integer i = 1; i <= aLength; i++)
1820     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1821
1822   return aSeq._retn();
1823 }
1824
1825
1826 //=============================================================================
1827 /*!
1828  *  GetShapesOnShapeAsCompound
1829  */
1830 //=============================================================================
1831 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1832                                            (GEOM::GEOM_Object_ptr theCheckShape,
1833                                             GEOM::GEOM_Object_ptr theShape,
1834                                             CORBA::Short          theShapeType,
1835                                             GEOM::shape_state     theState)
1836 {
1837   GEOM::GEOM_Object_var aGEOMObject;
1838
1839   //Set a not done flag
1840   GetOperations()->SetNotDone();
1841
1842   //Get the reference objects
1843   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1844   Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1845
1846   if (aShape.IsNull() || aCheckShape.IsNull() )
1847     return aGEOMObject._retn();
1848
1849   //Get Shapes On Shape
1850   Handle(::GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1851     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1852
1853   if (anObject.IsNull())
1854     return aGEOMObject._retn();
1855
1856   return GetObject(anObject);
1857 }
1858
1859
1860 //=============================================================================
1861 /*!
1862  *  GetShapesOnShapeIDs
1863  */
1864 //=============================================================================
1865 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1866                                            (GEOM::GEOM_Object_ptr theCheckShape,
1867                                             GEOM::GEOM_Object_ptr theShape,
1868                                             CORBA::Short          theShapeType,
1869                                             GEOM::shape_state     theState)
1870 {
1871   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1872
1873   //Set a not done flag
1874   GetOperations()->SetNotDone();
1875
1876   //Get the reference objects
1877   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1878   Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1879
1880   if (aShape.IsNull() || aCheckShape.IsNull() )
1881     return aSeq._retn();
1882
1883   //Get Shapes On Shape
1884   Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1885     (aCheckShape,aShape, theShapeType,ShapeState(theState));
1886   if (!GetOperations()->IsDone() || aHSeq.IsNull())
1887     return aSeq._retn();
1888
1889   Standard_Integer aLength = aHSeq->Length();
1890   aSeq->length(aLength);
1891   for (Standard_Integer i = 1; i <= aLength; i++)
1892     aSeq[i-1] = aHSeq->Value(i);
1893
1894   return aSeq._retn();
1895 }
1896
1897
1898 //=============================================================================
1899 /*!
1900  *  GetInPlace
1901  */
1902 //=============================================================================
1903 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1904                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1905                                            GEOM::GEOM_Object_ptr theShapeWhat)
1906 {
1907   GEOM::GEOM_Object_var aGEOMObject;
1908
1909   //Set a not done flag
1910   GetOperations()->SetNotDone();
1911
1912   //Get the reference objects
1913   Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1914   Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1915
1916   if (aShapeWhere.IsNull() ||
1917       aShapeWhat.IsNull()) return aGEOMObject._retn();
1918
1919   //Get Shapes in place of aShapeWhat
1920   Handle(::GEOM_Object) anObject =
1921     GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1922   if (!GetOperations()->IsDone() || anObject.IsNull())
1923     return aGEOMObject._retn();
1924
1925   return GetObject(anObject);
1926 }
1927
1928 //=============================================================================
1929 /*!
1930  *  GetInPlaceOld
1931  */
1932 //=============================================================================
1933 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1934                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1935                                            GEOM::GEOM_Object_ptr theShapeWhat)
1936 {
1937   GEOM::GEOM_Object_var aGEOMObject;
1938
1939   //Set a not done flag
1940   GetOperations()->SetNotDone();
1941
1942   //Get the reference objects
1943   Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1944   Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1945
1946   if (aShapeWhere.IsNull() ||
1947       aShapeWhat.IsNull()) return aGEOMObject._retn();
1948
1949   //Get Shapes in place of aShapeWhat
1950   Handle(::GEOM_Object) anObject =
1951     GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1952   if (!GetOperations()->IsDone() || anObject.IsNull())
1953     return aGEOMObject._retn();
1954
1955   return GetObject(anObject);
1956 }
1957
1958 //=============================================================================
1959 /*!
1960  *  GetInPlaceByHistory
1961  */
1962 //=============================================================================
1963 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1964                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1965                                            GEOM::GEOM_Object_ptr theShapeWhat)
1966 {
1967   GEOM::GEOM_Object_var aGEOMObject;
1968
1969   //Set a not done flag
1970   GetOperations()->SetNotDone();
1971
1972   //Get the reference objects
1973   Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1974   Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1975
1976   if (aShapeWhere.IsNull() ||
1977       aShapeWhat.IsNull()) return aGEOMObject._retn();
1978
1979   //Get Shapes in place of aShapeWhat
1980   Handle(::GEOM_Object) anObject =
1981     GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1982   if (!GetOperations()->IsDone() || anObject.IsNull())
1983     return aGEOMObject._retn();
1984
1985   return GetObject(anObject);
1986 }
1987
1988 //=============================================================================
1989 /*!
1990  *  GetSame
1991  */
1992 //=============================================================================
1993 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1994                                           (GEOM::GEOM_Object_ptr theShapeWhere,
1995                                            GEOM::GEOM_Object_ptr theShapeWhat)
1996 {
1997   GEOM::GEOM_Object_var aGEOMObject;
1998
1999   //Set a not done flag
2000   GetOperations()->SetNotDone();
2001
2002   //Get the reference objects
2003   Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2004   Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2005
2006   if (aShapeWhere.IsNull() ||
2007       aShapeWhat.IsNull()) return aGEOMObject._retn();
2008
2009   //Get Shapes in place of aShapeWhat
2010   Handle(::GEOM_Object) anObject =
2011     GetOperations()->GetSame(aShapeWhere, aShapeWhat);
2012   if (!GetOperations()->IsDone() || anObject.IsNull())
2013     return aGEOMObject._retn();
2014
2015   return GetObject(anObject);
2016 }
2017
2018 //=============================================================================
2019 /*!
2020  *  GetSameIDs
2021  */
2022 //=============================================================================
2023 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
2024                                           (GEOM::GEOM_Object_ptr theShapeWhere,
2025                                            GEOM::GEOM_Object_ptr theShapeWhat) {
2026   GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
2027
2028   //Get the reference objects
2029   Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2030   Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2031
2032   if (aShapeWhere.IsNull() ||
2033       aShapeWhat.IsNull()) return aSeq._retn();
2034
2035
2036   Handle(TColStd_HSequenceOfInteger) aHSeq =
2037     GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
2038
2039   if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
2040
2041   Standard_Integer aLength = aHSeq->Length();
2042   aSeq->length(aLength);
2043   for (Standard_Integer i = 1; i <= aLength; i++)
2044     aSeq[i-1] = aHSeq->Value(i);
2045
2046   return aSeq._retn();
2047 }
2048
2049 //=============================================================================
2050 /*!
2051  *  ExtendEdge
2052  */
2053 //=============================================================================
2054 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendEdge
2055                                   (GEOM::GEOM_Object_ptr theEdge,
2056                                    CORBA::Double         theMin,
2057                                    CORBA::Double         theMax)
2058 {
2059   GEOM::GEOM_Object_var aGEOMObject;
2060
2061   //Set a not done flag
2062   GetOperations()->SetNotDone();
2063
2064   //Get the reference objects
2065   Handle(::GEOM_Object) anEdge = GetObjectImpl(theEdge);
2066
2067   if (anEdge.IsNull()) {
2068     return aGEOMObject._retn();
2069   }
2070
2071   //Get Shapes in place of aShapeWhat
2072   Handle(::GEOM_Object) aNewEdge =
2073     GetOperations()->ExtendEdge(anEdge, theMin, theMax);
2074
2075   if (!GetOperations()->IsDone() || aNewEdge.IsNull()) {
2076     return aGEOMObject._retn();
2077   }
2078
2079   return GetObject(aNewEdge);
2080 }
2081
2082 //=============================================================================
2083 /*!
2084  *  ExtendFace
2085  */
2086 //=============================================================================
2087 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
2088                                   (GEOM::GEOM_Object_ptr theFace,
2089                                    CORBA::Double         theUMin,
2090                                    CORBA::Double         theUMax,
2091                                    CORBA::Double         theVMin,
2092                                    CORBA::Double         theVMax)
2093 {
2094   GEOM::GEOM_Object_var aGEOMObject;
2095
2096   //Set a not done flag
2097   GetOperations()->SetNotDone();
2098
2099   //Get the reference objects
2100   Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
2101
2102   if (aFace.IsNull()) {
2103     return aGEOMObject._retn();
2104   }
2105
2106   //Get Shapes in place of aShapeWhat
2107   Handle(::GEOM_Object) aNewFace =
2108     GetOperations()->ExtendFace(aFace, theUMin, theUMax, theVMin, theVMax);
2109
2110   if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2111     return aGEOMObject._retn();
2112   }
2113
2114   return GetObject(aNewFace);
2115 }
2116
2117 //=============================================================================
2118 /*!
2119  *  MakeSurfaceFromFace
2120  */
2121 //=============================================================================
2122 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
2123                                   (GEOM::GEOM_Object_ptr theFace)
2124 {
2125   GEOM::GEOM_Object_var aGEOMObject;
2126
2127   //Set a not done flag
2128   GetOperations()->SetNotDone();
2129
2130   //Get the reference object
2131   Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
2132
2133   if (aFace.IsNull()) {
2134     return aGEOMObject._retn();
2135   }
2136
2137   //Get Shapes in place of aShapeWhat
2138   Handle(::GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
2139
2140   if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2141     return aGEOMObject._retn();
2142   }
2143
2144   return GetObject(aNewFace);
2145 }
2146
2147 //=============================================================================
2148 /*!
2149  *  GetSubShapeEdgeSorted
2150  */
2151 //=============================================================================
2152 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapeEdgeSorted
2153                                         (GEOM::GEOM_Object_ptr theShape,
2154                                          GEOM::GEOM_Object_ptr theStartPoint)
2155 {
2156   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
2157
2158   //Set a not done flag
2159   GetOperations()->SetNotDone();
2160
2161   //Get the reference objects
2162   Handle(::GEOM_Object) aShape      = GetObjectImpl(theShape);
2163   Handle(::GEOM_Object) aStartPoint = GetObjectImpl(theStartPoint);
2164
2165   if (aShape.IsNull() || aStartPoint.IsNull()) {
2166     return aSeq._retn();
2167   }
2168
2169   //Get Shapes On Shape
2170   Handle(TColStd_HSequenceOfTransient) aHSeq =
2171       GetOperations()->GetSubShapeEdgeSorted(aShape, aStartPoint);
2172
2173   if (!GetOperations()->IsDone() || aHSeq.IsNull())
2174     return aSeq._retn();
2175
2176   const Standard_Integer aLength = aHSeq->Length();
2177   Standard_Integer       i;
2178
2179   aSeq->length(aLength);
2180
2181   for (i = 1; i <= aLength; i++) {
2182     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
2183   }
2184
2185   return aSeq._retn();
2186 }
2187
2188 //=============================================================================
2189 /*!
2190  *  GetSubShapesWithTolerance
2191  */
2192 //=============================================================================
2193 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapesWithTolerance
2194                      (GEOM::GEOM_Object_ptr      theShape,
2195                       CORBA::Short               theShapeType,
2196                       GEOM::comparison_condition theCondition,
2197                       CORBA::Double              theTolerance)
2198 {
2199   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
2200
2201   //Set a not done flag
2202   GetOperations()->SetNotDone();
2203
2204   //Get the reference objects
2205   Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
2206
2207   if (aShape.IsNull()) {
2208     return aSeq._retn();
2209   }
2210
2211   //Get Shapes On Shape
2212   const GEOMUtils::ComparisonCondition aCondition =
2213                 ComparisonCondition(theCondition);
2214   Handle(TColStd_HSequenceOfTransient) aHSeq      =
2215       GetOperations()->GetSubShapesWithTolerance
2216                 (aShape, theShapeType, aCondition, theTolerance);
2217
2218   if (!GetOperations()->IsDone() || aHSeq.IsNull())
2219     return aSeq._retn();
2220
2221   const Standard_Integer aLength = aHSeq->Length();
2222   Standard_Integer       i;
2223
2224   aSeq->length(aLength);
2225
2226   for (i = 1; i <= aLength; i++) {
2227     aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
2228   }
2229
2230   return aSeq._retn();
2231 }
2232
2233 //=============================================================================
2234 /*!
2235  *  MakeExtraction
2236  */
2237 //=============================================================================
2238 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
2239          (GEOM::GEOM_Object_ptr                              theShape,
2240           const GEOM::ListOfLong                            &theSubShapeIDs,
2241           GEOM::GEOM_IShapesOperations::ExtractionStats_out  theStats)
2242 {
2243   GEOM::GEOM_Object_var aGEOMObject;
2244
2245   //Set a not done flag
2246   theStats = new GEOM::GEOM_IShapesOperations::ExtractionStats;
2247   GetOperations()->SetNotDone();
2248
2249   //Get the reference object
2250   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
2251
2252   if (aShape.IsNull()) {
2253     return aGEOMObject._retn();
2254   }
2255
2256   const int aNbIDs = theSubShapeIDs.length();
2257
2258   if (aNbIDs == 0) {
2259     return aGEOMObject._retn();
2260   }
2261
2262   int                              i;
2263   Handle(TColStd_HArray1OfInteger) anArray =
2264     new TColStd_HArray1OfInteger (1, aNbIDs);
2265
2266   for (i = 0; i < aNbIDs; i++) {
2267     anArray->SetValue(i + 1, theSubShapeIDs[i]);
2268   }
2269
2270   //Get Shapes in place of aShapeWhat
2271   std::list<GEOMImpl_IShapesOperations::ExtractionStat> aStats;
2272   Handle(GEOM_Object)                                   aResult =
2273           GetOperations()->MakeExtraction(aShape, anArray, aStats);
2274
2275   if (!GetOperations()->IsDone() || aResult.IsNull()) {
2276     return aGEOMObject._retn();
2277   }
2278
2279   // Convert statistics.
2280   const int aNbStats = aStats.size();
2281
2282   theStats->length(aNbStats);
2283
2284   // fill the local CORBA array with values from lists
2285   std::list<GEOMImpl_IShapesOperations::ExtractionStat>::const_iterator
2286     anIt = aStats.begin();
2287
2288   for (i = 0; anIt != aStats.end(); i++, anIt++) {
2289     GEOM::GEOM_IShapesOperations::ExtractionStat_var aResStat =
2290       new GEOM::GEOM_IShapesOperations::ExtractionStat;
2291
2292     // Copy type
2293     switch (anIt->type) {
2294     case GEOMImpl_IShapesOperations::EST_Removed:
2295       aResStat->type = GEOM::GEOM_IShapesOperations::EST_Removed;
2296       break;
2297     case GEOMImpl_IShapesOperations::EST_Modified:
2298       aResStat->type = GEOM::GEOM_IShapesOperations::EST_Modified;
2299       break;
2300     case GEOMImpl_IShapesOperations::EST_Added:
2301       aResStat->type = GEOM::GEOM_IShapesOperations::EST_Added;
2302       break;
2303     default:
2304       break;
2305     }
2306
2307     // Copy the list of IDs
2308     std::list<Standard_Integer> aIDList    = anIt->indices;
2309     GEOM::ListOfLong_var        aResIDList = new GEOM::ListOfLong;
2310
2311     aResIDList->length(aIDList.size());
2312
2313     std::list<Standard_Integer>::iterator anIDIt = aIDList.begin();
2314     int j = 0;
2315
2316     for (; anIDIt != aIDList.end(); j++, anIDIt++) {
2317       aResIDList[j] = *anIDIt;
2318     }
2319
2320     aResStat->indices = aResIDList;
2321
2322     theStats[(_CORBA_ULong)i] = aResStat;
2323   }
2324
2325   return GetObject(aResult);
2326 }