_MEDfieldnProfile30.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 #include <string.h>
00023 
00024 void
00025 _MEDfieldnProfile30(int dummy, ...) {
00026 
00027   va_list params;
00028   va_start(params,dummy);
00029 
00030 
00031   const med_idt           fid                     = va_arg(params, const med_idt           );
00032   const char * const      fieldname               = va_arg(params, const char * const      );
00033   const med_int           numdt                   = va_arg(params, const med_int           );
00034   const med_int           numit                   = va_arg(params, const med_int           );
00035   const med_entity_type   entitype                = va_arg(params, const med_entity_type   );
00036   const med_geometry_type geotype                 = va_arg(params, const med_geometry_type );
00037         char * const      defaultprofilename      = va_arg(params,       char * const      );
00038         char * const      defaultlocalizationname = va_arg(params,       char * const      );
00039         med_int *         fret                    = va_arg(params,       med_int *         );
00040 
00041   med_int  _ret=-1,_err=-1;
00042   med_idt  _gid=0,_datagroup1=0;
00043   char     _path[(MED_TAILLE_CHA+MED_NAME_SIZE+1)+(2*MED_MAX_PARA+1)+1]=MED_CHA;
00044   char     _datagroupname1[2*MED_TAILLE_NOM_ENTITE+2]="";
00045   char     _geotypename      [MED_TAILLE_NOM_ENTITE+1]="";
00046   char     _profilename  [MED_NAME_SIZE+1]="";
00047   med_int  _numdt=0, _numit=0;
00048   med_size _n=0;
00049 
00050   /*
00051    * On inhibe le gestionnaire d'erreur HDF 5
00052    */
00053   _MEDmodeErreurVerrouiller();
00054 
00055   NOFINALBLANK(fieldname,ERROR);
00056 
00057   /*
00058    * On construit le chemin d'acc�s jusqu'aux groupes <type_ent>[.<type_geo>]
00059    */
00060   strcat(_path,fieldname);
00061   strcat(_path,"/");
00062   _MEDgetComputationStepName(MED_SORT_DTIT,numdt,numit,&_path[strlen(_path)]);
00063   strcat(_path,"/");
00064 
00065   if ((_gid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00066     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
00067     SSCRUTE(fieldname);SSCRUTE(_path); goto ERROR;
00068   }
00069 
00070 
00071   /*Lit l'attribut MED_NOM_NDT  */
00072   if ( _MEDattrEntierLire(_gid,MED_NOM_NDT, &_numdt) < 0) {
00073     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00074     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NDT);
00075     ISCRUTE(_numdt);goto ERROR;
00076   }
00077 
00078   if ( _numdt != numdt) {
00079     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00080     SSCRUTE(fieldname);ISCRUTE(_numdt);ISCRUTE(numdt);goto ERROR;
00081   }
00082 
00083   /*Lit l'attribut MED_NOM_NOR */
00084   if ( _MEDattrEntierLire(_gid,MED_NOM_NOR, &_numit) < 0) {
00085     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00086     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NOR);
00087     ISCRUTE(_numit); goto ERROR;
00088   }
00089 
00090   if ( _numit != numit) {
00091     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00092     SSCRUTE(fieldname);ISCRUTE(_numit);ISCRUTE(numit);goto ERROR;
00093   }
00094 
00095   /*
00096    * Si le Data Group  de niveau <type_ent>[.<type_geo>] n'existe pas retroune 0
00097    */
00098 
00099   if (_MEDgetEntityTypeName(_datagroupname1,entitype) < 0) {
00100     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ENTITY,_datagroupname1);
00101     goto ERROR;
00102   }
00103 
00104   if (entitype != MED_NODE) {
00105     if ( entitype == MED_STRUCT_ELEMENT ) {
00106       if ( MEDstructElementName(fid,geotype,_geotypename) < 0 ) {
00107         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDstructElementName");
00108         ISCRUTE_int(geotype);goto ERROR;
00109       }
00110     } else {
00111       if (_MEDgetGeometryTypeName(_geotypename,geotype) < 0) {
00112         MED_ERR_(_ret,MED_ERR_READ,MED_ERR_GEOMETRIC,_geotypename);
00113         goto ERROR;
00114       }
00115     }
00116     strcat(_datagroupname1,".");
00117     strcat(_datagroupname1,_geotypename);
00118   }
00119 /*   strcat(_path,_datagroupname1); */
00120 /*   strcat(_path,"/"); */
00121 
00122 
00123   if ((_datagroup1 = _MEDdatagroupOuvrir(_gid,_datagroupname1)) < 0) {
00124     *defaultprofilename='\0';
00125     *defaultlocalizationname='\0';
00126     _ret = 0;
00127     goto ERROR;
00128   }
00129 
00130   if ((_err=_MEDnObjects(_datagroup1,".",&_n)) <0)
00131     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00132       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_datagroupname1);
00133       goto ERROR;
00134     }
00135 
00136   /* Lit le nom du profil associ� s'il en existe d�j� un */
00137   if ( _MEDattrStringLire(_datagroup1,MED_NOM_PFL,MED_NAME_SIZE,_profilename) < 0 ) {
00138     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00139     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_PFL);
00140     goto ERROR;
00141   }
00142 
00143   if ( strcmp(_profilename,MED_NO_PROFILE_INTERNAL) ) {
00144     strncpy(defaultprofilename,_profilename,MED_NAME_SIZE+1);
00145     defaultprofilename[MED_NAME_SIZE]='\0';
00146   } else {
00147     defaultprofilename[0]='\0';
00148   }
00149 
00150   /* Lit le nom de la localization associ� s'il en existe d�j� une */
00151   if ( _MEDattrStringLire(_datagroup1,MED_NOM_GAU,MED_NAME_SIZE,defaultlocalizationname) < 0 ) {
00152     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00153     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_GAU);
00154     goto ERROR;
00155   }
00156 
00157   _ret = (med_int) _n;
00158 
00159  ERROR:
00160 
00161 
00162   if (_datagroup1>0)            if (_MEDdatagroupFermer(_datagroup1) < 0) {
00163     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00164     SSCRUTE(_datagroupname1); ISCRUTE_id(_datagroup1);
00165   }
00166 
00167   if (_gid>0)            if (_MEDdatagroupFermer(_gid) < 0) {
00168     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00169     ISCRUTE_id(_gid);
00170   }
00171 
00172   va_end(params);
00173   *fret = _ret;
00174   return;
00175 }

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