MEDpolyedreConnLire.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 MEDpolyedreConnLire(med_idt fid,char *maa,med_int *indexp,med_int np,med_int *indexf,med_int nf,
00028                    med_int *con,med_connectivite type_conn)
00029 {
00030   med_err ret;
00031   med_idt maaid, entid, geoid, dataset;
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_dataset1[MED_TAILLE_NOM_ENTITE+1];
00036   char nom_dataset2[MED_TAILLE_NOM_ENTITE+1];
00037   char nom_dataset3[MED_TAILLE_NOM_ENTITE+1];
00038   med_geometrie_element type_geo;
00039   med_entite_maillage type_ent;
00040 
00041   /*
00042    * On inhibe le gestionnaire d'erreur HDF 5
00043    */
00044   _MEDmodeErreurVerrouiller();
00045 if (MEDcheckVersion(fid) < 0) return -1;
00046 
00047 
00048   /*
00049    * Si le maillage n'existe pas => erreur
00050    */
00051   strcpy(chemin,MED_MAA);
00052   strcat(chemin,maa);
00053   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00054       return -1;
00055 
00056   /*
00057    * On met a jour le nom du groupe HDF representant
00058    * le type des entites
00059    */
00060   type_ent = MED_MAILLE;
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    type_geo = MED_POLYEDRE;
00074    if ((ret = _MEDnomGeometrie30(nom_geo,type_geo)) < 0)
00075      return -1;
00076    if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00077      return -1;
00078 
00079    /*
00080     * On va lire les tableaux "indexp", "indexf" et "con" 
00081     * dans les datasets HDF
00082     */
00083    switch(type_conn)
00084      {
00085      case MED_NOD :
00086        strcpy(nom_dataset1,MED_NOM_INN);
00087        strcpy(nom_dataset2,MED_NOM_IFN);
00088        strcpy(nom_dataset3,MED_NOM_NOD);
00089        break;
00090 
00091      case MED_DESC :
00092        strcpy(nom_dataset1,MED_NOM_IND);
00093        strcpy(nom_dataset2,MED_NOM_IFD);
00094        strcpy(nom_dataset3,MED_NOM_DES);
00095        break;
00096        
00097      default :
00098        return -1;
00099      }
00100 
00101 #if defined(HAVE_F77INT64)
00102    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,
00103                                  (unsigned char*) indexp)) < 0)
00104      return -1;
00105    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,
00106                                  (unsigned char*) indexf)) < 0)
00107      return -1;
00108    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset3,MED_INT64,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00109                                  (unsigned char*) con)) < 0)
00110      return -1;
00111 #else
00112    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,
00113                                  (unsigned char*) indexp)) < 0)
00114      return -1;
00115    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,
00116                                  (unsigned char*) indexf)) < 0)
00117      return -1;
00118    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset3,MED_INT32,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00119                                  (unsigned char*) con)) < 0)
00120      return -1;
00121 #endif
00122 
00123    /*
00124     * On ferme tout 
00125     */
00126    if ((ret = _MEDdatagroupFermer(geoid)) < 0)
00127      return -1;
00128    if ((ret = _MEDdatagroupFermer(entid)) < 0)
00129      return -1;
00130    if ((ret = _MEDdatagroupFermer(maaid)) < 0)
00131      return -1;
00132 
00133   return ret;
00134 }

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