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