Back to index

salome-med  6.5.0
MEDfamMaaCr.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 <stdio.h>
00023 #include <cstring>
00024 
00025 namespace med_2_1{
00026 
00027 med_err
00028 MEDfamMaaCr(med_idt fid,char *maa,
00029             med_int *numfam,med_int *attide,
00030             med_int *attval,char *attdes,int *indatt,char *gro,int *indgro,
00031             med_int nfamilles)
00032 {
00033   med_err ret;
00034   med_int i;
00035   med_int natt,ngro;
00036   med_int numf;
00037   char nomfam[MED_TAILLE_NOM+1];
00038 
00039   /* La famille de numero 0 n'a aucun attribut, ni aucun groupe
00040      Les familles de numero > 0 sont des familles de noeuds
00041      Les familles de numero < 0 sont des familles d'elements */
00042   for (i=0;i<nfamilles;i++)
00043     {
00044       numf = *(numfam+i);
00045       if (numf == 0)
00046         strcpy(nomfam,"FAMILLE_0");
00047       if (numf > 0)
00048         {
00049           strcpy(nomfam,"FAMILLE_NOEUD_");
00050           sprintf(nomfam,"%s%d",nomfam,numf);
00051           nomfam[MED_TAILLE_NOM] = '\0';
00052         }
00053       if (numf < 0)
00054         {
00055           strcpy(nomfam,"FAMILLE_ELEMENT_");
00056           sprintf(nomfam,"%s%d",nomfam,-numf);
00057           nomfam[MED_TAILLE_NOM] = '\0';
00058         }       
00059       natt = *(indatt+i+1) - *(indatt+i);
00060       ngro = (*(indgro+i+1) - *(indgro+i))/MED_TAILLE_LNOM;
00061       if ((ret = MEDfamCr(fid,maa,nomfam,numf,
00062                           attide+*(indatt+i),
00063                           attval+*(indatt+i),
00064                           attdes+*(indatt+i)*MED_TAILLE_DESC,natt,
00065                           gro+*(indgro+i),ngro)) < 0)
00066         return -1;
00067     }
00068     
00069   return 0;
00070 }
00071 
00072 }