Back to index

salome-med  6.5.0
MEDcoordEcr.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_outils.hxx"
00020 #include "med.hxx"
00021 
00022 #include <stdlib.h>
00023 #include <string.h>
00024 
00025 namespace med_2_1{
00026 
00027 med_err 
00028 MEDcoordEcr(med_idt fid, char *maa, med_int mdim, med_float *coo, 
00029             med_mode_switch mode_coo,med_int n,
00030             med_mode_acces mode, med_repere type_rep, char *nom, char *unit)
00031 {
00032   med_idt maaid, noeid, dataset;
00033   med_err ret;
00034   med_size dimd[1];
00035   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00036   med_int type_rep_int; 
00037   /*
00038    * On inhibe le gestionnaire d'erreur HDF
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    * Si le Data Group "NOE" n'existe pas
00052    * on le cree
00053    */
00054   /* EF : A faire : gerer le mode MED_REMP*/
00055   if ((noeid = _MEDdatagroupOuvrir(maaid,MED_NOM_NOE)) < 0)
00056     if ((noeid = _MEDdatagroupCreer(maaid,MED_NOM_NOE)) < 0)
00057       return -1;
00058 
00059   /*
00060    * Creation du Data Set "COO"
00061    */
00062   dimd[0] = n*mdim;
00063   if ((ret = _MEDdatasetNumEcrire(noeid,MED_NOM_COO,MED_REEL64,mode_coo,mdim,MED_ALL,MED_NOPF,0,MED_NOPG,dimd,
00064                                   (unsigned char*) coo,mode)) < 0)
00065     return -1;
00066   
00067   /*
00068    * On re-ouvre le Data Set "COO" pour y placer des attributs
00069    */
00070   if ((dataset = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0)
00071     return -1;
00072 
00073   /*
00074    * Attribut NBR (nombre de noeuds)
00075    */
00076   if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n,mode)) < 0)
00077     return -1;
00078 
00079   /*
00080    * L'attribut "REP"
00081    */
00082   type_rep_int = (med_int) type_rep; 
00083   if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_REP,&type_rep_int,mode)) < 0)
00084     return -1;
00085 
00086   /*
00087    * Attribut "NOM"
00088    */
00089   if ((ret = _MEDattrStringEcrire(dataset,MED_NOM_NOM,mdim*MED_TAILLE_PNOM,nom,mode)) < 0)
00090     return -1;
00091 
00092   /*
00093    * Attribut "UNI"
00094    */
00095   if ((ret = _MEDattrStringEcrire(dataset,MED_NOM_UNI,mdim*MED_TAILLE_PNOM,unit,mode)) < 0)
00096     return -1;
00097 
00098   /*
00099    * On ferme tout
00100    */
00101   if ((ret = _MEDdatasetFermer(dataset)) < 0)
00102     return -1;
00103   if ((ret = _MEDdatagroupFermer(noeid)) < 0)
00104     return -1;
00105   if ((ret = _MEDdatagroupFermer(maaid)) < 0)
00106     return -1;
00107 
00108   return 0; 
00109 }
00110 
00111 }