MEDnEntMaa.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  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 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 med_int
00027 MEDnEntMaa(med_idt fid, char *maa, med_table quoi, med_entite_maillage type_ent, 
00028            med_geometrie_element type_geo, med_connectivite type_conn)
00029 {
00030   med_idt root=0, maaid=0, entid=0,geoid=0, dataset=0;
00031   med_int ret=-1;
00032   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00033   char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00034   char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00035   char nom_dataset[MED_TAILLE_NOM_ENTITE+1];
00036   med_int res = 0;
00037   med_entite_maillage _type_ent=type_ent;
00038 
00039   if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00040 
00041   /*
00042    * On inhibe le gestionnaire d'erreur HDF 5
00043    */
00044   _MEDmodeErreurVerrouiller();
00045 if (MEDcheckVersion(fid) < 0) return -1;
00046 
00047 
00048   /*
00049    * Si le maillage n'existe pas => erreur
00050    */
00051   strcpy(chemin,MED_MAA);
00052   strcat(chemin,maa);
00053   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00054     goto ERROR;
00055 
00056   /*
00057    * On met a jour le nom du Data Group representant
00058    * le type des entites
00059    */
00060   if ( _MEDnomEntite(nom_ent,_type_ent) < 0)
00061     goto ERROR;
00062 
00063    /*
00064     * Si le Data Group des entites n'existe pas => res = 0
00065     */
00066   entid = _MEDdatagroupOuvrir(maaid,nom_ent);
00067 
00068    /*
00069     * Pour les mailles, les faces et le aretes
00070     * si le Data Group du type geometrique n'existe pas => res = 0
00071     */
00072   if ((_type_ent==MED_MAILLE)||(_type_ent==MED_FACE)||(_type_ent==MED_ARETE))
00073     {
00074       if ( _MEDnomGeometrie30(nom_geo,type_geo) < 0)
00075         goto ERROR;
00076       geoid = _MEDdatagroupOuvrir(entid,nom_geo);
00077     }
00078   else
00079     geoid = -1;
00080   
00081    /*
00082     * Ouverture du Data Set renvoye par _MEDnomDataset()
00083     * S'il n'existe pas => erreur
00084     * Sinon lecture de l'attribut NBR
00085     */
00086    if (geoid == -1)
00087      root = entid;
00088    else
00089      root = geoid;
00090    if ( _MEDnomDataset(nom_dataset,quoi,type_conn) < 0)
00091      goto ERROR;
00092    dataset = _MEDdatasetOuvrir(root,nom_dataset);
00093    if (dataset > 0)
00094      if ( _MEDattrEntierLire(dataset,MED_NOM_NBR,&res) < 0)
00095        goto ERROR;
00096 
00097    /*
00098     * On ferme tout
00099     */
00100     ret=res;
00101    ERROR :
00102    if (dataset > 0)
00103      if ( _MEDdatasetFermer(dataset) < 0)
00104        ret=-1;
00105    if (geoid > 0)
00106      if ( _MEDdatagroupFermer(geoid) < 0)
00107        ret=-1;
00108    if (entid > 0)
00109      if ( _MEDdatagroupFermer(entid) < 0)
00110        ret=-1;
00111    if (maaid > 0)
00112      if ( _MEDdatagroupFermer(maaid) < 0)
00113        ret=-1;
00114 /*ICI;_MEDobjetsOuverts(fid);*/
00115   return ret;
00116 }
00117      
00118 
00119 

Généré le Thu Oct 8 14:26:16 2015 pour MED fichier par  doxygen 1.6.1