Back to index

salome-med  6.5.0
MEDnVal.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 <string.h>
00021 #include <stdlib.h>
00022 #include "med_outils.hxx"
00023 
00024 namespace med_2_1{
00025 
00026 med_int 
00027 MEDnVal(med_idt fid, char *champ, med_entite_maillage type_ent, 
00028         med_geometrie_element type_geo,med_int numdt, med_int numo)
00029 {
00030   med_int n;
00031   med_idt datagroup;
00032   med_err ret;
00033   char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2],nomdatagroup2[2*MED_MAX_PARA+1];
00034   char tmp1   [MED_TAILLE_NOM_ENTITE+1];
00035   char chemin [MED_TAILLE_CHA+(MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA)+1+100];
00036 
00037   /*
00038    * On inhibe le gestionnaire d'erreur HDF 
00039    */
00040   _MEDmodeErreurVerrouiller();
00041 
00042   /*
00043    * On cree le chemin d'accès
00044    */
00045   strcpy(chemin,MED_CHA);
00046   strcat(chemin,champ);
00047   strcat(chemin,"/");
00048 
00049   /* On cree le nom du datagroup de niveau 1 */
00050   if ((ret = _MEDnomEntite(nomdatagroup1,type_ent)) < 0)
00051     return -1;
00052   if ((type_ent != MED_NOEUD))
00053     {
00054       if ((ret = _MEDnomGeometrie(tmp1,type_geo)) < 0)
00055         return -1;
00056       strcat(nomdatagroup1,".");
00057       strcat(nomdatagroup1,tmp1);
00058     }
00059   strcat(chemin,nomdatagroup1);
00060   strcat(chemin,"/");
00061 
00062   /* Creation du datagroup de niveau 2 <numdt>.<numoo> */
00063   sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
00064   strcat(chemin,nomdatagroup2);
00065  
00066  /*
00067    * Acces au champ
00068   */
00069   if ((datagroup = _MEDdatagroupOuvrir(fid,chemin)) < 0) 
00070     return 0;
00071   if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,&n)) < 0)
00072     return -1;
00073 
00074   /*
00075    * fermetures 
00076    */
00077   if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00078     return -1;
00079  
00080   return n;
00081 }
00082 
00083 }