1 |
|
5 |
|
2 |
|
|
#include <stdio.h>
|
3 |
|
|
#include <math.h>
|
4 |
|
|
#include "r3d_struct.h"
|
5 |
|
|
#include "m3d_const.h"
|
6 |
|
|
#include "prototype2.h"
|
7 |
|
|
extern float elan ;
|
8 |
|
|
extern GEST_MEM *gest_r ;
|
9 |
|
|
int r3d_test(FACE *face,float amin,int index,NOEUD **lis_possible,int *lis_signe,float *critere,float *coord,int *ierr)
|
10 |
|
|
{
|
11 |
|
|
NOEUD *noe_p ;
|
12 |
|
|
/* modif 30/10/92 */
|
13 |
|
|
FACE *face1, *face2, *face3 ;
|
14 |
|
|
NOEUD *nj1, *nj2, *nj3, *n1, *n2, *n3, *n4;
|
15 |
|
|
int j1, j2, j3, num_c ;
|
16 |
|
|
int min_j ;
|
17 |
|
|
TETRAEDRE *tetra ;
|
18 |
|
|
CONNEC *connec ;
|
19 |
|
|
int nb_killed ;
|
20 |
|
|
|
21 |
|
|
noe_p = (NOEUD*)lis_possible[index] ;/* adresse du noeud selecte */
|
22 |
|
|
|
23 |
|
|
n1 = n2 = n3 = NULL ;
|
24 |
|
|
/* point connectable ? */
|
25 |
|
|
if (noe_p->mark == KILLED) return(FAUX) ;/* point elimine */
|
26 |
|
|
if (noe_p->mark == NO_CONNEC) return(FAUX) ;
|
27 |
|
|
/* tetra aplati */
|
28 |
|
|
|
29 |
|
|
if (critere[index] <0.001) return(FAUX) ;
|
30 |
|
|
|
31 |
|
|
/* noeud au dessus */
|
32 |
|
|
if (lis_signe[index] == NEGATIF) return(FAUX) ;
|
33 |
|
|
|
34 |
|
|
/* parcours de la liste des tetras detruits EVITER DE BOUCLER */
|
35 |
|
|
/* reperer l'octree d'appartenance du noeud */
|
36 |
|
|
connec =(face->n1)->tete ;
|
37 |
|
|
nb_killed = 0 ;
|
38 |
|
|
while (connec!=NULL)
|
39 |
|
|
{
|
40 |
|
|
tetra = connec->tetra ;/* tetra connecte au noeud */
|
41 |
|
|
if ((tetra->mark == KILLED) && (gest_r->numele[4*(tetra->num) + 1]!=123456789))
|
42 |
|
|
{
|
43 |
|
|
if ( (tetra->face1->n1==face->n1) || (tetra->face1->n1==face->n2) || (tetra->face1->n1==face->n3) || (tetra->face1->n1==noe_p))
|
44 |
|
|
{
|
45 |
|
|
if ( (tetra->face1->n2==face->n1) || (tetra->face1->n2==face->n2) || (tetra->face1->n2==face->n3)
|
46 |
|
|
|| (tetra->face1->n2==noe_p))
|
47 |
|
|
{
|
48 |
|
|
if ( (tetra->face1->n3==face->n1) || (tetra->face1->n3==face->n2) || (tetra->face1->n3==face->n3)
|
49 |
|
|
|| (tetra->face1->n3==noe_p))
|
50 |
|
|
{
|
51 |
|
|
/* determination du 4 e noeud du tetra */
|
52 |
|
|
n4 = NULL ;
|
53 |
|
|
if ( (tetra->face2->n1!=tetra->face1->n1) && (tetra->face2->n1!=tetra->face1->n2)
|
54 |
|
|
&& (tetra->face2->n1!=tetra->face1->n3))
|
55 |
|
|
{
|
56 |
|
|
n4 = tetra->face2->n1 ;
|
57 |
|
|
}
|
58 |
|
|
else if ( (tetra->face2->n2!=tetra->face1->n1) && (tetra->face2->n2!=tetra->face1->n2) &&
|
59 |
|
|
(tetra->face2->n2!=tetra->face1->n3))
|
60 |
|
|
{
|
61 |
|
|
n4 = tetra->face2->n2 ;
|
62 |
|
|
}
|
63 |
|
|
else n4 = tetra->face2->n3 ;
|
64 |
|
|
if ( (n4==face->n1) || (n4==face->n2) || (n4==face->n3)
|
65 |
|
|
|| (n4==noe_p))
|
66 |
|
|
{
|
67 |
|
|
nb_killed ++;
|
68 |
|
|
if (nb_killed>2)
|
69 |
|
|
{
|
70 |
|
|
return(FAUX) ;
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
connec = connec->suivant ;
|
78 |
|
|
}
|
79 |
|
|
/* les faces du tetra coupent-elles le front */
|
80 |
|
|
*ierr = FAUX ;
|
81 |
|
|
if (r3d_cpfront(coord,face,noe_p,ierr))
|
82 |
|
|
{
|
83 |
|
|
return(FAUX) ;
|
84 |
|
|
}
|
85 |
|
|
/* dernier test (30/10/1992) */
|
86 |
|
|
/* ************************** */
|
87 |
|
|
/* test d'existence des faces */
|
88 |
|
|
/* ************************** */
|
89 |
|
|
if (noe_p->mark == CARD_NULL) return(VRAI) ;
|
90 |
|
|
nj1 = face->n1 ;
|
91 |
|
|
nj2 = face->n2 ;
|
92 |
|
|
nj3 = face->n3 ;
|
93 |
|
|
j1 = nj1->num ;
|
94 |
|
|
j2 = nj2->num ;
|
95 |
|
|
j3 = nj3->num ;
|
96 |
|
|
num_c = noe_p->num ;
|
97 |
|
|
/* recherche de la face j3 j2 num_c */
|
98 |
|
|
min_j = min(j3,j2) ;
|
99 |
|
|
min_j = min(min_j,num_c) ;
|
100 |
|
|
if (min_j==j3)
|
101 |
|
|
{
|
102 |
|
|
n1 = nj3 ;
|
103 |
|
|
n2 = nj2 ;
|
104 |
|
|
n3 = noe_p ;
|
105 |
|
|
}
|
106 |
|
|
if (min_j==j2)
|
107 |
|
|
{
|
108 |
|
|
n1 = nj2 ;
|
109 |
|
|
n2 = noe_p ;
|
110 |
|
|
n3 = nj3 ;
|
111 |
|
|
}
|
112 |
|
|
if (min_j==num_c)
|
113 |
|
|
{
|
114 |
|
|
n1 = noe_p ;
|
115 |
|
|
n2 = nj3 ;
|
116 |
|
|
n3 = nj2 ;
|
117 |
|
|
}
|
118 |
|
|
/* recherche de la face n1,n2,n3 */
|
119 |
|
|
face1 = r3d_recface2(coord,n1,n2,n3) ;
|
120 |
|
|
if (face1!=NULL)
|
121 |
|
|
{
|
122 |
|
|
/* on teste si la face a ete detruite */
|
123 |
|
|
if (face1->mark==KILLED)
|
124 |
|
|
{
|
125 |
|
|
return(FAUX) ;
|
126 |
|
|
}
|
127 |
|
|
}
|
128 |
|
|
/* recherche de la face j1 j3 num_c */
|
129 |
|
|
min_j = min(j1,j3) ;
|
130 |
|
|
min_j = min(min_j,num_c) ;
|
131 |
|
|
if (min_j==j1)
|
132 |
|
|
{
|
133 |
|
|
n1 = nj1 ;
|
134 |
|
|
n2 = nj3 ;
|
135 |
|
|
n3 = noe_p ;
|
136 |
|
|
}
|
137 |
|
|
if (min_j==j3)
|
138 |
|
|
{
|
139 |
|
|
n1 = nj3 ;
|
140 |
|
|
n2 = noe_p ;
|
141 |
|
|
n3 = nj1 ;
|
142 |
|
|
}
|
143 |
|
|
if (min_j==num_c)
|
144 |
|
|
{
|
145 |
|
|
n1 = noe_p ;
|
146 |
|
|
n2 = nj1 ;
|
147 |
|
|
n3 = nj3 ;
|
148 |
|
|
}
|
149 |
|
|
/* recherche de la face n1,n2,n3 */
|
150 |
|
|
face2 = r3d_recface2(coord,n1,n2,n3) ;
|
151 |
|
|
if (face2!=NULL)
|
152 |
|
|
{
|
153 |
|
|
/* on teste si la face a ete detruite */
|
154 |
|
|
if (face2->mark==KILLED)
|
155 |
|
|
{
|
156 |
|
|
return(FAUX) ;
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
/* recherche de la face j2 j1 num_c */
|
160 |
|
|
min_j = min(j2,j1) ;
|
161 |
|
|
min_j = min(min_j,num_c) ;
|
162 |
|
|
if (min_j==j2)
|
163 |
|
|
{
|
164 |
|
|
n1 = nj2 ;
|
165 |
|
|
n2 = nj1 ;
|
166 |
|
|
n3 = noe_p ;
|
167 |
|
|
}
|
168 |
|
|
if (min_j==j1)
|
169 |
|
|
{
|
170 |
|
|
n1 = nj1 ;
|
171 |
|
|
n2 = noe_p ;
|
172 |
|
|
n3 = nj2 ;
|
173 |
|
|
}
|
174 |
|
|
if (min_j==num_c)
|
175 |
|
|
{
|
176 |
|
|
n1 = noe_p ;
|
177 |
|
|
n2 = nj2 ;
|
178 |
|
|
n3 = nj1 ;
|
179 |
|
|
}
|
180 |
|
|
/* recherche de la face n1,n2,n3 */
|
181 |
|
|
face3 = r3d_recface2(coord,n1,n2,n3) ;
|
182 |
|
|
if (face3!=NULL)
|
183 |
|
|
{
|
184 |
|
|
/* on teste si la face a ete detruite */
|
185 |
|
|
if (face3->mark==KILLED)
|
186 |
|
|
{
|
187 |
|
|
return(FAUX) ;
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
return(VRAI) ;
|
191 |
|
|
}
|