1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 /*************************************************************************
21 * COPYRIGHT (C) 1999 - 2002 EDF R&D
22 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
23 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE
24 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
25 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
27 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
28 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
29 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
30 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
32 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
33 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
34 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
36 *************************************************************************/
39 #include "med_outils.hxx"
44 extern int mode_interlace;
49 MEDconnEcr(med_idt fid,char *maa, med_int mdim, med_int *connectivite,med_mode_switch mode_switch,
50 med_int nbre,med_mode_acces mode,med_entite_maillage type_ent,
51 med_geometrie_element type_geo,med_connectivite type_conn)
53 med_idt maaid, entid, geoid, dataset;
56 char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
57 char nom_ent[MED_TAILLE_NOM_ENTITE+1];
58 char nom_geo[MED_TAILLE_NOM_ENTITE+1];
59 char nom_dataset[MED_TAILLE_NOM_ENTITE+1];
65 * On inhibe le gestionnaire d'erreur HDF 5
67 _MEDmodeErreurVerrouiller();
70 * Si le maillage n'existe pas => erreur
72 strcpy(chemin,MED_MAA);
74 if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
78 * On met a jour le nom du Data Group representant
81 if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0)
84 * Si le Data Group des entites n'existe pas on le cree
87 if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
88 if ((entid = _MEDdatagroupCreer(maaid,nom_ent)) < 0)
92 * On cree s'il n'existe pas le Data Group du type geometrique
95 if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0)
97 if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
98 if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0)
102 * On regarde si le Data Set existe et on le cree sinon
104 if ((ret=_MEDparametresGeometrie(type_ent,type_geo,&dim,&nnoe,&ndes))<0)
106 if (mdim == 2 || mdim == 3)
107 if (type_ent == MED_MAILLE && dim == 1)
110 if (type_ent == MED_MAILLE && dim == 2)
115 strcpy(nom_dataset,MED_NOM_NOD);
116 taille = nsup + nnoe;
120 strcpy(nom_dataset,MED_NOM_DES);
121 taille = nsup + ndes;
127 dimd[0] = nbre*taille;
128 #if defined(IRIX64)||defined(OSF1)
129 if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset,MED_INT64,mode_switch,(med_size)taille,MED_ALL,MED_NOPF,0,MED_NOPG,dimd,
130 (unsigned char*) connectivite,mode)) < 0)
133 if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset,MED_INT32,mode_switch,(med_size)taille,MED_ALL,MED_NOPF,0,MED_NOPG,dimd,
134 (unsigned char*) connectivite,mode)) < 0)
139 * Attribut NBR (nombre de noeuds ou d'elements)
141 if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset)) < 0)
143 if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&nbre,mode)) < 0)
149 if ((ret = _MEDdatasetFermer(dataset)) < 0)
151 if ((ret = _MEDdatagroupFermer(geoid)) < 0)
153 if ((ret = _MEDdatagroupFermer(entid)) < 0)
155 if ((ret = _MEDdatagroupFermer(maaid)) < 0)