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 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 : face = tetra->face1 ; break ;
|
26 |
|
|
case 1 : face = tetra->face2 ; break ;
|
27 |
|
|
case 2 : face = tetra->face3 ; break ;
|
28 |
|
|
case 3 : face = tetra->face4 ; break ;
|
29 |
|
|
default :return(FAUX) ;
|
30 |
|
|
}
|
31 |
|
|
if (face->hist == 0) return(VRAI) ;
|
32 |
|
|
|
33 |
|
|
/* sinon 2 tetraedres adjacents */
|
34 |
|
|
if ((face->tetra1 == NULL) || (face->tetra2 == NULL))
|
35 |
|
|
{
|
36 |
|
|
sprintf(mess,"%s%d %d\n","Erreur face libre,m3d_arete M3D_BEST",(int)face->tetra1,(int)face->tetra2) ;
|
37 |
|
|
//aff_text(mess);
|
38 |
|
|
m3d_erreur(ERR_SYST) ;
|
39 |
|
|
return(FAUX) ;
|
40 |
|
|
}
|
41 |
|
|
*nb = 2 ;
|
42 |
|
|
tab[0] = face->tetra1 ;
|
43 |
|
|
tab[1] = face->tetra2 ;
|
44 |
|
|
/* reperage de toutes les faces de la coquille et orientation */
|
45 |
|
|
/* elimination de la face commune */
|
46 |
|
|
for (j=0;j<2;j++)
|
47 |
|
|
{
|
48 |
|
|
ele = tab[j] ;
|
49 |
|
|
tab_face[0] = ele->face1 ;
|
50 |
|
|
tab_face[1] = ele->face2 ;
|
51 |
|
|
tab_face[2] = ele->face3 ;
|
52 |
|
|
tab_face[3] = ele->face4 ;
|
53 |
|
|
for (k=0;k<4;k++)
|
54 |
|
|
{
|
55 |
|
|
if (tab_face[k] != face)
|
56 |
|
|
{
|
57 |
|
|
tab_coq[(*nb_face)] = tab_face[k] ;
|
58 |
|
|
if (tab_face[k]->hist == 0) tab_switch[*nb_face] = FAUX ;
|
59 |
|
|
else tab_switch[*nb_face] = m3d_switch2(gest->coord,tab_face[k],ele,gest->numele) ;
|
60 |
|
|
(*nb_face)++ ;
|
61 |
|
|
}
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
/* liste des noeuds */
|
65 |
|
|
for (j=0;j<*nb_face;j++)
|
66 |
|
|
{
|
67 |
|
|
if (tab_coq[j]->n1->mark != TRAITE)
|
68 |
|
|
{
|
69 |
|
|
if (*nb_noeud>=100)
|
70 |
|
|
{
|
71 |
|
|
m3d_erreur(ERR_SYST) ;
|
72 |
|
|
return(FAUX) ;
|
73 |
|
|
}
|
74 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n1 ;
|
75 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n1->mark ;
|
76 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ;
|
77 |
|
|
tab_coq[j]->n1->mark = TRAITE ;
|
78 |
|
|
}
|
79 |
|
|
if (tab_coq[j]->n2->mark != TRAITE)
|
80 |
|
|
{
|
81 |
|
|
if (*nb_noeud>=100)
|
82 |
|
|
{
|
83 |
|
|
m3d_erreur(ERR_SYST) ;
|
84 |
|
|
return(FAUX) ;
|
85 |
|
|
}
|
86 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n2 ;
|
87 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n2->mark ;
|
88 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ;
|
89 |
|
|
tab_coq[j]->n2->mark = TRAITE ;
|
90 |
|
|
}
|
91 |
|
|
if (tab_coq[j]->n3->mark != TRAITE)
|
92 |
|
|
{
|
93 |
|
|
if (*nb_noeud>=100)
|
94 |
|
|
{
|
95 |
|
|
m3d_erreur(ERR_SYST) ;
|
96 |
|
|
return(FAUX) ;
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
tab_noeud[*nb_noeud] = tab_coq[j]->n3 ;
|
100 |
|
|
tab_mark[*nb_noeud] = tab_coq[j]->n3->mark ;
|
101 |
|
|
(*nb_noeud) = (*nb_noeud) + 1 ;
|
102 |
|
|
tab_coq[j]->n3->mark = TRAITE ;
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
for (j=0;j<*nb_noeud;j++) tab_noeud[j]->mark = tab_mark[j] ;
|
106 |
|
|
/* table des noeuds et des faces */
|
107 |
|
|
for (j=0;j<gest->nb_noeud;j++) neww[j] = -1 ;
|
108 |
|
|
/* coordonnees */
|
109 |
|
|
for (j=0;j<*nb_noeud;j++)
|
110 |
|
|
{
|
111 |
|
|
neww[tab_noeud[j]->num] = j ;
|
112 |
|
|
old[j] = tab_noeud[j]->num ;
|
113 |
|
|
vcoord[x(j)] = gest->coord[x(tab_noeud[j]->num)] ;
|
114 |
|
|
vcoord[y(j)] = gest->coord[y(tab_noeud[j]->num)] ;
|
115 |
|
|
vcoord[z(j)] = gest->coord[z(tab_noeud[j]->num)] ;
|
116 |
|
|
}
|
117 |
|
|
/* connectivite */
|
118 |
|
|
for (j=0;j<*nb_face;j++)
|
119 |
|
|
{
|
120 |
|
|
face = tab_coq[j] ;
|
121 |
|
|
if (!tab_switch[j])
|
122 |
|
|
{
|
123 |
|
|
tabele[3*j] = neww[(face->n1->num)] ;
|
124 |
|
|
tabele[3*j+1] = neww[(face->n2->num)] ;
|
125 |
|
|
tabele[3*j+2] = neww[(face->n3->num)] ;
|
126 |
|
|
}
|
127 |
|
|
else
|
128 |
|
|
{
|
129 |
|
|
tabele[3*j] = neww[(face->n1->num)] ;
|
130 |
|
|
tabele[3*j+2] = neww[(face->n2->num)] ;
|
131 |
|
|
tabele[3*j+1] = neww[(face->n3->num)] ;
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
return(VRAI) ;
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|