MEDpolygoneInfo.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 MEDpolygoneInfo(med_idt fid, char *maa, med_entite_maillage type_ent, med_connectivite type_conn, 
00028                 med_int *consize)
00029 {
00030   med_idt root=0, 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_entite_maillage _type_ent=type_ent;
00037 
00038   if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00039   /*
00040    * On inhibe le gestionnaire d'erreur HDF 5
00041    */
00042   _MEDmodeErreurVerrouiller();
00043 if (MEDcheckVersion(fid) < 0) return -1;
00044 
00045 
00046   /*
00047    * Si le maillage n'existe pas => erreur
00048    */
00049   strcpy(chemin,MED_MAA);
00050   strcat(chemin,maa);
00051   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00052     goto ERROR;
00053 
00054   /*
00055    * Acces au groupe HDF des entites (MAILLE | FACE)
00056    */
00057   if ( _MEDnomEntite(nom_ent,_type_ent) < 0)
00058     goto ERROR;
00059   if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00060     goto ERROR;
00061 
00062   /*
00063    * Acces au groupe HDF du type geometrique MED_POLYGONE
00064    */
00065   if ( _MEDnomGeometrie30(nom_geo,MED_POLYGONE) < 0)
00066     goto ERROR;
00067   if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00068     goto ERROR;
00069   
00070    /*
00071     * Ouverture du dataset HDF correspondant au mode de connectivite 
00072     * S'il n'existe pas => erreur
00073     * Sinon lecture de l'attribut HDF "TAI" qui designe la taille
00074     * du tableau des connectivites
00075     */ 
00076    switch(type_conn)
00077      {
00078      case MED_NOD :
00079        strcpy(nom_dataset,MED_NOM_NOD);
00080        break;
00081 
00082      case MED_DESC :
00083        strcpy(nom_dataset,MED_NOM_DES);
00084        break;
00085        
00086      default :
00087        goto ERROR;
00088      }
00089    if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset)) < 0)
00090      goto ERROR;
00091    if ( _MEDattrEntierLire(dataset,MED_NOM_TAI,consize) < 0)
00092      goto ERROR;
00093    if ( _MEDdatasetFermer(dataset) < 0)
00094      goto ERROR;
00095 
00096    /*
00097     * On ferme tout
00098     */
00099    ret=0;
00100    ERROR:
00101    if (geoid > 0)
00102      if ( _MEDdatagroupFermer(geoid) < 0)
00103         ret=-1;
00104    if (entid > 0)
00105      if ( _MEDdatagroupFermer(entid) < 0)
00106         ret=-1;
00107    if ( _MEDdatagroupFermer(maaid) < 0)
00108       ret=-1;
00109 
00110   return ret;
00111 }

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