Test_MEDstructElementConstAttInfo.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  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   med_int            _ncomponent=0;
00057   med_entity_type    _attentitytype=MED_UNDEF_ENTITY_TYPE;
00058   char               _profilename[MED_NAME_SIZE+1]="";
00059   med_int            _profilesize=0;
00060 
00061 
00062   /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
00063   _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
00064   if (_fid < 0) {
00065     MESSAGE("Erreur à la lecture du fichier current.med");
00066     return -1;
00067   }
00068 
00069   if ( (_nstructelement = MEDnStructElement(_fid)) <0) _ret=_nstructelement;
00070 
00071   for ( _i=1; _i<= _nstructelement; ++_i) {
00072 
00073     if (
00074         MEDstructElementInfo(_fid,
00075                              _i,
00076                              _elementname,
00077                              &_geotype,
00078                              &_elementdim,
00079                              _supportmeshname,
00080                              &_entitytype,
00081                              &_nnode,
00082                              &_ncell,
00083                              &_geocelltype,
00084                              &_nconstantattribute,
00085                              &_anyprofile,
00086                              &_nvariableattribute
00087                              )
00088     ) return -1;
00089 
00090     fprintf(stdout,"Elément de structure n° %d |%s| de type géométrique n° %d et de dimension %d\n",
00091             _i,_elementname,_geotype,_elementdim);
00092     if ( strlen(_supportmeshname) ) {
00093       fprintf(stdout,"\t Maillage support de nom |%s|",_supportmeshname);
00094       if (_ncell)
00095         fprintf(stdout," avec %d maille(s) de type %d et ",_ncell,_geocelltype);
00096       if (_nnode)
00097         fprintf(stdout," avec %d noeud(s)\n",_nnode);
00098       else {
00099         fprintf(stderr,"\n Erreur : les noeuds doivent être définis s'il existe un maillage support\n");
00100       }
00101     } else
00102       fprintf(stdout,"\t Maillage support implicite sur noeud\n");
00103       fprintf(stdout,"\t Nombre d'attribut(s) constant(s) : %d",_nconstantattribute);
00104       if (_anyprofile) fprintf(stdout,", avec profil.\n"); else fprintf(stdout,", sans profil.\n");
00105       if ( _nconstantattribute ) {
00106         for (_j=1;_j<=_nconstantattribute;++_j) {
00107           if ( MEDstructElementConstAttInfo(_fid,
00108                                             _elementname,
00109                                             _j,
00110                                             _constattname,
00111                                             &_constatttype,
00112                                             &_ncomponent,
00113                                             &_attentitytype,
00114                                             _profilename,
00115                                             &_profilesize
00116                                             ) < 0
00117                ) return -1;
00118           fprintf(stdout,"\t\t Attribut constant de nom |%s| de type %d à %d composantes\n",
00119                   _constattname,_constatttype,_ncomponent);
00120           fprintf(stdout,"\t\t  Cet Attribut est attaché au type d'entité  %d avec un profil |%s| de taille %d\n",
00121                   _attentitytype,_profilename,_profilesize);
00122 
00123         }
00124       }
00125       fprintf(stdout,"\t Nombre d'attributs variables : %d\n",_nvariableattribute);
00126 
00127   }
00128 
00129   
00130   if (MEDfileClose(_fid) < 0) {
00131     MESSAGE("ERROR : file closing");
00132     return -1;
00133   }
00134 
00135   return _ret;
00136 
00137 
00138 }
00139 

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1