# Test_MEDstructElementVarAttInfo.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018
    00019 #include <med.h>
    00020 #define MESGERR 1
    00021 #include <med_utils.h>
    00022 #include <string.h>
    00023
    00024 #ifdef DEF_LECT_ECR
    00025 #define MODE_ACCES MED_ACC_RDWR
    00026 #elif DEF_LECT_AJOUT
    00027 #define MODE_ACCES MED_ACC_RDEXT
    00028 #else
    00029 #define MODE_ACCES MED_ACC_CREAT
    00030 #endif
    00031
    00032 int main (int argc, char **argv)
    00033
    00034 {
    00035   med_err           _ret=0;
    00036   med_idt           _fid=0;
    00037   int               _i  =0;
    00038   int               _j  =0;
    00039   med_int           _nstructelement=0;
    00040
    00041   med_geometry_type _geotype=MED_NONE;
    00042
    00043   char              _elementname[MED_NAME_SIZE+1]="";
    00044   med_int           _elementdim=0;
    00045   char              _supportmeshname[MED_NAME_SIZE+1]="";
    00046   med_entity_type   _entitytype=MED_UNDEF_ENTITY_TYPE;
    00047   med_int           _nnode=0;
    00048   med_int           _ncell=0;
    00049   med_geometry_type _geocelltype=MED_NONE;
    00050   med_int           _nconstantattribute=0;
    00051   med_bool          _anyprofile=0;
    00052   med_int           _nvariableattribute=0;
    00053
    00054   char               _constattname[MED_NAME_SIZE+1]="";
    00055   med_attribute_type _constatttype=MED_ATT_UNDEF;
    00056   char               _varattname[MED_NAME_SIZE+1]="";
    00057   med_attribute_type _varatttype=MED_ATT_UNDEF;
    00058   med_int            _ncomponent=0;
    00059   med_entity_type    _attentitytype=MED_UNDEF_ENTITY_TYPE;
    00060   char               _profilename[MED_NAME_SIZE+1]="";
    00061   med_int            _profilesize=0;
    00062
    00063
    00064   /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
    00065   _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
    00066   if (_fid < 0) {
    00067     MESSAGE("Erreur à la lecture du fichier current.med");
    00068     return -1;
    00069   }
    00070
    00071   if ( (_nstructelement = MEDnStructElement(_fid)) <0) _ret=_nstructelement;
    00072
    00073   for ( _i=1; _i<= _nstructelement; ++_i) {
    00074
    00075     if (
    00076         MEDstructElementInfo(_fid,
    00077                              _i,
    00078                              _elementname,
    00079                              &_geotype,
    00080                              &_elementdim,
    00081                              _supportmeshname,
    00082                              &_entitytype,
    00083                              &_nnode,
    00084                              &_ncell,
    00085                              &_geocelltype,
    00086                              &_nconstantattribute,
    00087                              &_anyprofile,
    00088                              &_nvariableattribute
    00089                              )
    00090     ) return -1;
    00091
    00092     fprintf(stdout,"Elément de structure n° %d |%s| de type géométrique n° %d et de dimension %d\n",
    00093             _i,_elementname,_geotype,_elementdim);
    00094     if ( strlen(_supportmeshname) ) {
    00095       fprintf(stdout,"\t Maillage support de nom |%s|",_supportmeshname);
    00096       if (_ncell)
    00097         fprintf(stdout," avec %d maille(s) de type %d et ",_ncell,_geocelltype);
    00098       if (_nnode)
    00099         fprintf(stdout," avec %d noeud(s)\n",_nnode);
    00100       else {
    00101         fprintf(stderr,"\n Erreur : les noeuds doivent être définis s'il existe un maillage support\n");
    00102       }
    00103     } else
    00104       fprintf(stdout,"\t Maillage support implicite sur noeud\n");
    00105       fprintf(stdout,"\t Nombre d'attribut(s) constant(s) : %d",_nconstantattribute);
    00106       if (_anyprofile) fprintf(stdout,", avec profil.\n"); else fprintf(stdout,", sans profil.\n");
    00107       if ( _nconstantattribute ) {
    00108         for (_j=1;_j<=_nconstantattribute;++_j) {
    00109           if ( MEDstructElementConstAttInfo(_fid,
    00110                                             _elementname,
    00111                                             _j,
    00112                                             _constattname,
    00113                                             &_constatttype,
    00114                                             &_ncomponent,
    00115                                             &_attentitytype,
    00116                                             _profilename,
    00117                                             &_profilesize
    00118                                             ) < 0
    00119                ) return -1;
    00120           fprintf(stdout,"\t\t Attribut constant de nom |%s| de type %d à %d composantes\n",
    00121                   _constattname,_constatttype,_ncomponent);
    00122           fprintf(stdout,"\t\t  Cet Attribut est attaché au type d'entité  %d avec un profil |%s| de taille %d\n",
    00123                   _attentitytype,_profilename,_profilesize);
    00124
    00125         }
    00126       }
    00127
    00128       fprintf(stdout,"\t Nombre d'attributs variables : %d\n",_nvariableattribute);
    00129       if ( _nvariableattribute ) {
    00130         for (_j=1;_j<=_nvariableattribute;++_j) {
    00131           if ( MEDstructElementVarAttInfo(_fid,
    00132                                           _elementname,
    00133                                           _j,
    00134                                           _varattname,
    00135                                           &_varatttype,
    00136                                           &_ncomponent ) < 0
    00137                ) return -1;
    00138           fprintf(stdout,"\t\t Attribut variable de nom |%s| de type %d à %d composantes\n",
    00139                   _varattname,_varatttype,_ncomponent);
    00140         }
    00141       }
    00142
    00143   }
    00144
    00145
    00146   if (MEDfileClose(_fid) < 0) {
    00147     MESSAGE("ERROR : file closing");
    00148     return -1;
    00149   }
    00150
    00151   return _ret;
    00152
    00153
    00154 }
    00155