MEDpolyedreInfo.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 #include <med_config.h>
00021 #include <med_outils.h>
00022 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 med_err
00027 MEDpolyedreInfo(med_idt fid, char *maa,med_connectivite type_conn,med_int *nf,
00028                 med_int *consize)
00029 {
00030   med_idt  maaid=0, entid=0, geoid=0, dataset=0;
00031   med_err  _ret = -1;
00032   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00033   char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00034   char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00035   char nom_dataset[MED_TAILLE_NOM_ENTITE+1];
00036   med_int res = 0;
00037   med_entite_maillage type_ent;
00038   med_geometrie_element type_geo;
00039 
00040   /*
00041    * On inhibe le gestionnaire d'erreur HDF 5
00042    */
00043   _MEDmodeErreurVerrouiller();
00044 if (MEDcheckVersion(fid) < 0) goto ERROR;
00045 
00046 
00047   /*
00048    * Si le maillage n'existe pas => erreur
00049    */
00050   strcpy(chemin,MED_MAA);
00051   strcat(chemin,maa);
00052   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00053     goto ERROR;
00054 
00055   /*
00056    * Acces au groupe HDF des entites (MED_MAILLE)
00057    */
00058   type_ent = MED_MAILLE;
00059   if ( _MEDnomEntite(nom_ent,type_ent) < 0)
00060     goto ERROR;
00061   if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00062     goto ERROR;
00063 
00064   /*
00065    * Acces au groupe HDF du type geometrique MED_POLYEDRE
00066    */
00067   type_geo = MED_POLYEDRE;
00068   if ( _MEDnomGeometrie30(nom_geo,type_geo) < 0)
00069     goto ERROR;
00070   if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00071     goto ERROR;
00072   
00073    /*
00074     * Ouverture du dataset HDF correspondant au mode de connectivite 
00075     * S'il n'existe pas => erreur
00076     * Sinon lecture de l'attribut HDF "TAI" qui designe la taille
00077     * du tableau des connectivites et de l'attribut "TTI" qui
00078     * designe la taille du tableau "indexf"
00079     */ 
00080    switch(type_conn)
00081      {
00082      case MED_NOD :
00083        strcpy(nom_dataset,MED_NOM_NOD);
00084        break;
00085 
00086      case MED_DESC :
00087        strcpy(nom_dataset,MED_NOM_DES);
00088        break;
00089        
00090      default :
00091        goto ERROR;
00092      }
00093 
00094    if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset)) < 0)
00095      goto ERROR;
00096    if ( _MEDattrEntierLire(dataset,MED_NOM_TAI,consize) < 0)
00097      goto ERROR;
00098    if ( _MEDdatasetFermer(dataset) < 0)
00099      goto ERROR;
00100 
00101    if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset)) < 0)
00102      goto ERROR;
00103    if ( _MEDattrEntierLire(dataset,MED_NOM_TTI,nf) < 0)
00104      goto ERROR;
00105    if (_MEDdatasetFermer(dataset) < 0)
00106      goto ERROR;
00107 
00108    /*
00109     * On ferme tout
00110     */
00111    _ret=0;
00112 
00113  ERROR:
00114 
00115    if (geoid > 0) if (_MEDdatagroupFermer(geoid) < 0) _ret= -1;
00116    if (entid > 0) if (_MEDdatagroupFermer(entid) < 0) _ret= -1;
00117    if (maaid > 0) if (_MEDdatagroupFermer(maaid) < 0)  _ret= -1;
00118 
00119   return _ret;
00120 }

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