1 |
|
5 |
#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 500
|
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_arete(TETRAEDRE *tetra,int num_arete,int *nb_noeud,int *nb_face,float *vcoord,int *tabele,int *neww,int *old,TETRAEDRE **tab,int *nb,FACE **tab_coq)
|
14 |
|
|
{
|
15 |
|
|
NOEUD *n1, *n2, *nc, *tab_noeud[500] ;
|
16 |
|
|
CONNEC *connec ;
|
17 |
|
|
TETRAEDRE *ele ;
|
18 |
|
|
FACE *tab_face[4], *face ;
|
19 |
|
|
int i, j, k, is_ok ;
|
20 |
|
|
int m3d_arete();
|
21 |
|
|
int tab_mark[500], tab_switch[500] ;
|
22 |
|
|
/* determination des tetraedres adjacents a l'arete */
|
23 |
|
|
switch(num_arete)
|
24 |
|
|
{
|
25 |
|
|
case 1 :
|
26 |
|
|
n1 = tetra->face1->n1 ;
|
27 |
|
|
n2 = tetra->face1->n2 ;
|
28 |
|
|
break ;
|
29 |
|
|
case 2 :
|
30 |
|
|
n1 = tetra->face1->n2 ;
|
31 |
|
|
n2 = tetra->face1->n3 ;
|
32 |
|
|
break ;
|
33 |
|
|
case 3 :
|
34 |
|
|
n1 = tetra->face1->n3 ;
|
35 |
|
|
n2 = tetra->face1->n1 ;
|
36 |
|
|
break ;
|
37 |
|
|
case 4 :
|
38 |
|
|
n1 = tetra->face1->n1 ;
|
39 |
|
|
NOEUD_TETRA(tetra,n2) ;
|
40 |
|
|
break ;
|
41 |
|
|
case 5 :
|
42 |
|
|
n1 = tetra->face1->n2 ;
|
43 |
|
|
NOEUD_TETRA(tetra,n2) ;
|
44 |
|
|
break ;
|
45 |
|
|
case 6 :
|
46 |
|
|
n1 = tetra->face1->n3 ;
|
47 |
|
|
NOEUD_TETRA(tetra,n2) ;
|
48 |
|
|
break ;
|
49 |
|
|
default :
|
50 |
|
|
m3d_erreur(ERR_SYST) ;
|
51 |
|
|
return(FAUX) ;
|
52 |
|
|
}
|
53 |
|
|
/* tetraedres connectes au noeud n1 */
|
54 |
|
|
/* BIG probleme : les noeuds bougent */
|
55 |
|
|
|
56 |
|
|
*nb = 0 ;
|
57 |
|
|
connec = n1->lis_con ;
|
58 |
|
|
while (connec != NULL)
|
59 |
|
|
{
|
60 |
|
|
if ((connec->tetra)->mark != KILLED)
|
61 |
|
|
{
|
62 |
|
|
i = 0 ;
|
63 |
|
|
NOEUD_TETRA((connec->tetra),nc)
|
64 |
|
|
if (connec->tetra->face1->n1 == n1) i ++ ;
|
65 |
|
|
if (connec->tetra->face1->n1 == n2) i ++ ;
|
66 |
|
|
if (connec->tetra->face1->n2 == n1) i ++ ;
|
67 |
|
|
if (connec->tetra->face1->n2 == n2) i ++ ;
|
68 |
|
|
if (connec->tetra->face1->n3 == n1) i ++ ;
|
69 |
|
|
if (connec->tetra->face1->n3 == n2) i ++ ;
|
70 |
|
|
if (nc == n1) i ++ ;
|
71 |
|
|
if (nc == n2) i ++ ;
|
72 |
|
|
if (i>=2)/* arete commune */
|
73 |
|
|
{
|
74 |
|
|
if (*nb >999)
|
75 |
|
|
{
|
76 |
|
|
m3d_erreur(ERR_SYST) ;
|
77 |
|
|
return(FAUX) ;
|
78 |
|
|
}
|
79 |
|
|
tab[*nb] = connec->tetra ;
|
80 |
|
|
(*nb) ++ ;
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
connec = connec->suivant ;
|
84 |
|
|
}
|
85 |
|
|
/* reperage de toutes les faces de la coquille et orientation */
|
86 |
|
|
/* elimination des faces contenant les noeuds n1 et n2 */
|
87 |
|
|
*nb_face = 0 ;
|
88 |
|
|
is_ok = VRAI ;
|
89 |
|
|
for (j=0;j<*nb;j++)
|
90 |
|
|
{
|
91 |
|
|
ele = tab[j] ;
|
92 |
|
|
tab_face[0] = ele->face1 ;
|
93 |
|
|
tab_face[1] = ele->face2 ;
|
94 |
|
|
tab_face[2] = ele->face3 ;
|
95 |
|
|
tab_face[3] = ele->face4 ;
|
96 |
|
|
for (k=0;k<4;k++)
|
97 |
|
|
{
|
98 |
|
|
if (tab_face[k]->mark!= TRAITE)
|
99 |
|
|
{
|
100 |
|
|
i = 0 ;
|
101 |
|
|
if (tab_face[k]->n1 == n1) i ++ ;
|
102 |
|
|
if (tab_face[k]->n1 == n2) i ++ ;
|
103 |
|
|
if (tab_face[k]->n2 == n1) i ++ ;
|
104 |
|
|
if (tab_face[k]->n2 == n2) i ++ ;
|
105 |
|
|
if (tab_face[k]->n3 == n1) i ++ ;
|
106 |
|
|
if (tab_face[k]->n3 == n2) i ++ ;
|
107 |
|
|
if ((i>= 2) && (tab_face[k]->hist == 0))
|
108 |
|
|
{
|
109 |
|
|
is_ok = FAUX ;
|
110 |
|
|
}
|
111 |
|
|
if (i<2)
|
112 |
|
|
{
|
113 |
|
|
if (*nb_face>=500)
|
114 |
|
|
{
|
115 |
|
|
m3d_erreur(ERR_SYST) ;
|
116 |
|
|
return(FAUX) ;
|
117 |
|
|
}
|
118 |
|
|
tab_coq[(*nb_face)] = tab_face[k] ;
|
119 |
|
|
tab_mark[(*nb_face)] = tab_face[k]->mark ;
|
120 |
|
|
tab_face[k]->mark = TRAITE ;
|
121 |
|
|
if (tab_face[k]->hist == 0) tab_switch[*nb_face] = FAUX ;
|
122 |
|
|
else tab_switch[*nb_face] = m3d_switch2(gest->coord,tab_face[k],ele,gest->numele) ;
|
123 |
|
|
(*nb_face)++ ;
|
124 |
|
|
}
|
125 |
|
|
}
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
/* remise a jour des marqueurs */
|
129 |
|
|
for (j=0;j<*nb_face;j++) tab_coq[j]->mark = tab_mark[j] ;
|
130 |
|
|
/* remise a jour des marqueurs */
|
131 |
|
|
for (j=0;j<*nb;j++) tab[j]->mark = FAUX ;
|
132 |
|
|
if (is_ok == FAUX) return(VRAI) ;
|
133 |
|
|
/* liste des noeuds */
|
134 |
|
|
*nb_noeud = 0 ;
|
135 |
|
|
for (j=0;j<*nb_face;j++)
|
136 |
|
|
{
|
137 |
|
|
if (tab_coq[j]->n1->mark != TRAITE)
|
138 |
|
|
{
|
139 |
|
|
if (*nb_noeud>=500) return(FAUX) ;
|
140 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n1 ;
|
141 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n1->mark ;
|
142 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ;
|
143 |
|
|
tab_coq[j]->n1->mark = TRAITE ;
|
144 |
|
|
}
|
145 |
|
|
if (tab_coq[j]->n2->mark != TRAITE)
|
146 |
|
|
{
|
147 |
|
|
if (*nb_noeud>=500) return(FAUX) ;
|
148 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n2 ;
|
149 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n2->mark ;
|
150 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ;
|
151 |
|
|
tab_coq[j]->n2->mark = TRAITE ;
|
152 |
|
|
}
|
153 |
|
|
if (tab_coq[j]->n3->mark != TRAITE)
|
154 |
|
|
{
|
155 |
|
|
if (*nb_noeud>=500) return(FAUX) ;
|
156 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n3 ;
|
157 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n3->mark ;
|
158 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ;
|
159 |
|
|
tab_coq[j]->n3->mark = TRAITE ;
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
for (j=0;j<*nb_noeud;j++) tab_noeud[j]->mark = tab_mark[j] ;
|
163 |
|
|
/* table des noeuds et des faces */
|
164 |
|
|
for (j=0;j<gest->nb_noeud;j++) neww[j] = -1 ;
|
165 |
|
|
/* coordonnees */
|
166 |
|
|
for (j=0;j<*nb_noeud;j++)
|
167 |
|
|
{
|
168 |
|
|
neww[tab_noeud[j]->num] = j ;
|
169 |
|
|
old[j] = tab_noeud[j]->num ;
|
170 |
|
|
vcoord[x(j)] = gest->coord[x(tab_noeud[j]->num)] ;
|
171 |
|
|
vcoord[y(j)] = gest->coord[y(tab_noeud[j]->num)] ;
|
172 |
|
|
vcoord[z(j)] = gest->coord[z(tab_noeud[j]->num)] ;
|
173 |
|
|
}
|
174 |
|
|
/* connectivite */
|
175 |
|
|
for (j=0;j<*nb_face;j++)
|
176 |
|
|
{
|
177 |
|
|
face = tab_coq[j] ;
|
178 |
|
|
if (!tab_switch[j])
|
179 |
|
|
{
|
180 |
|
|
tabele[3*j] = neww[(face->n1->num)] ;
|
181 |
|
|
tabele[3*j+1] = neww[(face->n2->num)] ;
|
182 |
|
|
tabele[3*j+2] = neww[(face->n3->num)] ;
|
183 |
|
|
}
|
184 |
|
|
else
|
185 |
|
|
{
|
186 |
|
|
tabele[3*j] = neww[(face->n1->num)] ;
|
187 |
|
|
tabele[3*j+2] = neww[(face->n2->num)] ;
|
188 |
|
|
tabele[3*j+1] = neww[(face->n3->num)] ;
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
return(VRAI) ;
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|