MEDfamInfo.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 <stdlib.h>
00024 #include <string.h>
00025 
00026 med_err
00027 MEDfamInfo(med_idt fid,char *maa,int indice, char *famille,
00028            med_int *numero,
00029            med_int *attr_ident, med_int *attr_val, char *attr_desc,
00030            med_int *n_attr, char *groupe ,med_int *n_groupe)
00031 {
00032   med_idt famid,datagroup;
00033   med_err ret;
00034   char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_FAS_ENTITE+2*MED_TAILLE_NOM+1];
00035   char stockage[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_FAS_ENTITE+2*MED_TAILLE_NOM+1];
00036   int num;
00037   int nfamnoe,nfammai;
00038   int n_tmp;
00039   med_booleen _isfam0=MED_FAUX;
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    * On recupere le nom de la famille
00050    */
00051   num = indice - 1;
00052   strcpy(famille,"");
00053 
00054   /* Acces a la famille :
00055    * nfam = nfamnoe + 1 + nfammai
00056    * Repartition selon l'indice "num" dans le datagroup :
00057    *    - 0..nfammai - 1 : familles des mailles/faces/aretes
00058    *    - nfamai : famille 0
00059    *    - (nfamai + 1)..(nfammai+nfamnoe) : familles de noeuds
00060    */
00061 
00062   /* On va compter les familles de mailles/faces/aretes */
00063   strcpy(chemin,MED_MAA);
00064   strcat(chemin,maa);
00065   strcat(chemin,MED_FAS);
00066 
00067   strcpy(stockage,chemin);
00068   strcat(stockage,MED_FAS_ELEME_NOM);
00069   nfammai = 0;
00070   n_tmp = 0;
00071   if ((ret =_MEDnObjets(fid,stockage,&n_tmp)) == 0)
00072     nfammai = (med_int ) n_tmp;
00073   strcat(stockage,"/");
00074 
00075   /* Pour la famille 0 */
00076   if (num == nfammai) {
00077     strcpy(stockage,chemin);
00078     strcpy(famille,FAMILLE_ZERO);
00079   }
00080 
00081   if (num > nfammai) {
00082     /* C'est une famille de noeuds */
00083     strcpy(stockage,chemin);
00084     strcat(stockage,MED_FAS_NOEUD_NOM);
00085     strcat(stockage,"/");
00086     num = num - nfammai - 1;
00087   }
00088 
00089 
00090   /*
00091    * Si le Data Group de la famille n'existe pas => erreur
00092    */
00093   /* pour la famille 0, on connait déjà le nom */
00094   if (strcmp(famille,FAMILLE_ZERO)) {
00095     _isfam0=MED_FAUX;
00096     if ((ret = _MEDobjetIdentifier(fid,stockage,num, famille)) < 0)
00097       return -1;
00098   } else
00099     _isfam0=MED_VRAI;
00100 
00101   strcat(stockage,famille);
00102   if ((famid = _MEDdatagroupOuvrir(fid,stockage)) < 0)
00103     return -1;
00104 
00105   /*
00106    * L'attribut NUM
00107    */
00108   if ((ret = _MEDattrEntierLire(famid,MED_NOM_NUM,numero)) < 0)
00109     return -1;
00110 
00111   /*
00112    * Le Data Group "GRO"
00113    */
00114   if (!_isfam0) { /*famille différente de la famille zéro*/
00115     if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_GRO)) >= 0) {
00116       /*
00117        * L'attribut "NBR"
00118        */
00119       if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_groupe)) < 0)
00120         return -1;
00121 
00122       /*
00123        * Data Set des noms des groupes "NOM"
00124        */
00125       if ((ret = _MEDdatasetStringLire(datagroup,MED_NOM_NOM,groupe)) < 0)
00126         return -1;
00127 
00128       /*
00129        * On ferme le Data Group
00130        */
00131       if ((ret = _MEDdatagroupFermer(datagroup)) < 0) return -1;
00132     } else
00133       *n_groupe = 0;
00134   } else
00135     *n_groupe = 0;
00136 
00137 
00138   /*
00139    * Le Data Group "ATT"
00140    */
00141 
00142   if (!_isfam0) { /*famille différente de la famille zéro*/
00143     if ( (datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_ATT)) >= 0) {
00144       /*
00145        * L'attribut "NBR"
00146        */
00147       if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_attr)) < 0)
00148         return -1;
00149 
00150       /*
00151        * Le Data Set "IDE"
00152        */
00153 #if defined(HAVE_F77INT64)
00154       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT64,
00155                                     MED_NO_INTERLACE,1,MED_ALL,
00156                                     MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00157                                     (unsigned char*) attr_ident)) < 0)
00158         return -1;
00159 #else
00160       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT32,
00161                                     MED_NO_INTERLACE,1,MED_ALL,
00162                                     MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00163                                     (unsigned char*) attr_ident)) < 0)
00164         return -1;
00165 #endif
00166 
00167       /*
00168        * Le Data Set "VAL"
00169        */
00170 #if defined(HAVE_F77INT64)
00171       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT64,
00172                                     MED_NO_INTERLACE,1,MED_ALL,
00173                                     MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00174                                     (unsigned char *) attr_val)) < 0)
00175         return -1;
00176 #else
00177       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT32,
00178                                     MED_NO_INTERLACE,1,MED_ALL,
00179                                     MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00180                                     (unsigned char *) attr_val)) < 0)
00181         return -1;
00182 #endif
00183 
00184       /*
00185        * Le Data Set "DES"
00186        */
00187       ret = _MEDdatasetStringLire(datagroup,MED_NOM_DES,attr_desc);
00188 
00189       /*
00190        * On ferme le Data Group
00191        */
00192       if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00193         return -1;
00194     } else
00195       *n_attr = 0;
00196   } else
00197     *n_attr = 0;
00198 
00199   /*
00200    * On ferme tout
00201    */
00202 
00203   if ((ret = _MEDdatagroupFermer(famid)) < 0)
00204     return -1;
00205 
00206   return 0;
00207 }
00208 
00209 
00210 

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