# Test_MEDstructElementInfo.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   med_int           _nstructelement=0;
    00039
    00040   med_geometry_type _geotype=MED_NONE;
    00041
    00042   char              _elementname[MED_NAME_SIZE+1]="";
    00043   med_int           _elementdim=0;
    00044   char              _supportmeshname[MED_NAME_SIZE+1]="";
    00045   med_entity_type   _entitytype=MED_UNDEF_ENTITY_TYPE;
    00046   med_int           _nnode=0;
    00047   med_int           _ncell=0;
    00048   med_geometry_type _geocelltype=MED_NONE;
    00049   med_int           _nconstantattribute=0;
    00050   med_bool          _anyprofile=0;
    00051   med_int           _nvariableattribute=0;
    00052
    00053
    00054   /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
    00055   _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
    00056   if (_fid < 0) {
    00057     MESSAGE("Erreur à la lecture du fichier current.med");
    00058     return -1;
    00059   }
    00060
    00061   if ( (_nstructelement = MEDnStructElement(_fid)) <0) _ret=_nstructelement;
    00062
    00063   for ( _i=1; _i<= _nstructelement; ++_i) {
    00064
    00065     if (
    00066         MEDstructElementInfo(_fid,
    00067                              _i,
    00068                              _elementname,
    00069                              &_geotype,
    00070                              &_elementdim,
    00071                              _supportmeshname,
    00072                              &_entitytype,
    00073                              &_nnode,
    00074                              &_ncell,
    00075                              &_geocelltype,
    00076                              &_nconstantattribute,
    00077                              &_anyprofile,
    00078                              &_nvariableattribute
    00079                              )
    00080     ) return -1;
    00081
    00082     fprintf(stdout,"Elément de structure n° %d |%s| de type géométrique n° %d et de dimension %d\n",
    00083             _i,_elementname,_geotype,_elementdim);
    00084     if ( strlen(_supportmeshname) ) {
    00085       fprintf(stdout,"\t Maillage support de nom |%s|",_supportmeshname);
    00086       if (_ncell)
    00087         fprintf(stdout," avec %d mailles de type %d et ",_ncell,_geocelltype);
    00088       if (_nnode)
    00089         fprintf(stdout," avec %d noeuds\n",_nnode);
    00090       else {
    00091         fprintf(stderr,"\n Erreur : les noeuds doivent être définis s'il existe un maillage support\n");
    00092       }
    00093     } else
    00094       fprintf(stdout," avec support implicite sur noeud\n");
    00095
    00096    fprintf(stdout,"\t Nombre d'attributs constants : %d",_nconstantattribute);
    00097    if (_anyprofile) fprintf(stdout,", avec profil.\n"); else fprintf(stdout,", sans profil.\n");
    00098    fprintf(stdout,"\t Nombre d'attributs variables : %d\n",_nvariableattribute);
    00099
    00100   }
    00101
    00102
    00103   if (MEDfileClose(_fid) < 0) {
    00104     MESSAGE("ERROR : file closing");
    00105     return -1;
    00106   }
    00107
    00108   return _ret;
    00109
    00110
    00111 }
    00112