Back to index

salome-med  6.5.0
MEDfamInfo.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 #include "med.hxx"
00020 #include "med_outils.hxx"
00021 
00022 #include <stdlib.h>
00023 #include <string.h>
00024 
00025 namespace med_2_1{
00026 
00027 med_err 
00028 MEDfamInfo(med_idt fid,char *maa,int indice, char *famille, 
00029            med_int *numero,
00030            med_int *attr_ident, med_int *attr_val, char *attr_desc,
00031            med_int *n_attr, char *groupe ,med_int *n_groupe)
00032 {
00033   med_idt famid,datagroup;
00034   med_err ret;
00035   char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+2*MED_TAILLE_NOM+1];
00036   int num;
00037 
00038   /*
00039    * On inhibe le gestionnaire d'erreur HDF 5
00040    */
00041   _MEDmodeErreurVerrouiller();
00042 
00043   /*
00044    * On recupere le nom de la famille
00045    */
00046   num = indice - 1;
00047   strcpy(chemin,MED_MAA);
00048   strcat(chemin,maa);
00049   strcat(chemin,MED_FAS); 
00050   if ((ret = _MEDobjetIdentifier(fid,chemin,num,famille)) < 0)
00051     return -1;
00052 
00053   /* 
00054    * Si le Data Group de la famille n'existe pas => erreur
00055    */
00056   strcat(chemin,famille);
00057   if ((famid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00058     return -1;
00059 
00060   /*
00061    * L'attribut NUM
00062    */
00063   if ((ret = _MEDattrEntierLire(famid,MED_NOM_NUM,numero)) < 0)
00064     return -1;
00065 
00066   /*
00067    * Le Data Group "GRO"
00068    */
00069   if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_GRO)) >= 0)
00070     {
00071       /*
00072        * L'attribut "NBR"
00073        */
00074       if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_groupe)) < 0)
00075         return -1;
00076       
00077       /* 
00078        * Data Set des noms des groupes "NOM"
00079        */
00080       if ((ret = _MEDdatasetStringLire(datagroup,MED_NOM_NOM,groupe)) < 0)
00081         return -1;
00082 
00083       /* 
00084        * On ferme le Data Group
00085        */
00086       if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00087         return -1;
00088     }
00089   else
00090     *n_groupe = 0;
00091 
00092   /*
00093    * Le Data Group "ATT"
00094    */
00095   if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_ATT)) >= 0)
00096     {
00097       /*
00098        * L'attribut "NBR"
00099        */
00100       if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_attr)) < 0)
00101         return -1;
00102       
00103       /*
00104        * Le Data Set "IDE"
00105        */
00106 #if defined(HAVE_F77INT64)
00107       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT64,
00108                                     MED_NO_INTERLACE,1,MED_ALL,
00109                                     MED_NOPF,0,MED_NOPG,
00110                                     (unsigned char*) attr_ident)) < 0)
00111         return -1;     
00112 #else
00113       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT32,
00114                                     MED_NO_INTERLACE,1,MED_ALL,
00115                                     MED_NOPF,0,MED_NOPG,
00116                                     (unsigned char*) attr_ident)) < 0)
00117         return -1;     
00118 #endif
00119 
00120       /*
00121        * Le Data Set "VAL"
00122        */
00123 #if defined(HAVE_F77INT64)
00124       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT64,
00125                                     MED_NO_INTERLACE,1,MED_ALL,
00126                                     MED_NOPF,0,MED_NOPG,
00127                                     (unsigned char *) attr_val)) < 0)
00128         return -1;
00129 #else
00130       if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT32,
00131                                     MED_NO_INTERLACE,1,MED_ALL,
00132                                     MED_NOPF,0,MED_NOPG,
00133                                     (unsigned char *) attr_val)) < 0)
00134         return -1;
00135 #endif
00136 
00137       /*
00138        * Le Data Set "DES"
00139        */
00140       ret = _MEDdatasetStringLire(datagroup,MED_NOM_DES,attr_desc);
00141 
00142       /* 
00143        * On ferme le Data Group
00144        */
00145       if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00146         return -1;
00147     }
00148   else
00149     *n_attr = 0;
00150 
00151   /* 
00152    * On ferme tout
00153    */ 
00154   if ((ret = _MEDdatagroupFermer(famid)) < 0)
00155     return -1;
00156 
00157   return 0; 
00158 }
00159 
00160 }