]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_I/GEOM_IBlocksOperations_i.cc
Salome HOME
d5435c5d1bc9e9c33586de649fb59fc7d22e9845
[modules/geom.git] / src / GEOM_I / GEOM_IBlocksOperations_i.cc
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_IBlocksOperations_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 <TColStd_HSequenceOfTransient.hxx>
35 #include <TColStd_HArray1OfInteger.hxx>
36
37 //=============================================================================
38 /*!
39  *   constructor:
40  */
41 //=============================================================================
42 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
43                                                     GEOM::GEOM_Gen_ptr theEngine,
44                                                     ::GEOMImpl_IBlocksOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
46 {
47   MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
48 }
49
50 //=============================================================================
51 /*!
52  *  destructor
53  */
54 //=============================================================================
55 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
56 {
57   MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
58 }
59
60
61 //=============================================================================
62 /*!
63  *  MakeQuad
64  */
65 //=============================================================================
66 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
67                (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
68                 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
69 {
70   GEOM::GEOM_Object_var aGEOMObject;
71
72   //Set a not done flag
73   GetOperations()->SetNotDone();
74
75   //Get the reference edges
76   Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
77   Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
78   Handle(GEOM_Object) anEdge3 = GetObjectImpl(theEdge3);
79   Handle(GEOM_Object) anEdge4 = GetObjectImpl(theEdge4);
80
81   if (anEdge1.IsNull() || anEdge2.IsNull() ||
82       anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
83
84   //Create the Face
85   Handle(GEOM_Object) anObject =
86     GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
87   if (!GetOperations()->IsDone() || anObject.IsNull())
88     return aGEOMObject._retn();
89
90   return GetObject(anObject);
91 }
92
93 //=============================================================================
94 /*!
95  *  MakeQuad2Edges
96  */
97 //=============================================================================
98 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
99                (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
100 {
101   GEOM::GEOM_Object_var aGEOMObject;
102
103   //Set a not done flag
104   GetOperations()->SetNotDone();
105
106   //Get the reference edges
107   Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
108   Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
109
110   if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
111
112   //Create the Face
113   Handle(GEOM_Object) anObject =
114     GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
115   if (!GetOperations()->IsDone() || anObject.IsNull())
116     return aGEOMObject._retn();
117
118   return GetObject(anObject);
119 }
120
121 //=============================================================================
122 /*!
123  *  MakeQuad4Vertices
124  */
125 //=============================================================================
126 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
127                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
128                        GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
129 {
130   GEOM::GEOM_Object_var aGEOMObject;
131
132   //Set a not done flag
133   GetOperations()->SetNotDone();
134
135   //Get the reference points
136   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
137   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
138   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
139   Handle(GEOM_Object) aPnt4 = GetObjectImpl(thePnt4);
140
141   if (aPnt1.IsNull() || aPnt2.IsNull() ||
142       aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
143
144   //Create the Face
145   Handle(GEOM_Object) anObject =
146     GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
147   if (!GetOperations()->IsDone() || anObject.IsNull())
148     return aGEOMObject._retn();
149
150   return GetObject(anObject);
151 }
152
153 //=============================================================================
154 /*!
155  *  MakeHexa
156  */
157 //=============================================================================
158 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
159                (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
160                 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
161                 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
162 {
163   GEOM::GEOM_Object_var aGEOMObject;
164
165   //Set a not done flag
166   GetOperations()->SetNotDone();
167
168   //Get the reference Faces
169   Handle(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
170   Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
171   Handle(GEOM_Object) anFace3 = GetObjectImpl(theFace3);
172   Handle(GEOM_Object) anFace4 = GetObjectImpl(theFace4);
173   Handle(GEOM_Object) anFace5 = GetObjectImpl(theFace5);
174   Handle(GEOM_Object) anFace6 = GetObjectImpl(theFace6);
175
176   if (anFace1.IsNull() || anFace2.IsNull() ||
177       anFace3.IsNull() || anFace4.IsNull() ||
178       anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
179
180   //Create the Face
181   Handle(GEOM_Object) anObject = GetOperations()->MakeHexa
182     (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
183   if (!GetOperations()->IsDone() || anObject.IsNull())
184     return aGEOMObject._retn();
185
186   return GetObject(anObject);
187 }
188
189 //=============================================================================
190 /*!
191  *  MakeHexa2Faces
192  */
193 //=============================================================================
194 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
195                (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
196 {
197   GEOM::GEOM_Object_var aGEOMObject;
198
199   //Set a not done flag
200   GetOperations()->SetNotDone();
201
202   //Get the reference Faces
203   Handle(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
204   Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
205
206   if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
207
208   //Create the Face
209   Handle(GEOM_Object) anObject =
210     GetOperations()->MakeHexa2Faces(anFace1, anFace2);
211   if (!GetOperations()->IsDone() || anObject.IsNull())
212     return aGEOMObject._retn();
213
214   return GetObject(anObject);
215 }
216
217 //=============================================================================
218 /*!
219  *  MakeBlockCompound
220  */
221 //=============================================================================
222 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
223                                             (GEOM::GEOM_Object_ptr theCompound)
224 {
225   GEOM::GEOM_Object_var aGEOMObject;
226
227   //Set a not done flag
228   GetOperations()->SetNotDone();
229
230   //Get the reference Compound
231   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
232   if (aCompound.IsNull()) return aGEOMObject._retn();
233
234   //Create the Blocks Compound
235   Handle(GEOM_Object) anObject =
236     GetOperations()->MakeBlockCompound(aCompound);
237   if (!GetOperations()->IsDone() || anObject.IsNull())
238     return aGEOMObject._retn();
239
240   return GetObject(anObject);
241 }
242
243 //=============================================================================
244 /*!
245  *  GetPoint
246  */
247 //=============================================================================
248 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
249                                                           const CORBA::Double   theX,
250                                                           const CORBA::Double   theY,
251                                                           const CORBA::Double   theZ,
252                                                           const CORBA::Double   theEpsilon)
253 {
254   GEOM::GEOM_Object_var aGEOMObject;
255
256   //Set a not done flag
257   GetOperations()->SetNotDone();
258
259   //Get the reference Objects
260   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
261   if (aShape.IsNull()) return aGEOMObject._retn();
262
263   //Create the Point
264   Handle(GEOM_Object) anObject =
265     GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
266   if (!GetOperations()->IsDone() || anObject.IsNull())
267     return aGEOMObject._retn();
268
269   return GetObject(anObject);
270 }
271
272 //=============================================================================
273 /*!
274  *  GetEdge
275  */
276 //=============================================================================
277 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
278                                                          GEOM::GEOM_Object_ptr thePoint1,
279                                                          GEOM::GEOM_Object_ptr thePoint2)
280 {
281   GEOM::GEOM_Object_var aGEOMObject;
282
283   //Set a not done flag
284   GetOperations()->SetNotDone();
285
286   //Get the reference Objects
287   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
288   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
289   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
290
291   if (aShape.IsNull() ||
292       aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
293
294   //Create the Point
295   Handle(GEOM_Object) anObject =
296     GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
297   if (!GetOperations()->IsDone() || anObject.IsNull())
298     return aGEOMObject._retn();
299
300   return GetObject(anObject);
301 }
302
303 //=============================================================================
304 /*!
305  *  GetEdgeNearPoint
306  */
307 //=============================================================================
308 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
309                                                                   GEOM::GEOM_Object_ptr thePoint)
310 {
311   GEOM::GEOM_Object_var aGEOMObject;
312
313   //Set a not done flag
314   GetOperations()->SetNotDone();
315
316   //Get the reference Objects
317   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
318   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
319
320   if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
321
322   //Create the Edge
323   Handle(GEOM_Object) anObject =
324     GetOperations()->GetEdgeNearPoint(aShape, aPoint);
325   if (!GetOperations()->IsDone() || anObject.IsNull())
326     return aGEOMObject._retn();
327
328   return GetObject(anObject);
329 }
330
331 //=============================================================================
332 /*!
333  *  GetFaceByPoints
334  */
335 //=============================================================================
336 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
337                                               (GEOM::GEOM_Object_ptr theShape,
338                                                GEOM::GEOM_Object_ptr thePoint1,
339                                                GEOM::GEOM_Object_ptr thePoint2,
340                                                GEOM::GEOM_Object_ptr thePoint3,
341                                                GEOM::GEOM_Object_ptr thePoint4)
342 {
343   GEOM::GEOM_Object_var aGEOMObject;
344
345   //Set a not done flag
346   GetOperations()->SetNotDone();
347
348   //Get the reference Objects
349   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
350   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
351   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
352   Handle(GEOM_Object) aPoint3 = GetObjectImpl(thePoint3);
353   Handle(GEOM_Object) aPoint4 = GetObjectImpl(thePoint4);
354
355   if (aShape.IsNull() ||
356       aPoint1.IsNull() || aPoint2.IsNull() ||
357       aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
358
359   //Create the Face
360   Handle(GEOM_Object) anObject =
361     GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
362   if (!GetOperations()->IsDone() || anObject.IsNull())
363     return aGEOMObject._retn();
364
365   return GetObject(anObject);
366 }
367
368 //=============================================================================
369 /*!
370  *  GetFaceByEdges
371  */
372 //=============================================================================
373 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
374                                                (GEOM::GEOM_Object_ptr theShape,
375                                                 GEOM::GEOM_Object_ptr theEdge1,
376                                                 GEOM::GEOM_Object_ptr theEdge2)
377 {
378   GEOM::GEOM_Object_var aGEOMObject;
379
380   //Set a not done flag
381   GetOperations()->SetNotDone();
382
383   //Get the reference Objects
384   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
385   Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
386   Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
387
388   if (aShape.IsNull() ||
389       anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
390
391   //Create the Face
392   Handle(GEOM_Object) anObject =
393     GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
394   if (!GetOperations()->IsDone() || anObject.IsNull())
395     return aGEOMObject._retn();
396
397   return GetObject(anObject);
398 }
399
400 //=============================================================================
401 /*!
402  *  GetOppositeFace
403  */
404 //=============================================================================
405 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
406                                                                  GEOM::GEOM_Object_ptr theFace)
407 {
408   GEOM::GEOM_Object_var aGEOMObject;
409
410   //Set a not done flag
411   GetOperations()->SetNotDone();
412
413   //Get the reference Objects
414   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
415   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
416
417   if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
418
419   //Create the Face
420   Handle(GEOM_Object) anObject =
421     GetOperations()->GetOppositeFace(aShape, aFace);
422   if (!GetOperations()->IsDone() || anObject.IsNull())
423     return aGEOMObject._retn();
424
425   return GetObject(anObject);
426 }
427
428 //=============================================================================
429 /*!
430  *  GetFaceNearPoint
431  */
432 //=============================================================================
433 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
434                                                                   GEOM::GEOM_Object_ptr thePoint)
435 {
436   GEOM::GEOM_Object_var aGEOMObject;
437
438   //Set a not done flag
439   GetOperations()->SetNotDone();
440
441   //Get the reference Objects
442   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
443   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
444
445   if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
446
447   //Create the Face
448   Handle(GEOM_Object) anObject =
449     GetOperations()->GetFaceNearPoint(aShape, aPoint);
450   if (!GetOperations()->IsDone() || anObject.IsNull())
451     return aGEOMObject._retn();
452
453   return GetObject(anObject);
454 }
455
456 //=============================================================================
457 /*!
458  *  GetFaceByNormale
459  */
460 //=============================================================================
461 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
462                                                                   GEOM::GEOM_Object_ptr theVector)
463 {
464   GEOM::GEOM_Object_var aGEOMObject;
465
466   //Set a not done flag
467   GetOperations()->SetNotDone();
468
469   //Get the reference Objects
470   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
471   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
472
473   if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
474
475   //Create the Face
476   Handle(GEOM_Object) anObject =
477     GetOperations()->GetFaceByNormale(aShape, aVector);
478   if (!GetOperations()->IsDone() || anObject.IsNull())
479     return aGEOMObject._retn();
480
481   return GetObject(anObject);
482 }
483
484 //=============================================================================
485 /*!
486  *  ExplodeCompoundOfBlocks
487  */
488 //=============================================================================
489 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
490                                           (GEOM::GEOM_Object_ptr theCompound,
491                                            const CORBA::Long     theMinNbFaces,
492                                            const CORBA::Long     theMaxNbFaces)
493 {
494   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
495
496   //Set a not done flag
497   GetOperations()->SetNotDone();
498
499   //Get the reference Compound
500   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
501   if (aCompound.IsNull()) return aSeq._retn();
502
503   //Explode
504   Handle(TColStd_HSequenceOfTransient) aHSeq =
505     GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
506   if (!GetOperations()->IsDone() || aHSeq.IsNull())
507     return aSeq._retn();
508
509   Standard_Integer aLength = aHSeq->Length();
510   aSeq->length(aLength);
511   for (Standard_Integer i = 1; i <= aLength; i++)
512     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
513
514   return aSeq._retn();
515 }
516
517 //=============================================================================
518 /*!
519  *  IsCompoundOfBlocks
520  */
521 //=============================================================================
522 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
523                                           (GEOM::GEOM_Object_ptr theCompound,
524                                            const CORBA::Long     theMinNbFaces,
525                                            const CORBA::Long     theMaxNbFaces,
526                                            CORBA::Long&          theNbBlocks)
527 {
528   theNbBlocks = 0;
529   CORBA::Boolean isComp = false;
530
531   //Set a not done flag
532   GetOperations()->SetNotDone();
533
534   //Get the reference Compound
535   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
536   if (aCompound.IsNull()) return isComp;
537
538   //Check
539   Standard_Integer nbBlocks = 0;
540   isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
541                                                theMinNbFaces,
542                                                theMaxNbFaces,
543                                                nbBlocks);
544   if (!GetOperations()->IsDone())
545     return isComp;
546
547   theNbBlocks = nbBlocks;
548   return isComp;
549 }
550
551 //=============================================================================
552 /*!
553  *  CheckCompoundOfBlocks
554  */
555 //=============================================================================
556 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
557                                           (GEOM::GEOM_Object_ptr theCompound,
558                                            GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
559 {
560   CORBA::Boolean isComp = false;
561
562   //Set a not done flag
563   GetOperations()->SetNotDone();
564
565   //Get the reference Compound
566   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
567   if (aCompound.IsNull()) return isComp;
568
569   //Check
570   std::list<GEOMImpl_IBlocksOperations::BCError> errList;
571   isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
572   if (!GetOperations()->IsDone())
573     return isComp;
574
575   const int nbErr = errList.size();
576   GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
577     new GEOM::GEOM_IBlocksOperations::BCErrors();
578   anErrArray->length(nbErr);
579
580   // fill the local CORBA array with values from lists
581   std::list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
582   int i = 0;
583   for (; errIt != errList.end(); i++, errIt++) {
584     GEOM::GEOM_IBlocksOperations::BCError_var anError =
585       new GEOM::GEOM_IBlocksOperations::BCError();
586
587     GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
588
589     switch (errStruct.error) {
590     case GEOMImpl_IBlocksOperations::NOT_BLOCK:
591       anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
592       break;
593     case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
594       anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
595       break;
596     case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
597       anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
598       break;
599     case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
600       anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
601       break;
602     case GEOMImpl_IBlocksOperations::NOT_GLUED:
603       anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
604       break;
605     default:
606       break;
607     }
608
609     std::list<int> sshList = errStruct.incriminated;
610     GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
611     anIncrims->length(sshList.size());
612
613     std::list<int>::iterator sshIt = sshList.begin();
614     int jj = 0;
615     for (; sshIt != sshList.end(); jj++, sshIt++) {
616       anIncrims[jj] = *sshIt;
617     }
618
619     anError->incriminated = anIncrims;
620
621     anErrArray[i] = anError;
622   }
623
624   // initialize out-parameter with local array
625   theErrors = anErrArray._retn();
626
627   return isComp;
628 }
629
630 //=============================================================================
631 /*!
632  *  PrintBCErrors
633  */
634 //=============================================================================
635 char* GEOM_IBlocksOperations_i::PrintBCErrors
636                       (GEOM::GEOM_Object_ptr theCompound,
637                        const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
638 {
639   //Get the reference Compound
640   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
641   if (aCompound.IsNull()) return NULL;
642
643   // Convert the errors sequence
644   std::list<GEOMImpl_IBlocksOperations::BCError> anErrors;
645   int nbErr = theErrors.length();
646   int ie = 0;
647   for (; ie < nbErr; ie++) {
648     const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
649     const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
650     const GEOM::ListOfLong incrims = err.incriminated;
651
652     GEOMImpl_IBlocksOperations::BCError errStruct;
653     switch (typ) {
654     case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
655       errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
656       break;
657     case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
658       errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
659       break;
660     case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
661       errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
662       break;
663     case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
664       errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
665       break;
666     case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
667       errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
668       break;
669     default:
670       break;
671     }
672
673     int ii = 0;
674     int aLen = incrims.length();
675     for (; ii < aLen; ii++) {
676       errStruct.incriminated.push_back(incrims[ii]);
677     }
678
679     anErrors.push_back(errStruct);
680   }
681
682   TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
683   return CORBA::string_dup(aDescr.ToCString());
684 }
685
686 //=============================================================================
687 /*!
688  *  RemoveExtraEdges
689  */
690 //=============================================================================
691 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
692                                       (GEOM::GEOM_Object_ptr theShape,
693                                        CORBA::Long           theOptimumNbFaces)
694 {
695   GEOM::GEOM_Object_var aGEOMObject;
696
697   //Set a not done flag
698   GetOperations()->SetNotDone();
699
700   //Get the reference Objects
701   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
702   if (aShape.IsNull()) return aGEOMObject._retn();
703
704   //Get the result
705   Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
706   if (!GetOperations()->IsDone() || anObject.IsNull())
707     return aGEOMObject._retn();
708
709   return GetObject(anObject);
710 }
711
712 //=============================================================================
713 /*!
714  *  CheckAndImprove
715  */
716 //=============================================================================
717 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
718 {
719   GEOM::GEOM_Object_var aGEOMObject;
720
721   //Set a not done flag
722   GetOperations()->SetNotDone();
723
724   //Get the reference Objects
725   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
726   if (aCompound.IsNull()) return aGEOMObject._retn();
727
728   //Get the result
729   Handle(GEOM_Object) anObject =
730     GetOperations()->CheckAndImprove(aCompound);
731   if (!GetOperations()->IsDone() || anObject.IsNull())
732     return aGEOMObject._retn();
733
734   return GetObject(anObject);
735 }
736
737 //=============================================================================
738 /*!
739  *  GetBlockNearPoint
740  */
741 //=============================================================================
742 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
743                                                                    GEOM::GEOM_Object_ptr thePoint)
744 {
745   GEOM::GEOM_Object_var aGEOMObject;
746
747   //Set a not done flag
748   GetOperations()->SetNotDone();
749
750   //Get the reference Objects
751   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
752   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
753
754   if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
755
756   //Get the block
757   Handle(GEOM_Object) anObject =
758     GetOperations()->GetBlockNearPoint(aCompound, aPoint);
759   if (!GetOperations()->IsDone() || anObject.IsNull())
760     return aGEOMObject._retn();
761
762   return GetObject(anObject);
763 }
764
765 //=============================================================================
766 /*!
767  *  GetBlockByParts
768  */
769 //=============================================================================
770 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
771                                                                  const GEOM::ListOfGO& theParts)
772 {
773   GEOM::GEOM_Object_var aGEOMObject;
774
775   //Set a not done flag
776   GetOperations()->SetNotDone();
777
778   //Get the reference Compound
779   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
780   if (aCompound.IsNull()) return aGEOMObject._retn();
781
782   //Get the parts
783   int ind, aLen;
784   Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
785
786   aLen = theParts.length();
787   for (ind = 0; ind < aLen; ind++) {
788     Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
789     if (aSh.IsNull()) return aGEOMObject._retn();
790     aParts->Append(aSh);
791   }
792
793   //Get the Block
794   Handle(GEOM_Object) anObject =
795     GetOperations()->GetBlockByParts(aCompound, aParts);
796   if (!GetOperations()->IsDone() || anObject.IsNull())
797     return aGEOMObject._retn();
798
799   return GetObject(anObject);
800 }
801
802 //=============================================================================
803 /*!
804  *  GetBlocksByParts
805  */
806 //=============================================================================
807 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
808                                                             const GEOM::ListOfGO& theParts)
809 {
810   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
811
812   //Set a not done flag
813   GetOperations()->SetNotDone();
814
815   //Get the reference Compound
816   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
817   if (aCompound.IsNull()) return aSeq._retn();
818
819   //Get the parts
820   int ind, aLen;
821   Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
822
823   aLen = theParts.length();
824   for (ind = 0; ind < aLen; ind++) {
825     Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
826     if (aSh.IsNull()) return aSeq._retn();
827     aParts->Append(aSh);
828   }
829
830   //Get the Block
831   Handle(TColStd_HSequenceOfTransient) aHSeq =
832     GetOperations()->GetBlocksByParts(aCompound, aParts);
833   if (!GetOperations()->IsDone() || aHSeq.IsNull())
834     return aSeq._retn();
835
836   Standard_Integer aLength = aHSeq->Length();
837   aSeq->length(aLength);
838   for (Standard_Integer i = 1; i <= aLength; i++)
839     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
840
841   return aSeq._retn();
842 }
843
844 //=============================================================================
845 /*!
846  *  MakeMultiTransformation1D
847  */
848 //=============================================================================
849 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
850                                               (GEOM::GEOM_Object_ptr theBlock,
851                                                const CORBA::Long     theDirFace1,
852                                                const CORBA::Long     theDirFace2,
853                                                const CORBA::Long     theNbTimes)
854 {
855   GEOM::GEOM_Object_var aGEOMObject;
856
857   //Set a not done flag
858   GetOperations()->SetNotDone();
859
860   //Get the object itself and the vector of translation
861   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
862   if (aBasicObject.IsNull()) return aGEOMObject._retn();
863
864   //Perform the transformation
865   Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
866     (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
867   if (!GetOperations()->IsDone() || anObject.IsNull())  return aGEOMObject._retn();
868
869   return GetObject(anObject);
870 }
871
872 //=============================================================================
873 /*!
874  *  MakeMultiTransformation2D
875  */
876 //=============================================================================
877 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
878                                            (GEOM::GEOM_Object_ptr theBlock,
879                                             const CORBA::Long     theDirFace1U,
880                                             const CORBA::Long     theDirFace2U,
881                                             const CORBA::Long     theNbTimesU,
882                                             const CORBA::Long     theDirFace1V,
883                                             const CORBA::Long     theDirFace2V,
884                                             const CORBA::Long     theNbTimesV)
885 {
886   GEOM::GEOM_Object_var aGEOMObject;
887
888   //Set a not done flag
889   GetOperations()->SetNotDone();
890
891   //Get the object itself
892   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
893   if (aBasicObject.IsNull()) return aGEOMObject._retn();
894
895   //Perform the transformation
896   Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
897     (aBasicObject,
898      theDirFace1U, theDirFace2U, theNbTimesU,
899      theDirFace1V, theDirFace2V, theNbTimesV);
900   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
901
902   return GetObject(anObject);
903 }
904
905 //=============================================================================
906 /*!
907  *  Propagate
908  */
909 //=============================================================================
910 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
911 {
912   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
913
914   //Set a not done flag
915   GetOperations()->SetNotDone();
916
917   //Get the reference Shape
918   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
919   if (aShape.IsNull()) return aSeq._retn();
920
921   //Get the Propagation chains
922   Handle(TColStd_HSequenceOfTransient) aHSeq =
923     GetOperations()->Propagate(aShape);
924   if (!GetOperations()->IsDone() || aHSeq.IsNull())
925     return aSeq._retn();
926
927   Standard_Integer aLength = aHSeq->Length();
928   aSeq->length(aLength);
929   for (Standard_Integer i = 1; i <= aLength; i++)
930     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
931
932   return aSeq._retn();
933 }