Back to index

salome-med  6.5.0
MEDnumLire.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 MEDnumLire(med_idt fid,char *maa, med_int *num, med_int n, 
00029            med_entite_maillage type_ent,med_geometrie_element type_geo)
00030 {
00031   med_idt root,maaid,entid,geoid;
00032   med_err ret;
00033   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00034   char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00035   char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00036 
00037   /*
00038    * On inhibe le gestionnaire d'erreur HDF 5
00039    */
00040   _MEDmodeErreurVerrouiller(); 
00041 
00042   /*
00043    * Si le maillage n'existe pas => erreur
00044    */
00045   strcpy(chemin,MED_MAA);
00046   strcat(chemin,maa);
00047   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00048       return -1;
00049 
00050   /*
00051    * On met a jour le nom du Data Group representant
00052    * le type des entites
00053    */
00054    if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0)
00055      return -1;
00056 
00057    /*
00058     * Si le Data Group des entites n'existe pas => erreur
00059     */
00060    if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00061      return -1;
00062 
00063    /*
00064     * Pour les mailles, les faces et le aretes, 
00065     * si le Data Group du type geometrique => erreur
00066     */
00067    if ((type_ent==MED_MAILLE)||(type_ent==MED_FACE)||(type_ent==MED_ARETE))
00068      {
00069        if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0)
00070          return -1;
00071        if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00072          return -1;
00073      }
00074    else 
00075      geoid = -1;
00076 
00077    /*
00078     * lecture du Data Set "NUM" 
00079     */
00080    if (geoid == -1)
00081      root = entid;
00082    else
00083      root = geoid;
00084 #if defined(HAVE_F77INT64)
00085    if ((ret = _MEDdatasetNumLire(root,MED_NOM_NUM,MED_INT64,
00086                                  MED_NO_INTERLACE,1,MED_ALL,
00087                                  MED_NOPF,0,MED_NOPG,
00088                                  (unsigned char*) num)) < 0)
00089      return -1;
00090 #else
00091    if ((ret = _MEDdatasetNumLire(root,MED_NOM_NUM,MED_INT32,
00092                                  MED_NO_INTERLACE,1,MED_ALL,
00093                                  MED_NOPF,0,MED_NOPG,
00094                                  (unsigned char*) num)) < 0)
00095      return -1;
00096 #endif
00097 
00098    /*
00099     * On ferme tout
00100     */
00101    if (geoid != -1)
00102      if ((ret = _MEDdatagroupFermer(geoid)) < 0)
00103        return -1;
00104    if ((ret = _MEDdatagroupFermer(entid)) < 0)
00105      return -1;
00106    if ((ret = _MEDdatagroupFermer(maaid)) < 0)
00107      return -1;
00108 
00109   return 0; 
00110 }
00111 
00112 }