1 |
francois |
283 |
#include <stdio.h> |
2 |
|
|
#include "m3d_struct.h" |
3 |
|
|
#include "m3d_const.h" |
4 |
|
|
#include "m3d_hotes.h" |
5 |
|
|
#include "m3d_erreur.h" |
6 |
|
|
#include "prototype.h" |
7 |
|
|
#define NB_TRAITE 100 |
8 |
|
|
#define TRAITE 987654321 |
9 |
|
|
extern GEST_MEM *gest ; |
10 |
|
|
extern int debug ; |
11 |
|
|
extern float crit_min ; |
12 |
|
|
/* routine de tete du mailleur */ |
13 |
|
|
int m3d_coq(TETRAEDRE *tetra,int num_face,int *nb_noeud,int *nb_face,float *vcoord,int *tabele,int *neww,int *old,TETRAEDRE **tab,int *nb,FACE **tab_coq) |
14 |
|
|
{ |
15 |
|
|
FACE *face, *tab_face[4] ; |
16 |
|
|
TETRAEDRE *ele; |
17 |
|
|
char mess[255]; |
18 |
|
|
int tab_switch[100], tab_mark[100] ; |
19 |
|
|
NOEUD *tab_noeud[100] ; |
20 |
|
|
int j, k ; |
21 |
|
|
*nb_face = 0 ; |
22 |
|
|
*nb_noeud = 0 ; |
23 |
|
|
switch (num_face) |
24 |
|
|
{ |
25 |
|
|
case 0 : |
26 |
|
|
face = tetra->face1 ; |
27 |
|
|
break ; |
28 |
|
|
case 1 : |
29 |
|
|
face = tetra->face2 ; |
30 |
|
|
break ; |
31 |
|
|
case 2 : |
32 |
|
|
face = tetra->face3 ; |
33 |
|
|
break ; |
34 |
|
|
case 3 : |
35 |
|
|
face = tetra->face4 ; |
36 |
|
|
break ; |
37 |
|
|
default : |
38 |
|
|
return(FAUX) ; |
39 |
|
|
} |
40 |
|
|
if (face->hist == 0) return(VRAI) ; |
41 |
|
|
|
42 |
|
|
/* sinon 2 tetraedres adjacents */ |
43 |
|
|
if ((face->tetra1 == NULL) || (face->tetra2 == NULL)) |
44 |
|
|
{ |
45 |
|
|
//sprintf(mess,"%s%d %d\n","Erreur face libre,m3d_arete M3D_BEST",(int)face->tetra1,(int)face->tetra2) ; |
46 |
|
|
//aff_text(mess); |
47 |
|
|
m3d_erreur(ERR_SYST) ; |
48 |
|
|
return(FAUX) ; |
49 |
|
|
} |
50 |
|
|
*nb = 2 ; |
51 |
|
|
tab[0] = face->tetra1 ; |
52 |
|
|
tab[1] = face->tetra2 ; |
53 |
|
|
/* reperage de toutes les faces de la coquille et orientation */ |
54 |
|
|
/* elimination de la face commune */ |
55 |
|
|
for (j=0;j<2;j++) |
56 |
|
|
{ |
57 |
|
|
ele = tab[j] ; |
58 |
|
|
tab_face[0] = ele->face1 ; |
59 |
|
|
tab_face[1] = ele->face2 ; |
60 |
|
|
tab_face[2] = ele->face3 ; |
61 |
|
|
tab_face[3] = ele->face4 ; |
62 |
|
|
for (k=0;k<4;k++) |
63 |
|
|
{ |
64 |
|
|
if (tab_face[k] != face) |
65 |
|
|
{ |
66 |
|
|
tab_coq[(*nb_face)] = tab_face[k] ; |
67 |
|
|
if (tab_face[k]->hist == 0) tab_switch[*nb_face] = FAUX ; |
68 |
|
|
else tab_switch[*nb_face] = m3d_switch2(gest->coord,tab_face[k],ele,gest->numele) ; |
69 |
|
|
(*nb_face)++ ; |
70 |
|
|
} |
71 |
|
|
} |
72 |
|
|
} |
73 |
|
|
/* liste des noeuds */ |
74 |
|
|
for (j=0;j<*nb_face;j++) |
75 |
|
|
{ |
76 |
|
|
if (tab_coq[j]->n1->mark != TRAITE) |
77 |
|
|
{ |
78 |
|
|
if (*nb_noeud>=100) |
79 |
|
|
{ |
80 |
|
|
m3d_erreur(ERR_SYST) ; |
81 |
|
|
return(FAUX) ; |
82 |
|
|
} |
83 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n1 ; |
84 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n1->mark ; |
85 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ; |
86 |
|
|
tab_coq[j]->n1->mark = TRAITE ; |
87 |
|
|
} |
88 |
|
|
if (tab_coq[j]->n2->mark != TRAITE) |
89 |
|
|
{ |
90 |
|
|
if (*nb_noeud>=100) |
91 |
|
|
{ |
92 |
|
|
m3d_erreur(ERR_SYST) ; |
93 |
|
|
return(FAUX) ; |
94 |
|
|
} |
95 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n2 ; |
96 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n2->mark ; |
97 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ; |
98 |
|
|
tab_coq[j]->n2->mark = TRAITE ; |
99 |
|
|
} |
100 |
|
|
if (tab_coq[j]->n3->mark != TRAITE) |
101 |
|
|
{ |
102 |
|
|
if (*nb_noeud>=100) |
103 |
|
|
{ |
104 |
|
|
m3d_erreur(ERR_SYST) ; |
105 |
|
|
return(FAUX) ; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n3 ; |
109 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n3->mark ; |
110 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ; |
111 |
|
|
tab_coq[j]->n3->mark = TRAITE ; |
112 |
|
|
} |
113 |
|
|
} |
114 |
|
|
for (j=0;j<*nb_noeud;j++) tab_noeud[j]->mark = tab_mark[j] ; |
115 |
|
|
/* table des noeuds et des faces */ |
116 |
|
|
for (j=0;j<gest->nb_noeud;j++) neww[j] = -1 ; |
117 |
|
|
/* coordonnees */ |
118 |
|
|
for (j=0;j<*nb_noeud;j++) |
119 |
|
|
{ |
120 |
|
|
neww[tab_noeud[j]->num] = j ; |
121 |
|
|
old[j] = tab_noeud[j]->num ; |
122 |
|
|
vcoord[x(j)] = gest->coord[x(tab_noeud[j]->num)] ; |
123 |
|
|
vcoord[y(j)] = gest->coord[y(tab_noeud[j]->num)] ; |
124 |
|
|
vcoord[z(j)] = gest->coord[z(tab_noeud[j]->num)] ; |
125 |
|
|
} |
126 |
|
|
/* connectivite */ |
127 |
|
|
for (j=0;j<*nb_face;j++) |
128 |
|
|
{ |
129 |
|
|
face = tab_coq[j] ; |
130 |
|
|
if (!tab_switch[j]) |
131 |
|
|
{ |
132 |
|
|
tabele[3*j] = neww[(face->n1->num)] ; |
133 |
|
|
tabele[3*j+1] = neww[(face->n2->num)] ; |
134 |
|
|
tabele[3*j+2] = neww[(face->n3->num)] ; |
135 |
|
|
} |
136 |
|
|
else |
137 |
|
|
{ |
138 |
|
|
tabele[3*j] = neww[(face->n1->num)] ; |
139 |
|
|
tabele[3*j+2] = neww[(face->n2->num)] ; |
140 |
|
|
tabele[3*j+1] = neww[(face->n3->num)] ; |
141 |
|
|
} |
142 |
|
|
} |
143 |
|
|
return(VRAI) ; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|