Salome HOME
First publish of HEXABLOCKcomponant
[modules/hexablock.git] / src / HEXABLOCK_I / HexDocument_impl.cxx
1 using namespace std;
2
3 #include "utilities.h"
4
5 #include <string>
6
7 #include "HEXABLOCK.hxx"
8 #include "HexDocument_impl.hxx"
9 // 
10
11 #include "HexVertex_impl.hxx"
12 #include "HexEdge_impl.hxx"
13 #include "HexQuad_impl.hxx"
14 #include "HexHexa_impl.hxx"
15 #include "HexVector_impl.hxx"
16 #include "HexElements_impl.hxx"
17 #include "HexCrossElements_impl.hxx"
18 #include "HexCylinder_impl.hxx"
19 #include "HexPipe_impl.hxx"
20 #include "HexLaw_impl.hxx"
21 #include "HexPropagation_impl.hxx"
22 #include "HexGroup_impl.hxx"
23
24
25 using namespace HEXABLOCK_ORB;
26
27 Document_impl::Document_impl(HEXA_NS::Document *ptrCpp):_document_cpp(ptrCpp)
28 {
29 }
30
31 ::CORBA::Long Document_impl::saveVtk(const char* fname) throw (SALOME::SALOME_Exception)
32 {
33   ::CORBA::Long ret = _document_cpp->saveVtk( fname );
34   return ret;
35 }
36 void Document_impl::purge() throw (SALOME::SALOME_Exception)
37 {
38   _document_cpp->purge();
39 }
40
41 HEXA_NS::Document* Document_impl::GetImpl() throw (SALOME::SALOME_Exception)
42 {
43   return _document_cpp;
44 }
45
46
47 char* Document_impl::getFile() throw (SALOME::SALOME_Exception)
48 {
49   return CORBA::string_dup (_document_cpp->getFile());
50 }
51
52 void Document_impl::setFile(const char* fileName) throw (SALOME::SALOME_Exception)
53 {
54   _document_cpp->setFile(fileName);
55 }
56
57 ::CORBA::Boolean Document_impl::isSavedFile() throw (SALOME::SALOME_Exception)
58 {
59   return _document_cpp->isSaved();
60 }
61
62 ::CORBA::Long Document_impl::saveFile() throw (SALOME::SALOME_Exception)
63 {
64   return _document_cpp->saveFile();
65 }
66
67 void Document_impl::setTolerance(::CORBA::Double tol) throw (SALOME::SALOME_Exception)
68 {
69   _document_cpp->setTolerance(tol);
70 }
71
72 ::CORBA::Double Document_impl::getTolerance() throw (SALOME::SALOME_Exception)
73 {
74   return   _document_cpp->getTolerance();
75 }
76
77 Vertex_ptr Document_impl::addVertex(::CORBA::Double x, ::CORBA::Double y, ::CORBA::Double z)
78   throw(SALOME::SALOME_Exception)
79 {
80   Vertex_ptr result   = Vertex::_nil();
81
82   HEXA_NS::Vertex* v  = _document_cpp->addVertex( x, y, z );
83   if ( v != NULL ){
84     Vertex_impl* servantCorba = new Vertex_impl(v);
85     result = servantCorba->_this();
86   }
87   return result;
88 }
89
90 ::CORBA::Long Document_impl::countVertex() throw (SALOME::SALOME_Exception)
91 {
92   return  _document_cpp->countVertex();
93 }
94
95 Vertex_ptr Document_impl::getVertex(::CORBA::Long i) throw (SALOME::SALOME_Exception)
96 {
97   Vertex_ptr result   = Vertex::_nil();
98
99   HEXA_NS::Vertex* v = _document_cpp->getVertex(i);
100   if ( v != NULL ){
101     Vertex_impl* servantCorba = new Vertex_impl(v);
102     result = servantCorba->_this();
103   }
104   return result;
105 }
106
107
108 Vertex_ptr Document_impl::findVertex(::CORBA::Double x, ::CORBA::Double y, ::CORBA::Double z)
109   throw (SALOME::SALOME_Exception)
110 {
111   Vertex_ptr result = Vertex::_nil();
112
113   HEXA_NS::Vertex* v = _document_cpp->findVertex( x, y, z);
114   if ( v != NULL ){
115     Vertex_impl* servantCorba = new Vertex_impl(v);
116     result = servantCorba->_this();
117   }
118   return result;
119 }
120
121
122 Edge_ptr Document_impl::addEdge(Vertex_ptr v0In, Vertex_ptr v1In)
123   throw(SALOME::SALOME_Exception)
124 {
125   Edge_ptr result = Edge::_nil();
126
127   Vertex_impl* v0InServant = ::DownCast<Vertex_impl*>( v0In );
128   Vertex_impl* v1InServant = ::DownCast<Vertex_impl*>( v1In );
129   ASSERT( v0InServant );
130   ASSERT( v1InServant );
131   if ( v0InServant &&  v1InServant ) {
132     HEXA_NS::Vertex* v0 = v0InServant->GetImpl();
133     HEXA_NS::Vertex* v1 = v1InServant->GetImpl();
134     HEXA_NS::Edge* e = _document_cpp->addEdge( v0, v1 );
135     if ( e != NULL ){
136       Edge_impl* servantCorba = new Edge_impl(e);
137       result = servantCorba->_this();
138     }
139   }
140   return result;
141 }
142
143
144 ::CORBA::Long Document_impl::countEdge() throw (SALOME::SALOME_Exception)
145 {
146   return  _document_cpp->countEdge();
147 }
148
149 Edge_ptr Document_impl::getEdge(::CORBA::Long i) throw (SALOME::SALOME_Exception)
150 {
151   Edge_ptr result = Edge::_nil();
152
153   HEXA_NS::Edge* e = _document_cpp->getEdge(i);
154   if ( e != NULL ){
155     Edge_impl* servantCorba = new Edge_impl(e);
156     result = servantCorba->_this();
157   }
158   return result;
159 }
160
161 Edge_ptr Document_impl::findEdge(Vertex_ptr p0In, Vertex_ptr p1In)
162   throw (SALOME::SALOME_Exception)
163 {
164   Edge_ptr result = Edge::_nil();
165
166   Vertex_impl* p0InServant = ::DownCast<Vertex_impl*>( p0In );
167   Vertex_impl* p1InServant = ::DownCast<Vertex_impl*>( p1In );
168   ASSERT( p0InServant );
169   ASSERT( p1InServant );
170
171   if ( p0InServant &&  p1InServant ) {
172     HEXA_NS::Vertex* p0 = p0InServant->GetImpl();
173     HEXA_NS::Vertex* p1 = p1InServant->GetImpl();
174     HEXA_NS::Edge* e = _document_cpp->findEdge( p0, p1 );
175
176     if ( e != NULL ){
177       Edge_impl* servantCorba = new Edge_impl(e);
178       result = servantCorba->_this();
179     }
180   }
181   return result;
182 }
183
184
185 Quad_ptr Document_impl::addQuad(Edge_ptr e0In, Edge_ptr e1In, Edge_ptr e2In, Edge_ptr e3In)
186 throw (SALOME::SALOME_Exception)
187 {
188   Quad_ptr result = Quad::_nil();
189
190   Edge_impl* e0InServant = ::DownCast<Edge_impl*>( e0In );
191   Edge_impl* e1InServant = ::DownCast<Edge_impl*>( e1In );
192   Edge_impl* e2InServant = ::DownCast<Edge_impl*>( e2In );
193   Edge_impl* e3InServant = ::DownCast<Edge_impl*>( e3In );
194   ASSERT( e0InServant );
195   ASSERT( e1InServant );
196   ASSERT( e2InServant );
197   ASSERT( e3InServant );
198   if ( e0InServant &&  e1InServant && e2InServant &&  e3InServant) {
199     HEXA_NS::Edge* e0 = e0InServant->GetImpl();
200     HEXA_NS::Edge* e1 = e1InServant->GetImpl();
201     HEXA_NS::Edge* e2 = e2InServant->GetImpl();
202     HEXA_NS::Edge* e3 = e3InServant->GetImpl();
203     HEXA_NS::Quad* q = _document_cpp->addQuad( e0, e1, e2, e3 );
204     if ( q !=  NULL ){
205       Quad_impl* servantCorba = new Quad_impl(q);
206       result = servantCorba->_this();
207     }
208   }
209   return result;
210 }
211
212 Quad_ptr Document_impl::addQuadVertices( Vertex_ptr v0In, Vertex_ptr v1In,
213                                  Vertex_ptr v2In, Vertex_ptr v3In )
214   throw (SALOME::SALOME_Exception)
215 {
216   Quad_ptr result = Quad::_nil();
217
218   Vertex_impl* v0InServant = ::DownCast<Vertex_impl*>( v0In );
219   Vertex_impl* v1InServant = ::DownCast<Vertex_impl*>( v1In );
220   Vertex_impl* v2InServant = ::DownCast<Vertex_impl*>( v2In );
221   Vertex_impl* v3InServant = ::DownCast<Vertex_impl*>( v3In );
222   ASSERT( v0InServant );
223   ASSERT( v1InServant );
224   ASSERT( v2InServant );
225   ASSERT( v3InServant );
226
227   if ( v0InServant &&  v1InServant && v2InServant &&  v3InServant) {
228     HEXA_NS::Vertex* v0 = v0InServant->GetImpl();
229     HEXA_NS::Vertex* v1 = v1InServant->GetImpl();
230     HEXA_NS::Vertex* v2 = v2InServant->GetImpl();
231     HEXA_NS::Vertex* v3 = v3InServant->GetImpl();
232     HEXA_NS::Quad* q = _document_cpp->addQuadVertices( v0, v1, v2, v3 );
233     if ( q !=  NULL ){
234       Quad_impl* servantCorba = new Quad_impl(q);
235       result = servantCorba->_this();
236     }
237   }
238   return result;
239 }
240
241 ::CORBA::Long Document_impl::countQuad() throw (SALOME::SALOME_Exception)
242 {
243   return  _document_cpp->countQuad();
244 }
245
246 Quad_ptr Document_impl::getQuad(::CORBA::Long i) throw (SALOME::SALOME_Exception)
247 {
248   Quad_ptr result = Quad::_nil();
249
250   HEXA_NS::Quad* q = _document_cpp->getQuad(i);
251   if ( q != NULL ){
252     Quad_impl* servantCorba = new Quad_impl(q);
253     result = servantCorba->_this();
254   }
255   return result;
256 }
257
258 Quad_ptr Document_impl::findQuad(Vertex_ptr p0In, Vertex_ptr p1In) throw (SALOME::SALOME_Exception)
259 {
260   Quad_ptr result = Quad::_nil();
261
262   Vertex_impl* p0InServant = ::DownCast<Vertex_impl*>( p0In );
263   Vertex_impl* p1InServant = ::DownCast<Vertex_impl*>( p1In );
264   ASSERT( p0InServant );
265   ASSERT( p1InServant );
266
267   if ( p0InServant &&  p1InServant ) {
268     HEXA_NS::Vertex* p0 = p0InServant->GetImpl();
269     HEXA_NS::Vertex* p1 = p1InServant->GetImpl();
270
271     HEXA_NS::Quad* q = _document_cpp->findQuad( p0, p1 );
272     if ( q != NULL ){
273       Quad_impl* servantCorba = new Quad_impl(q);
274       result = servantCorba->_this();
275     }
276   }
277   return result;
278 }
279
280
281 Hexa_ptr Document_impl::addHexa(Quad_ptr q0In, Quad_ptr q1In, Quad_ptr q2In, Quad_ptr q3In, Quad_ptr q4In, Quad_ptr q5In)
282   throw (SALOME::SALOME_Exception)
283 {
284   Hexa_ptr result = Hexa::_nil();
285
286   Quad_impl* q0InServant = ::DownCast<Quad_impl*>( q0In );
287   Quad_impl* q1InServant = ::DownCast<Quad_impl*>( q1In );
288   Quad_impl* q2InServant = ::DownCast<Quad_impl*>( q2In );
289   Quad_impl* q3InServant = ::DownCast<Quad_impl*>( q3In );
290   Quad_impl* q4InServant = ::DownCast<Quad_impl*>( q4In );
291   Quad_impl* q5InServant = ::DownCast<Quad_impl*>( q5In );
292
293   ASSERT( q0InServant );
294   ASSERT( q1InServant );
295   ASSERT( q2InServant );
296   ASSERT( q3InServant );
297   ASSERT( q4InServant );
298   ASSERT( q5InServant );
299
300   if ( q0InServant &&  q1InServant && q2InServant &&  q3InServant
301         && q4InServant &&  q5InServant ){
302     HEXA_NS::Quad* q0 = q0InServant->GetImpl();
303     HEXA_NS::Quad* q1 = q1InServant->GetImpl();
304     HEXA_NS::Quad* q2 = q2InServant->GetImpl();
305     HEXA_NS::Quad* q3 = q3InServant->GetImpl();
306     HEXA_NS::Quad* q4 = q4InServant->GetImpl();
307     HEXA_NS::Quad* q5 = q5InServant->GetImpl();
308     HEXA_NS::Hexa* h = _document_cpp->addHexa( q0, q1, q2, q3, q4, q5 );
309     if ( h != NULL ){
310       Hexa_impl* servantCorba = new Hexa_impl(h);
311       result = servantCorba->_this();
312     }
313   }
314   return result;
315 }
316
317
318
319 Hexa_ptr Document_impl::addHexaVertices( Vertex_ptr v0In, Vertex_ptr v1In, Vertex_ptr v2In, Vertex_ptr v3In, Vertex_ptr v4In, Vertex_ptr v5In, Vertex_ptr v6In, Vertex_ptr v7In )
320   throw (SALOME::SALOME_Exception)
321 {
322   Hexa_ptr result = Hexa::_nil();
323
324   Vertex_impl* v0InServant = ::DownCast<Vertex_impl*>( v0In );
325   Vertex_impl* v1InServant = ::DownCast<Vertex_impl*>( v1In );
326   Vertex_impl* v2InServant = ::DownCast<Vertex_impl*>( v2In );
327   Vertex_impl* v3InServant = ::DownCast<Vertex_impl*>( v3In );
328   Vertex_impl* v4InServant = ::DownCast<Vertex_impl*>( v4In );
329   Vertex_impl* v5InServant = ::DownCast<Vertex_impl*>( v5In );
330   Vertex_impl* v6InServant = ::DownCast<Vertex_impl*>( v6In );
331   Vertex_impl* v7InServant = ::DownCast<Vertex_impl*>( v7In );
332   ASSERT( v0InServant );
333   ASSERT( v1InServant );
334   ASSERT( v2InServant );
335   ASSERT( v3InServant );
336   ASSERT( v4InServant );
337   ASSERT( v5InServant );
338   ASSERT( v6InServant );
339   ASSERT( v7InServant );
340
341   if ( v0InServant &&  v1InServant && v2InServant &&  v3InServant
342         && v4InServant &&  v5InServant && v6InServant &&  v7InServant ){
343     HEXA_NS::Vertex* v0 = v0InServant->GetImpl();
344     HEXA_NS::Vertex* v1 = v1InServant->GetImpl();
345     HEXA_NS::Vertex* v2 = v2InServant->GetImpl();
346     HEXA_NS::Vertex* v3 = v3InServant->GetImpl();
347     HEXA_NS::Vertex* v4 = v4InServant->GetImpl();
348     HEXA_NS::Vertex* v5 = v5InServant->GetImpl();
349     HEXA_NS::Vertex* v6 = v6InServant->GetImpl();
350     HEXA_NS::Vertex* v7 = v7InServant->GetImpl();
351
352     HEXA_NS::Hexa* h = _document_cpp->addHexaVertices( v0, v1, v2, v3, v4, v5, v6, v7 );
353     if ( h != NULL ){
354       Hexa_impl* servantCorba = new Hexa_impl(h);
355       result =  servantCorba->_this();
356     }
357   }
358   return result;
359 }
360
361
362
363 ::CORBA::Long Document_impl::countHexa() throw (SALOME::SALOME_Exception)
364 {
365   return  _document_cpp->countHexa();
366 }
367
368 Hexa_ptr Document_impl::getHexa(::CORBA::Long i) throw (SALOME::SALOME_Exception)
369 {
370   Hexa_ptr result = Hexa::_nil();
371
372   HEXA_NS::Hexa* h = _document_cpp->getHexa(i);
373   if ( h!= NULL ){
374     Hexa_impl* servantCorba = new Hexa_impl(h);
375     result = servantCorba->_this();
376   }
377   return result;
378 }
379
380
381 Hexa_ptr Document_impl::findHexa(Vertex_ptr p0In, Vertex_ptr p1In) throw (SALOME::SALOME_Exception)
382 {
383   Hexa_ptr result = Hexa::_nil();
384
385   Vertex_impl* v0InServant = ::DownCast<Vertex_impl*>( p0In );
386   Vertex_impl* v1InServant = ::DownCast<Vertex_impl*>( p1In );
387   ASSERT( v0InServant );
388   ASSERT( v1InServant );
389
390   if ( v0InServant &&  v1InServant ) {
391     HEXA_NS::Vertex* v0 = v0InServant->GetImpl();
392     HEXA_NS::Vertex* v1 = v1InServant->GetImpl();
393     HEXA_NS::Hexa* h = _document_cpp->findHexa( v0, v1 );
394     if ( h != NULL ){
395       Hexa_impl* servantCorba = new Hexa_impl(h);
396       result = servantCorba->_this();
397     }
398   }
399   return result;
400 }
401
402 Vector_ptr Document_impl::addVector( ::CORBA::Double dx, ::CORBA::Double dy, ::CORBA::Double dz )
403     throw(SALOME::SALOME_Exception)
404 {
405   Vector_ptr result = Vector::_nil();
406   HEXA_NS::Vector* v = _document_cpp->addVector( dx, dy, dz );
407
408   if ( v != NULL ){
409     Vector_impl* servantCorba = new Vector_impl(v);
410     result = servantCorba->_this();
411   }
412   return result;
413 }
414
415 Vector_ptr Document_impl::addVectorVertices( Vertex_ptr v0In, Vertex_ptr v1In )
416     throw(SALOME::SALOME_Exception)
417 {
418   Vector_ptr result = Vector::_nil();
419
420   Vertex_impl* v0InServant = ::DownCast<Vertex_impl*>( v0In );
421   Vertex_impl* v1InServant = ::DownCast<Vertex_impl*>( v1In );
422   ASSERT( v0InServant );
423   ASSERT( v1InServant );
424
425   if ( v0InServant &&  v1InServant ) {
426     HEXA_NS::Vertex* v0 = v0InServant->GetImpl();
427     HEXA_NS::Vertex* v1 = v1InServant->GetImpl();
428     HEXA_NS::Vector* v = _document_cpp->addVectorVertices( v0, v1 );
429     if ( v != NULL ){
430       Vector_impl* servantCorba = new Vector_impl(v);
431       result = servantCorba->_this();
432     }
433   }
434   return result;
435 }
436
437
438 // ::CORBA::Long Document_impl::countVector() throw (SALOME::SALOME_Exception)
439 // {
440 //   return  _document_cpp->countVector();
441 // }
442 // 
443 // Vector_ptr Document_impl::getVector(::CORBA::Long i) throw (SALOME::SALOME_Exception)
444 // {
445 //   HEXA_NS::Vector* h = _document_cpp->getVector(i);
446 //   Vector_impl* servantCorba = new Vector_impl(h);
447 //   return servantCorba->_this();
448 // }
449
450
451 Cylinder_ptr Document_impl::addCylinder( Vertex_ptr baseIn, Vector_ptr directionIn,
452       ::CORBA::Double radius, ::CORBA::Double height)
453 throw (SALOME::SALOME_Exception)
454 {
455   Cylinder_ptr result = Cylinder::_nil();
456
457   Vertex_impl* baseServant      = ::DownCast<Vertex_impl*>( baseIn );
458   Vector_impl* directionServant = ::DownCast<Vector_impl*>( directionIn );
459   ASSERT( baseServant );
460   ASSERT( directionServant );
461
462   if ( baseServant &&  directionServant ) {
463     HEXA_NS::Vertex* base = baseServant->GetImpl();
464     HEXA_NS::Vector* direction = directionServant->GetImpl();
465     HEXA_NS::Cylinder* c = _document_cpp->addCylinder( base, direction, radius, height );
466     if ( c!= NULL ){
467       Cylinder_impl* servantCorba = new Cylinder_impl(c);
468       result = servantCorba->_this();
469     }
470   }
471
472   return result;
473 }
474
475 // ::CORBA::Long Document_impl::countCylinder() throw (SALOME::SALOME_Exception)
476 // {
477 //   return  _document_cpp->countCylinder();
478 // }
479 // 
480 // 
481 // Cylinder_ptr Document_impl::getCylinder(::CORBA::Long i) throw (SALOME::SALOME_Exception)
482 // {
483 //   HEXA_NS::Cylinder* c = _document_cpp->getCylinder(i);
484 //   Cylinder_impl* servantCorba = new Cylinder_impl(c);
485 //   return servantCorba->_this();
486 // }
487
488
489 Pipe_ptr Document_impl::addPipe( Vertex_ptr baseIn, Vector_ptr directionIn,
490                   ::CORBA::Double int_radius, ::CORBA::Double ext_radius, ::CORBA::Double height)
491 throw (SALOME::SALOME_Exception)
492 {
493   Pipe_ptr result = Pipe::_nil();
494
495   Vertex_impl* baseServant      = ::DownCast<Vertex_impl*>( baseIn );
496   Vector_impl* directionServant = ::DownCast<Vector_impl*>( directionIn );
497   ASSERT( baseServant );
498   ASSERT( directionServant );
499
500   if ( baseServant &&  directionServant ) {
501     HEXA_NS::Vertex* base = baseServant->GetImpl();
502     HEXA_NS::Vector* direction = directionServant->GetImpl();
503     HEXA_NS::Pipe* c = _document_cpp->addPipe( base, direction, int_radius, ext_radius, height );
504     if ( c!= NULL ){
505       Pipe_impl* servantCorba = new Pipe_impl(c);
506       result = servantCorba->_this();
507     }
508   }
509
510   return result;
511 }
512
513
514 // ::CORBA::Long Document_impl::countPipe() throw (SALOME::SALOME_Exception)
515 // {
516 //   return  _document_cpp->countPipe();
517 // }
518 // 
519 // Pipe_ptr Document_impl::getPipe(::CORBA::Long i) throw (SALOME::SALOME_Exception)
520 // {
521 //   HEXA_NS::Pipe* p = _document_cpp->getPipe(i);
522 //   Pipe_impl* servantCorba = new Pipe_impl(p);
523 //   return servantCorba->_this();
524 // }
525
526 ::CORBA::Boolean Document_impl::removeHexa(Hexa_ptr hIn) throw (SALOME::SALOME_Exception)
527 {
528   Hexa_impl* hServant = ::DownCast<Hexa_impl*>( hIn );
529   ASSERT( hServant );
530
531   if ( hServant ) {
532     HEXA_NS::Hexa* h = hServant->GetImpl();
533     int ok = _document_cpp->removeHexa(h);
534     if ( ok == HOK )
535       return true;
536     else
537       return false;
538   }
539 }
540
541
542 ::CORBA::Boolean Document_impl::removeConnectedHexa(Hexa_ptr hIn) throw (SALOME::SALOME_Exception)
543 {
544   Hexa_impl* hServant = ::DownCast<Hexa_impl*>( hIn );
545   ASSERT( hServant );
546
547   if ( hServant ) {
548     HEXA_NS::Hexa* h = hServant->GetImpl();
549     int ok = _document_cpp->removeConnectedHexa(h);
550     if ( ok == HOK )
551       return true;
552     else
553       return false; 
554   }
555 }
556
557
558 Elements_ptr Document_impl::makeCartesian( Vertex_ptr ptIn,
559                             Vector_ptr vxIn, Vector_ptr vyIn, Vector_ptr vzIn,
560                             ::CORBA::Long nx, ::CORBA::Long ny, ::CORBA::Long nz)
561   throw (SALOME::SALOME_Exception)
562 {
563   Elements_ptr result = Elements::_nil();
564
565   Vertex_impl* ptInServant = ::DownCast<Vertex_impl*>( ptIn);
566   Vector_impl* vxInServant = ::DownCast<Vector_impl*>( vxIn );
567   Vector_impl* vyInServant = ::DownCast<Vector_impl*>( vyIn );
568   Vector_impl* vzInServant = ::DownCast<Vector_impl*>( vzIn );
569   ASSERT( ptInServant );
570   ASSERT( vxInServant );
571   ASSERT( vyInServant );
572   ASSERT( vzInServant );
573
574   if ( ptInServant &&  vxInServant &&  vyInServant && vzInServant ){
575     HEXA_NS::Vertex* pt = ptInServant->GetImpl();
576     HEXA_NS::Vector* vx = vxInServant->GetImpl();
577     HEXA_NS::Vector* vy = vyInServant->GetImpl();
578     HEXA_NS::Vector* vz = vzInServant->GetImpl();
579
580     HEXA_NS::Elements* l = _document_cpp->makeCartesian(
581         pt,
582         vx, vy, vz,
583         nx, ny, nz );
584     if ( l != NULL ){
585       Elements_impl* servantCorba = new Elements_impl(l);
586       result = servantCorba->_this();
587     }
588   }
589   return result;
590
591 }
592
593
594
595 Elements_ptr Document_impl::makeCartesian1(
596     Vertex_ptr vxIn, 
597     Vector_ptr vr1In,
598     ::CORBA::Long px, ::CORBA::Long py, ::CORBA::Long pz,
599     ::CORBA::Long mx, ::CORBA::Long my, ::CORBA::Long mz )
600     throw(SALOME::SALOME_Exception)
601 {
602   Elements_ptr result = Elements::_nil();
603
604   Vertex_impl* vxInServant  = ::DownCast<Vertex_impl*>( vxIn );
605   Vector_impl* vr1InServant = ::DownCast<Vector_impl*>( vr1In );
606   ASSERT( vxInServant );
607   ASSERT( vr1InServant );
608
609   if ( vxInServant &&  vr1InServant ){
610     HEXA_NS::Vertex* vx  = vxInServant->GetImpl();
611     HEXA_NS::Vector* vr1 = vr1InServant->GetImpl();
612
613     HEXA_NS::Elements* l = _document_cpp->makeCartesian(
614         vx,
615         vr1,
616         px, py, pz,
617         mx, my, mz );
618
619     if ( l != NULL ){
620       Elements_impl* servantCorba = new Elements_impl(l);
621       result = servantCorba->_this();
622     }
623   }
624   return result;
625 }
626
627
628 Elements_ptr Document_impl::makeCylindrical( Vertex_ptr ptIn,
629                               Vector_ptr vexIn, Vector_ptr vezIn,
630                               ::CORBA::Double dr, ::CORBA::Double da, ::CORBA::Double dl,
631                               ::CORBA::Long nr,   ::CORBA::Long na, ::CORBA::Long nl,
632                               ::CORBA::Boolean fill)
633   throw (SALOME::SALOME_Exception)
634 {
635   Elements_ptr result = Elements::_nil();
636
637   Vertex_impl* ptServant = ::DownCast<Vertex_impl*>( ptIn );
638   Vector_impl* vexServant = ::DownCast<Vector_impl*>( vexIn );
639   Vector_impl* vezServant = ::DownCast<Vector_impl*>( vezIn );
640   ASSERT( ptServant );
641   ASSERT( vexServant );
642   ASSERT( vezServant );
643
644   if ( ptServant && vexServant && vezServant) {
645     HEXA_NS::Vertex* pt  = ptServant->GetImpl();
646     HEXA_NS::Vector* vex = vexServant->GetImpl();
647     HEXA_NS::Vector* vez = vezServant->GetImpl();
648     HEXA_NS::Elements* l = _document_cpp->makeCylindrical( pt,
649                                           vex, vez,
650                                           dr, da, dl, nr, na, nl, fill );
651     if ( l != NULL ){
652       Elements_impl* servantCorba = new Elements_impl(l);
653       result = servantCorba->_this();
654     }
655   }
656   return result;
657 }
658
659
660
661 // Elements_ptr Document_impl::makeSpherical( Vertex_ptr ptIn,
662 //     ::CORBA::Double dx, ::CORBA::Double dy, ::CORBA::Double dz,
663 //     ::CORBA::Long n)
664 //   throw (SALOME::SALOME_Exception)
665 // {
666 //   Vertex_impl* ptServant = ::DownCast<Vertex_impl*>( ptIn );
667 //   ASSERT( ptServant );
668 // 
669 //   if ( ptServant ) {
670 //     HEXA_NS::Vertex* pt = ptServant->GetImpl();
671 //     HEXA_NS::Elements* l = _document_cpp->makeSpherical( pt,  dx, dy, dz, n );
672 //     Elements_impl* servantCorba = new Elements_impl(l);
673 //     return servantCorba->_this();
674 //   }
675 // }
676
677 Elements_ptr Document_impl::makeSpherical(
678     Vertex_ptr ptIn,
679     Vector_ptr dvIn,
680     ::CORBA::Long n,
681     ::CORBA::Double k )
682   throw (SALOME::SALOME_Exception) //CS_TODO
683 {
684   Elements_ptr result = Elements::_nil();
685
686   Vertex_impl* ptServant = ::DownCast<Vertex_impl*>( ptIn );
687   Vector_impl* dvServant = ::DownCast<Vector_impl*>( dvIn );
688   ASSERT( ptServant );
689   ASSERT( dvServant );
690
691   if ( ptServant && dvServant ) {
692     HEXA_NS::Vertex* pt = ptServant->GetImpl();
693     HEXA_NS::Vector* dv = dvServant->GetImpl();
694     HEXA_NS::Elements* l = _document_cpp->makeSpherical( pt, dv, n, k );
695     if ( l != NULL ){
696       Elements_impl* servantCorba = new Elements_impl(l);
697       result = servantCorba->_this();
698     }
699   }
700   return result;
701 }
702
703
704
705   
706
707
708 // Elements_ptr Document_impl::makeCylinder(Cylinder_ptr cylIn, ::CORBA::Long nr, ::CORBA::Long na, ::CORBA::Long nl)
709 Elements_ptr Document_impl::makeCylinder(Cylinder_ptr cylIn, Vector_ptr vrIn, ::CORBA::Long nr, ::CORBA::Long na, ::CORBA::Long nl)
710   throw (SALOME::SALOME_Exception)
711 {
712   Elements_ptr result = Elements::_nil();
713
714   Cylinder_impl* cylServant = ::DownCast<Cylinder_impl*>( cylIn );
715   Vector_impl* vrServant = ::DownCast<Vector_impl*>( vrIn );
716   ASSERT( cylServant );
717   ASSERT( vrServant );
718
719   if ( cylServant && vrServant ) {
720     HEXA_NS::Cylinder* cyl  = cylServant->GetImpl();
721     HEXA_NS::Vector* vr     = vrServant->GetImpl();
722     HEXA_NS::Elements* l = _document_cpp->makeCylinder( cyl, vr,  nr, na, nl );
723     if ( l != NULL ){
724       Elements_impl* servantCorba = new Elements_impl(l);
725       result = servantCorba->_this();
726     }
727   }
728   return result;
729 }
730
731 // Elements_ptr Document_impl::makePipe( Pipe_ptr pIn, ::CORBA::Long nr, ::CORBA::Long na, ::CORBA::Long nl)
732 //   throw (SALOME::SALOME_Exception)
733 // {
734 //   Pipe_impl* pServant = ::DownCast<Pipe_impl*>( pIn );
735 //   ASSERT( pServant );
736 // 
737 //   if ( pServant ) {
738 //     HEXA_NS::Pipe* p= pServant->GetImpl();
739 //     HEXA_NS::Elements* l = _document_cpp->makePipe(  p, nr, na, nl );
740 //     Elements_impl* servantCorba = new Elements_impl(l);
741 //     return servantCorba->_this();
742 //   }
743 // }
744
745
746 CrossElements_ptr Document_impl::makeCylinders(Cylinder_ptr c1In, Cylinder_ptr c2In)
747   throw (SALOME::SALOME_Exception)
748 {
749   CrossElements_ptr result = CrossElements::_nil();
750
751   Cylinder_impl* c1Servant = ::DownCast<Cylinder_impl*>( c1In );
752   Cylinder_impl* c2Servant = ::DownCast<Cylinder_impl*>( c2In );
753   ASSERT( c1Servant );
754   ASSERT( c2Servant );
755
756   if ( c1Servant && c2Servant ) {
757     HEXA_NS::Cylinder* c1= c1Servant->GetImpl();
758     HEXA_NS::Cylinder* c2= c2Servant->GetImpl();
759
760     HEXA_NS::CrossElements* l = _document_cpp->makeCylinders(c1,c2);
761     if (l != NULL ){
762       CrossElements_impl* servantCorba = new CrossElements_impl(l);
763       result = servantCorba->_this();
764     }
765   }
766   return result;
767 }
768
769
770 // Elements_ptr Document_impl::makePipes(
771 //             Pipe_ptr p1In, ::CORBA::Long n1r, ::CORBA::Long n1a, ::CORBA::Long n1l,
772 //             Pipe_ptr p2In, ::CORBA::Long n2r, ::CORBA::Long n2a, ::CORBA::Long n2l )
773 //   throw (SALOME::SALOME_Exception)
774 // {
775 //   Pipe_impl* p1Servant = ::DownCast<Pipe_impl*>( p1In );
776 //   Pipe_impl* p2Servant = ::DownCast<Pipe_impl*>( p2In );
777 //   ASSERT( p1Servant );
778 //   ASSERT( p2Servant );
779 // 
780 //   if ( p1Servant && p2Servant ) {
781 //     HEXA_NS::Pipe* p1= p1Servant->GetImpl();
782 //     HEXA_NS::Pipe* p2= p2Servant->GetImpl();
783 // 
784 //     HEXA_NS::Elements* l = _document_cpp->makePipes( p1, n1r, n1a, n1l, p2, n2r, n2a, n2l );
785 //     Elements_impl* servantCorba = new Elements_impl(l);
786 //     return servantCorba->_this();
787 //   }
788 // }
789
790
791
792 Elements_ptr Document_impl::prismQuad(Quad_ptr qdIn, Vector_ptr vIn, ::CORBA::Long nb) throw (SALOME::SALOME_Exception)
793 {
794   Elements_ptr result = Elements::_nil();
795
796   Quad_impl* qServant   = ::DownCast<Quad_impl*>( qdIn );
797   Vector_impl* vServant = ::DownCast<Vector_impl*>( vIn );
798   ASSERT( qServant );
799   ASSERT( vServant);
800
801   if ( qServant && vServant ) {
802     HEXA_NS::Quad* qd = qServant->GetImpl();
803     HEXA_NS::Vector* v = vServant->GetImpl();
804
805     HEXA_NS::Elements* l = _document_cpp->prismQuad(qd, v, nb);
806     if ( l!= NULL ){
807       Elements_impl* servantCorba = new Elements_impl(l);
808       result = servantCorba->_this();
809     }
810   }
811
812   return result;
813 }
814
815
816 //CS_Bruno
817
818 // // loop on meshes
819 //       for ( int i = 0; i < theMeshesArray.length(); i++) {
820 //         SMESH::SMESH_Mesh_var anInitMesh = theMeshesArray[i];
821 //         if ( !anInitMesh->_is_nil() ) {
822 //           SMESH_Mesh_i* anInitImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( anInitMesh ).in() );
823 //           if ( anInitImpl ) {
824 //             ::SMESH_Mesh& aInitLocMesh = anInitImpl->GetImpl();
825
826 Elements_ptr Document_impl::prismQuads(const Quads& qdsIn, Vector_ptr vIn, ::CORBA::Long nb) throw (SALOME::SALOME_Exception)
827 {
828   Elements_ptr result = Elements::_nil();
829
830   HEXA_NS::Quads qds;
831   for ( int i = 0; i < qdsIn.length(); i++) {
832     Quad_impl* qServant = ::DownCast<Quad_impl*>( qdsIn[i] );
833     ASSERT( qServant );
834     HEXA_NS::Quad* qd = qServant->GetImpl();
835     qds.push_back(qd);
836   }
837
838   Vector_impl* vServant = ::DownCast<Vector_impl*>( vIn );
839   ASSERT( vServant);
840
841   if ( vServant ) {
842     HEXA_NS::Vector* v = vServant->GetImpl();
843     HEXA_NS::Elements* l = _document_cpp->prismQuads(qds, v, nb);
844     if ( l!= NULL ){
845       Elements_impl* servantCorba = new Elements_impl(l);
846       result = servantCorba->_this();
847     }
848   }
849
850   return result;
851 }
852
853
854 Elements_ptr Document_impl::joinQuad(Quad_ptr qaIn, Quad_ptr qbIn, Vertex_ptr va1In, Vertex_ptr vb1In, Vertex_ptr va2In, Vertex_ptr vb2In, ::CORBA::Long nb) throw (SALOME::SALOME_Exception)
855 {
856   Elements_ptr result = Elements::_nil();
857
858   Quad_impl* qaServant = ::DownCast<Quad_impl*>( qaIn );
859   Quad_impl* qbServant = ::DownCast<Quad_impl*>( qbIn );
860
861   Vertex_impl* va1Servant = ::DownCast<Vertex_impl*>( va1In );
862   Vertex_impl* vb1Servant = ::DownCast<Vertex_impl*>( vb1In );
863   Vertex_impl* va2Servant = ::DownCast<Vertex_impl*>( va2In );
864   Vertex_impl* vb2Servant = ::DownCast<Vertex_impl*>( vb2In );
865
866   ASSERT( qaServant );
867   ASSERT( qbServant );
868   ASSERT( va1Servant );
869   ASSERT( vb1Servant );
870   ASSERT( va2Servant );
871   ASSERT( vb2Servant );
872
873   if ( qaServant && qbServant && va1Servant && vb1Servant && va2Servant && vb2Servant ){
874     HEXA_NS::Quad* qa = qaServant->GetImpl();
875     HEXA_NS::Quad* qb = qbServant->GetImpl();
876     HEXA_NS::Vertex* va1 = va1Servant->GetImpl();
877     HEXA_NS::Vertex* vb1 = vb1Servant->GetImpl();
878     HEXA_NS::Vertex* va2 = va2Servant->GetImpl();
879     HEXA_NS::Vertex* vb2 = vb2Servant->GetImpl();
880
881     HEXA_NS::Elements* l = _document_cpp->joinQuad(qa, qb, va1, vb1, va2, vb2, nb);
882     if ( l!= NULL ){
883       Elements_impl* servantCorba = new Elements_impl(l);
884       result = servantCorba->_this();
885     }
886   }
887
888   return result;
889 }
890
891
892
893 Elements_ptr Document_impl::joinQuads(const Quads& qdsIn, Quad_ptr qbIn, Vertex_ptr va1In, Vertex_ptr vb1In, Vertex_ptr va2In, Vertex_ptr vb2In, ::CORBA::Long nb) throw (SALOME::SALOME_Exception)
894 {
895   Elements_ptr result = Elements::_nil();
896
897   Quad_impl*   qbServant  = ::DownCast<Quad_impl*>( qbIn );
898   Vertex_impl* va1Servant = ::DownCast<Vertex_impl*>( va1In );
899   Vertex_impl* vb1Servant = ::DownCast<Vertex_impl*>( vb1In );
900   Vertex_impl* va2Servant = ::DownCast<Vertex_impl*>( va2In );
901   Vertex_impl* vb2Servant = ::DownCast<Vertex_impl*>( vb2In );
902
903   ASSERT( qbServant );
904   ASSERT( va1Servant );
905   ASSERT( vb1Servant );
906   ASSERT( va2Servant );
907   ASSERT( vb2Servant );
908
909   if ( qbServant && va1Servant && vb1Servant && va2Servant && vb2Servant ) {
910     HEXA_NS::Quad*    qb = qbServant->GetImpl();
911     HEXA_NS::Vertex* va1 = va1Servant->GetImpl();
912     HEXA_NS::Vertex* vb1 = vb1Servant->GetImpl();
913     HEXA_NS::Vertex* va2 = va2Servant->GetImpl();
914     HEXA_NS::Vertex* vb2 = vb2Servant->GetImpl();
915
916 //     MESSAGE("joinQuads  AAAAAAAAAAAAA");
917     HEXA_NS::Quads qds;
918     for ( int i = 0; i < qdsIn.length(); i++) {
919       Quad_impl* qServant = ::DownCast<Quad_impl*>( qdsIn[i] );
920       ASSERT( qServant );
921       HEXA_NS::Quad* qd = qServant->GetImpl();
922       qds.push_back(qd);
923     }
924
925     HEXA_NS::Elements* l = _document_cpp->joinQuads(qds, qb, va1, vb1, va2, vb2, nb);
926     if ( l!= NULL ){
927       Elements_impl* servantCorba = new Elements_impl(l);
928       result = servantCorba->_this();
929     }
930   }
931
932   return result;
933 }
934
935
936
937
938
939
940 ::CORBA::Long Document_impl::mergeQuads(Quad_ptr qaIn, Quad_ptr qbIn, Vertex_ptr va1In, Vertex_ptr vb1In, Vertex_ptr va2In, Vertex_ptr vb2In) throw (SALOME::SALOME_Exception)
941 {
942   Quad_impl* qaServant = ::DownCast<Quad_impl*>( qaIn );
943   Quad_impl* qbServant = ::DownCast<Quad_impl*>( qbIn );
944
945   Vertex_impl* va1Servant = ::DownCast<Vertex_impl*>( va1In );
946   Vertex_impl* vb1Servant = ::DownCast<Vertex_impl*>( vb1In );
947   Vertex_impl* va2Servant = ::DownCast<Vertex_impl*>( va2In );
948   Vertex_impl* vb2Servant = ::DownCast<Vertex_impl*>( vb2In );
949
950   ASSERT( qaServant );
951   ASSERT( qbServant );
952   ASSERT( va1Servant );
953   ASSERT( vb1Servant );
954   ASSERT( va2Servant );
955   ASSERT( vb2Servant );
956
957   if ( qaServant && qbServant && va1Servant && vb1Servant && va2Servant && vb2Servant ){
958     HEXA_NS::Quad* qa = qaServant->GetImpl();
959     HEXA_NS::Quad* qb = qbServant->GetImpl();
960     HEXA_NS::Vertex* va1 = va1Servant->GetImpl();
961     HEXA_NS::Vertex* vb1 = vb1Servant->GetImpl();
962     HEXA_NS::Vertex* va2 = va2Servant->GetImpl();
963     HEXA_NS::Vertex* vb2 = vb2Servant->GetImpl();
964
965     return _document_cpp->mergeQuads(qa, qb, va1, vb1, va2, vb2);
966 //     HEXA_NS::Elements* l = _document_cpp->mergeQuads(qa, qb, va1, vb1, va2, vb2);
967 //     Elements_impl* servantCorba = new Elements_impl(l);
968 //     return servantCorba->_this();
969   }
970 }
971
972
973
974 ::CORBA::Long Document_impl::mergeEdges(Edge_ptr e1In, Edge_ptr e2In, Vertex_ptr v1In, Vertex_ptr v2In) throw (SALOME::SALOME_Exception)
975 {
976   Edge_impl* e1Servant = ::DownCast<Edge_impl*>( e1In );
977   Edge_impl* e2Servant = ::DownCast<Edge_impl*>( e2In );
978
979   Vertex_impl* v1Servant = ::DownCast<Vertex_impl*>( v1In );
980   Vertex_impl* v2Servant = ::DownCast<Vertex_impl*>( v2In );
981
982   ASSERT( e1Servant );
983   ASSERT( e2Servant );
984   ASSERT( v1Servant );
985   ASSERT( v2Servant );
986
987   if ( e1Servant && e2Servant && v1Servant && v2Servant ){
988     HEXA_NS::Edge* e1 = e1Servant->GetImpl();
989     HEXA_NS::Edge* e2 = e2Servant->GetImpl();
990
991     HEXA_NS::Vertex* v1 = v1Servant->GetImpl();
992     HEXA_NS::Vertex* v2 = v2Servant->GetImpl();
993
994 //     HEXA_NS::Elements* l = _document_cpp->mergeEdges(e1, e2, v1, v2);
995 //     Elements_impl* servantCorba = new Elements_impl(l);
996 //     return servantCorba->_this();
997
998     return _document_cpp->mergeEdges(e1, e2, v1, v2);
999   }
1000 }
1001
1002 ::CORBA::Long Document_impl::mergeVertices(Vertex_ptr v1In, Vertex_ptr v2In) throw (SALOME::SALOME_Exception)
1003 {
1004   Vertex_impl* v1Servant = ::DownCast<Vertex_impl*>( v1In );
1005   Vertex_impl* v2Servant = ::DownCast<Vertex_impl*>( v2In );
1006
1007   ASSERT( v1Servant );
1008   ASSERT( v2Servant );
1009
1010   if ( v1Servant && v2Servant ){
1011     HEXA_NS::Vertex* v1 = v1Servant->GetImpl();
1012     HEXA_NS::Vertex* v2 = v2Servant->GetImpl();
1013
1014 //     HEXA_NS::Elements* l = _document_cpp->mergeVertices(v1, v2);
1015 //     Elements_impl* servantCorba = new Elements_impl(l);
1016 //     return servantCorba->_this();
1017     return _document_cpp->mergeVertices(v1, v2);
1018   }
1019 }
1020
1021
1022 Elements_ptr Document_impl::disconnectQuad(Hexa_ptr hexIn, Quad_ptr quadIn) throw (SALOME::SALOME_Exception)
1023 // ::CORBA::Long Document_impl::disconnectQuad(Hexa_ptr hexIn, Quad_ptr quadIn) throw (SALOME::SALOME_Exception)
1024 // Quad_ptr Document_impl::disconnectQuad(Hexa_ptr hexIn, Quad_ptr quadIn) throw (SALOME::SALOME_Exception)
1025 {
1026   Elements_ptr result = Elements::_nil();
1027 //   Quad_ptr result = Quad::_nil();
1028   Hexa_impl* hServant = ::DownCast<Hexa_impl*>( hexIn );
1029   Quad_impl* qServant = ::DownCast<Quad_impl*>( quadIn );
1030
1031   ASSERT( hServant );
1032   ASSERT( qServant );
1033
1034   if ( hServant && qServant ){
1035     HEXA_NS::Hexa* h = hServant->GetImpl();
1036     HEXA_NS::Quad* q = qServant->GetImpl();
1037
1038     HEXA_NS::Elements* elements = _document_cpp->disconnectQuad(h, q);
1039     if (elements != NULL ){
1040         Elements_impl* servantCorba = new Elements_impl(elements);
1041         result = servantCorba->_this();
1042     }
1043 //     HEXA_NS::Quad* qOut = _document_cpp->disconnectQuad(h, q);
1044 //     if (qOut != NULL ){
1045 //      Quad_impl* servantCorba = new Quad_impl(qOut);
1046 //      result = servantCorba->_this();
1047 //     }
1048   }
1049   return result;
1050 }
1051
1052
1053 // Edge_ptr Document_impl::disconnectEdge(Hexa_ptr hexIn, Edge_ptr edgeIn) throw (SALOME::SALOME_Exception)
1054 // ::CORBA::Long Document_impl::disconnectEdge(Hexa_ptr hexIn, Edge_ptr edgeIn) throw (SALOME::SALOME_Exception)
1055 Elements_ptr Document_impl::disconnectEdge(Hexa_ptr hexIn, Edge_ptr edgeIn) throw (SALOME::SALOME_Exception)
1056 {
1057   Elements_ptr result = Elements::_nil();
1058
1059   Hexa_impl* hServant = ::DownCast<Hexa_impl*>( hexIn );
1060   Edge_impl* eServant = ::DownCast<Edge_impl*>( edgeIn );
1061
1062   ASSERT( hServant );
1063   ASSERT( eServant );
1064
1065   if ( hServant && eServant ){
1066     HEXA_NS::Hexa* h = hServant->GetImpl();
1067     HEXA_NS::Edge* e = eServant->GetImpl();
1068
1069     HEXA_NS::Elements* r = _document_cpp->disconnectEdge(h, e);
1070     if ( r!= NULL ){
1071       Elements_impl* servantCorba = new Elements_impl(r);
1072       result = servantCorba->_this();
1073     }
1074
1075 //     HEXA_NS::Edge* r = _document_cpp->disconnectEdge(h, e);
1076 //     Edge_impl* servantCorba = new Edge_impl(r);
1077 //     return servantCorba->_this();
1078
1079 //     return _document_cpp->disconnectEdge(h, e);
1080   }
1081   return result;
1082 }
1083
1084 // Vertex_ptr Document_impl::disconnectVertex(Hexa_ptr hexIn, Vertex_ptr vxIn) throw (SALOME::SALOME_Exception)
1085 Elements_ptr Document_impl::disconnectVertex(Hexa_ptr hexIn, Vertex_ptr vxIn) throw (SALOME::SALOME_Exception)
1086 {
1087   Elements_ptr result = Elements::_nil();
1088
1089   Hexa_impl* hServant   = ::DownCast<Hexa_impl*>( hexIn );
1090   Vertex_impl* vServant = ::DownCast<Vertex_impl*>( vxIn );
1091
1092   ASSERT( hServant );
1093   ASSERT( vServant );
1094
1095   if ( hServant && vServant ){
1096     HEXA_NS::Hexa* h = hServant->GetImpl();
1097     HEXA_NS::Vertex* v = vServant->GetImpl();
1098
1099     HEXA_NS::Elements* r = _document_cpp->disconnectVertex(h, v);
1100     if ( r!= NULL ){
1101       Elements_impl* servantCorba = new Elements_impl(r);
1102       result = servantCorba->_this();
1103     }
1104 //     HEXA_NS::Vertex* r = _document_cpp->disconnectVertex(h, v);
1105 //     Vertex_impl* servantCorba = new Vertex_impl(r);
1106 //     return servantCorba->_this();
1107 // //     return _document_cpp->disconnectVertex(h, v);
1108   }
1109
1110   return result;
1111 }
1112
1113 Elements_ptr Document_impl::cut(Edge_ptr eIn, ::CORBA::Long nb_of_cuts) throw (SALOME::SALOME_Exception)
1114 {
1115   Elements_ptr result = Elements::_nil();
1116
1117   Edge_impl* eServant = ::DownCast<Edge_impl*>( eIn );
1118   ASSERT( eServant );
1119
1120   if ( eServant ){
1121     HEXA_NS::Edge* e = eServant->GetImpl();
1122     HEXA_NS::Elements* r = _document_cpp->cut(e, nb_of_cuts);
1123     if ( r!= NULL ){
1124       Elements_impl* servantCorba = new Elements_impl(r);
1125       result = servantCorba->_this();
1126     }
1127   }
1128
1129   return result;
1130 }
1131
1132
1133 Elements_ptr Document_impl::makeTranslation(Elements_ptr lIn, Vector_ptr vecIn) throw (SALOME::SALOME_Exception)
1134 {
1135   Elements_ptr result = Elements::_nil();
1136
1137   Elements_impl* lServant = ::DownCast<Elements_impl*>( lIn );
1138   Vector_impl* vecServant = ::DownCast<Vector_impl*>( vecIn );
1139   ASSERT( lServant );
1140   ASSERT( vecServant );
1141
1142   if ( lServant && vecServant ){
1143     HEXA_NS::Elements* l = lServant->GetImpl();
1144     HEXA_NS::Vector* vec = vecServant->GetImpl();
1145
1146     HEXA_NS::Elements* r = _document_cpp->makeTranslation(l, vec);
1147     if ( r != NULL ){
1148       Elements_impl* servantCorba = new Elements_impl(r);
1149       result = servantCorba->_this();
1150     }
1151   }
1152   return result;
1153 }
1154
1155
1156 Elements_ptr Document_impl::makeRotation(Elements_ptr lIn, Vertex_ptr pIn, Vector_ptr vecIn, ::CORBA::Double angle) throw (SALOME::SALOME_Exception)
1157 {
1158   Elements_ptr result = Elements::_nil();
1159
1160   Elements_impl* lServant = ::DownCast<Elements_impl*>( lIn );
1161   Vertex_impl*   pServant = ::DownCast<Vertex_impl*>( pIn );
1162   Vector_impl* vecServant = ::DownCast<Vector_impl*>( vecIn );
1163
1164   ASSERT( lServant );
1165   ASSERT( pServant );
1166   ASSERT( vecServant );
1167
1168   if ( lServant && pServant && vecServant ){
1169     HEXA_NS::Elements* l = lServant->GetImpl();
1170     HEXA_NS::Vertex*   p = pServant->GetImpl();
1171     HEXA_NS::Vector* vec = vecServant->GetImpl();
1172
1173     HEXA_NS::Elements* r = _document_cpp->makeRotation(l, p, vec, angle);
1174     if ( r != NULL ){
1175       Elements_impl* servantCorba = new Elements_impl(r);
1176       result = servantCorba->_this();
1177     }
1178   }
1179   return result;
1180 }
1181
1182
1183 void Document_impl::performTranslation(Elements_ptr lIn, Vector_ptr vecIn) throw (SALOME::SALOME_Exception)
1184 {
1185   Elements_impl* lServant  = ::DownCast<Elements_impl*>( lIn );
1186   Vector_impl* vecServant = ::DownCast<Vector_impl*>( vecIn );
1187
1188   ASSERT( lServant );
1189   ASSERT( vecServant );
1190
1191   if ( lServant && vecServant ){
1192     HEXA_NS::Elements* l = lServant->GetImpl();
1193     HEXA_NS::Vector* vec = vecServant->GetImpl();
1194     _document_cpp->performTranslation(l, vec);
1195   }
1196 }
1197
1198
1199 void Document_impl::performRotation(Elements_ptr lIn, Vertex_ptr pIn, Vector_ptr vecIn, ::CORBA::Double angle) throw (SALOME::SALOME_Exception)
1200 {
1201   Elements_impl* lServant = ::DownCast<Elements_impl*>( lIn );
1202   Vertex_impl*   pServant = ::DownCast<Vertex_impl*>( pIn );
1203   Vector_impl* vecServant = ::DownCast<Vector_impl*>( vecIn );
1204
1205   ASSERT( lServant );
1206   ASSERT( pServant );
1207   ASSERT( vecServant );
1208
1209   if ( lServant && pServant && vecServant ){
1210     HEXA_NS::Elements* l = lServant->GetImpl();
1211     HEXA_NS::Vertex*   p = pServant->GetImpl();
1212     HEXA_NS::Vector* vec = vecServant->GetImpl();
1213     _document_cpp->performRotation(l, p, vec, angle);
1214   }
1215 }
1216
1217 Group_ptr Document_impl::addHexaGroup(const char* name) throw (SALOME::SALOME_Exception)
1218 {
1219   Group_ptr result = Group::_nil();
1220   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::HexaCell );
1221   if ( g != NULL ){
1222     Group_impl* servantCorba = new Group_impl(g);
1223     result = servantCorba->_this();
1224   }
1225   return result;
1226 }
1227
1228
1229 Group_ptr Document_impl::addQuadGroup(const char* name) throw (SALOME::SALOME_Exception)
1230 {
1231   Group_ptr result = Group::_nil();
1232   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::QuadCell );
1233   if ( g != NULL ){
1234     Group_impl* servantCorba = new Group_impl(g);
1235     result = servantCorba->_this();
1236   }
1237   return result;
1238 }
1239
1240 Group_ptr Document_impl::addEdgeGroup(const char* name) throw (SALOME::SALOME_Exception)
1241 {
1242   Group_ptr result = Group::_nil();
1243   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::EdgeCell );
1244   if ( g != NULL ){
1245     Group_impl* servantCorba = new Group_impl(g);
1246     result = servantCorba->_this();
1247   }
1248   return result;
1249 }
1250
1251
1252 Group_ptr Document_impl::addHexaNodeGroup(const char* name) throw (SALOME::SALOME_Exception)
1253 {
1254   Group_ptr result = Group::_nil();
1255   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::HexaNode );
1256   if ( g != NULL ){
1257     Group_impl* servantCorba = new Group_impl(g);
1258     result = servantCorba->_this();
1259   }
1260   return result;
1261 }
1262
1263 Group_ptr Document_impl::addQuadNodeGroup(const char* name) throw (SALOME::SALOME_Exception)
1264 {
1265   Group_ptr result = Group::_nil();
1266   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::QuadNode );
1267   if ( g != NULL ){
1268     Group_impl* servantCorba = new Group_impl(g);
1269     result = servantCorba->_this();
1270   }
1271   return result;
1272 }
1273
1274
1275 Group_ptr Document_impl::addEdgeNodeGroup(const char* name) throw (SALOME::SALOME_Exception)
1276 {
1277   Group_ptr result = Group::_nil();
1278   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::EdgeNode );
1279   if ( g != NULL ){
1280     Group_impl* servantCorba = new Group_impl(g);
1281     result = servantCorba->_this();
1282   }
1283   return result;
1284 }
1285
1286
1287 Group_ptr Document_impl::addVertexNodeGroup(const char* name) throw (SALOME::SALOME_Exception)
1288 {
1289   Group_ptr result = Group::_nil();
1290   HEXA_NS::Group* g = _document_cpp->addGroup( name, HEXA_NS::Vertex_Node );
1291   if ( g != NULL ){
1292     Group_impl* servantCorba = new Group_impl(g);
1293     result = servantCorba->_this();
1294   }
1295   return result;
1296 }
1297
1298
1299 ::CORBA::Long Document_impl::removeGroup(Group_ptr gIn) throw (SALOME::SALOME_Exception)
1300 {
1301   Group_impl* gInServant = ::DownCast<Group_impl*>( gIn );
1302   ASSERT( gInServant );
1303
1304   if ( gInServant ) {
1305     HEXA_NS::Group* g = gInServant->GetImpl();
1306     int ok = _document_cpp->removeGroup(g);
1307     return ok;
1308   }
1309 }
1310
1311 ::CORBA::Long Document_impl::countGroup() throw (SALOME::SALOME_Exception)
1312 {
1313   return _document_cpp->countGroup();
1314 }
1315
1316
1317 Group_ptr Document_impl::getGroup(::CORBA::Long i) throw (SALOME::SALOME_Exception)
1318 {
1319   Group_ptr result  = Group::_nil();
1320   HEXA_NS::Group* g = _document_cpp->getGroup(i);
1321   if ( g != NULL ){ //CS_TODO 
1322     Group_impl* servantCorba = new Group_impl(g);
1323     result = servantCorba->_this();
1324   }
1325   return result;
1326 }
1327
1328
1329 Group_ptr Document_impl::findGroup(const char* name) throw (SALOME::SALOME_Exception)
1330 {
1331   Group_ptr result  = Group::_nil();
1332   HEXA_NS::Group* g = _document_cpp->findGroup(name);
1333   if ( g != NULL ){ //CS_TODO 
1334     Group_impl* servantCorba = new Group_impl(g);
1335     result = servantCorba->_this();
1336   }
1337   return result;
1338 }
1339
1340
1341 Law_ptr Document_impl::addLaw(const char* name, ::CORBA::Long nb_nodes) throw (SALOME::SALOME_Exception)
1342 {
1343   Law_ptr result  = Law::_nil();
1344
1345   HEXA_NS::Law* l = _document_cpp->addLaw(name, nb_nodes);
1346   if ( l != NULL ){
1347     Law_impl* servantCorba = new Law_impl(l);
1348     result = servantCorba->_this(); 
1349   }
1350
1351   return result;
1352 }
1353
1354
1355 ::CORBA::Long Document_impl::countLaw() throw (SALOME::SALOME_Exception)
1356 {
1357   return _document_cpp->countLaw();
1358 }
1359
1360 Law_ptr Document_impl::getLaw(::CORBA::Long i) throw (SALOME::SALOME_Exception)
1361 {
1362   Law_ptr result = Law::_nil();
1363
1364   HEXA_NS::Law* l = _document_cpp->getLaw(i);
1365   if ( l != NULL ){
1366     Law_impl* servantCorba = new Law_impl(l);
1367     result = servantCorba->_this();
1368   }
1369   return result;
1370 }
1371
1372
1373 void Document_impl::removeLaw(Law_ptr l) throw (SALOME::SALOME_Exception)
1374 {
1375   Law_impl* lServant = ::DownCast<Law_impl*>(l);
1376   ASSERT( lServant );
1377   if ( lServant ) {
1378     HEXA_NS::Law* l = lServant->GetImpl();
1379     _document_cpp->removeLaw(l);
1380   }
1381 }
1382
1383
1384
1385 Law_ptr Document_impl::findLaw(const char* name) throw (SALOME::SALOME_Exception)
1386 {
1387   Law_ptr result  = Law::_nil();
1388
1389   HEXA_NS::Law* l = _document_cpp->findLaw(name);
1390   if ( l != NULL ){
1391     Law_impl* servantCorba = new Law_impl(l);
1392     result = servantCorba->_this();
1393   }
1394
1395   return result;
1396 }
1397
1398
1399 ::CORBA::Long Document_impl::countPropagation() throw (SALOME::SALOME_Exception)
1400 {
1401   return _document_cpp->countPropagation();
1402 }
1403
1404
1405 Propagation_ptr Document_impl::getPropagation(::CORBA::Long i) throw (SALOME::SALOME_Exception)
1406 {
1407   Propagation_ptr result  = Propagation::_nil();
1408
1409   HEXA_NS::Propagation* p = _document_cpp->getPropagation(i);
1410 //   //CS_Test
1411 // 
1412 //   const HEXA_NS::Edges& edges_cpp = p->getEdges();
1413 // 
1414 // //   HEXA_NS::Edges::const_iterator itertest = edges_cpp.begin();
1415 // //   itertest != edges_cpp.end();
1416 //   for ( HEXA_NS::Edges::const_iterator iter = edges_cpp.begin();
1417 //      iter != edges_cpp.end();
1418 //         ++iter ){
1419 //     *iter;
1420 //   }
1421 //   //CS_Test
1422
1423   if ( p != NULL ){
1424     Propagation_impl* servantCorba = new Propagation_impl(p);
1425     result = servantCorba->_this();
1426   }
1427   return result;
1428 }
1429
1430 Propagation_ptr Document_impl::findPropagation(Edge_ptr eIn) throw (SALOME::SALOME_Exception)
1431 {
1432   Propagation_ptr result  = Propagation::_nil();
1433
1434   Edge_impl* eServant = ::DownCast<Edge_impl*>( eIn );
1435   ASSERT( eServant );
1436
1437   if ( eServant ) {
1438     HEXA_NS::Edge* e= eServant->GetImpl();
1439
1440     HEXA_NS::Propagation* p = _document_cpp->findPropagation(e);
1441     if ( p != NULL ){
1442       Propagation_impl* servantCorba = new Propagation_impl(p);
1443       result = servantCorba->_this();
1444     }
1445   }
1446
1447   return result;
1448 }
1449
1450
1451
1452
1453 // HEXA_ORB::HEXA_ORB::Hexas* Document_impl::addCartesian1(HEXA_ORB::Vertex_ptr v, HEXA_ORB::Vector_ptr v1, ::CORBA::Long px, ::CORBA::Long py, ::CORBA::Long pz, ::CORBA::Long mx, ::CORBA::Long my, ::CORBA::Long mz)
1454 //     throw (SALOME::SALOME_Exception)
1455 // {
1456 //   HEXA_ORB::HEXA_ORB::Hexas* servantGrid = new HEXA_ORB::HEXA_ORB::Hexas;
1457 // 
1458 // //   std::cout<<"v->x()"<< v->x() << std::endl;
1459 // //   std::cout<<"v->y()"<< v->y() << std::endl;
1460 // //   std::cout<<"v->z()"<< v->z() << std::endl;
1461 // //   
1462 // //   std::cout<<"v1->dx()"<< v1->dx() << std::endl;
1463 // //   std::cout<<"v1->dy()"<< v1->dy() << std::endl;
1464 // //   std::cout<<"v1->dz()"<< v1->dz() << std::endl;
1465 // // 
1466 // //   HEXA_NS::Vertex* tmpVertex = _document_cpp->vertex( v->x(), v->y(), v->z() );
1467 // // //   HEXA_NS::Vertex* tmpVertex = new HEXA_NS::Vertex(_document_cpp, v->x(), v->y(), v->z() );
1468 // //   std::cout<<"tmpVertex OK"<<std::endl;
1469 // // 
1470 // // 
1471 // //   HEXA_NS::Vector* tmpVector = _document_cpp->vector( v1->dx(), v1->dy(), v1->dz() );
1472 // // //   HEXA_NS::Vector* tmpVector = new HEXA_NS::Vector(_document_cpp, v1->dx(), v1->dy(), v1->dz() );
1473 // //   std::cout<<"tmpVector OK"<<std::endl;
1474 // // 
1475 // // //   HEXA_NS::HEXA_ORB::Hexas* grid = _document_cpp->cartesian( tmpVertex, tmpVector, px, py, pz, mx, my, mz );
1476 // //   std::cout<<"px->"<<px<<std::endl;
1477 // //   std::cout<<"py->"<<py<<std::endl;
1478 // //   std::cout<<"pz->"<<pz<<std::endl;
1479 // // 
1480 // //   HEXA_NS::HEXA_ORB::Hexas* grid = _document_cpp->cartesian( tmpVertex, tmpVector, px, py, pz);
1481 // //   std::cout<<"grid OK"<<std::endl;
1482 // //   tmpVertex->remove();
1483 // //   std::cout<<"tmpVertex->remove() OK"<<std::endl;
1484 // //   tmpVector->remove();
1485 // //   std::cout<<"tmpVector->remove() OK"<<std::endl;
1486 // // 
1487 // // 
1488 // // 
1489 // //   HEXA_NS::Hexa *oneHexa = grid->getHexa (0,0,0);
1490 // //   std::cout<<"grid->getHexa  OK"<<std::endl;
1491 // // 
1492 // //   Hexa_impl *servantHexa = new Hexa_impl( oneHexa );
1493 // //   (*servantGrid)[ 0 ] = servantHexa->_this();
1494 // // 
1495 // // // 
1496 // // //   CORBA::ULong i = 0;
1497 // // //   for (int nz=0; nz<pz ; nz++){
1498 // // //     for (int ny=nz+1; ny<py-nz-1 ; ny++){
1499 // // //       for (int nx=nz+1; nx<px-nz-1 ; nx++){
1500 // // //         HEXA_NS::Hexa *oneHexa = grid->getHexa (nx, ny, nz);
1501 // // // //         oneHexa->remove (); CS_TODO ? (not)
1502 // // //         Hexa_impl *servantHexa = new Hexa_impl( oneHexa );
1503 // // //         (*servantGrid)[ i++ ] = servantHexa->_this();
1504 // // //       }
1505 // // //     }
1506 // // //   }
1507 //   return servantGrid;
1508 // }
1509