_MEDlocalizationInfoByName30.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
00027 _MEDlocalizationInfoByName30(int dummy, ...) {
00028 
00029 
00030   med_idt           _lzid=0;
00031   med_err           _ret=-1;
00032   char              _path[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
00033 /*   char              _sectionmeshname   [MED_NAME_SIZE+1]=""; */
00034   char              _sectiongeotypename[MED_TAILLE_NOM_ENTITE+1]="";
00035   med_int           _intgeotype     = -1,_nbofsectiongeotype=0, _nsectionmeshcell=0;
00036   med_geometry_type _sectiongeotype =MED_UNDEF_GEOTYPE;
00037   med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;
00038 
00039 
00040   MED_VARGS_DECL(const, med_idt                   , , fid                  );
00041   MED_VARGS_DECL(const, char        * , const       , localizationname     );
00042   MED_VARGS_DECL(, med_geometry_type *, const , geotype                    );
00043   MED_VARGS_DECL(, med_int           *, const , spacedimension             );
00044   MED_VARGS_DECL(, med_int           *, const , nbofipoint                 );
00045   MED_VARGS_DECL(, char        *, const       , geointerpname              );
00046   MED_VARGS_DECL(, char        *, const       , sectionmeshname            );
00047   MED_VARGS_DECL(, med_int     *, const       , nsectionmeshcell           );
00048   MED_VARGS_DECL(, med_geometry_type *, const , sectiongeotype             );
00049   MED_VARGS_DECL(, med_err *                 ,, fret                       );
00050 
00051   va_list params;
00052   va_start(params,dummy);
00053 
00054   MED_VARGS_DEF(const, med_idt                   , , fid                  );
00055   MED_VARGS_DEF(const, char        * , const       , localizationname     );
00056   MED_VARGS_DEF(, med_geometry_type *, const , geotype                    );
00057   MED_VARGS_DEF(, med_int           *, const , spacedimension             );
00058   MED_VARGS_DEF(, med_int           *, const , nbofipoint                 );
00059   MED_VARGS_DEF(, char        *, const       , geointerpname              );
00060   MED_VARGS_DEF(, char        *, const       , sectionmeshname            );
00061   MED_VARGS_DEF(, med_int     *, const       , nsectionmeshcell           );
00062   MED_VARGS_DEF(, med_geometry_type *, const , sectiongeotype             );
00063   MED_VARGS_DEF(, med_err *                 ,, fret                       );
00064 
00065   /*
00066    * On inhibe le gestionnaire d'erreur HDF 5
00067    */
00068   _MEDmodeErreurVerrouiller();
00069 
00070   /*
00071    * ouverture du groupe /GAUSS/"nom"
00072    */
00073   strcat(_path,localizationname);
00074   if ((_lzid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00075     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_LOCALIZATION_MSG);
00076     SSCRUTE(_path);
00077     goto ERROR;
00078   }
00079 
00080   /*
00081    * Lecture de l'attribut MED_NOM_NBR
00082    */
00083   if (_MEDattrEntierLire(_lzid,MED_NOM_NBR,nbofipoint) < 0) {
00084     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00085     SSCRUTE(_path);SSCRUTE(MED_NOM_NBR);ISCRUTE(*nbofipoint);
00086     goto ERROR;
00087   }
00088 
00089 
00090   /*
00091    * On lit <typgeo> sous forme d'attribut
00092    */
00093   /* sizeof(enum) tjrs = sizeof(int) en C, or
00094      sur machines 64 bits par défaut med_int==long,
00095      du coup sur  machines 64 bits _MEDattributeIntWr utilise 
00096      le type hdf NATIVE_LONG, ce qui pose un problème qd on passe
00097      un enum.
00098   */
00099   if (_MEDattrEntierLire(_lzid,MED_NOM_GEO,&_intgeotype) < 0) {
00100     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00101     SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intgeotype);
00102     goto ERROR;
00103   };
00104   *geotype = (med_geometry_type) _intgeotype;
00105 
00106   /*
00107    * On lit <spacedimension>
00108    */
00109   if (_MEDattrEntierLire(_lzid,MED_NOM_DIM,spacedimension) < 0) {
00110     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00111     SSCRUTE(localizationname);SSCRUTE(MED_NOM_DIM);ISCRUTE(*spacedimension);
00112     goto ERROR;
00113   };
00114 
00115   /*
00116    * Lecture de l'attribut MED_NOM_NOM (nom du maillage de section)
00117    */
00118   if ( _MEDattrStringLire(_lzid,MED_NOM_NOM,MED_NAME_SIZE,sectionmeshname) < 0) {
00119     sectionmeshname[0]='\0';
00120   }
00121 
00122   if ( strlen(sectionmeshname) &&
00123        ( _intgeotype > MED_STRUCT_GEO_INTERNAL) &&
00124        ( _intgeotype < MED_STRUCT_GEO_SUP_INTERNAL) ) {
00125 
00126     if ( (_nbofsectiongeotype = MEDmeshnEntity(fid,sectionmeshname,MED_NO_DT,MED_NO_IT,
00127                                                MED_CELL,MED_ALL_GEOTYPE,MED_CONNECTIVITY,MED_NODAL,
00128                                                &_chgt,&_trsf) )  < 0) {
00129       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00130       ISCRUTE(_nbofsectiongeotype);goto ERROR;
00131     }
00132 
00133     if ( (_nbofsectiongeotype != 1 ) ) {
00134       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_RANGE,""); ISCRUTE(_nbofsectiongeotype); goto ERROR;
00135     }
00136 
00137     if ( MEDmeshEntityInfo( fid,sectionmeshname,MED_NO_DT,MED_NO_IT,
00138                             MED_CELL, 1, _sectiongeotypename, &_sectiongeotype ) < 0 ) {
00139           MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshEntityInfo");
00140           SSCRUTE(_sectiongeotypename);ISCRUTE_int(_sectiongeotype);goto ERROR;
00141     }
00142 
00143     if ( (_nsectionmeshcell = MEDmeshnEntity(fid,sectionmeshname,MED_NO_DT,MED_NO_IT,
00144                                            MED_CELL,_sectiongeotype,MED_CONNECTIVITY,MED_NODAL,
00145                                            &_chgt,&_trsf) )  < 0) {
00146       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00147       ISCRUTE(_nsectionmeshcell);goto ERROR;
00148     }
00149   }
00150   *sectiongeotype= _sectiongeotype;
00151   *nsectionmeshcell= _nsectionmeshcell;
00152 
00153 
00154 
00155   if ( _MEDattrStringLire(_lzid,MED_NOM_INM,MED_NAME_SIZE,geointerpname) < 0) {
00156     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00157     SSCRUTE(localizationname);SSCRUTE(MED_NOM_INM);SSCRUTE(geointerpname);
00158     goto ERROR;
00159   }
00160 
00161   _ret = 0;
00162  ERROR:
00163 
00164   if ( _lzid > 0 ) if ( _MEDdatagroupFermer(_lzid) < 0) {
00165     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_GAUSS);
00166     ISCRUTE_id(_lzid);
00167   }
00168 
00169   va_end(params);
00170   *fret = _ret;
00171   return;
00172   }

Généré le Mon Nov 7 16:21:23 2011 pour MED fichier par  doxygen 1.6.1