Back to index

salome-med  6.5.0
MEDequivEcr.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 <string.h>
00023 #include <stdlib.h>
00024 
00025 extern int mode_interlace; 
00026 
00027 namespace med_2_1{
00028 
00029 med_err 
00030 MEDequivEcr(med_idt fid, char *maa, char *eq, med_int *corr, med_int n, 
00031             med_mode_acces mode, med_entite_maillage typ_ent, med_geometrie_element typ_geo)
00032 {
00033   med_idt eqid, datagroup;
00034   med_err ret;
00035   char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1]; 
00036   char nomdatagroup[MED_TAILLE_NOM+1];
00037   char tmp[MED_TAILLE_NOM_ENTITE+1];
00038   med_size dimd[1];
00039 
00040   if (typ_geo == MED_TETRA4 || typ_geo == MED_TETRA10 ||
00041       typ_geo == MED_HEXA8  || typ_geo == MED_HEXA20  ||
00042       typ_geo == MED_PENTA6 || typ_geo == MED_PENTA15 ||
00043       typ_geo == MED_PYRA5  || typ_geo == MED_PYRA13)
00044     return -1;
00045 
00046   /*
00047    * On inhibe le gestionnaire d'erreur HDF 5
00048    */
00049   _MEDmodeErreurVerrouiller();
00050 
00051   /* 
00052    * Si le Data Group de "eq" n'existe pas => erreur
00053    */
00054   strcpy(chemin,MED_MAA);
00055   strcat(chemin,maa);
00056   strcat(chemin,MED_EQS);
00057   strcat(chemin,eq);
00058   if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00059     return -1;  
00060 
00061   /*
00062    * Ecriture de l'equivalence
00063    */
00064   if ((ret = _MEDnomEntite(nomdatagroup,typ_ent)) < 0)
00065     return -1;
00066   if ((typ_ent != MED_NOEUD))
00067     {
00068       if ((ret = _MEDnomGeometrie(tmp,typ_geo)) < 0)
00069         return -1;
00070       strcat(nomdatagroup,".");
00071       strcat(nomdatagroup,tmp);
00072     }
00073   datagroup = 0;
00074   if (((datagroup = _MEDdatagroupOuvrir(eqid,nomdatagroup)) > 0) && 
00075       (mode != MED_REMP))
00076     return -1;
00077   else
00078     if (datagroup > 0)
00079       _MEDdatagroupFermer(datagroup);
00080 
00081   /* EF : verifier que  marche si le data groupe existe dj */
00082   if ((datagroup = _MEDdatagroupCreer(eqid,nomdatagroup)) < 0)
00083     return -1;
00084 
00085   if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n,mode)) < 0)
00086     return -1;
00087 
00088   dimd[0] = 2*n;
00089 
00090 #if defined(HAVE_F77INT64)
00091   if ((ret =  _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd,
00092                                 (unsigned char*) corr,mode)) < 0)
00093     return -1;
00094 #else
00095   if ((ret =  _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,0,MED_NOPG,dimd,
00096                                 (unsigned char*) corr,mode)) < 0)
00097     return -1;
00098 #endif
00099 
00100   /*
00101    * On ferme tout 
00102    */
00103   if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00104     return -1;
00105   if ((ret = _MEDdatagroupFermer(eqid)) < 0)
00106     return -1;
00107 
00108   return 0; 
00109 }
00110 
00111 }