1 |
|
5 |
/* 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 transk ;
|
13 |
|
|
extern int nb_max_noe ;
|
14 |
|
|
#define BLOC_ENTETE " 151"
|
15 |
|
|
#define BLOC_ELE " 780"
|
16 |
|
|
#define BLOC_NOEUD " 15" /* simple precision */
|
17 |
|
|
#define BLOC_NOEUD_DOUBLE " 781" /* double precision */
|
18 |
|
|
#define BLOC_NOEUD_MAS " 2411" /* double precision master series */
|
19 |
|
|
#define BLOC_ELE_MAS " 2412"
|
20 |
|
|
#define PLANE_STRESS_LINEAR 41
|
21 |
|
|
#define PLANE_STRESS_PARABOLIC 42
|
22 |
|
|
#define PLANE_STRAIN_LINEAR 51
|
23 |
|
|
#define PLANE_STRAIN_PARABOLIC 52
|
24 |
|
|
#define FLAT_PLATE_LINEAR 61
|
25 |
|
|
#define FLAT_PLATE_PARABOLIC 62
|
26 |
|
|
#define MEMBRANE_LINEAR 74
|
27 |
|
|
#define MEMBRANE_PARABOLIC 72
|
28 |
|
|
#define AXISYMMETRIC_LINEAR 81
|
29 |
|
|
#define AXISYMMETRIC_PARABOLIC 82
|
30 |
|
|
#define THIN_SHELL_LINEAR 91
|
31 |
|
|
#define THIN_SHELL_PARABOLIC 92
|
32 |
|
|
|
33 |
|
|
void m3d_rids(int *nb_noeud,int *nb_ele,float *coord,int *numele,int *ierr)
|
34 |
|
|
{
|
35 |
|
|
FILE *stream, *output ;
|
36 |
|
|
char line[MAX_LINE] ;
|
37 |
|
|
char temp[MAX_LINE] ;
|
38 |
|
|
char temp1[MAX_LINE] ;
|
39 |
|
|
char temp2[MAX_LINE] ;
|
40 |
|
|
char temp3[MAX_LINE] ;
|
41 |
|
|
char tabel[MAX_LINE] ;
|
42 |
|
|
int j,i, num, type , index, icoul ;
|
43 |
|
|
int is_double = 0 ;
|
44 |
|
|
/* declaration des fonctions */
|
45 |
|
|
char *ext_noe, *ext_ele ;
|
46 |
|
|
int *corresp, j1, j2, j3, j4, j5, j6, itype ;
|
47 |
|
|
int *old, *neww, *tablin, *numele2 , ief;
|
48 |
|
|
float *coord2 ;
|
49 |
|
|
|
50 |
|
|
*ierr = FAUX ;
|
51 |
|
|
j = 0 ;
|
52 |
|
|
itype = 0 ;
|
53 |
|
|
|
54 |
|
|
/* le nom du fichier est donne en entier */
|
55 |
|
|
temp[0] = 0 ;
|
56 |
|
|
strcpy(temp,gest->buffer) ;
|
57 |
|
|
|
58 |
|
|
/* ouverture du fichier */
|
59 |
|
|
if (!(stream = fopen(temp,"r")))
|
60 |
|
|
{
|
61 |
|
|
m3d_erreur(ERR_OPEN) ;
|
62 |
|
|
*ierr = VRAI ;
|
63 |
|
|
return ;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/* le maillage lineaire ou quadratique */
|
67 |
|
|
|
68 |
|
|
/* recherche du bloc element */
|
69 |
|
|
|
70 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
71 |
|
|
{
|
72 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
73 |
|
|
*ierr = VRAI ;
|
74 |
|
|
return ;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
while ( (strncmp(line,BLOC_ELE,6)) && (strncmp(line,BLOC_ELE_MAS,6)) )
|
78 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
79 |
|
|
{
|
80 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
81 |
|
|
*ierr = VRAI ;
|
82 |
|
|
return ;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
/* on pointe sur le bloc des elements */
|
86 |
|
|
|
87 |
|
|
/* lecture de la ligne suivante */
|
88 |
|
|
|
89 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
90 |
|
|
{
|
91 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
92 |
|
|
*ierr = VRAI ;
|
93 |
|
|
return ;
|
94 |
|
|
}
|
95 |
|
|
if (sscanf(line,"%d%d",&i,&itype)!=2)
|
96 |
|
|
{
|
97 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
98 |
|
|
*ierr = VRAI ;
|
99 |
|
|
return ;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
switch(itype)
|
103 |
|
|
{
|
104 |
|
|
case PLANE_STRESS_LINEAR :
|
105 |
|
|
case PLANE_STRAIN_LINEAR :
|
106 |
|
|
case FLAT_PLATE_LINEAR :
|
107 |
|
|
case MEMBRANE_LINEAR :
|
108 |
|
|
case AXISYMMETRIC_LINEAR :
|
109 |
|
|
case THIN_SHELL_LINEAR : gest->is_qua = FAUX ;
|
110 |
|
|
break ;
|
111 |
|
|
case PLANE_STRESS_PARABOLIC :
|
112 |
|
|
case PLANE_STRAIN_PARABOLIC :
|
113 |
|
|
case FLAT_PLATE_PARABOLIC :
|
114 |
|
|
case MEMBRANE_PARABOLIC :
|
115 |
|
|
case AXISYMMETRIC_PARABOLIC :
|
116 |
|
|
case THIN_SHELL_PARABOLIC : gest->is_qua = VRAI ;
|
117 |
|
|
break ;
|
118 |
|
|
default :
|
119 |
|
|
m3d_erreur(ERR_TYPE_ELE) ;
|
120 |
|
|
*ierr = VRAI ;
|
121 |
|
|
return ;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
rewind(stream) ;
|
125 |
|
|
|
126 |
|
|
/* recherche du bloc des noeuds */
|
127 |
|
|
|
128 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
129 |
|
|
{
|
130 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
131 |
|
|
*ierr = VRAI ;
|
132 |
|
|
return ;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
while ( (strncmp(line,BLOC_NOEUD,6)) && (strncmp(line,BLOC_NOEUD_DOUBLE,6)) && (strncmp(line,BLOC_NOEUD_MAS,6)) )
|
136 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
137 |
|
|
{
|
138 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
139 |
|
|
*ierr = VRAI ;
|
140 |
|
|
return ;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
/* test sur le code */
|
144 |
|
|
|
145 |
|
|
ief = 0 ;
|
146 |
|
|
tabel[0] = 0 ;
|
147 |
|
|
strncat(tabel,line,6) ;/* 6 premiers caracteres */
|
148 |
|
|
ief = atoi(tabel) ;
|
149 |
|
|
if ((ief == 781) || (ief == 2411)) is_double = VRAI ;
|
150 |
|
|
else is_double = FAUX ;
|
151 |
|
|
|
152 |
|
|
/* on pointe sur le bloc des noeuds */
|
153 |
|
|
|
154 |
|
|
/* lecture du bloc */
|
155 |
|
|
/* reperer le plus grand numero */
|
156 |
|
|
index = 0 ;
|
157 |
|
|
|
158 |
|
|
*nb_noeud = 0 ;
|
159 |
|
|
j = 0 ;
|
160 |
|
|
|
161 |
|
|
while (index != -1)
|
162 |
|
|
{
|
163 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
164 |
|
|
{
|
165 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
166 |
|
|
*ierr = VRAI ;
|
167 |
|
|
return ;
|
168 |
|
|
}
|
169 |
|
|
if (sscanf(line,"%d",&index)!=1)
|
170 |
|
|
{
|
171 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
172 |
|
|
*ierr = VRAI ;
|
173 |
|
|
return ;
|
174 |
|
|
}
|
175 |
|
|
if (is_double) /* un record supplementaire */
|
176 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
177 |
|
|
{
|
178 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
179 |
|
|
*ierr = VRAI ;
|
180 |
|
|
return ;
|
181 |
|
|
}
|
182 |
|
|
*nb_noeud = *nb_noeud + 1 ;
|
183 |
|
|
if (index>j) j = index ;
|
184 |
|
|
}
|
185 |
|
|
*nb_noeud = *nb_noeud - 1 ;
|
186 |
|
|
/* rewind */
|
187 |
|
|
rewind(stream) ;
|
188 |
|
|
|
189 |
|
|
/* alloc du tableau de correspondance */
|
190 |
|
|
if (*nb_noeud>=nb_max_noe)
|
191 |
|
|
{
|
192 |
|
|
m3d_erreur(ERR_NB_NOE) ;
|
193 |
|
|
*ierr = VRAI ;
|
194 |
|
|
return ;
|
195 |
|
|
}
|
196 |
|
|
gest->numax = j ;
|
197 |
|
|
corresp = (int*)calloc(j+1,sizeof(int)) ;
|
198 |
|
|
if (corresp == NULL)
|
199 |
|
|
{
|
200 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
201 |
|
|
*ierr = VRAI ;
|
202 |
|
|
return ;
|
203 |
|
|
}
|
204 |
|
|
/* plus grand numero */
|
205 |
|
|
gest->tabcor = (int*)calloc((*nb_noeud)+1,sizeof(int)) ;
|
206 |
|
|
if (gest->tabcor == NULL)
|
207 |
|
|
{
|
208 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
209 |
|
|
*ierr = VRAI ;
|
210 |
|
|
return ;
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
/* maillage lineaire */
|
214 |
|
|
if (gest->is_qua == FAUX)
|
215 |
|
|
{
|
216 |
|
|
/* recherche du bloc des noeuds */
|
217 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
218 |
|
|
{
|
219 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
220 |
|
|
*ierr = VRAI ;
|
221 |
|
|
return ;
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
while ( (strncmp(line,BLOC_NOEUD,6)) && (strncmp(line,BLOC_NOEUD_DOUBLE,6)) && (strncmp(line,BLOC_NOEUD_MAS,6)) )
|
225 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
226 |
|
|
{
|
227 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
228 |
|
|
*ierr = VRAI ;
|
229 |
|
|
return ;
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
/* on pointe sur le bloc des noeuds */
|
233 |
|
|
/* lecture du bloc */
|
234 |
|
|
for (i=0;i<*nb_noeud;i++)
|
235 |
|
|
{
|
236 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
237 |
|
|
{
|
238 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
239 |
|
|
*ierr = VRAI ;
|
240 |
|
|
return ;
|
241 |
|
|
}
|
242 |
|
|
if (!is_double) sscanf(line,"%d%d%d%d%f%f%f",&j,&j1,&j1,&j1,coord+3*i,coord+3*i+1,coord+3*i+2) ;
|
243 |
|
|
else
|
244 |
|
|
{
|
245 |
|
|
sscanf(line,"%d%d%d%d",&j,&j1,&j1,&icoul) ;
|
246 |
|
|
/* lecture de la ligne suivante */
|
247 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
248 |
|
|
{
|
249 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
250 |
|
|
*ierr = VRAI ;
|
251 |
|
|
return ;
|
252 |
|
|
}
|
253 |
|
|
sscanf(line,"%s%s%s",temp1,temp2,temp3) ;
|
254 |
|
|
/* decodage et affectation des coordonnees */
|
255 |
|
|
m3d_convfd(temp1,coord+3*i) ;
|
256 |
|
|
m3d_convfd(temp2,coord+3*i+1) ;
|
257 |
|
|
m3d_convfd(temp3,coord+3*i+2) ;
|
258 |
|
|
}
|
259 |
|
|
corresp[j] = i + 1 ;
|
260 |
|
|
gest->tabcor[i+1] = j ;
|
261 |
|
|
}
|
262 |
|
|
/* recherche du bloc des elements */
|
263 |
|
|
|
264 |
|
|
while ( (strncmp(line,BLOC_ELE,6)) && (strncmp(line,BLOC_ELE_MAS,6)) )
|
265 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
266 |
|
|
{
|
267 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
268 |
|
|
*ierr = VRAI ;
|
269 |
|
|
return ;
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
/* on pointe sur le bloc des elements */
|
273 |
|
|
|
274 |
|
|
i = 0 ;
|
275 |
|
|
index = 1 ;
|
276 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
277 |
|
|
{
|
278 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
279 |
|
|
*ierr = VRAI ;
|
280 |
|
|
return ;
|
281 |
|
|
}
|
282 |
|
|
if (sscanf(line,"%d",&index)!=1)
|
283 |
|
|
{
|
284 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
285 |
|
|
*ierr = VRAI ;
|
286 |
|
|
return ;
|
287 |
|
|
}
|
288 |
|
|
while (index!=-1)
|
289 |
|
|
{
|
290 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
291 |
|
|
{
|
292 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
293 |
|
|
*ierr = VRAI ;
|
294 |
|
|
return ;
|
295 |
|
|
}
|
296 |
|
|
if (sscanf(line,"%d%d%d",&j1,&j2,&j3)!=3)
|
297 |
|
|
{
|
298 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
299 |
|
|
*ierr = VRAI ;
|
300 |
|
|
return ;
|
301 |
|
|
}
|
302 |
|
|
numele[3*i] = corresp[j1] ;
|
303 |
|
|
numele[3*i+1] = corresp[j2] ;
|
304 |
|
|
numele[3*i+2] = corresp[j3] ;
|
305 |
|
|
i ++ ;
|
306 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
307 |
|
|
{
|
308 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
309 |
|
|
*ierr = VRAI ;
|
310 |
|
|
return ;
|
311 |
|
|
}
|
312 |
|
|
if (sscanf(line,"%d",&index)!=1)
|
313 |
|
|
{
|
314 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
315 |
|
|
*ierr = VRAI ;
|
316 |
|
|
return ;
|
317 |
|
|
}
|
318 |
|
|
}
|
319 |
|
|
*nb_ele = i ;
|
320 |
|
|
}
|
321 |
|
|
else
|
322 |
|
|
{
|
323 |
|
|
/* tableau des coordonnees des noeuds quadratiques,
|
324 |
|
|
le maillage se fait evidemment en lineaire puis on fait un simple
|
325 |
|
|
post-traitement */
|
326 |
|
|
|
327 |
|
|
/* lecture des noeuds ->on remplit coord2 */
|
328 |
|
|
gest->coord2 = (float*)calloc(3*(*nb_noeud),sizeof(float)) ;
|
329 |
|
|
if (gest->coord2 == NULL)
|
330 |
|
|
{
|
331 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
332 |
|
|
*ierr = VRAI ;
|
333 |
|
|
return ;
|
334 |
|
|
}
|
335 |
|
|
coord2 = gest->coord2 ;
|
336 |
|
|
gest->tablin = (int*)calloc((*nb_noeud)+1,sizeof(int)) ;
|
337 |
|
|
/* les noeuds sont ils des noeuds du maillage */
|
338 |
|
|
if (gest->tablin == NULL)
|
339 |
|
|
{
|
340 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
341 |
|
|
*ierr = VRAI ;
|
342 |
|
|
return ;
|
343 |
|
|
}
|
344 |
|
|
tablin = gest->tablin ;
|
345 |
|
|
for (i=0;i<=*nb_noeud;i++) tablin[i] = VRAI ;
|
346 |
|
|
gest->neww = (int*)calloc((*nb_noeud)+1,sizeof(int)) ;
|
347 |
|
|
if (gest->neww == NULL)
|
348 |
|
|
{
|
349 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
350 |
|
|
*ierr = VRAI ;
|
351 |
|
|
return ;
|
352 |
|
|
}
|
353 |
|
|
neww = gest->neww ;
|
354 |
|
|
gest->old = (int*)calloc((*nb_noeud)+1,sizeof(int)) ;
|
355 |
|
|
if (gest->old == NULL)
|
356 |
|
|
{
|
357 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
358 |
|
|
*ierr = VRAI ;
|
359 |
|
|
return ;
|
360 |
|
|
}
|
361 |
|
|
old = gest->old ;
|
362 |
|
|
gest->nb_noe_qua = *nb_noeud ;
|
363 |
|
|
/* lecture des noeuds */
|
364 |
|
|
ief = 0 ;
|
365 |
|
|
/* reperage du bloc des noeuds */
|
366 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
367 |
|
|
{
|
368 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
369 |
|
|
*ierr = VRAI ;
|
370 |
|
|
return ;
|
371 |
|
|
}
|
372 |
|
|
|
373 |
|
|
while ( (strncmp(line,BLOC_NOEUD,6)) && (strncmp(line,BLOC_NOEUD_DOUBLE,6)) && (strncmp(line,BLOC_NOEUD_MAS,6)) )
|
374 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
375 |
|
|
{
|
376 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
377 |
|
|
*ierr = VRAI ;
|
378 |
|
|
return ;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
/* on pointe sur le bloc des noeuds */
|
382 |
|
|
/* lecture du bloc */
|
383 |
|
|
for (i=0;i<*nb_noeud;i++)
|
384 |
|
|
{
|
385 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
386 |
|
|
{
|
387 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
388 |
|
|
*ierr = VRAI ;
|
389 |
|
|
return ;
|
390 |
|
|
}
|
391 |
|
|
if (!is_double) sscanf(line,"%d%d%d%d%f%f%f",&j,&j1,&j1,&icoul,coord2+3*i,coord2+3*i+1,coord2+3*i+2) ;
|
392 |
|
|
else
|
393 |
|
|
{
|
394 |
|
|
sscanf(line,"%d%d%d%d",&j,&j1,&j1,&icoul) ;
|
395 |
|
|
/* lecture de la ligne suivante */
|
396 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
397 |
|
|
{
|
398 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
399 |
|
|
*ierr = VRAI ;
|
400 |
|
|
return ;
|
401 |
|
|
}
|
402 |
|
|
sscanf(line,"%s%s%s",temp1,temp2,temp3) ;
|
403 |
|
|
/* decodage et affectation des coordonnees */
|
404 |
|
|
m3d_convfd(temp1,coord2+3*i) ;
|
405 |
|
|
m3d_convfd(temp2,coord2+3*i+1) ;
|
406 |
|
|
m3d_convfd(temp3,coord2+3*i+2) ;
|
407 |
|
|
}
|
408 |
|
|
corresp[j] = i + 1 ;
|
409 |
|
|
gest->tabcor[i+1] = j ;
|
410 |
|
|
}
|
411 |
|
|
/* on a rempli le tableau des noeuds quadratiques */
|
412 |
|
|
/* parcours des elements gestions des noeuds quadratiques */
|
413 |
|
|
/* reperer les numeros de noeuds quadratiques */
|
414 |
|
|
|
415 |
|
|
/* recherche du bloc des elements */
|
416 |
|
|
|
417 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
418 |
|
|
{
|
419 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
420 |
|
|
*ierr = VRAI ;
|
421 |
|
|
return ;
|
422 |
|
|
}
|
423 |
|
|
|
424 |
|
|
while ( (strncmp(line,BLOC_ELE,6)) && (strncmp(line,BLOC_ELE_MAS,6)) )
|
425 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
426 |
|
|
{
|
427 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
428 |
|
|
*ierr = VRAI ;
|
429 |
|
|
return ;
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
/* determination du nombre d'elements */
|
433 |
|
|
i = 0 ;
|
434 |
|
|
index = 1 ;
|
435 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
436 |
|
|
{
|
437 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
438 |
|
|
*ierr = VRAI ;
|
439 |
|
|
return ;
|
440 |
|
|
}
|
441 |
|
|
if (sscanf(line,"%d",&index)!=1)
|
442 |
|
|
{
|
443 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
444 |
|
|
*ierr = VRAI ;
|
445 |
|
|
return ;
|
446 |
|
|
}
|
447 |
|
|
while (index!=-1)
|
448 |
|
|
{
|
449 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
450 |
|
|
{
|
451 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
452 |
|
|
*ierr = VRAI ;
|
453 |
|
|
return ;
|
454 |
|
|
}
|
455 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
456 |
|
|
{
|
457 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
458 |
|
|
*ierr = VRAI ;
|
459 |
|
|
return ;
|
460 |
|
|
}
|
461 |
|
|
if (strncmp ( line+21,"D",1 ) != 0) if (sscanf(line,"%d",&index)!=1)
|
462 |
|
|
{
|
463 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
464 |
|
|
*ierr = VRAI ;
|
465 |
|
|
return ;
|
466 |
|
|
}
|
467 |
|
|
i++ ;
|
468 |
|
|
}
|
469 |
|
|
*nb_ele = i ;
|
470 |
|
|
rewind(stream) ;
|
471 |
|
|
|
472 |
|
|
/* recherche du bloc element */
|
473 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
474 |
|
|
{
|
475 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
476 |
|
|
*ierr = VRAI ;
|
477 |
|
|
return ;
|
478 |
|
|
}
|
479 |
|
|
|
480 |
|
|
while ( (strncmp(line,BLOC_ELE,6)) && (strncmp(line,BLOC_ELE_MAS,6)) )
|
481 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
482 |
|
|
{
|
483 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
484 |
|
|
*ierr = VRAI ;
|
485 |
|
|
return ;
|
486 |
|
|
}
|
487 |
|
|
|
488 |
|
|
/* on pointe sur le bloc des elements */
|
489 |
|
|
gest->numele2 = (int*)calloc(6 * (*nb_ele),sizeof(int)) ;
|
490 |
|
|
if (gest->numele2 == NULL)
|
491 |
|
|
{
|
492 |
|
|
m3d_erreur(ERR_ALLOC) ;
|
493 |
|
|
*ierr = VRAI ;
|
494 |
|
|
return ;
|
495 |
|
|
}
|
496 |
|
|
numele2 = gest->numele2 ;
|
497 |
|
|
for (i=0;i<*nb_ele;i++)
|
498 |
|
|
{
|
499 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
500 |
|
|
{
|
501 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
502 |
|
|
*ierr = VRAI ;
|
503 |
|
|
return ;
|
504 |
|
|
}
|
505 |
|
|
if (!fgets(line,MAX_LINE,stream))
|
506 |
|
|
{
|
507 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
508 |
|
|
*ierr = VRAI ;
|
509 |
|
|
return ;
|
510 |
|
|
}
|
511 |
|
|
if (sscanf(line,"%d%d%d%d%d%d",&j1,&j2,&j3,&j4,&j5,&j6)!=6)
|
512 |
|
|
{
|
513 |
|
|
m3d_erreur(ERR_FORMAT) ;
|
514 |
|
|
*ierr = VRAI ;
|
515 |
|
|
return ;
|
516 |
|
|
}
|
517 |
|
|
numele[3*i] = corresp[j1] ;
|
518 |
|
|
numele[3*i+1] = corresp[j3] ;
|
519 |
|
|
numele[3*i+2] = corresp[j5] ;
|
520 |
|
|
numele2[6*i] = numele[3*i] ;
|
521 |
|
|
numele2[6*i+2] = numele[3*i+1] ;
|
522 |
|
|
numele2[6*i+4] = numele[3*i+2] ;
|
523 |
|
|
numele2[6*i+1] = corresp[j2] ;
|
524 |
|
|
numele2[6*i+3] = corresp[j4] ;
|
525 |
|
|
numele2[6*i+5] = corresp[j6] ;
|
526 |
|
|
tablin[(corresp[j2])] = FAUX ;
|
527 |
|
|
tablin[(corresp[j4])] = FAUX ;
|
528 |
|
|
tablin[(corresp[j6])] = FAUX ;
|
529 |
|
|
}
|
530 |
|
|
/* parcours du tableau des coordonnees coord2 */
|
531 |
|
|
*nb_noeud = 0 ;
|
532 |
|
|
for (i=1;i<=gest->nb_noe_qua;i++)/* numeros fortran */
|
533 |
|
|
{
|
534 |
|
|
if (tablin[i]==VRAI)
|
535 |
|
|
{
|
536 |
|
|
coord[x(*nb_noeud)] = coord2[x(i-1)] ;
|
537 |
|
|
coord[y(*nb_noeud)] = coord2[y(i-1)] ;
|
538 |
|
|
coord[z(*nb_noeud)] = coord2[z(i-1)] ;
|
539 |
|
|
*nb_noeud = *nb_noeud + 1 ;
|
540 |
|
|
/* correspondance */
|
541 |
|
|
neww[i] = *nb_noeud ;
|
542 |
|
|
old[*nb_noeud] = i ;
|
543 |
|
|
}
|
544 |
|
|
}
|
545 |
|
|
/* renumerotation des elements */
|
546 |
|
|
for (i=0;i<*nb_ele;i++)/* numeros fortran */
|
547 |
|
|
{
|
548 |
|
|
numele[3*i] = neww[numele[3*i]] ;
|
549 |
|
|
numele[3*i+1] = neww[numele[3*i+1]] ;
|
550 |
|
|
numele[3*i+2] = neww[numele[3*i+2]] ;
|
551 |
|
|
}
|
552 |
|
|
}
|
553 |
|
|
free(corresp) ;
|
554 |
|
|
fclose(stream) ;
|
555 |
|
|
return ;
|
556 |
|
|
}
|