# _MEDfilterEntityCr30.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 <hdf5.h>
    00023 #include <string.h>
    00024
    00025 void _MEDfilterEntityCr30(int dummy, ...)
    00026 {
    00027
    00028
    00029   med_err    _ret=-1;
    00030   med_int    _profilearraysize=0;
    00031   med_storage_mode  _storagemode;
    00032
    00033   MED_VARGS_DECL(const, med_idt           , , fid                     );
    00034   MED_VARGS_DECL(const, med_int           , , nbofentity              );
    00035   MED_VARGS_DECL(const, med_int           , , nbofvaluesperentity     );
    00036   MED_VARGS_DECL(const, med_int           , , nbofconstituentpervalue );
    00037   MED_VARGS_DECL(const, med_int           , , constituentselect       );
    00038   MED_VARGS_DECL(const, med_switch_mode   , , switchmode              );
    00039   MED_VARGS_DECL(const, med_storage_mode  , , storagemode             );
    00040   MED_VARGS_DECL(const, char * , const      , profilename             );
    00041   MED_VARGS_DECL(const, med_int           , , filterarraysize         );
    00042   MED_VARGS_DECL(const, med_int *         , , filterarray             );
    00043   MED_VARGS_DECL(, med_filter*, const       , filter                  );
    00044   MED_VARGS_DECL(, med_err *               ,, fret                    );
    00045
    00046   va_list params;
    00047   va_start(params,dummy);
    00048
    00049   MED_VARGS_DEF(const, med_idt           , , fid                     );
    00050   MED_VARGS_DEF(const, med_int           , , nbofentity              );
    00051   MED_VARGS_DEF(const, med_int           , , nbofvaluesperentity     );
    00052   MED_VARGS_DEF(const, med_int           , , nbofconstituentpervalue );
    00053   MED_VARGS_DEF(const, med_int           , , constituentselect       );
    00054   MED_VARGS_DEF(const, med_switch_mode   , , switchmode              );
    00055   MED_VARGS_DEF(const, med_storage_mode  , , storagemode             );
    00056   MED_VARGS_DEF(const, char * , const      , profilename             );
    00057   MED_VARGS_DEF(const, med_int           , , filterarraysize         );
    00058   MED_VARGS_DEF(const, med_int *         , , filterarray             );
    00059   MED_VARGS_DEF(, med_filter*, const       , filter                  );
    00060   MED_VARGS_DEF(, med_err *               ,, fret                    );
    00061
    00062   _storagemode=storagemode;
    00063
    00064   /* TRUC BIZZARD AVEC LES ANCIENS PROFILS, A VERIFIER */
    00065   NOFINALBLANK(profilename,ERROR);
    00066
    00067   if ( (filterarraysize <= 0) && (filterarray != NULL ) ) {
    00068     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,MED_ERR_ARRAY_MSG);
    00069     ISCRUTE(filterarraysize);
    00070     MESSAGE(MED_ERR_NULL_MSG);ISCRUTE_long((long)filterarray);
    00071     goto ERROR;
    00072   }
    00073
    00074   if ( strlen(profilename) ) {
    00075     _profilearraysize = MEDprofileSizeByName(fid,profilename);
    00076     if ( filterarraysize > _profilearraysize  ) {
    00077       MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,MED_ERR_GSIZE_MSG);ISCRUTE(filterarraysize);
    00078       SSCRUTE(profilename);ISCRUTE(_profilearraysize);
    00079       goto ERROR;
    00080     }
    00081   } else {
    00082     /*Faux si un filterarray est présent !*/
    00083 /*     _storagemode = MED_GLOBAL_PFLMODE; */
    00084   }
    00085
    00086   /* Verify constituentselect is between [0, nbofconstituentpervalue] ( 0 is MED_ALL_CONSTITUENT ) */
    00087   if ( constituentselect > nbofconstituentpervalue) {
    00088     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,MED_ERR_VALUE_MSG);ISCRUTE(constituentselect);
    00089     ISCRUTE(nbofconstituentpervalue);
    00090     goto ERROR;
    00091   }
    00092
    00093   /* Verify nbofvaluesperentity > 0 */
    00094   if ( nbofvaluesperentity  < 1 ) {
    00095     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_FILTER,MED_ERR_VALUE_MSG);
    00096     ISCRUTE(nbofvaluesperentity);
    00097     goto ERROR;
    00098   }
    00099
    00100   switch(switchmode) {
    00101   case MED_FULL_INTERLACE :
    00102
    00103     if ( (!strlen(profilename)) && (filterarraysize == MED_NO_FILTER_SIZE)  ) {
    00104
    00105       if ( _MEDselectAllEntitiesFullI(fid, nbofentity, nbofvaluesperentity, nbofconstituentpervalue,
    00106                                  constituentselect, filter) < 0) {
    00107         MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00108         MESSAGE("MED_FULL_INTERLACE, MED_NO_PROFILE, MED_NO_FILTER");
    00109         goto ERROR;
    00110       }
    00111
    00112     } else {
    00113
    00114       switch(_storagemode) {
    00115       case MED_GLOBAL_PFLMODE :
    00116
    00117         if ( _MEDfilterEntityFullIGlobalCr(fid,nbofentity,nbofvaluesperentity,nbofconstituentpervalue,constituentselect,
    00118                                            _storagemode,profilename,filterarraysize,filterarray,filter) < 0 ) {
    00119           MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00120           MESSAGE("MED_FULL_INTERLACE, MED_GLOBAL_PFLMODE");
    00121           goto ERROR;
    00122         }
    00123         break;
    00124       case MED_COMPACT_PFLMODE :
    00125         if ( _MEDfilterEntityFullICompactCr(fid,nbofentity,nbofvaluesperentity,nbofconstituentpervalue,constituentselect,
    00126                                             _storagemode,profilename,filterarraysize,filterarray,filter) < 0 ) {
    00127           MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00128           MESSAGE("MED_FULL_INTERLACE, MED_COMPACT_PFLMODE");
    00129           goto ERROR;
    00130         }
    00131         break;
    00132       default:
    00133         MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00134         MESSAGE("MED_UNDEF_PFLMODE");
    00135         MESSAGE("MED_FULL_INTERLACE");
    00136         SSCRUTE(profilename);
    00137         ISCRUTE_int(_storagemode);
    00138         ISCRUTE(_profilearraysize);
    00139         goto ERROR;
    00140         break;
    00141       }
    00142     }
    00143     break;
    00144   case MED_NO_INTERLACE :
    00145
    00146     if ( (!strlen(profilename)) && (filterarraysize == MED_NO_FILTER_SIZE)  ) {
    00147
    00148       if ( _MEDselectAllEntitiesNoI(fid, nbofentity, nbofvaluesperentity, nbofconstituentpervalue,
    00149                                       constituentselect, filter) < 0) {
    00150         MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00151         MESSAGE("MED_NO_INTERLACE, MED_NO_PROFILE, MED_NO_FILTER");
    00152         goto ERROR;
    00153       }
    00154
    00155     } else {
    00156
    00157       switch(_storagemode) {
    00158
    00159       case MED_GLOBAL_PFLMODE :
    00160
    00161         if ( _MEDfilterEntityNoIGlobalCr(fid,nbofentity,nbofvaluesperentity,nbofconstituentpervalue,constituentselect,
    00162                                            _storagemode,profilename,filterarraysize,filterarray,filter) < 0 ) {
    00163           MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00164           MESSAGE("MED_NO_INTERLACE, MED_GLOBAL_PFLMODE");
    00165           goto ERROR;
    00166         }
    00167         break;
    00168
    00169       case MED_COMPACT_PFLMODE :
    00170         if ( _MEDfilterEntityNoICompactCr(fid,nbofentity,nbofvaluesperentity,nbofconstituentpervalue,constituentselect,
    00171                                             _storagemode,profilename,filterarraysize,filterarray,filter) < 0 ) {
    00172           MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00173           MESSAGE("MED_NO_INTERLACE, MED_COMPACT_PFLMODE");
    00174           goto ERROR;
    00175         }
    00176         break;
    00177
    00178       default:
    00179         MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,MED_ERR_MODE_MSG);
    00180         MESSAGE("MED_UNDEF_PFLMODE");
    00181         MESSAGE("MED_NO_INTERLACE");
    00182         SSCRUTE(profilename);
    00183         ISCRUTE_int(_storagemode);
    00184         ISCRUTE(_profilearraysize);
    00185         goto ERROR;
    00186         break;
    00187       }
    00188
    00189     }
    00190     break;
    00191
    00192   default:
    00193     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_INTERLACINGMODE,MED_ERR_VALUE_MSG);
    00194     ISCRUTE_int(switchmode);
    00195     goto ERROR;
    00196   }
    00197
    00198   _ret = 0;
    00199
    00200  ERROR:
    00201
    00202   /*   if ( _memspace ) if ( (_ret = H5Sclose(_memspace)) < 0) { */
    00203   /*     MESSAGE("Impossible de fermer le memspace : "); */
    00204   /*     ISCRUTE(_memspace);  _ret = -1; */
    00205   /*   } */
    00206
    00207   va_end(params);
    00208   *fret = _ret;
    00209
    00210   return;
    00211 }