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