Back to index

salome-med  6.5.0
MEDattrNumLire.cxx
Go to the documentation of this file.
00001 /*************************************************************************
00002 * COPYRIGHT (C) 1999 - 2002  EDF R&D
00003 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
00004 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE 
00005 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00006 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00007 *  
00008 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
00009 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
00010 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
00011 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
00012 *
00013 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
00014 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
00015 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
00016 *
00017 *************************************************************************/
00018 
00019 
00020 #include "med.hxx"
00021 #include "med_outils.hxx"
00022 
00023 #include <cstring>
00024 
00025 /*
00026  * - Nom de la fonction : _MEDattrNumLire
00027  * - Description : lecture d'un attribut entier
00028  * - Parametres :
00029  *     - pere (IN)  : l'ID de l'objet HDF pere ou placer l'attribut
00030  *     - type (IN)  : le type du champ {MED_REEL64,MED_INT}
00031  *     - nom  (IN)  : le nom de l'attribut 
00032  *     - val  (OUT) : la valeur de l'attribut
00033  * - Resultat : 0 en cas de succes, -1 sinon
00034  */ 
00035 
00036 namespace med_2_1{
00037 
00038 med_err 
00039 _MEDattrNumLire(med_idt pere,med_type_champ type,char *nom,unsigned char *val)
00040 {
00041   med_idt attid;
00042   med_err ret;
00043   int type_hdf;
00044 
00045   if ((attid = H5Aopen_name(pere,nom)) < 0)
00046     return -1;
00047 
00048   switch(type) 
00049     {
00050     case MED_REEL64 :
00051 #if defined(PCLINUX) || defined(OSF1) || defined(PPRO_NT) || defined(PCLINUX64) || defined(PCLINUX64_32)
00052       type_hdf = H5T_IEEE_F64BE;
00053 #else 
00054       type_hdf = H5T_IEEE_F64LE;
00055 #endif
00056       break;
00057       
00058     case MED_INT :
00059 #if defined(HAVE_F77INT64)
00060       type_hdf = H5T_NATIVE_LONG; 
00061 #else
00062       type_hdf = H5T_NATIVE_INT;
00063 #endif
00064       break;
00065       
00066     default :
00067       return -1;
00068     }
00069 
00070   if ((ret = H5Aread(attid,type_hdf,val)) < 0)
00071     return -1;
00072 
00073   if (strcmp(nom, MED_NOM_NGA) == 0 ) {
00074     med_int* ngauss = (med_int*)val;
00075     if( *ngauss <= 0 || *ngauss > 128) 
00076       *ngauss =1;
00077   }
00078 
00079   if ((ret = H5Aclose(attid)) < 0)
00080     return -1;
00081 
00082   return 0;
00083 }
00084 
00085 }