ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/diamesh/src/m3d_racsis.cpp
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
File size: 2594 byte(s)
Log Message:
structure de l'écriture

File Contents

# User Rev Content
1 francois 283 /* lecture des fichiers */
2     #include <stdio.h>
3     #include <string.h>
4     #include <stdlib.h>
5     #include "m3d_const.h"
6     #include "m3d_hotes.h"
7     #include "m3d_struct.h"
8     #include "m3d_erreur.h"
9     #include "prototype.h"
10     extern int format ;
11     extern GEST_MEM *gest ;
12     extern int nb_max_noe ;
13     void m3d_racsis(int *nb_noeud,int *nb_ele,float *coord,int *numele,int *ierr)
14     {
15     FILE *stream ;
16     char line[MAX_LINE] ;
17     char temp[MAX_LINE] ;
18     char tabel[MAX_LINE] ;
19     int j,i, index;
20     /* declaration des fonctions */
21     char *ext_ele ;
22     int *corresp, itype ;
23     int *old, *tablin, *numele2;
24     float *coord2 ;
25    
26     *ierr = FAUX ;
27     j = 0 ;
28     itype = 0 ;
29    
30     if (format == ACSIS)
31     {
32     temp[0] = 0 ;
33     strcpy(temp,gest->buffer) ;
34    
35     /* ouverture du fichier */
36     if (!(stream = fopen(temp,"r")))
37     {
38     *ierr = VRAI ;
39     m3d_erreur(ERR_OPEN);
40     return ;
41     }
42    
43     /* lecture des parametres */
44     if (!fgets(line,MAX_LINE,stream))
45     {
46     *ierr = VRAI ;
47     m3d_erreur(ERR_FORMAT);
48     return ;
49     }
50     if (sscanf(line,"%d %d",nb_noeud,nb_ele)!=2)
51     {
52     *ierr = VRAI ;
53     m3d_erreur(ERR_FORMAT);
54     return ;
55     }
56     gest->tabcor = (int*)calloc((*nb_noeud)+1,sizeof(int)) ;
57     if (gest->tabcor == NULL)
58     {
59     *ierr = VRAI ;
60     m3d_erreur(ERR_ALLOC);
61     return ;
62     }
63     /* lecture des noeud */
64     for (i=0;i<*nb_noeud;i++)
65     {
66     if (!fgets(line,MAX_LINE,stream))
67     {
68     *ierr = VRAI ;
69     m3d_erreur(ERR_FORMAT);
70     return ;
71     }
72    
73     /* coordonnees */
74     if (sscanf(line,"%d %f %f %f",&gest->tabcor[i+1],coord+3*i,coord+3*i+1,coord+3*i+2)!=4)
75     {
76     *ierr = VRAI ;
77     m3d_erreur(ERR_FORMAT);
78     return ;
79     }
80     }
81     gest->numax = *nb_noeud ;
82     /* lecture des elements */
83     for (i=0;i<*nb_ele;i++)
84     {
85     if (!fgets(line,MAX_LINE,stream))
86     {
87     *ierr = VRAI ;
88     m3d_erreur(ERR_FORMAT);
89     return ;
90     }
91     if (sscanf(line,"%d %d %d %d",&j,numele+3*i,numele+3*i+1,numele+3*i+2)!=4)
92     {
93     *ierr = VRAI ;
94     m3d_erreur(ERR_FORMAT);
95     return ;
96     }
97     }
98    
99     }
100     else
101     {
102     *ierr = VRAI ;
103     m3d_erreur(ERR_FORMAT);
104     return ;
105     }
106     return ;
107     }