Salome HOME
sources v1.2
[modules/smesh.git] / src / DriverMED / DriverMED_R_SMESHDS_Mesh.cxx
1 //  SMESH DriverMED : driver to read and write 'med' files
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DriverMED_R_SMESHDS_Mesh.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "DriverMED_R_SMESHDS_Mesh.h"
29 #include "DriverMED_R_SMDS_Mesh.h"
30 #include "utilities.h"
31
32 #include <stdlib.h>
33
34 DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh() {
35   myFileId=-1;
36 }
37
38 DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh() {
39 ;
40 }
41
42 void DriverMED_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
43   //myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh);
44   myMesh = aMesh;
45 }
46
47 void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile) {
48   myFile = aFile;
49 }
50
51 void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId) {
52   myFileId = aFileId;
53 }
54
55 void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId) {
56   myMeshId = aMeshId;
57 }
58
59 void DriverMED_R_SMESHDS_Mesh::Read() {
60
61   string myClass = string("SMDS_Mesh");
62   string myExtension = string("MED");
63
64   DriverMED_R_SMDS_Mesh* myReader = new DriverMED_R_SMDS_Mesh;
65
66   myReader->SetMesh(myMesh);
67   myReader->SetMeshId(myMeshId);
68   myReader->SetFile(myFile);
69   myReader->SetFileId(-1);
70
71   myReader->Read();
72
73 }
74
75 void DriverMED_R_SMESHDS_Mesh::Add() {
76
77   string myClass = string("SMDS_Mesh");
78   string myExtension = string("MED");
79
80   DriverMED_R_SMDS_Mesh* myReader = new DriverMED_R_SMDS_Mesh;
81
82   myReader->SetMesh(myMesh);
83   myReader->SetMeshId(myMeshId);
84
85   SCRUTE(myFileId);
86   myReader->SetFileId(myFileId);
87
88   myReader->Read();
89
90 }
91
92 void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
93
94   med_err ret = 0;
95   int i,j,k,l;
96   int numero;
97   char message[200];
98   Standard_Boolean ok;
99   /* nombre d'objets MED */
100   char nom_universel[MED_TAILLE_LNOM+1];
101   med_int long_fichier_en_tete; 
102   char *fichier_en_tete;
103   char version_hdf[10];
104   char version_med[10];
105   med_int nmaa,mdim,nnoe;
106   med_int nmai[MED_NBR_GEOMETRIE_MAILLE],nfac[MED_NBR_GEOMETRIE_FACE];
107   med_int nare[MED_NBR_GEOMETRIE_ARETE];
108   /* nom du maillage */
109   char nommaa[MED_TAILLE_NOM+1];
110   /* noeuds */
111   med_float *coo;
112   char nomcoo[3*MED_TAILLE_PNOM+1];
113   char unicoo[3*MED_TAILLE_PNOM+1];
114   char *nomnoe;
115   med_int *numnoe;
116   med_int *nufano; 
117   med_repere rep;
118   med_booleen inonoe,inunoe;
119   med_mode_switch mode_coo;
120   char str[MED_TAILLE_PNOM+1];
121   /* elements */
122   med_int nsup;
123   med_int edim;
124   med_int taille;
125   med_int elem_id;
126   med_int cmpt = 0;
127   med_int *connectivite;
128   char *nomele;
129   med_int *numele;
130   med_int *nufael;
131   med_booleen inoele, inuele;
132   med_connectivite typ_con;
133   med_geometrie_element typgeo;
134   med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {MED_POINT1,MED_SEG2, 
135                                                    MED_SEG3,MED_TRIA3,
136                                                    MED_TRIA6,MED_QUAD4,
137                                                    MED_QUAD8,MED_TETRA4,
138                                                    MED_TETRA10,MED_HEXA8,
139                                                    MED_HEXA20,MED_PENTA6,
140                                                    MED_PENTA15,MED_PYRA5,
141                                                    MED_PYRA13};
142   med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5};
143   med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
144   char nommai[MED_NBR_GEOMETRIE_MAILLE] [MED_TAILLE_NOM+1] = {"MED_POINT1",
145                                                           "MED_SEG2", 
146                                                           "MED_SEG3",
147                                                           "MED_TRIA3",
148                                                           "MED_TRIA6",
149                                                           "MED_QUAD4",
150                                                           "MED_QUAD8",
151                                                           "MED_TETRA4",
152                                                           "MED_TETRA10",
153                                                           "MED_HEXA8",
154                                                           "MED_HEXA20",
155                                                           "MED_PENTA6",
156                                                           "MED_PENTA15",
157                                                           "MED_PYRA5",
158                                                           "MED_PYRA13"};
159   med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6,
160                                                  MED_QUAD4,MED_QUAD8};
161   med_int desfac[MED_NBR_GEOMETRIE_FACE] = {3,3,4,4};
162   med_int nfaces[MED_NBR_GEOMETRIE_FACE];
163   char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6",
164                                                        "MED_QUAD4","MED_QUAD8"};
165   med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3};
166   med_int desare[MED_NBR_GEOMETRIE_ARETE] = {2,3};
167   med_int naretes[MED_NBR_GEOMETRIE_ARETE];
168   char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"};
169   /* familles */
170   med_int nfam;
171   med_int natt,ngro;
172   char *attdes,*gro;
173   med_int *attval,*attide;
174   char nomfam[MED_TAILLE_NOM+1];
175   med_int numfam;
176   char str1[MED_TAILLE_DESC+1];
177   char str2[MED_TAILLE_LNOM+1];
178   string fam;
179   string fam_type;
180   string fam_id;
181   
182   char* file2Read;
183   bool locally_managed;
184
185   if (myFileId==-1) 
186     locally_managed = true;
187   else
188     locally_managed = false;
189
190   if (locally_managed)
191     { 
192     file2Read = (char*)myFile.c_str();
193     myFileId = MEDouvrir(file2Read,MED_LECT);
194     if (myFileId < 0)
195       {
196         fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
197         exit(EXIT_FAILURE);
198       }
199     numero = 1;
200     }
201   else
202     numero = myMeshId;
203   sprintf(nommaa,"Mesh %d",myMeshId);//pour load
204   SCRUTE(nommaa);
205     
206   typ_con = MED_NOD;
207   mode_coo = MED_FULL_INTERLACE;
208   mdim = 3;
209
210   Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh);
211
212   //TopoDS_Shape myShape = mySMESHDSMesh->ShapeToMesh();
213
214   /****************************************************************************
215   *                       NOMBRES D'OBJETS MED                                *
216   ****************************************************************************/
217   fprintf(stdout,"\n(****************************)\n");
218   fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
219   fprintf(stdout,"(****************************)\n");
220
221   /* lecture du nom et de la dimension du maillage */
222   /*!  fprintf(stdout,"%d %d\n",myFileId,numero);
223   ret = MEDmaaInfo(myFileId,numero,nommaa,&mdim);
224   fprintf(stdout,"%d\n",ret);
225   if (ret < 0)
226     {
227       fprintf(stderr,">> ERREUR : lecture du nom du maillage \n");
228       exit(EXIT_FAILURE);
229     }
230   fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
231   fprintf(stdout,"- Dimension du maillage : %d\n",mdim);
232   */
233   /* Combien de noeuds ? */
234   nnoe = MEDnEntMaa(myFileId,nommaa,MED_COOR,MED_NOEUD,MED_POINT1,typ_con);
235   if (nnoe < 0)
236     {
237       fprintf(stderr,">> ERREUR : lecture du nombre de noeuds \n");
238       exit(EXIT_FAILURE);
239     }
240   fprintf(stdout,"- Nombre de noeuds : %d \n",nnoe);
241
242   /* Combien de mailles, faces ou aretes ? */
243   for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
244     {
245       nmailles[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_MAILLE,typmai[i],
246                                typ_con);
247       if (nmailles[i] < 0)
248         {
249           fprintf(stderr,">> ERREUR : lecture du nombre de mailles \n");
250           exit(EXIT_FAILURE);
251         }
252       fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[i],nmailles[i]);
253     }
254
255   for (i=0;i<MED_NBR_GEOMETRIE_FACE;i++)
256     {
257       nfaces[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_FACE,typfac[i],
258                              typ_con);
259       if (nfaces[i] < 0)
260         {
261           fprintf(stderr,">> ERREUR : lecture du nombre de faces \n");
262           exit(EXIT_FAILURE);
263         }
264       fprintf (stdout,"- Nombre de faces de type %s : %d \n",nomfac[i],nfaces[i]);
265     }    
266
267   for (i=0;i<MED_NBR_GEOMETRIE_ARETE;i++)
268     {
269       naretes[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_ARETE,typare[i],
270                               typ_con); 
271       if (naretes[i] < 0)
272         {
273           fprintf(stderr,">> ERREUR : lecture du nombre d'aretes \n");
274           exit(EXIT_FAILURE);
275         }
276       fprintf (stdout,"- Nombre d'aretes de type %s : %d \n",nomare[i],naretes[i]);
277     }
278
279   /* nombre de familles */
280   nfam = MEDnFam(myFileId,nommaa,0,MED_FAMILLE);
281   if (nfam < 0)
282     {
283       fprintf(stderr,">> ERREUR : lecture du nombre de familles \n");
284       exit(EXIT_FAILURE);
285     }   
286   fprintf(stdout,"- Nombre de familles : %d \n",nfam);
287
288   vector<int> family[nfam];
289
290   /****************************************************************************
291   *                       LECTURE DES NOEUDS                                  *
292   ****************************************************************************/
293   fprintf(stdout,"\n(************************)\n");
294   fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
295   fprintf(stdout,"(************************)\n");
296
297   /* Allocations memoires */
298   /* table des coordonnees 
299      profil : (dimension * nombre de noeuds ) */
300   coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
301   /* table  des numeros, des numeros de familles des noeuds
302      profil : (nombre de noeuds) */
303   numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
304   nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
305   /* table des noms des noeuds 
306      profil : (nnoe*MED_TAILLE_PNOM+1) */
307   nomnoe = (char*) malloc(MED_TAILLE_PNOM*nnoe+1);
308
309   /* lecture des noeuds : 
310      - coordonnees
311      - noms (optionnel dans un fichier MED) 
312      - numeros (optionnel dans un fichier MED) 
313      - numeros des familles */
314   ret = MEDnoeudsLire(myFileId,nommaa,mdim,coo,mode_coo,&rep,
315                       nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe,
316                       nufano,nnoe);
317   if (ret < 0)
318     strcpy(message,">> ERREUR : lecture des noeuds \n");
319
320   if (inunoe) {
321     for (int i=0;i<nnoe;i++) {
322       ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],numnoe[i]);
323       //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
324     }
325   }
326   else {
327     for (int i=0;i<nnoe;i++) {
328       ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],i+1);
329       //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
330       family[*(nufano+i)].push_back(numnoe[i]);
331     }
332   }
333
334   fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
335   for (i=0;i<nnoe;i++)
336     fprintf(stdout," %d ",*(nufano+i));
337   fprintf(stdout,"\n");
338
339   /* liberation memoire */
340   free(coo);
341   free(nomnoe);
342   free(numnoe);
343   free(nufano);
344
345   /****************************************************************************
346   *                       LECTURE DES ELEMENTS                                *
347   ****************************************************************************/
348   fprintf(stdout,"\n(**************************)\n");
349   fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
350   fprintf(stdout,"(**************************)");
351   //fprintf(Out,"CELLS\n");
352   /* Lecture des connectivites, noms, numeros des mailles */
353   //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]);
354
355   if (ret == 0)
356     for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
357       {
358         if (nmailles[i] > 0 && ret == 0)
359           {
360             /* dimension de la maille */
361             edim = typmai[i] / 100;
362             nsup = 0;
363             if (mdim  == 2 || mdim == 3)
364               if (edim == 1)
365                 nsup = 1;
366             if (mdim == 3)
367               if (edim == 2)
368                 nsup = 1;
369
370             taille = nsup+typmai[i]%100;
371             //taille = typmai[i]%100;
372             
373             /* allocation memoire */
374             connectivite = (med_int*)malloc(sizeof(med_int)*
375                                             taille*nmailles[i]);
376             nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM*
377                                    nmailles[i]+1);
378             numele = (med_int*)malloc(sizeof(med_int)*
379                                       nmailles[i]);
380             nufael = (med_int*)malloc(sizeof(med_int)*
381                                       nmailles[i]);
382             
383             /* lecture des données */
384             ret = MEDelementsLire(myFileId,nommaa,mdim,connectivite,mode_coo,
385                                   nomele,&inoele,numele,&inuele,nufael,
386                                   nmailles[i],MED_MAILLE,typmai[i],
387                                   typ_con);
388
389             switch (typmai[i])
390               {
391               case MED_TRIA3  : {
392                 if (inuele) {
393                   for (j=0;j<nmailles[i];j++) {
394                     elem_id=*(numele+j);
395                     ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),elem_id);
396                     //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
397                   }
398                 }
399                 else {
400                   for (j=0;j<nmailles[i];j++) {
401                     cmpt++;
402                     ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),cmpt);
403                     //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
404                   }
405                 }
406
407                 break;
408               }
409               case MED_QUAD4  : {
410                 if (inuele) {
411                   for (j=0;j<nmailles[i];j++) {
412                     elem_id=*(numele+j);
413                     ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),elem_id);
414                     //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
415                   }
416                 }
417                 else {
418                   for (j=0;j<nmailles[i];j++) {
419                     cmpt++;
420                     ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),cmpt);
421                     //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
422                   }
423                 }
424                 break;
425               }
426               case MED_HEXA8  : {
427                 if (inuele) {
428                   for (j=0;j<nmailles[i];j++) {
429                     elem_id=*(numele+j);
430                     ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7),elem_id);
431                     //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
432                   }
433                 }
434                 else {
435                   for (j=0;j<nmailles[i];j++) {
436                     cmpt++;
437                     ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),cmpt);
438                     //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
439                   }
440                 }
441                 break;
442               }
443               default : {
444                 break ;
445               }
446               }
447
448             fprintf(stdout,"\n  - Numéros de familles : \n");
449             for (j=0;j<nmailles[i];j++)
450               fprintf(stdout," %d ",*(nufael+j));
451             
452             /* liberation memoire */
453             free(connectivite);
454             free(nomele);
455             free(numele);
456             free(nufael);
457           }
458       }
459
460   /****************************************************************************
461    *                       LECTURE DES FAMILLES                                *
462    ****************************************************************************/
463   printf("\n(*************************)\n");
464   printf("(* FAMILLES DU MAILLAGE : *)\n");
465   printf("(*************************)\n");
466   if (ret == 0)
467     for (i=0;i<nfam;i++)
468       {
469         
470         /* nombre de groupes */
471         ngro = MEDnFam(myFileId,nommaa,i+1,MED_GROUPE);
472         if (ngro < 0)  
473           {
474             ret = -1;
475             strcpy(message,
476                    ">> ERREUR : lecture du nombre de groupes d'une famille \n");
477           }
478         
479         /* nombre d'attributs */
480         if (ret == 0)
481           {
482             natt = MEDnFam(myFileId,nommaa,i+1,MED_ATTR);
483             if (natt < 0)
484               {
485                 ret = -1;
486                 strcpy(message,
487                    ">> ERREUR : lecture du nombre d'attributs d'une famille\n");
488               }
489           }
490
491         if (ret == 0)
492           fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,ngro); 
493
494         /* nom,numero,attributs,groupes */
495         if (ret == 0)
496           {
497             attide = (med_int*) malloc(sizeof(med_int)*natt);
498             attval = (med_int*) malloc(sizeof(med_int)*natt);       
499             attdes = (char *) malloc(MED_TAILLE_DESC*natt+1);
500             gro = (char*) malloc(MED_TAILLE_LNOM*ngro+1);
501             ret = MEDfamInfo(myFileId,nommaa,i+1,nomfam,&numfam,attide,attval,
502                              attdes,&natt,gro,&ngro);
503
504             fam = string(nomfam);
505             fam_type = fam.substr(1,1);
506             fam_id = fam.substr(2,1);
507             if ((fam_type==string("V"))||(fam_type==string("A"))||(fam_type==string("F")))
508               LinkMeshToShape(fam_type, fam_id, family[i]);
509
510             fprintf(stdout,"  - Famille de nom %s et de numero %d : \n",nomfam,numfam);
511             fprintf(stdout,"  - Attributs : \n");
512             for (j=0;j<natt;j++)
513               {
514                 strncpy(str1,attdes+j*MED_TAILLE_DESC,MED_TAILLE_DESC);
515                 str1[MED_TAILLE_DESC] = '\0';
516                 fprintf(stdout,"   ide = %d - val = %d - des = %s\n",*(attide+j),
517                        *(attval+j),str1);
518               }
519             free(attide);
520             free(attval);
521             free(attdes);
522             fprintf(stdout,"  - Groupes :\n");
523             for (j=0;j<ngro;j++)
524               {
525                 strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
526                 str2[MED_TAILLE_LNOM] = '\0';
527                 fprintf(stdout,"   gro = %s\n",str2);
528               }
529             free(gro);
530           }
531       }
532
533   if (locally_managed)
534     ret = MEDfermer(myFileId);
535
536 }
537
538 void DriverMED_R_SMESHDS_Mesh::LinkMeshToShape(string fam_type, string fam_id, vector<int> myNodes) {
539
540   Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh);
541
542   int id = atoi(fam_id.c_str());
543   if (fam_type==string("V")) { //Linked to a vertex
544     for (int i=0;i<myNodes.size();i++) {
545       Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]);
546       const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem);
547       //const TopoDS_Vertex& S;//le recuperer !!!
548       //mySMESHDSMesh->SetNodeOnVertex (node,S);
549     }
550   }
551   else 
552   if (fam_type==string("E")) { //Linked to an edge
553     for (int i=0;i<myNodes.size();i++) {
554       Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]);
555       const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem);
556       //const TopoDS_Edge& S;//le recuperer !!!
557       //mySMESHDSMesh->SetNodeOnEdge (node,S);
558     }
559   }
560   else 
561   if (fam_type==string("F")) { //Linked to a face
562     for (int i=0;i<myNodes.size();i++) {
563       Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]);
564       const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem);
565       //const TopoDS_Face& S;//le recuperer !!!
566       //mySMESHDSMesh->SetNodeOnFace (node,S);
567     }
568   }
569
570 }
571