# _MEDfieldValueAdvancedRd236.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_config.h>
    00020 #include <med.h>
    00021 #include <med_outils.h>
    00022
    00023 #include <string.h>
    00024 #include <stdlib.h>
    00025
    00026 #include <2.3.6/med23v30.h>
    00027 #include <2.3.6/med23v30_proto.h>
    00028 #include "2.3.6/med23v30_misc.h"
    00029
    00030
    00031 void _MEDfieldValueAdvancedRd236(int dummy,...) {
    00032
    00033
    00034   med_err               _ret=-1;
    00035 /*   med_int               _nbofconstituentpervalue=0,_nbofvaluesperentityfromloc=0; */
    00036 /*   med_int               _nbofvaluesperentity=0,_profilearraysize=0; */
    00037   med_bool              _filterparameterexist=MED_FALSE;
    00038
    00039   char _localizationname   [MED_NAME_SIZE+1]=""; /*TODO DEFAULT? */
    00040   char _profilename        [MED_NAME_SIZE+1]=""; /*TODO DEFAULT? */
    00041   char _geotypename[MED_TAILLE_NOM_ENTITE+1]="";
    00042   char _pfltmp             [MED_NAME_SIZE+1]="";
    00043   med_filter *               _filter           = NULL;
    00044   med_filter                 _tmpfilter        = MED_FILTER_INIT;
    00045   med_filter                 _paramfilter      = MED_FILTER_INIT;
    00046
    00047   MED_VARGS_DECL(const, med_idt               , , fid              );
    00048   MED_VARGS_DECL(const, char * , const          , fieldname        );
    00049   MED_VARGS_DECL(const, med_int               , , numdt            );
    00050   MED_VARGS_DECL(const, med_int               , , numit            );
    00051   MED_VARGS_DECL(const, med_entity_type       , , entitytype       );
    00052   MED_VARGS_DECL(const, med_geometry_type     , , geotype          );
    00053   MED_VARGS_DECL(const, char * , const          , meshname         );
    00054   MED_VARGS_DECL(const, med_storage_mode      , , storagemode      );
    00055   MED_VARGS_DECL(const, char * , const          , profilename      );
    00056   MED_VARGS_DECL(const, med_switch_mode       , , switchmode       );
    00057   MED_VARGS_DECL(const, med_int               , , componentselect  );
    00058   MED_VARGS_DECL(const, med_filter* , const     , filter           );
    00059   MED_VARGS_DECL(,unsigned char*, const         , value            );
    00060   MED_VARGS_DECL(, med_err *                   ,, fret             );
    00061
    00062   va_list params;
    00063   va_start(params,dummy);
    00064
    00065   MED_VARGS_DEF(const, med_idt               , , fid              );
    00066   MED_VARGS_DEF(const, char * , const          , fieldname        );
    00067   MED_VARGS_DEF(const, med_int               , , numdt            );
    00068   MED_VARGS_DEF(const, med_int               , , numit            );
    00069   MED_VARGS_DEF(const, med_entity_type       , , entitytype       );
    00070   MED_VARGS_DEF(const, med_geometry_type     , , geotype          );
    00071   MED_VARGS_DEF(const, char * , const          , meshname         );
    00072   MED_VARGS_DEF(const, med_storage_mode      , , storagemode      );
    00073   MED_VARGS_DEF(const, char * , const          , profilename      );
    00074   MED_VARGS_DEF(const, med_switch_mode       , , switchmode       );
    00075   MED_VARGS_DEF(const, med_int               , , componentselect  );
    00076   MED_VARGS_DEF(const, med_filter* , const     , filter           );
    00077   MED_VARGS_DEF(,unsigned char*, const         , value            );
    00078   MED_VARGS_DEF(, med_err *                   ,, fret             );
    00079
    00080   if (filter) {
    00081     _filter=(med_filter*)(filter); _filterparameterexist=MED_TRUE;
    00082   }
    00083   else {
    00084     _filter=&_tmpfilter;
    00085 /*   (*_filter).nbofentity              = nbofentity; */
    00086 /*   (*_filter).nbofvaluesperentity     = nbofvaluesperentity; */
    00087 /*   (*_filter).nbofconstituentpervalue = nbofconstituentpervalue; */
    00088     (*_filter).constituentselect       = componentselect;
    00089     (*_filter).switchmode              = switchmode;
    00090     (*_filter).storagemode             = storagemode;
    00091     strcpy((*_filter).profilename,profilename);
    00092 /*   (*_filter).profilearraysize        = profilearraysize; */
    00093   }
    00094
    00095
    00096   /*
    00097    * On inhibe le gestionnaire d'erreur HDF 5
    00098    */
    00099   _MEDmodeErreurVerrouiller();
    00100
    00101   /*
    00102    * Il n'existe pas de possibilité de filtrage par n° d'entité sur les champs en 2.3.6
    00103    */
    00104   if (_filterparameterexist)
    00105     if ( (*_filter).filterarraysize ) {
    00106       MED_ERR_(_ret,MED_ERR_NULL,MED_ERR_FILTER,MED_ERR_VALUE_MSG);
    00107       ISCRUTE((*_filter).filterarraysize);
    00108       goto ERROR;
    00109     }
    00110
    00111   NOFINALBLANK(profilename,ERROR);
    00112
    00113   if ( strlen((*_filter).profilename) == 0 ) {  /* idem MED_NOPFL*/
    00114
    00115     _profilename[0]='\0';
    00116 /*     _profilearraysize = MED_UNDEF_SIZE; */
    00117   } else {
    00118     strncpy(_profilename,(*_filter).profilename,MED_NAME_SIZE+1);
    00119     _profilename[MED_NAME_SIZE]='\0'; /*On tronque les eventuels noms trop long*/
    00120
    00121     /* Le paramètre (*_filter).profilearraysize est positionné dans  _MEDfilterEntityCr236 */
    00122     /* Il est donc inutile de vérifier sa valeur  */
    00123   }
    00124
    00125
    00126   /*Pour vérifier les paramètres nbofvaluesperentity et nbofconstituentpervalue, il faudrait
    00127    appeler _MEDfieldnValue236 mais qui effectue aussi un check */
    00128 /*   if ( _nbofvaluesperentityfromloc != _nbofvaluesperentity ) { */
    00129 /*     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG); */
    00130 /*     SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_nbofvaluesperentityfromloc); */
    00131 /*     ISCRUTE(_nbofvaluesperentity);goto ERROR; */
    00132 /*   } */
    00133
    00134 /*   if (!_filterparameterexist) (*_filter).nbofvaluesperentity=_nbofvaluesperentity; */
    00135
    00136 #ifdef _DEBUG_
    00137     ISCRUTE((*_filter).nbofentity              );
    00138     ISCRUTE((*_filter).nbofvaluesperentity     );
    00139     ISCRUTE((*_filter).nbofconstituentpervalue );
    00140     ISCRUTE((*_filter).constituentselect       );
    00141     ISCRUTE_int((*_filter).switchmode              );
    00142     ISCRUTE((*_filter).filterarraysize         );
    00143     ISCRUTE((*_filter).profilearraysize        );
    00144     ISCRUTE_int((*_filter).storagemode             );
    00145     SSCRUTE((*_filter).profilename             );
    00146 #endif
    00147   /*
    00148    * Lecture du champ
    00149    */
    00150
    00151     if ( MEDchampLire( fid, (char *) meshname, (char *) fieldname, (unsigned char *) value,
    00152                        (*_filter).switchmode, (*_filter).constituentselect,
    00153                        _localizationname, _pfltmp,
    00154                        (*_filter).storagemode,
    00155                        entitytype, geotype, numdt, numit) < 0 ) {
    00156       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDchampLire");
    00157       SSCRUTE(fieldname);SSCRUTE(_profilename);
    00158       goto ERROR;
    00159     }
    00160
    00161     if (strcmp(_profilename,_pfltmp)) {
    00162       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PROFILE,MED_ERR_NAME_MSG);
    00163       SSCRUTE(_profilename);SSCRUTE(_pfltmp);
    00164       goto ERROR;
    00165     }
    00166
    00167     /*
    00168      * On ferme tout
    00169      */
    00170
    00171     _ret = 0;
    00172
    00173   ERROR:
    00174
    00175 /*   if ( pfluse ) { free(pfltab); free(pfltabtmp);} */
    00176
    00177   va_end(params);
    00178   *fret = _ret;
    00179   return;
    00180   }
    00181
    00182