MEDpolygoneConnLire.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 MEDpolygoneConnLire(med_idt fid, char *maa, med_int *index, med_int ni, 
00028                    med_int *con, med_entite_maillage type_ent, 
00029                    med_connectivite type_conn)
00030 {
00031   med_err ret;
00032   med_idt maaid, entid, geoid;
00033   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];  
00034   char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00035   char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00036   char nom_dataset1[MED_TAILLE_NOM_ENTITE+1], nom_dataset2[MED_TAILLE_NOM_ENTITE+1];
00037   med_geometrie_element type_geo = MED_POLYGONE;
00038   med_entite_maillage _type_ent=type_ent;
00039 
00040   if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00041 
00042   /*
00043    * On inhibe le gestionnaire d'erreur HDF 5
00044    */
00045   _MEDmodeErreurVerrouiller();
00046 if (MEDcheckVersion(fid) < 0) return -1;
00047 
00048 
00049   /*
00050    * Si le maillage n'existe pas => erreur
00051    */
00052   strcpy(chemin,MED_MAA);
00053   strcat(chemin,maa);
00054   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00055       return -1;
00056 
00057   /*
00058    * On met a jour le nom du groupe HDF representant
00059    * le type des entites
00060    */
00061    if ((ret = _MEDnomEntite(nom_ent,_type_ent)) < 0)
00062      return -1;
00063 
00064    /*
00065     * Si le groupe HDF  des entites n'existe pas => erreur
00066     */
00067    if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00068      return -1;
00069 
00070    /*
00071     * Si le groupe HDF du type geometrique n'existe pas => erreur
00072     */
00073   if ((ret = _MEDnomGeometrie30(nom_geo,type_geo)) < 0)
00074      return -1;
00075    if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00076      return -1;
00077 
00078    /*
00079     * lecture des tableaux "index" et "con"
00080     * stockes dans des dataset HDF
00081     */
00082    switch(type_conn)
00083      {
00084      case MED_NOD :
00085        strcpy(nom_dataset1,MED_NOM_INN);
00086        strcpy(nom_dataset2,MED_NOM_NOD);
00087        break;
00088 
00089      case MED_DESC :
00090        strcpy(nom_dataset1,MED_NOM_IND);
00091        strcpy(nom_dataset2,MED_NOM_DES);
00092        break;
00093        
00094      default :
00095        return -1;
00096      }
00097 
00098 #if defined(HAVE_F77INT64)
00099    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset1,MED_INT64,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00100                                  (unsigned char*) index)) < 0)
00101      return -1;
00102    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset2,MED_INT64,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00103                                    (unsigned char*) con)) < 0)
00104      return -1;
00105 #else
00106    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset1,MED_INT32,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00107                                    (unsigned char*) index)) < 0)
00108      return -1;
00109    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset2,MED_INT32,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00110                                    (unsigned char*) con)) < 0)
00111      return -1;
00112 #endif
00113 
00114    /*
00115     * On ferme tout 
00116     */
00117    if ((ret = _MEDdatagroupFermer(geoid)) < 0)
00118      return -1;
00119    if ((ret = _MEDdatagroupFermer(entid)) < 0)
00120      return -1;
00121    if ((ret = _MEDdatagroupFermer(maaid)) < 0)
00122      return -1;
00123 
00124   return ret;
00125 }

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