1 |
|
5 |
|
2 |
|
|
#include <math.h>
|
3 |
|
|
#include <string.h>
|
4 |
|
|
#include <signal.h>
|
5 |
|
|
#include <stdlib.h>
|
6 |
|
|
#include <stdio.h>
|
7 |
|
|
#include "m3d_struct.h"
|
8 |
|
|
#include "m3d_message.h"
|
9 |
|
|
#include "m3d_const.h"
|
10 |
|
|
#include "m3d_hotes.h"
|
11 |
|
|
#include "m3d_erreur.h"
|
12 |
|
|
#include "prototype.h"
|
13 |
|
|
extern GEST_MEM *gest ;
|
14 |
|
|
extern int debug ;
|
15 |
|
|
extern int is_best ;
|
16 |
|
|
extern int nb_max_noe ;
|
17 |
|
|
extern int nb_max_ele ;
|
18 |
|
|
extern float crit_min ;
|
19 |
|
|
extern float dimp ;
|
20 |
|
|
extern int save ;
|
21 |
|
|
extern int recover ;
|
22 |
|
|
extern int is_recover ;
|
23 |
|
|
/* routine de tete du mailleur */
|
24 |
|
|
int m3d_maidft(void)
|
25 |
|
|
{
|
26 |
|
|
FACE *face ;
|
27 |
|
|
float dmin, dmax ;
|
28 |
|
|
int i ;
|
29 |
|
|
OCT *oct, *oct0 ;
|
30 |
|
|
int ierr ;
|
31 |
|
|
float som, dmoyen ;
|
32 |
|
|
float *coord, cmin ;
|
33 |
|
|
char mess[255];
|
34 |
|
|
/* debut du code executable */
|
35 |
|
|
/* initialisations des variables */
|
36 |
|
|
ierr = 0 ;
|
37 |
|
|
/* on dispose maintenant de xmin, xmax, ymin, ymax, zmin, zmax */
|
38 |
|
|
/* ----------------------------------------------------- */
|
39 |
|
|
/* creation de la BD */
|
40 |
|
|
/* ----------------------------------------------------- */
|
41 |
|
|
coord = gest->coord ;
|
42 |
|
|
|
43 |
|
|
if (!m3d_c_bd())
|
44 |
|
|
{
|
45 |
|
|
return(FAUX) ;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
/* ----------------------------------------------------- */
|
49 |
|
|
/* calcul de la taille moyenne des mailles de peau */
|
50 |
|
|
/* ----------------------------------------------------- */
|
51 |
|
|
|
52 |
|
|
gest->nb_info = gest->nb_init ;
|
53 |
|
|
|
54 |
|
|
gest->val_noeud = (float*)calloc(gest->nb_info,sizeof(float)) ;/* valeur du critere aux noeuds */
|
55 |
|
|
ERREUR_ALLOC_FAUX(gest->val_noeud)
|
56 |
|
|
|
57 |
|
|
/* ----------------------------------------------------- */
|
58 |
|
|
/* calcul du critere en chaque noeud de la peau */
|
59 |
|
|
/* ----------------------------------------------------- */
|
60 |
|
|
|
61 |
|
|
if (!m3d_crit())
|
62 |
|
|
{
|
63 |
|
|
return(FAUX) ;
|
64 |
|
|
}
|
65 |
|
|
/* calcul de la taille moyenne de maille */
|
66 |
|
|
dmin = dimp ;
|
67 |
|
|
dmax = 0. ;
|
68 |
|
|
som = 0. ;
|
69 |
|
|
for (i=0;i<gest->nb_info;i++)
|
70 |
|
|
{
|
71 |
|
|
if (gest->val_noeud[i]<dmin) dmin = gest->val_noeud[i] ;
|
72 |
|
|
if (gest->val_noeud[i]>dmax) dmax = gest->val_noeud[i] ;
|
73 |
|
|
som = som + gest->val_noeud[i] ;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
dmoyen = som/gest->nb_info ;
|
77 |
|
|
|
78 |
|
|
/* ----------------------------------------------------- */
|
79 |
|
|
/* TYPE DE MAILLAGE */
|
80 |
|
|
/* ----------------------------------------------------- */
|
81 |
|
|
|
82 |
|
|
gest->rap = dmax/dmin ;
|
83 |
|
|
|
84 |
|
|
if (!is_recover)
|
85 |
|
|
{
|
86 |
|
|
sprintf(mess,"%s %f\n",MESS_RAPPORT_TAILLE,gest->rap) ;
|
87 |
|
|
//aff_text(mess);
|
88 |
|
|
}
|
89 |
|
|
/* creation de oct0 */
|
90 |
|
|
oct0 = m3d_c_oct() ;
|
91 |
|
|
if (oct0 == NULL)
|
92 |
|
|
{
|
93 |
|
|
return(FAUX) ;
|
94 |
|
|
}
|
95 |
|
|
gest->root = oct0 ;
|
96 |
|
|
oct0->taille = 1.0010 * dimp ;
|
97 |
|
|
oct0->vec[0] = 0. ;
|
98 |
|
|
oct0->vec[1] = 0. ;
|
99 |
|
|
oct0->vec[2] = 0. ;
|
100 |
|
|
|
101 |
|
|
for (i=0;i<gest->nb_init;i++)
|
102 |
|
|
{
|
103 |
|
|
oct = NULL ;
|
104 |
|
|
m3d_dec_oct(oct0,coord+3*i,gest->val_noeud[i],&oct,&ierr) ;
|
105 |
|
|
if (ierr == VRAI) return(FAUX) ;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
if (!m3d_g_noe())
|
110 |
|
|
{
|
111 |
|
|
return(FAUX) ;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
free(gest->val_noeud) ;
|
115 |
|
|
gest->val_noeud = NULL ;
|
116 |
|
|
|
117 |
|
|
/*
|
118 |
|
|
-----------------------------------------------------------------------------
|
119 |
|
|
constitution du maillage
|
120 |
|
|
-----------------------------------------------------------------------------
|
121 |
|
|
*/
|
122 |
|
|
|
123 |
|
|
ierr = FAUX ;
|
124 |
|
|
for (i=0;i<gest->nb_face;i++)
|
125 |
|
|
{
|
126 |
|
|
ADRESSE(face,i,face)
|
127 |
|
|
if (!m3d_if_oct(face))
|
128 |
|
|
{
|
129 |
|
|
return(FAUX) ;
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
if (!is_recover)
|
133 |
|
|
{
|
134 |
|
|
m3d_message(MAILLAGE_EN_COURS) ;
|
135 |
|
|
}
|
136 |
|
|
if (!m3d_c_mai())
|
137 |
|
|
{
|
138 |
|
|
save = 1 ;
|
139 |
|
|
return(FAUX) ;
|
140 |
|
|
}
|
141 |
|
|
FREE_ALLOC(objet)
|
142 |
|
|
FREE_ALLOC(oct)
|
143 |
|
|
if (!is_recover) m3d_message(MAILLAGE_TERMINE) ;
|
144 |
|
|
if (!is_recover) m3d_message(OPTIMISATION_EN_COURS) ;
|
145 |
|
|
|
146 |
|
|
if (!is_best)
|
147 |
|
|
{
|
148 |
|
|
cmin = crit_min ;
|
149 |
|
|
crit_min = min(0.2,2*cmin) ;
|
150 |
|
|
if (debug)
|
151 |
|
|
{
|
152 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
153 |
|
|
//aff_text(mess);
|
154 |
|
|
}
|
155 |
|
|
if (!m3d_best())
|
156 |
|
|
{
|
157 |
|
|
m3d_erreur(ERR_SYST) ;
|
158 |
|
|
save = 1 ;
|
159 |
|
|
return(FAUX) ;
|
160 |
|
|
}
|
161 |
|
|
crit_min = 2*cmin + 0.1 ;
|
162 |
|
|
if (debug)
|
163 |
|
|
{
|
164 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
165 |
|
|
//aff_text(mess);
|
166 |
|
|
}
|
167 |
|
|
if (!m3d_best())
|
168 |
|
|
{
|
169 |
|
|
m3d_erreur(ERR_SYST) ;
|
170 |
|
|
save = 1 ;
|
171 |
|
|
return(FAUX) ;
|
172 |
|
|
}
|
173 |
|
|
crit_min = 2*cmin + 0.2 ;
|
174 |
|
|
if (debug)
|
175 |
|
|
{
|
176 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
177 |
|
|
//aff_text(mess);
|
178 |
|
|
}
|
179 |
|
|
if (!m3d_best())
|
180 |
|
|
{
|
181 |
|
|
m3d_erreur(ERR_SYST) ;
|
182 |
|
|
save = 1 ;
|
183 |
|
|
return(FAUX) ;
|
184 |
|
|
}
|
185 |
|
|
crit_min = 2*cmin + 0.3 ;
|
186 |
|
|
if (debug)
|
187 |
|
|
{
|
188 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
189 |
|
|
//aff_text(mess);
|
190 |
|
|
}
|
191 |
|
|
if (!m3d_best())
|
192 |
|
|
{
|
193 |
|
|
m3d_erreur(ERR_SYST) ;
|
194 |
|
|
save = 1 ;
|
195 |
|
|
return(FAUX) ;
|
196 |
|
|
}
|
197 |
|
|
crit_min = 2*cmin + 0.2 ;
|
198 |
|
|
if (debug)
|
199 |
|
|
{
|
200 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
201 |
|
|
//aff_text(mess);
|
202 |
|
|
}
|
203 |
|
|
if (!m3d_best())
|
204 |
|
|
{
|
205 |
|
|
m3d_erreur(ERR_SYST) ;
|
206 |
|
|
save = 1 ;
|
207 |
|
|
return(FAUX) ;
|
208 |
|
|
}
|
209 |
|
|
crit_min = 2*cmin + 0.1 ;
|
210 |
|
|
if (debug)
|
211 |
|
|
{
|
212 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
213 |
|
|
//aff_text(mess);
|
214 |
|
|
}
|
215 |
|
|
if (!m3d_best())
|
216 |
|
|
{
|
217 |
|
|
m3d_erreur(ERR_SYST) ;
|
218 |
|
|
save = 1 ;
|
219 |
|
|
return(FAUX) ;
|
220 |
|
|
}
|
221 |
|
|
crit_min = min(0.2,2*cmin) ;
|
222 |
|
|
if (debug)
|
223 |
|
|
{
|
224 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
225 |
|
|
//aff_text(mess);
|
226 |
|
|
}
|
227 |
|
|
if (!m3d_best())
|
228 |
|
|
{
|
229 |
|
|
m3d_erreur(ERR_SYST) ;
|
230 |
|
|
save = 1 ;
|
231 |
|
|
return(FAUX) ;
|
232 |
|
|
}
|
233 |
|
|
}
|
234 |
|
|
else
|
235 |
|
|
{
|
236 |
|
|
if (debug)
|
237 |
|
|
{
|
238 |
|
|
sprintf(mess,"critere de qualite impose : %f\n",crit_min) ;
|
239 |
|
|
//aff_text(mess);
|
240 |
|
|
}
|
241 |
|
|
if (!m3d_best())
|
242 |
|
|
{
|
243 |
|
|
m3d_erreur(ERR_SYST) ;
|
244 |
|
|
save = 1 ;
|
245 |
|
|
return(FAUX) ;
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
if (!is_recover) m3d_message(OPTIMISATION_TERMINEE) ;
|
249 |
|
|
if (save) m3d_wri(RECOVER) ;
|
250 |
|
|
/* bilan sur la memoire */
|
251 |
|
|
/* listes de structures */
|
252 |
|
|
|
253 |
|
|
FREE_ALLOC(connec)
|
254 |
|
|
|
255 |
|
|
/*
|
256 |
|
|
-----------------------------------------------------------------------------------------
|
257 |
|
|
elimination des noeuds non connectes et renumerotation des noeuds
|
258 |
|
|
compactage des listes de coordonnees et elements
|
259 |
|
|
-----------------------------------------------------------------------------------------
|
260 |
|
|
*/
|
261 |
|
|
|
262 |
|
|
if (!m3d_check())
|
263 |
|
|
{
|
264 |
|
|
if (debug)
|
265 |
|
|
{
|
266 |
|
|
sprintf(mess,"%s\n"," erreur maillage non conforme M3D_MAIDFT ") ;
|
267 |
|
|
//aff_text(mess);
|
268 |
|
|
}
|
269 |
|
|
m3d_erreur(ERR_SYST) ;
|
270 |
|
|
save = 1 ;
|
271 |
|
|
return(FAUX) ;
|
272 |
|
|
}
|
273 |
|
|
if (!is_recover) m3d_message(MAILLAGE_CONFORME) ;
|
274 |
|
|
FREE_ALLOC(tetra)
|
275 |
|
|
gest->corresp = (int*)calloc((gest->nb_noeud +1),sizeof(int)) ;
|
276 |
|
|
/* allocation memoire impossible */
|
277 |
|
|
if (gest->corresp == NULL)
|
278 |
|
|
{
|
279 |
|
|
m3d_erreur(ERR_SYST) ;
|
280 |
|
|
save = 1 ;
|
281 |
|
|
return(FAUX) ;
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
/* face */
|
285 |
|
|
FREE_ALLOC(face)
|
286 |
|
|
if (!m3d_comp())
|
287 |
|
|
{
|
288 |
|
|
if (debug)
|
289 |
|
|
{
|
290 |
|
|
sprintf(mess,"%s\n"," erreur compactage M3D_MAIDFT ") ;
|
291 |
|
|
//aff_text(mess);
|
292 |
|
|
}
|
293 |
|
|
m3d_erreur(ERR_SYST) ;
|
294 |
|
|
save = 1 ;
|
295 |
|
|
return(FAUX) ;
|
296 |
|
|
}
|
297 |
|
|
gest->corresp = NULL ;
|
298 |
|
|
/* noeuds */
|
299 |
|
|
FREE_ALLOC(noeud)
|
300 |
|
|
gest->maillage_termine = VRAI ;
|
301 |
|
|
return(VRAI) ;
|
302 |
|
|
}
|