_MEDnFamilyGroup30.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2011  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 void _MEDnFamilyGroup30(int dummy, ... )
00027 {
00028 
00029 
00030   va_list params;
00031   va_start(params,dummy);
00032 
00033   const med_idt      fid      = va_arg(params,const med_idt      );
00034   const char * const meshname = va_arg(params,const char * const );
00035   const int          famit    = va_arg(params,const int          );
00036   med_int *          fret     = va_arg(params,        med_int *  );
00037 
00038   med_int   _ret=-1,_err=-1;
00039   med_idt   _datagroup=0,_famid=0;
00040   char      _path   [MED_TAILLE_FAS+MED_NAME_SIZE+
00041                      MED_TAILLE_FAS_ENTITE+MED_NAME_SIZE+1] = MED_FAS;
00042   char      _family [MED_NAME_SIZE+1] = "";
00043   med_int   _n          = 0;
00044   med_size  _tmpn       = 0;
00045   int       _pathreflen = 0;
00046   int       _num        = famit-1;
00047   int       _nfamnoe=0,_nfammai=0;
00048 
00049   /*
00050    * On inhibe le gestionnaire d'erreur HDF
00051    */
00052   _MEDmodeErreurVerrouiller();
00053 
00054   strcat(_path,meshname);
00055   _pathreflen=strlen(_path);
00056 
00057   /* Acces a la _family :
00058    * nfam = _nfamnoe + 1 + _nfammai
00059    * Repartition selon l'indice "num" dans le datagroup :
00060    *    - 0.._nfammai - 1 : _familys des mailles/faces/aretes
00061    *    - nfamai : _family 0
00062    *    - (nfamai + 1)..(_nfammai+_nfamnoe) : familles de noeuds
00063    */
00064 
00065   /* Comptage des familles de mailles/faces/aretes */
00066   strncpy(&_path[_pathreflen],MED_FAS_ELEME,MED_TAILLE_FAS_ENTITE+1);
00067   if ( (_err = _MEDnObjects(fid,_path,&_tmpn)) < 0 )
00068     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00069       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_path);
00070       goto ERROR;
00071     }
00072   _nfammai = (med_int ) _tmpn;
00073 
00074   /* Pour la famille 0 */
00075   if (_num == _nfammai)  {_n=0;goto SORTIE;}
00076 
00077   /* C'est une _family de noeuds */
00078   if (_num > _nfammai) {
00079     strncpy(&_path[_pathreflen],MED_FAS_NOEUD,MED_TAILLE_FAS_ENTITE+1);
00080     _num = _num - _nfammai - 1;
00081   }
00082 
00083   /*
00084    * Si le Data Group de la _family n'existe pas => erreur
00085    */
00086   if ( _MEDobjectGetName(fid, _path ,_num, _family) < 0 ) {
00087     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);ISCRUTE_int(famit);
00088     goto ERROR;
00089   }
00090   strcat(_path,_family);
00091 
00092   if ((_famid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00093     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FAMILY_MSG);
00094     SSCRUTE(_family);SSCRUTE(_path);
00095     goto ERROR;
00096   }
00097 
00098   if ((_datagroup = _MEDdatagroupOuvrir(_famid,MED_NOM_GRO)) < 0)
00099     _n = 0;
00100   else {
00101     if ( _MEDattrEntierLire(_datagroup,MED_NOM_NBR,&_n) < 0) {
00102       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FAMILY_MSG);
00103       SSCRUTE(_family);SSCRUTE(_path);SSCRUTE(MED_NOM_GRO);
00104       SSCRUTE(MED_NOM_NBR);ISCRUTE(_n);goto ERROR;
00105     }
00106   }
00107 
00108  SORTIE:
00109   _ret=_n;
00110 
00111  ERROR:
00112 
00113  if (_datagroup>0)     if (_MEDdatagroupFermer(_datagroup) < 0) {
00114    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_NOM_GRO);
00115    SSCRUTE(_path);ISCRUTE_id(_datagroup);
00116  }
00117 
00118  if (_famid>0)     if (_MEDdatagroupFermer(_famid) < 0) {
00119    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_FAS);
00120    ISCRUTE_id(_famid);
00121  }
00122 
00123   va_end(params);
00124   *fret = _ret;
00125 
00126   return;
00127 }

Généré le Mon May 16 17:10:22 2011 pour MED fichier par  doxygen 1.6.1