MEDnChampRef.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 #include <med.h>
00019 #include "med_config.h"
00020 #include "med_outils.h"
00021 #include <string.h>
00022 /*
00023  * - Nom de la fonction : MEDnChampRef
00024  * - Description : Renvoi le nbre de maillages associés au champ ( <cha>/<type_ent>[.<type_geo>]/<numdtt>.<numoo> )
00025  * - Parametres :
00026  *     - fid        (IN) : ID du fichier HDF courant
00027  *     - cha        (IN) : le nom du champ 
00028  *     - type_ent   (IN) : entité du champ concernée  {MED_NOEUD,MED_ARETE,MED_FACE,MED_MAILLE}
00029  *      - type_geo  (IN) : type géométrique de l'entité concerné {MED_POINT,MED_SEG2 ......}
00030  *       - numdt    (IN) : n° du pas de temps (MED_NOPDT si aucun)
00031  *       - numo     (IN) : n° d'ordre utilisé (MED_NONOR si aucun)
00032  * - Resultat : 0 en cas de succes, -1 sinon
00033  */ 
00034 
00035 
00036 med_int MEDnChampRef(med_idt fid, char * cha, med_entite_maillage type_ent, 
00037                      med_geometrie_element type_geo,
00038                      med_int numdt, med_int numo)
00039 
00040 {
00041   char chemin[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+2*MED_MAX_PARA+1];
00042   int n1;
00043   char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2];
00044   char nomdatagroup2[2*MED_MAX_PARA+1];
00045   char tmp1         [MED_TAILLE_NOM_ENTITE+1];
00046 
00047   /*
00048    * On inhibe le gestionnaire d'erreur HDF 5
00049    */
00050   _MEDmodeErreurVerrouiller();
00051 if (MEDcheckVersion(fid) < 0) return -1;
00052 
00053 
00054   /*
00055    * On construit le chemin d'accès de niveau 0
00056    */
00057   strcpy(chemin,MED_CHA);
00058   strcat(chemin,cha);
00059   strcat(chemin,"/");
00060 
00061   /* 
00062    * On construit le nom du datagroup de niveau 1 <_type_ent>[.<type_geo>] n'existe pas => erreur
00063    */
00064 
00065   if ( _MEDnomEntite(nomdatagroup1,type_ent ) < 0) {
00066     MESSAGE("L'entité demandée n'est pas une entité <med_entite_maillage> : ");
00067     SSCRUTE(chemin); ISCRUTE(type_ent); return -1;
00068   };
00069   if ((type_ent != MED_NOEUD)) {
00070     if ( _MEDnomGeometrie30(tmp1,type_geo) < 0) {
00071       MESSAGE("Le type géométrique demandé n'est pas un <med_geometrie_element> : ");
00072       SSCRUTE(chemin); ISCRUTE(type_geo); return -1;
00073     };
00074     strcat(nomdatagroup1,".");
00075     strcat(nomdatagroup1,tmp1);
00076   }
00077   strcat(chemin,nomdatagroup1);
00078   strcat(chemin,"/");
00079 
00080   
00081   /*
00082    *  On construit le nom du datagroup de niveau 2 <numdtt>.<numoo> n'existe pas => erreur
00083    */
00084 
00085   sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
00086   strcat(chemin,nomdatagroup2);
00087   
00088   n1 = 0;
00089   if ( _MEDnObjets(fid,chemin,&n1) < 0 ) {
00090     MESSAGE("Impossible d'itérer dans le groupe : ");
00091     SSCRUTE(chemin); return -1;
00092   };
00093 
00094   return (med_int) n1;
00095 
00096 }

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