MEDfamilyInfo.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 
00038 med_err
00039 MEDfamilyInfo(const med_idt        fid,
00040               const char *   const meshname,
00041               const int            famit,
00042               char * const         familyname,
00043               med_int *const       familynumber,
00044               char *const          groupname)
00045 {
00046   med_err    _ret=-1,_err=-1;
00047   med_idt    _datagroup=0,_famid=0;
00048   char       _path   [MED_TAILLE_FAS+MED_NAME_SIZE+
00049                      MED_TAILLE_FAS_ENTITE+MED_NAME_SIZE+1] = MED_FAS;
00050   med_int    _n          = 0;
00051   med_size   _tmpn       = 0;
00052   int        _pathreflen = 0;
00053   int        _num        = famit-1;
00054   int        _nfammai=0;
00055   med_int    _ngroup=0;
00056   med_filter _filter=MED_FILTER_INIT;
00057   /*
00058    * On inhibe le gestionnaire d'erreur HDF 5
00059    */
00060   _MEDmodeErreurVerrouiller();
00061 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00062 
00063   /*
00064    * On recupere le nom de la famille
00065    */
00066 
00067   /* Acces a la famille :
00068    * nfam = nfamnoe + 1 + nfammai
00069    * Repartition selon l'indice "num" dans le datagroup :
00070    *    - 0..nfammai - 1 : familles des mailles/faces/aretes
00071    *    - nfamai : famille 0
00072    *    - (nfamai + 1)..(nfammai+nfamnoe) : familles de noeuds
00073    */
00074 
00075   /* Comptage des familles de mailles/faces/aretes */
00076   strcat(_path,meshname);
00077   _pathreflen=strlen(_path);
00078 
00079   strncpy(&_path[_pathreflen],MED_FAS_ELEME,MED_TAILLE_FAS_ENTITE+1);
00080   if ( (_err = _MEDnObjects(fid,_path,&_tmpn)) < 0 )
00081     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00082       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_path);
00083       goto ERROR;
00084     }
00085 
00086   _nfammai = (med_int ) _tmpn;
00087 
00088 /*   SSCRUTE(_path); */
00089 /*   ISCRUTE(_nfammai); */
00090 
00091   /* Pour la famille 0 */
00092   /* (0<=_num<_nfammai) : famille éléments */
00093   /* (_num == _nfammai) : famille 0 */
00094   /* (_num > _nfammai ) : famille de noeuds */
00095   if (_num == _nfammai) {
00096     strcpy(familyname,FAMILLE_ZERO);
00097     groupname[0]='\0';
00098     *familynumber=0;
00099     return 0;
00100   }
00101 
00102 
00103   /* C'est une _family de noeuds */
00104   if (_num > _nfammai) {
00105     strncpy(&_path[_pathreflen],MED_FAS_NOEUD,MED_TAILLE_FAS_ENTITE+1);
00106     _num = _num - _nfammai - 1;
00107   }
00108 
00109 /*   SSCRUTE(_path); */
00110 
00111   /*
00112    * Si le Data Group de la famille n'existe pas => erreur
00113    */
00114   if ( _MEDobjectGetName(fid, _path ,_num, familyname) < 0 ) {
00115     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);ISCRUTE_int(famit);
00116     goto ERROR;
00117   }
00118 /*   SSCRUTE(familyname); */
00119   strcat(_path,familyname);
00120 /*   SSCRUTE(_path); */
00121 
00122   if ((_famid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00123     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FAMILY_MSG);
00124     SSCRUTE(_path);
00125     goto ERROR;
00126   }
00127 
00128   /*
00129    * L'attribut NUM
00130    */
00131   if ( _MEDattrEntierLire(_famid,MED_NOM_NUM,familynumber) < 0) {
00132       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FAMILY_MSG);
00133       SSCRUTE(familyname);SSCRUTE(_path);
00134       SSCRUTE(MED_NOM_NUM);ISCRUTE(*familynumber);goto ERROR;
00135   }
00136 /*   ISCRUTE(*familynumber); */
00137 
00138   /*
00139    * Le Data Group "GRO"
00140    */
00141   if ((_datagroup = _MEDdatagroupOuvrir(_famid,MED_NOM_GRO)) >= 0) {
00142 
00143     /*
00144      * L'attribut "NBR"
00145      */
00146     if ( _MEDattrEntierLire(_datagroup,MED_NOM_NBR,&_ngroup) < 0) {
00147       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FAMILY_MSG);
00148       SSCRUTE(familyname);SSCRUTE(_path);SSCRUTE(MED_NOM_GRO);
00149       SSCRUTE(MED_NOM_NBR);
00150       goto ERROR;
00151     }
00152 /*     ISCRUTE(_ngroup); */
00153 
00154     /*
00155      * Data Set des noms des groupes "NOM"
00156      */
00157     if ( MEDfilterEntityCr(fid, _ngroup, 1, 1, MED_ALL_CONSTITUENT,
00158                            MED_NO_INTERLACE,MED_UNDEF_PFLMODE,
00159                            MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00160       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00161       goto ERROR;
00162     }
00163 
00164     if ( _MEDdatasetRd(_datagroup,MED_NOM_NOM,MED_INTERNAL_LNAME,&_filter,
00165                        (unsigned char * const) groupname) < 0) {
00166       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_NOM);
00167       SSCRUTE(_path);SSCRUTE(MED_NOM_GRO);SSCRUTE(groupname);
00168       goto ERROR;
00169     }
00170 /*     SSCRUTE(groupname); */
00171 
00172     if ( MEDfilterClose(&_filter) < 0 ) {
00173       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_FAMILY_MSG);
00174       SSCRUTE(familyname);SSCRUTE(_path);SSCRUTE(MED_NOM_GRO);
00175       goto ERROR;
00176     }
00177 
00178   }
00179 
00180  _ret = 0;
00181 
00182  ERROR:
00183 
00184  if (_datagroup>0)     if (_MEDdatagroupFermer(_datagroup) < 0) {
00185    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_NOM_GRO);
00186    ISCRUTE_id(_datagroup);
00187  }
00188 
00189  if (_famid>0)         if (_MEDdatagroupFermer(_famid) < 0) {
00190    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,&_path[_pathreflen]);
00191    ISCRUTE_id(_famid);
00192  }
00193 
00194  return _ret;
00195 }
00196 
00197 

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