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