Salome HOME
8459854360677b869d95fb1416372f2de5478849
[modules/smesh.git] / src / DriverMED / DriverMED_W_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_W_SMESHDS_Mesh.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "DriverMED_W_SMESHDS_Mesh.h"
29 #include "DriverMED_W_SMDS_Mesh.h"
30 #include "SMDS_MeshElement.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include <TopExp.hxx>
33 #include <vector>
34 #include "utilities.h"
35
36 DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh()
37 {
38         ;
39 }
40
41 DriverMED_W_SMESHDS_Mesh::~DriverMED_W_SMESHDS_Mesh()
42 {
43         ;
44 }
45
46 void DriverMED_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
47 {
48         myMesh = aMesh;
49 }
50
51 void DriverMED_W_SMESHDS_Mesh::SetFile(string aFile)
52 {
53         myFile = aFile;
54 }
55
56 void DriverMED_W_SMESHDS_Mesh::SetFileId(med_idt aFileId)
57 {
58         myFileId = aFileId;
59 }
60
61 void DriverMED_W_SMESHDS_Mesh::SetMeshId(int aMeshId)
62 {
63         myMeshId = aMeshId;
64 }
65
66 void DriverMED_W_SMESHDS_Mesh::Write()
67 {
68
69         string myClass = string("SMDS_Mesh");
70         string myExtension = string("MED");
71
72         DriverMED_W_SMDS_Mesh *myWriter = new DriverMED_W_SMDS_Mesh;
73
74         myWriter->SetMesh(myMesh);
75         //  myWriter->SetFile(myFile);
76         myWriter->SetMeshId(myMeshId);
77         myWriter->SetFileId(myFileId);
78
79         myWriter->Write();
80
81 }
82
83 void DriverMED_W_SMESHDS_Mesh::Add()
84 {
85
86         med_err ret = 0;
87         int i, j, k, l;
88         int numero;
89         char message[200];
90         bool ok;
91         /* nombre d'objets MED */
92         char nom_universel[MED_TAILLE_LNOM + 1];
93         med_int long_fichier_en_tete;
94         char *fichier_en_tete;
95         char version_hdf[10];
96         char version_med[10];
97         med_int nmaa, mdim, nnoe;
98         med_int nmai[MED_NBR_GEOMETRIE_MAILLE], nfac[MED_NBR_GEOMETRIE_FACE];
99         med_int nare[MED_NBR_GEOMETRIE_ARETE];
100         /* nom du maillage */
101         char nommaa[MED_TAILLE_NOM + 1];
102         /* noeuds */
103         med_float *coo;
104         // PN : Initilialisation de nomcoo et unicoo pour lisibilite du maillage
105         char nomcoo[3 * MED_TAILLE_PNOM + 1] = "x       y        z      ";
106         char unicoo[3 * MED_TAILLE_PNOM + 1] = "m       m        m     ";
107         char *nomnoe;
108         med_int *numnoe;
109         med_int *nufano;
110         med_repere rep;
111         med_booleen inonoe, inunoe;
112         med_mode_switch mode_coo;
113         char str[MED_TAILLE_PNOM + 1];
114         med_int nbNodes;
115         /* elements */
116         med_int nsup;
117         med_int edim;
118         med_int taille;
119         med_int elem_id, myId;
120         med_int *connectivite;
121         char *nomele;
122         med_int *numele;
123         med_int *nufael;
124         med_booleen inoele, inuele;
125         med_connectivite typ_con;
126         med_geometrie_element typgeo;
127         med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
128                 { MED_POINT1, MED_SEG2,
129                 MED_SEG3, MED_TRIA3,
130                 MED_TRIA6, MED_QUAD4,
131                 MED_QUAD8, MED_TETRA4,
132                 MED_TETRA10, MED_HEXA8,
133                 MED_HEXA20, MED_PENTA6,
134                 MED_PENTA15, MED_PYRA5,
135                 MED_PYRA13
136         };
137         med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
138                 { 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
139         med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
140         char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
141                 "MED_SEG2",
142                 "MED_SEG3",
143                 "MED_TRIA3",
144                 "MED_TRIA6",
145                 "MED_QUAD4",
146                 "MED_QUAD8",
147                 "MED_TETRA4",
148                 "MED_TETRA10",
149                 "MED_HEXA8",
150                 "MED_HEXA20",
151                 "MED_PENTA6",
152                 "MED_PENTA15",
153                 "MED_PYRA5",
154                 "MED_PYRA13"
155         };
156         med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
157                 { MED_TRIA3, MED_TRIA6,
158                 MED_QUAD4, MED_QUAD8
159         };
160         med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
161         med_int nfaces[MED_NBR_GEOMETRIE_FACE];
162         char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
163                 { "MED_TRIA3", "MED_TRIA6",
164                 "MED_QUAD4", "MED_QUAD8"
165         };
166         med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
167                 { MED_SEG2, MED_SEG3 };
168         med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
169         med_int naretes[MED_NBR_GEOMETRIE_ARETE];
170         char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
171                 { "MED_SEG2", "MED_SEG3" };
172
173         typ_con = MED_NOD;
174         mode_coo = MED_FULL_INTERLACE;
175         numero = myMeshId;
176
177         //---- provisoire : switch pour ecrire les familles de mailles
178         int besoinfamilledemaille = 1;
179         //---- provisoire : switch pour ecrire les familles de mailles
180
181   /****************************************************************************
182    *                      OUVERTURE DU FICHIER EN ECRITURE                    *
183    ****************************************************************************/
184         char *file2Read = (char *)myFile.c_str();
185
186         MESSAGE(" file2Read " << file2Read)
187                 myFileId = MEDouvrir(file2Read, MED_REMP);
188         if (myFileId < 0)
189         {
190                 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
191                 exit(EXIT_FAILURE);
192         }
193
194   /****************************************************************************
195    *                       NOMBRES D'OBJETS MED                               *
196    ****************************************************************************/
197         MESSAGE("(****************************)");
198         MESSAGE("(* INFORMATIONS GENERALES : *)");
199         MESSAGE("(****************************)");
200
201         /* calcul de la dimension */
202         mdim = 2;
203         double epsilon = 0.00001;
204         double nodeRefX;
205         double nodeRefY;
206         double nodeRefZ;
207
208         bool dimX = true;
209         bool dimY = true;
210         bool dimZ = true;
211
212         int inode = 0;
213         SMDS_Iterator<const SMDS_MeshNode *> * myItNodes=myMesh->nodesIterator();
214         while(myItNodes->more())
215         {
216                 const SMDS_MeshNode * node = myItNodes->next();
217                 if (inode == 0)
218                 {
219                         nodeRefX = fabs(node->X());
220                         nodeRefY = fabs(node->Y());
221                         nodeRefZ = fabs(node->Z());
222                 }
223                 SCRUTE(inode);
224                 SCRUTE(nodeRefX);
225                 SCRUTE(nodeRefY);
226                 SCRUTE(nodeRefZ);
227
228                 if (inode != 0)
229                 {
230                         if ((fabs(fabs(node->X()) - nodeRefX) > epsilon) && dimX)
231                                 dimX = false;
232                         if ((fabs(fabs(node->Y()) - nodeRefY) > epsilon) && dimY)
233                                 dimY = false;
234                         if ((fabs(fabs(node->Z()) - nodeRefZ) > epsilon) && dimZ)
235                                 dimZ = false;
236                 }
237                 if (!dimX && !dimY && !dimZ)
238                 {
239                         mdim = 3;
240                         break;
241                 }
242                 inode++;
243         }
244
245         if (mdim != 3)
246         {
247                 if (dimX && dimY && dimZ)
248                         mdim = 0;
249                 else if (!dimX)
250                 {
251                         if (dimY && dimZ)
252                                 mdim = 1;
253                         else if ((dimY && !dimZ) || (!dimY && dimZ))
254                                 mdim = 2;
255                 }
256                 else if (!dimY)
257                 {
258                         if (dimX && dimZ)
259                                 mdim = 1;
260                         else if ((dimX && !dimZ) || (!dimX && dimZ))
261                                 mdim = 2;
262                 }
263                 else if (!dimZ)
264                 {
265                         if (dimY && dimX)
266                                 mdim = 1;
267                         else if ((dimY && !dimX) || (!dimY && dimX))
268                                 mdim = 2;
269                 }
270         }
271
272         MESSAGE(" mdim " << mdim);
273
274         /* creation du maillage */
275         //mdim=3;
276         sprintf(nommaa, "Mesh %d", numero);
277         SCRUTE(nommaa);
278         ret = MEDmaaCr(myFileId, nommaa, mdim);
279
280         ASSERT(ret == 0);
281         SCRUTE(ret);
282
283         /* Combien de noeuds ? */
284         nnoe = myMesh->NbNodes();
285         //SCRUTE(nnoe);
286         /* Combien de mailles, faces ou aretes ? */
287         for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
288                 nmailles[i] = 0;
289
290         int nb_of_nodes, nb_of_faces, nb_of_edges;
291         vector < int >elem_Id[MED_NBR_GEOMETRIE_MAILLE];
292
293         nb_of_edges = myMesh->NbEdges();
294         SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
295         while(itEdges->more())
296         {
297                 const SMDS_MeshEdge * elem = itEdges->next();
298
299                 nb_of_nodes = elem->NbNodes();
300
301                 switch (nb_of_nodes)
302                 {
303                 case 2:
304                 {
305                         elem_Id[1].push_back(elem->GetID());
306                         nmailles[1]++;
307                         break;
308                 }
309                 case 3:
310                 {
311                         elem_Id[2].push_back(elem->GetID());
312                         nmailles[2]++;
313                         break;
314                 }
315                 }
316         }
317
318         nb_of_faces = myMesh->NbFaces();
319         SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
320         while(itFaces->more())
321         {
322                 const SMDS_MeshElement * elem = itFaces->next();
323
324                 nb_of_nodes = elem->NbNodes();
325
326                 switch (nb_of_nodes)
327                 {
328                 case 3:
329                 {
330                         elem_Id[3].push_back(elem->GetID());
331                         nmailles[3]++;
332                         break;
333                 }
334                 case 4:
335                 {
336                         elem_Id[5].push_back(elem->GetID());
337                         nmailles[5]++;
338                         break;
339                 }
340                 case 6:
341                 {
342                         elem_Id[4].push_back(elem->GetID());
343                         nmailles[4]++;
344                         break;
345                 }
346                 }
347
348         }
349
350         SMDS_Iterator<const SMDS_MeshVolume *> * itVolumes=myMesh->volumesIterator();
351         while(itVolumes->more())
352         {
353                 const SMDS_MeshElement * elem = itVolumes->next();
354
355                 nb_of_nodes = elem->NbNodes();
356                 switch (nb_of_nodes)
357                 {
358                 case 8:
359                 {
360                         elem_Id[9].push_back(elem->GetID());
361                         nmailles[9]++;
362                         break;
363                 }
364                 case 4 :
365                 {
366                         elem_Id[7].push_back(elem->GetID());
367                         nmailles[7]++;
368                         break;
369                 }
370                 }
371         }
372
373   /****************************************************************************
374    *                       ECRITURE DES NOEUDS                                *
375    ****************************************************************************/
376         MESSAGE("(************************)");
377         MESSAGE("(* NOEUDS DU MAILLAGE : *)");
378         MESSAGE("(************************)");
379
380         /* Allocations memoires */
381         /* table des coordonnees
382          * profil : (dimension * nombre de noeuds ) */
383         coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
384         /* table  des numeros, des numeros de familles des noeuds
385          * profil : (nombre de noeuds) */
386         numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
387         nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
388         /* table des noms des noeuds
389          * profil : (nnoe*MED_TAILLE_PNOM+1) */
390         nomnoe = "";
391
392         /* PN  pour aster, il faut une famille 0 pour les noeuds et une autre pour les elements */
393         /* PN : Creation de la famille 0 */
394         char *nomfam = "FAMILLE_0";
395         char *attdes = "";
396         char *gro = 0;
397         med_int ngro = 0;
398         med_int natt = 1;
399         med_int attide = 0;
400         med_int attval = 0;
401         med_int numfam = 0;
402         med_int attvalabs = 1;
403         ret =
404                 MEDfamCr(myFileId, nommaa, nomfam, numfam, &attide, &attval, attdes,
405                 natt, gro, ngro);
406         ASSERT(ret == 0);
407
408         /* PN : FIN Creation de la famille 0 */
409
410         map < int, int >mapNoeud;
411         typedef pair < set < int >::iterator, bool > IsFamily;
412         int nbFamillesNoeud;
413
414         i = 0;
415         set < int >FamilySet;
416         nbFamillesNoeud = 0;
417         int verifienbnoeuds = 0;
418         med_int *rien = 0;
419
420         SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
421         while(itNodes->more())
422         {
423                 const SMDS_MeshNode * node = itNodes->next();
424
425                 if (mdim == 3)
426                 {
427                         coo[i * 3] = node->X();
428                         coo[i * 3 + 1] = node->Y();
429                         coo[i * 3 + 2] = node->Z();
430                 }
431                 else if (mdim == 2)
432                 {
433                         if (dimX)
434                         {
435                                 coo[i * 2] = node->Y();
436                                 coo[i * 2 + 1] = node->Z();
437                         }
438                         if (dimY)
439                         {
440                                 coo[i * 2] = node->X();
441                                 coo[i * 2 + 1] = node->Z();
442                         }
443                         if (dimZ)
444                         {
445                                 coo[i * 2] = node->X();
446                                 coo[i * 2 + 1] = node->Y();
447                         }
448                 }
449                 else
450                 {
451                         if (dimX)
452                         {
453                                 coo[i * 2] = node->Y();
454                                 coo[i * 2 + 1] = node->Z();
455                         }
456                         if (dimY)
457                         {
458                                 coo[i * 2] = node->X();
459                                 coo[i * 2 + 1] = node->Z();
460                         }
461                         if (dimZ)
462                         {
463                                 coo[i * 2] = node->X();
464                                 coo[i * 2 + 1] = node->Y();
465                         }
466                 }
467                 mapNoeud[node->GetID()] = i + 1;
468
469                 // renvoie 0 pour les noeuds internes du volume
470                 int numfamille = node->GetPosition()->GetShapeId();
471                 nufano[i] = numfamille;
472
473                 //SCRUTE(i);
474                 //SCRUTE(nufano[i]);
475                 //SCRUTE(coo[i*3]);
476                 //SCRUTE(coo[i*3+1]);
477                 //SCRUTE(coo[i*3+2]);
478                 if (nufano[i] != 0)
479                 {
480                         IsFamily deja = FamilySet.insert(nufano[i]);    // insert if new, or gives existant
481                         if (deja.second)        // actually inserted
482                         {
483                                 char famille[MED_TAILLE_NOM + 1];
484                                 sprintf(famille, "F%d", nufano[i]);
485                                 //          CreateFamily(strdup(nommaa),strdup(famille),nufano[i],attvalabs++);
486                                 attvalabs++;
487                                 CreateFamily(strdup(nommaa), strdup(famille), nufano[i],
488                                         numfamille);
489                                 //MESSAGE("---famille-noeud--- "<<nbFamillesNoeud<<" "<<nufano[i]);
490                                 nbFamillesNoeud++;
491                         }
492                 }
493
494                 i++;
495                 verifienbnoeuds++;
496         }
497         ret = MEDnoeudsEcr(myFileId, nommaa, mdim, coo, mode_coo, MED_CART,
498                 nomcoo, unicoo, nomnoe, MED_FAUX, rien, MED_FAUX,
499                 nufano, nnoe, MED_REMP);
500         ASSERT(ret == 0);
501         MESSAGE("--- Creation de " << verifienbnoeuds << " noeuds");
502         ASSERT(verifienbnoeuds == nnoe);
503         MESSAGE("--- Creation de " << nbFamillesNoeud << " familles de noeuds");
504
505         /* liberation memoire */
506         free(coo);
507         free(numnoe);
508         free(nufano);
509
510   /****************************************************************************
511    *                       ECRITURE DES ELEMENTS                              *
512    ****************************************************************************/
513         MESSAGE("(**************************)");
514         MESSAGE("(* ELEMENTS DU MAILLAGE : *)");
515         MESSAGE("(**************************)");
516
517         /* Ecriture des connectivites, noms, numeros des mailles */
518
519         if (ret == 0)
520         {
521                 int nbFamillesElts = 0;
522                 SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
523                 TopTools_IndexedMapOfShape myIndexToShape;
524                 TopExp::MapShapes(mySMESHDSMesh->ShapeToMesh(), myIndexToShape);
525
526                 map<int,int> mapFamille;
527
528                 if (besoinfamilledemaille == 1)
529                 {
530                         int t;
531                         for (t = 1; t <= myIndexToShape.Extent(); t++)
532                         {
533                                 const TopoDS_Shape S = myIndexToShape(t);
534                                 if (mySMESHDSMesh->HasMeshElements(S))
535                                 {
536                                         //MESSAGE ("********* Traitement de la Famille "<<-t);
537
538                                         SMESHDS_SubMesh * SM = mySMESHDSMesh->MeshElements(S);
539                                         SMDS_Iterator<const SMDS_MeshElement*> * ite=SM->GetElements();
540                                         bool plein = false;
541                                         while(ite->more())
542                                         {
543                                                 mapFamille[ite->next()->GetID()] = -t;
544                                                 plein = true;
545                                         }
546                                         if (plein)
547                                         {
548                                                 nbFamillesElts++;
549                                                 char famille[MED_TAILLE_NOM + 1];
550                                                 sprintf(famille, "E%d", t);
551                                                 CreateFamily(strdup(nommaa), strdup(famille), -t,
552                                                         attvalabs++);
553                                         }
554                                 }
555                         }
556                 }
557
558                 int indice = 1;
559                 for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
560                 {
561                         if (nmailles[i] > 0 && ret == 0)
562                         {
563                                 MESSAGE(" Start " << typmai[i]);
564
565                                 /* dimension de la maille */
566                                 edim = typmai[i] / 100;
567                                 nsup = 0;
568                                 if (mdim == 2 || mdim == 3)
569                                         if (edim == 1)
570                                                 nsup = 1;
571                                 if (mdim == 3)
572                                         if (edim == 2)
573                                                 nsup = 1;
574                                 //SCRUTE(nsup);
575
576                                 taille = nsup + typmai[i] % 100;
577                                 //SCRUTE(taille);
578
579                                 /* allocation memoire */
580                                 connectivite =
581                                         (med_int *) malloc(sizeof(med_int) * taille * nmailles[i]);
582                                 /* nomele =
583                                         (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
584                                         nmailles[i] + 1);*/
585                                 nomele = "";
586                                 numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
587                                 nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
588                                 nbNodes = typmai[i] % 100;
589
590                                 for (j = 0; j < nmailles[i]; j++)
591                                 {
592                                         myId = elem_Id[i][j];
593                                         const SMDS_MeshElement * elem =
594                                                 myMesh->FindElement(myId);
595                                         //*(numele+j) = myId;
596                                         *(numele + j) = indice++;
597
598                                         SMDS_Iterator<const SMDS_MeshElement *> * itk=elem->nodesIterator();
599                                         for (k = 0; itk->more(); k++)
600                                         {
601                                                 *(connectivite + j * taille + k) =
602                                                         mapNoeud[itk->next()->GetID()];
603                                         }
604                                         delete itk;
605
606                                         if (nsup)
607                                                 *(connectivite + j * taille + nbNodes) = 0;
608
609                                         if (besoinfamilledemaille == 1)
610                                         {
611                                                 if (mapFamille.find(myId) != mapFamille.end())
612                                                 {
613                                                         nufael[j] = mapFamille[myId];
614                                                 }
615                                                 else
616                                                 {
617                                                         nufael[j] = 0;
618                                                 }
619                                         }
620                                         else
621                                         {
622                                                 nufael[j] = 0;
623                                         }
624
625                                         //SCRUTE(myId);
626                                         //SCRUTE(j);
627                                         //SCRUTE(nufael[j]);
628                                 }
629
630                                 /* ecriture des donnĂ©es */
631
632                                 med_int *rien = 0;
633                                 ret =
634                                         MEDelementsEcr(myFileId, nommaa, mdim, connectivite,
635                                         mode_coo, nomele, MED_FAUX, numele, MED_VRAI, nufael,
636                                         nmailles[i], MED_MAILLE, typmai[i], typ_con, MED_REMP);
637                                 ASSERT(ret == 0);
638                                 //SCRUTE(ret);
639
640                                 if (ret < 0)
641                                         MESSAGE(">> ERREUR : ecriture des mailles \n");
642
643                                 /* liberation memoire */
644                                 free(connectivite);
645                                 free(numele);
646                                 free(nufael);
647                                 MESSAGE(" End " << typmai[i]);
648                         }
649                 };
650                 MESSAGE("--- Creation de " << nbFamillesElts << " familles d elements");
651
652         }
653
654           /****************************************************************************
655       *                      FERMETURE DU FICHIER                                *
656       ****************************************************************************/
657
658         ret = MEDfermer(myFileId);
659
660         if (ret != 0)
661                 fprintf(stderr, ">> ERREUR : erreur a la fermeture du fichier %s\n",
662                         file2Read);
663         MESSAGE("fichier ferme");
664
665 }
666
667 void DriverMED_W_SMESHDS_Mesh::CreateFamily(char *nommaa, char *famille, int i,
668         med_int k)
669 {
670
671         med_int ngro = 0;
672         med_int natt;
673
674         natt = 1;
675         char attdes[MED_TAILLE_DESC + 1];
676         char gro[MED_TAILLE_LNOM + 1];
677         char fam2[MED_TAILLE_LNOM + 1];
678
679         strcpy(attdes, "");
680         strcpy(gro, "");
681         strcpy(fam2, famille);
682
683         med_int *attide = new med_int[1];
684         med_int *attval = new med_int[1];
685         attide[0] = k;
686         attval[0] = k;
687
688         //MESSAGE("-------- Creation de la Famille : "<< famille << "numero " << i << " --------------");
689         med_int ret =
690                 MEDfamCr(myFileId, nommaa, fam2, i, attide, attval, attdes, natt, gro,
691                 ngro);
692         ASSERT(ret == 0);
693         delete[]attide;
694         delete[]attval;
695
696 }