1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
m3d_traite_front.cpp Type:Func
|
4 |
|
|
|
5 |
|
|
Traitement des cas de front
|
6 |
|
|
|
7 |
|
|
Date de creation : 11-3-1999 11 :40 :5
|
8 |
|
|
Derniere version : 11-3-1999 11 :40 :5
|
9 |
|
|
|
10 |
|
|
Vincent FRANCOIS
|
11 |
|
|
|
12 |
|
|
*****************************************************************/
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
/**************************/
|
19 |
|
|
/* include */
|
20 |
|
|
#include <stdio.h>
|
21 |
|
|
#include <string.h>
|
22 |
|
|
#include <stdlib.h>
|
23 |
|
|
#include <math.h>
|
24 |
|
|
#include "const.h"
|
25 |
|
|
#include "memoire.h"
|
26 |
|
|
#include "struct.h"
|
27 |
|
|
#include "struct3d.h"
|
28 |
|
|
#include "prototype.h"
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/**************************/
|
32 |
|
|
/* variables globales */
|
33 |
|
|
extern struct environnment env;
|
34 |
|
|
extern struct s_mesh *mesh;
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
struct tri_front
|
38 |
|
|
{
|
39 |
|
|
int num;
|
40 |
|
|
int crit;
|
41 |
|
|
struct tri_front *suivant;
|
42 |
|
|
};
|
43 |
|
|
|
44 |
|
|
/**************************/
|
45 |
|
|
/* programme principal */
|
46 |
|
|
|
47 |
|
|
int m3d_traite_front(int type,struct s_front3d *ft,struct cas_front *cas,int nb_cas,int *liste_cas,int nb_liste_cas)
|
48 |
|
|
{
|
49 |
|
|
int i,j,sol,ierr,listsol[50];
|
50 |
|
|
int numcas,fin,mode;
|
51 |
|
|
struct s_noeud *no;
|
52 |
|
|
struct tri_front *tete,liste_front[50],*pointeur,*pointeurprec;
|
53 |
|
|
struct s_front3d *ft1,*ft2,*ft3,*ftn1,*ftn2,*ftn3,*ftbase;
|
54 |
|
|
struct s_tetra *tet;
|
55 |
|
|
//struct s_triangle *tri1,*tri2;
|
56 |
|
|
float qualsol[50];
|
57 |
|
|
int iordre [50];
|
58 |
|
|
int nb_inter;
|
59 |
|
|
struct s_front3d *list_inter[50];
|
60 |
|
|
int neww,neww2;
|
61 |
|
|
|
62 |
|
|
switch (type)
|
63 |
|
|
{
|
64 |
|
|
case ADJACENT3 : numcas=liste_cas[nb_liste_cas-1];
|
65 |
|
|
sol=cas[numcas].num;
|
66 |
|
|
ierr=m3d_i_tetra(&tet,ft,sol,EXISTE,list_inter,&nb_inter);
|
67 |
|
|
if (ierr==VALIDE)
|
68 |
|
|
{
|
69 |
|
|
strcpy(tet->front,"ADJACENT3");
|
70 |
|
|
ft1=ft->voisin[0].ft;
|
71 |
|
|
ft2=ft->voisin[1].ft;
|
72 |
|
|
ft3=ft->voisin[2].ft;
|
73 |
|
|
m3d_ac_front(&ft,DETRUIT);
|
74 |
|
|
m3d_ac_front(&ft1,DETRUIT);
|
75 |
|
|
m3d_ac_front(&ft2,DETRUIT);
|
76 |
|
|
m3d_ac_front(&ft3,DETRUIT);
|
77 |
|
|
}
|
78 |
|
|
cas[numcas].traite=TRAITE;
|
79 |
|
|
break;
|
80 |
|
|
case ADJACENT2 : numcas=liste_cas[nb_liste_cas-1];
|
81 |
|
|
sol=cas[numcas].num;
|
82 |
|
|
ierr=m3d_i_tetra(&tet,ft,sol,EXISTE,list_inter,&nb_inter);
|
83 |
|
|
if (ierr==VALIDE)
|
84 |
|
|
{
|
85 |
|
|
strcpy(tet->front,"ADJACENT2");
|
86 |
|
|
if (cas[numcas].liaison[0]==0)
|
87 |
|
|
{
|
88 |
|
|
ft1=ft->voisin[1].ft;
|
89 |
|
|
ft2=ft->voisin[2].ft;
|
90 |
|
|
ft3=ft->voisin[0].ft;
|
91 |
|
|
neww=NEW1;
|
92 |
|
|
}
|
93 |
|
|
if (cas[numcas].liaison[1]==0)
|
94 |
|
|
{
|
95 |
|
|
ft1=ft->voisin[0].ft;
|
96 |
|
|
ft2=ft->voisin[2].ft;
|
97 |
|
|
ft3=ft->voisin[1].ft;
|
98 |
|
|
neww=NEW3;
|
99 |
|
|
}
|
100 |
|
|
if (cas[numcas].liaison[2]==0)
|
101 |
|
|
{
|
102 |
|
|
ft1=ft->voisin[0].ft;
|
103 |
|
|
ft2=ft->voisin[1].ft;
|
104 |
|
|
ft3=ft->voisin[2].ft;
|
105 |
|
|
neww=NEW2;
|
106 |
|
|
}
|
107 |
|
|
m3d_ac_front(&ft,DETRUIT);
|
108 |
|
|
m3d_ac_front(&ft1,DETRUIT);
|
109 |
|
|
m3d_ac_front(&ft2,DETRUIT);
|
110 |
|
|
m3d_update_front(&ftn1,NULL,tet,neww);
|
111 |
|
|
m3d_update_front(&ft3,NULL,NULL,LIAISON);
|
112 |
|
|
m3d_update_front(&ftn1,NULL,NULL,LIAISON);
|
113 |
|
|
m3d_update_front(&(ftn1->voisin[0].ft),NULL,NULL,LIAISON);
|
114 |
|
|
m3d_update_front(&(ftn1->voisin[1].ft),NULL,NULL,LIAISON);
|
115 |
|
|
m3d_update_front(&(ftn1->voisin[2].ft),NULL,NULL,LIAISON);
|
116 |
|
|
}
|
117 |
|
|
cas[numcas].traite=TRAITE;
|
118 |
|
|
break;
|
119 |
|
|
case ADJACENT1 : /* tri des differentes solution */
|
120 |
|
|
for (i=0;i<nb_liste_cas;i++)
|
121 |
|
|
{
|
122 |
|
|
liste_front[i].num=liste_cas[i];
|
123 |
|
|
sol=cas[liste_front[i].num].num;
|
124 |
|
|
liste_front[i].crit=m3d_cal_qual(ft->n1,ft->n2,ft->n3,sol);
|
125 |
|
|
if (i==0)
|
126 |
|
|
{
|
127 |
|
|
tete=&(liste_front[0]);
|
128 |
|
|
liste_front[0].suivant=NULL;
|
129 |
|
|
}
|
130 |
|
|
else
|
131 |
|
|
{
|
132 |
|
|
pointeurprec=NULL;
|
133 |
|
|
pointeur=tete;
|
134 |
|
|
fin=0;
|
135 |
|
|
do
|
136 |
|
|
{
|
137 |
|
|
if (pointeur->crit>liste_front[i].crit)
|
138 |
|
|
{
|
139 |
|
|
if (pointeurprec!=NULL) pointeurprec->suivant=&(liste_front[i]);
|
140 |
|
|
else tete=&(liste_front[i]);
|
141 |
|
|
liste_front[i].suivant=pointeur;
|
142 |
|
|
}
|
143 |
|
|
pointeurprec=pointeur;
|
144 |
|
|
pointeur=pointeur->suivant;
|
145 |
|
|
if (pointeur==NULL)
|
146 |
|
|
{
|
147 |
|
|
fin=1;
|
148 |
|
|
pointeurprec->suivant=&(liste_front[i]);
|
149 |
|
|
liste_front[i].suivant=NULL;
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
while (fin==0);
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
/* solution */
|
156 |
|
|
pointeur=tete;
|
157 |
|
|
fin=0;
|
158 |
|
|
while (fin==0)
|
159 |
|
|
{
|
160 |
|
|
numcas=pointeur->num;
|
161 |
|
|
sol=cas[numcas].num;
|
162 |
|
|
ierr=m3d_i_tetra(&tet,ft,sol,EXISTE,list_inter,&nb_inter);
|
163 |
|
|
cas[numcas].traite=TRAITE;
|
164 |
|
|
if (ierr==VALIDE) fin=1;
|
165 |
|
|
pointeur=pointeur->suivant;
|
166 |
|
|
if ((fin==0)&&(pointeur==NULL)) return(PASTROUVE);
|
167 |
|
|
}
|
168 |
|
|
strcpy(tet->front,"ADJACENT1");
|
169 |
|
|
if (cas[numcas].liaison[0]==1)
|
170 |
|
|
{
|
171 |
|
|
ft1=ft->voisin[0].ft;
|
172 |
|
|
ft2=ft->voisin[1].ft;
|
173 |
|
|
ft3=ft->voisin[2].ft;
|
174 |
|
|
neww=NEW2;
|
175 |
|
|
neww2=NEW3;
|
176 |
|
|
}
|
177 |
|
|
if (cas[numcas].liaison[1]==1)
|
178 |
|
|
{
|
179 |
|
|
ft1=ft->voisin[1].ft;
|
180 |
|
|
ft2=ft->voisin[0].ft;
|
181 |
|
|
ft3=ft->voisin[2].ft;
|
182 |
|
|
neww=NEW1;
|
183 |
|
|
neww2=NEW2;
|
184 |
|
|
}
|
185 |
|
|
if (cas[numcas].liaison[2]==1)
|
186 |
|
|
{
|
187 |
|
|
ft1=ft->voisin[2].ft;
|
188 |
|
|
ft2=ft->voisin[0].ft;
|
189 |
|
|
ft3=ft->voisin[1].ft;
|
190 |
|
|
neww=NEW1;
|
191 |
|
|
neww2=NEW3;
|
192 |
|
|
}
|
193 |
|
|
m3d_ac_front(&ft,DETRUIT);
|
194 |
|
|
m3d_ac_front(&ft1,DETRUIT);
|
195 |
|
|
m3d_update_front(&ftn1,NULL,tet,neww);
|
196 |
|
|
m3d_update_front(&ftn2,NULL,tet,neww2);
|
197 |
|
|
m3d_update_front(&ft2,NULL,NULL,LIAISON);
|
198 |
|
|
m3d_update_front(&ft3,NULL,NULL,LIAISON);
|
199 |
|
|
m3d_update_front(&ftn1,NULL,NULL,LIAISON);
|
200 |
|
|
m3d_update_front(&ftn2,NULL,NULL,LIAISON);
|
201 |
|
|
m3d_update_front(&(ftn1->voisin[0].ft),NULL,NULL,LIAISON);
|
202 |
|
|
m3d_update_front(&(ftn1->voisin[1].ft),NULL,NULL,LIAISON);
|
203 |
|
|
m3d_update_front(&(ftn1->voisin[2].ft),NULL,NULL,LIAISON);
|
204 |
|
|
m3d_update_front(&(ftn2->voisin[0].ft),NULL,NULL,LIAISON);
|
205 |
|
|
m3d_update_front(&(ftn2->voisin[1].ft),NULL,NULL,LIAISON);
|
206 |
|
|
m3d_update_front(&(ftn2->voisin[2].ft),NULL,NULL,LIAISON);
|
207 |
|
|
return(TROUVE);
|
208 |
|
|
case LIE3 :
|
209 |
|
|
case LIE2 :
|
210 |
|
|
case LIE1 :/* tri des differentes solution */
|
211 |
|
|
for (i=0;i<nb_liste_cas;i++)
|
212 |
|
|
{
|
213 |
|
|
liste_front[i].num=liste_cas[i];
|
214 |
|
|
sol=cas[liste_front[i].num].num;
|
215 |
|
|
liste_front[i].crit=m3d_cal_qual(ft->n1,ft->n2,ft->n3,sol);
|
216 |
|
|
if (i==0)
|
217 |
|
|
{
|
218 |
|
|
tete=&(liste_front[0]);
|
219 |
|
|
liste_front[0].suivant=NULL;
|
220 |
|
|
}
|
221 |
|
|
else
|
222 |
|
|
{
|
223 |
|
|
pointeurprec=NULL;
|
224 |
|
|
pointeur=tete;
|
225 |
|
|
fin=0;
|
226 |
|
|
do
|
227 |
|
|
{
|
228 |
|
|
if (pointeur->crit>liste_front[i].crit)
|
229 |
|
|
{
|
230 |
|
|
if (pointeurprec!=NULL) pointeurprec->suivant=&(liste_front[i]);
|
231 |
|
|
else tete=&(liste_front[i]);
|
232 |
|
|
liste_front[i].suivant=pointeur;
|
233 |
|
|
}
|
234 |
|
|
pointeurprec=pointeur;
|
235 |
|
|
pointeur=pointeur->suivant;
|
236 |
|
|
if (pointeur==NULL)
|
237 |
|
|
{
|
238 |
|
|
fin=1;
|
239 |
|
|
pointeurprec->suivant=&(liste_front[i]);
|
240 |
|
|
liste_front[i].suivant=NULL;
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
while (fin==0);
|
244 |
|
|
}
|
245 |
|
|
}
|
246 |
|
|
/* solution */
|
247 |
|
|
pointeur=tete;
|
248 |
|
|
fin=0;
|
249 |
|
|
while (fin==0)
|
250 |
|
|
{
|
251 |
|
|
numcas=pointeur->num;
|
252 |
|
|
sol=cas[numcas].num;
|
253 |
|
|
ierr=m3d_i_tetra(&tet,ft,sol,EXISTE,list_inter,&nb_inter);
|
254 |
|
|
cas[numcas].traite=TRAITE;
|
255 |
|
|
if (ierr==VALIDE) fin=1;
|
256 |
|
|
pointeur=pointeur->suivant;
|
257 |
|
|
if ((fin==0)&&(pointeur==NULL)) return(PASTROUVE);
|
258 |
|
|
}
|
259 |
|
|
strcpy(tet->front,"LIE");
|
260 |
|
|
ft1=ft->voisin[0].ft;
|
261 |
|
|
ft2=ft->voisin[1].ft;
|
262 |
|
|
ft3=ft->voisin[2].ft;
|
263 |
|
|
m3d_ac_front(&ft,DETRUIT);
|
264 |
|
|
m3d_update_front(&ftn1,NULL,tet,NEW1);
|
265 |
|
|
m3d_update_front(&ftn2,NULL,tet,NEW2);
|
266 |
|
|
m3d_update_front(&ftn3,NULL,tet,NEW3);
|
267 |
|
|
m3d_update_front(&ft1,NULL,NULL,LIAISON);
|
268 |
|
|
m3d_update_front(&ft2,NULL,NULL,LIAISON);
|
269 |
|
|
m3d_update_front(&ft3,NULL,NULL,LIAISON);
|
270 |
|
|
m3d_update_front(&ftn1,NULL,NULL,LIAISON);
|
271 |
|
|
m3d_update_front(&ftn2,NULL,NULL,LIAISON);
|
272 |
|
|
m3d_update_front(&ftn3,NULL,NULL,LIAISON);
|
273 |
|
|
m3d_update_front(&(ftn1->voisin[0].ft),NULL,NULL,LIAISON);
|
274 |
|
|
m3d_update_front(&(ftn1->voisin[1].ft),NULL,NULL,LIAISON);
|
275 |
|
|
m3d_update_front(&(ftn1->voisin[2].ft),NULL,NULL,LIAISON);
|
276 |
|
|
m3d_update_front(&(ftn2->voisin[0].ft),NULL,NULL,LIAISON);
|
277 |
|
|
m3d_update_front(&(ftn2->voisin[1].ft),NULL,NULL,LIAISON);
|
278 |
|
|
m3d_update_front(&(ftn2->voisin[2].ft),NULL,NULL,LIAISON);
|
279 |
|
|
m3d_update_front(&(ftn3->voisin[0].ft),NULL,NULL,LIAISON);
|
280 |
|
|
m3d_update_front(&(ftn3->voisin[1].ft),NULL,NULL,LIAISON);
|
281 |
|
|
m3d_update_front(&(ftn3->voisin[2].ft),NULL,NULL,LIAISON);
|
282 |
|
|
return(TROUVE);
|
283 |
|
|
case GENERAL : mode=m3d_gen_noe(ft,listsol,CREATION);
|
284 |
|
|
if (mode==CREATION) sol=listsol[0];
|
285 |
|
|
if (mode==EXISTE)
|
286 |
|
|
{
|
287 |
|
|
sol=listsol[0];
|
288 |
|
|
for (i=0;i<nb_cas;i++)
|
289 |
|
|
if (sol==cas[i].num)
|
290 |
|
|
if (cas[i].traite==PASTRAITE) return(i);
|
291 |
|
|
else return(PASTROUVE);
|
292 |
|
|
}
|
293 |
|
|
if (mode==MULTIEXISTE)
|
294 |
|
|
{
|
295 |
|
|
for (i=1;i<=listsol[0];i++)
|
296 |
|
|
{
|
297 |
|
|
for (j=0;j<nb_cas;j++)
|
298 |
|
|
{
|
299 |
|
|
if (listsol[i]==cas[j].num)
|
300 |
|
|
{
|
301 |
|
|
listsol[i]=-1;
|
302 |
|
|
qualsol[i]=100.;
|
303 |
|
|
}
|
304 |
|
|
}
|
305 |
|
|
if (listsol[i]>0) qualsol[i]=m3d_cal_qual(ft->n1,ft->n2,ft->n3,listsol[i]);
|
306 |
|
|
iordre[i-1]=i;
|
307 |
|
|
}
|
308 |
|
|
trirea(qualsol+1,&(listsol[0]),iordre);
|
309 |
|
|
ierr=NONVALIDE;
|
310 |
|
|
nb_inter=0;
|
311 |
|
|
for (i=1;i<=listsol[0];i++)
|
312 |
|
|
{
|
313 |
|
|
if ((ierr==NONVALIDE)&&(listsol[iordre[listsol[0]-i]]!=-1))
|
314 |
|
|
{
|
315 |
|
|
ierr=m3d_i_tetra(&tet,ft,listsol[iordre[listsol[0]-i]],mode,list_inter,&nb_inter);
|
316 |
|
|
if (ierr==NONVALIDE)
|
317 |
|
|
{
|
318 |
|
|
ierr=m3d_traite_destruction(ft,list_inter,nb_inter);
|
319 |
|
|
no=ADRESSE(listsol[iordre[listsol[0]-i]],noeud,mesh->);
|
320 |
|
|
if (no->etat!=ACTIF) no->etat=ACTIF;
|
321 |
|
|
if (ierr==VALIDE) ierr=m3d_i_tetra(&tet,ft,listsol[iordre[listsol[0]-i]],mode,list_inter,&nb_inter);
|
322 |
|
|
}
|
323 |
|
|
sol=listsol[iordre[listsol[0]-i]];
|
324 |
|
|
}
|
325 |
|
|
}
|
326 |
|
|
}
|
327 |
|
|
else ierr=m3d_i_tetra(&tet,ft,sol,mode,list_inter,&nb_inter);
|
328 |
|
|
if ((ierr==NONVALIDE) && (nb_inter>0))
|
329 |
|
|
{
|
330 |
|
|
ierr=m3d_traite_destruction(ft,list_inter,nb_inter);
|
331 |
|
|
no=ADRESSE(sol,noeud,mesh->);
|
332 |
|
|
if (no->etat!=ACTIF) no->etat=ACTIF;
|
333 |
|
|
if (ierr==VALIDE) ierr=m3d_i_tetra(&tet,ft,sol,mode,list_inter,&nb_inter);
|
334 |
|
|
}
|
335 |
|
|
if (ierr==VALIDE)
|
336 |
|
|
{
|
337 |
|
|
strcpy(tet->front,"GENERAL");
|
338 |
|
|
ft1=ft->voisin[0].ft;
|
339 |
|
|
ft2=ft->voisin[1].ft;
|
340 |
|
|
ft3=ft->voisin[2].ft;
|
341 |
|
|
ftbase=ft;
|
342 |
|
|
if (mode==CREATION) m3d_gen_noe(ft,&sol,UPDATE);
|
343 |
|
|
m3d_ac_front(&ft,DETRUIT);
|
344 |
|
|
m3d_update_front(&ftn1,NULL,tet,NEW1);
|
345 |
|
|
m3d_update_front(&ftn2,NULL,tet,NEW2);
|
346 |
|
|
m3d_update_front(&ftn3,NULL,tet,NEW3);
|
347 |
|
|
m3d_update_front(&ftn1,NULL,NULL,LIAISON);
|
348 |
|
|
m3d_update_front(&ftn2,NULL,NULL,LIAISON);
|
349 |
|
|
m3d_update_front(&ftn3,NULL,NULL,LIAISON);
|
350 |
|
|
m3d_update_front(&ft1,NULL,NULL,LIAISON);
|
351 |
|
|
m3d_update_front(&ft2,NULL,NULL,LIAISON);
|
352 |
|
|
m3d_update_front(&ft3,NULL,NULL,LIAISON);
|
353 |
|
|
m3d_update_front(&(ftn1->voisin[0].ft),NULL,NULL,LIAISON);
|
354 |
|
|
m3d_update_front(&(ftn1->voisin[1].ft),NULL,NULL,LIAISON);
|
355 |
|
|
m3d_update_front(&(ftn1->voisin[2].ft),NULL,NULL,LIAISON);
|
356 |
|
|
m3d_update_front(&(ftn2->voisin[0].ft),NULL,NULL,LIAISON);
|
357 |
|
|
m3d_update_front(&(ftn2->voisin[1].ft),NULL,NULL,LIAISON);
|
358 |
|
|
m3d_update_front(&(ftn2->voisin[2].ft),NULL,NULL,LIAISON);
|
359 |
|
|
m3d_update_front(&(ftn3->voisin[0].ft),NULL,NULL,LIAISON);
|
360 |
|
|
m3d_update_front(&(ftn3->voisin[1].ft),NULL,NULL,LIAISON);
|
361 |
|
|
m3d_update_front(&(ftn3->voisin[2].ft),NULL,NULL,LIAISON);
|
362 |
|
|
}
|
363 |
|
|
else
|
364 |
|
|
{
|
365 |
|
|
if (mode==CREATION) mesh->nb_noeud=mesh->nb_noeud-1;
|
366 |
|
|
return(PASTROUVE);
|
367 |
|
|
}
|
368 |
|
|
break;
|
369 |
|
|
}
|
370 |
|
|
if (ierr==NONVALIDE) return(PASTROUVE);
|
371 |
|
|
return(TROUVE);
|
372 |
|
|
}
|