MEDconnLire.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 
00020 #include <med.h>
00021 #include <med_config.h>
00022 #include <med_outils.h>
00023 
00024 #include <string.h>
00025 #include <stdlib.h>
00026 
00027 extern int mode_interlace; 
00028 
00029 med_err 
00030 MEDconnLire(med_idt fid,char *maa,med_int mdim,med_int *connectivite,med_mode_switch mode_switch,
00031             med_int * pfltabtmp, med_size psizetmp,
00032             med_entite_maillage type_ent, med_geometrie_element type_geo,med_connectivite type_conn)
00033 {
00034   med_idt maaid,entid,geoid;
00035   med_err ret;
00036   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00037   char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00038   char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00039   char nom_dataset[MED_TAILLE_NOM_ENTITE+1];
00040   med_size * pfltab=NULL;
00041   med_size    psize;
00042   int dim,nnoe,ndes;
00043   int taille;  
00044   int i,j;
00045   med_entite_maillage _type_ent=type_ent;
00046 
00047   if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00048   
00049   /*
00050    * On inhibe le gestionnaire d'erreur HDF 5
00051    */
00052   _MEDmodeErreurVerrouiller();
00053 if (MEDcheckVersion(fid) < 0) return -1;
00054 
00055   
00056   /*
00057    * Si le maillage n'existe pas => erreur
00058    */
00059   strcpy(chemin,MED_MAA);
00060   strcat(chemin,maa);
00061   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00062     return -1;
00063 
00064   /*
00065    * On met a jour le nom du Data Group representant
00066    * le type des entites
00067    */
00068    if ((ret = _MEDnomEntite(nom_ent,_type_ent)) < 0)
00069      return -1;
00070    /*
00071     * Si le Data Group des entites n'existe pas => erreur
00072     */
00073    if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00074      return -1;
00075 
00076    /*
00077     * si le Data Group du type geometrique n'existe pas => erreur
00078     */
00079    if ((ret = _MEDnomGeometrie30(nom_geo,type_geo)) < 0)
00080      return -1;
00081    if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00082      return -1;
00083 
00084    /*
00085     * Si le Data Set de la connectivite n'existe pas => erreur
00086     * Si oui => on le lit
00087     */
00088    if ((ret=_MEDparametresGeometrie(_type_ent,type_geo,&dim,&nnoe,&ndes))<0)
00089      return -1;
00090 
00091    psize = psizetmp;
00092    switch(type_conn)
00093      {
00094      case MED_NOD :
00095        strcpy(nom_dataset,MED_NOM_NOD);
00096        taille = nnoe;
00097        break;
00098 
00099      case MED_DESC :
00100        strcpy(nom_dataset,MED_NOM_DES);
00101        taille = ndes;
00102        if ( psizetmp != MED_NOPF ) {
00103          psize = psizetmp;
00104          pfltab = (med_size *) malloc (sizeof(med_size)*psize);
00105          for (i=0;i<psizetmp;i++)
00106            pfltab[i] = (med_size) (pfltabtmp[i]);
00107        };
00108        
00109        break;
00110        
00111      default :
00112        return -1;
00113      }
00114 
00115 
00116 #if defined(HAVE_F77INT64)
00117    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset,MED_INT64,
00118                                  mode_switch,(med_size)taille,MED_ALL,
00119                                  psize,MED_COMPACT,MED_PFL_NON_COMPACT,pfltab,MED_NOPG,0,
00120                                  (unsigned char*) connectivite)) < 0)
00121      return -1;
00122 #else
00123    if ((ret = _MEDdatasetNumLire(geoid,nom_dataset,MED_INT32,
00124                                  mode_switch,(med_size) taille,MED_ALL,
00125                                  psize,MED_COMPACT,MED_PFL_NON_COMPACT,pfltab,MED_NOPG,0,
00126                                  (unsigned char*) connectivite)) < 0)
00127      return -1;
00128 #endif 
00129 
00130    /*
00131     * On ferme tout 
00132     */
00133 
00134    if ( (psize != MED_NOPF) && (type_conn == MED_DESC) ) free(pfltab);
00135   
00136    if ((ret = _MEDdatagroupFermer(geoid)) < 0)
00137      return -1;
00138    if ((ret = _MEDdatagroupFermer(entid)) < 0)
00139      return -1;
00140    if ((ret = _MEDdatagroupFermer(maaid)) < 0)
00141      return -1;
00142 
00143    return 0; 
00144 }
00145 

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