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

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