1 |
francois |
283 |
|
2 |
|
|
#include <stdio.h> |
3 |
|
|
#include "r3d_struct.h" |
4 |
|
|
#include "m3d_const.h" |
5 |
|
|
#include "m3d_hotes.h" |
6 |
|
|
#include "m3d_macro.h" |
7 |
|
|
#include "prototype2.h" |
8 |
|
|
extern GEST_MEM *gest_r ; |
9 |
|
|
extern int debug ; |
10 |
|
|
extern float eps, eps2, eps3, eps4 ; |
11 |
|
|
extern int tab_plan[4] ; |
12 |
|
|
extern float tab_vn[5][3] ;/* normales entieres du tetra */ |
13 |
|
|
int r3d_cpfront(float *coord,FACE *face,NOEUD *noe_p,int *ierr) |
14 |
|
|
{ |
15 |
|
|
FACE *courant ; |
16 |
|
|
NOEUD *nj1, *nj2, *nj3 ; |
17 |
|
|
int i, j, k, is_inter ; |
18 |
|
|
int nb = 0; |
19 |
|
|
FACE *tab[NB_MAX_INTER] ; |
20 |
|
|
int tab_mark[NB_MAX_INTER] ; |
21 |
|
|
float v01[3] , v12[3], v02[3], v03[3], v13[3], v23[3] ; |
22 |
|
|
float v45[3], v56[3], v46[3] ; |
23 |
|
|
float vmin[3], vmax[3] ; |
24 |
|
|
int in0 , in1 , in2 , in3 ; |
25 |
|
|
int j1, j2, j3, num_c ; |
26 |
|
|
|
27 |
|
|
nj1 = face->n1 ; |
28 |
|
|
nj2 = face->n2 ; |
29 |
|
|
nj3 = face->n3 ; |
30 |
|
|
|
31 |
|
|
num_c = noe_p->num ; |
32 |
|
|
|
33 |
|
|
tab_plan[0] = FAUX ; |
34 |
|
|
tab_plan[1] = FAUX ; |
35 |
|
|
tab_plan[2] = FAUX ; |
36 |
|
|
tab_plan[3] = FAUX ; |
37 |
|
|
|
38 |
|
|
j1 = nj1->num ; |
39 |
|
|
j2 = nj2->num ; |
40 |
|
|
j3 = nj3->num ; |
41 |
|
|
|
42 |
|
|
in0 = 3 * j1 ; |
43 |
|
|
in1 = 3 * j2 ; |
44 |
|
|
in2 = 3 * j3 ; |
45 |
|
|
in3 = 3 * num_c ; |
46 |
|
|
|
47 |
|
|
/* donnees communes */ |
48 |
|
|
|
49 |
|
|
VECTEUR(v01,(coord+in0),(coord+in1)) |
50 |
|
|
VECTEUR(v12,(coord+in1),(coord+in2)) |
51 |
|
|
VECTEUR(v02,(coord+in0),(coord+in2)) |
52 |
|
|
VECTEUR(v03,(coord+in0),(coord+in3)) |
53 |
|
|
VECTEUR(v13,(coord+in1),(coord+in3)) |
54 |
|
|
VECTEUR(v23,(coord+in2),(coord+in3)) |
55 |
|
|
|
56 |
|
|
/* calcul des normales exterieures */ |
57 |
|
|
/* face 0 2 1 */ |
58 |
|
|
|
59 |
|
|
tab_vn[0][0] = PVECX(v02,v01) ; |
60 |
|
|
tab_vn[0][1] = PVECY(v02,v01) ; |
61 |
|
|
tab_vn[0][2] = PVECZ(v02,v01) ; |
62 |
|
|
/* face 0 1 3 */ |
63 |
|
|
tab_vn[1][0] = PVECX(v01,v03) ; |
64 |
|
|
tab_vn[1][1] = PVECY(v01,v03) ; |
65 |
|
|
tab_vn[1][2] = PVECZ(v01,v03) ; |
66 |
|
|
/* face 1 2 3 */ |
67 |
|
|
tab_vn[2][0] = PVECX(v12,v13) ; |
68 |
|
|
tab_vn[2][1] = PVECY(v12,v13) ; |
69 |
|
|
tab_vn[2][2] = PVECZ(v12,v13) ; |
70 |
|
|
/* face 0 3 2 */ |
71 |
|
|
tab_vn[3][0] = PVECX(v03,v02) ; |
72 |
|
|
tab_vn[3][1] = PVECY(v03,v02) ; |
73 |
|
|
tab_vn[3][2] = PVECZ(v03,v02) ; |
74 |
|
|
|
75 |
|
|
BOITE(nj1,nj2,nj3,noe_p,vmin,vmax) |
76 |
|
|
|
77 |
|
|
eps = max(vmax[0]-vmin[0],vmax[1]-vmin[1]) ; |
78 |
|
|
eps = max(eps,vmax[2]-vmin[2]) ; |
79 |
|
|
|
80 |
|
|
eps = eps * 0.001 ; |
81 |
|
|
eps2 = eps * eps ; |
82 |
|
|
eps3 = eps2 * eps ; |
83 |
|
|
eps4 = eps3 * eps ; |
84 |
|
|
|
85 |
|
|
/* on prend toutes les faces de la coquille : traitement local */ |
86 |
|
|
|
87 |
|
|
for (i=0;i<gest_r->nb_face;i++) |
88 |
|
|
{ |
89 |
|
|
ADRESSE(face,i,courant) |
90 |
|
|
if ((courant->mark!=(size_t)face)&&(courant!=face)) |
91 |
|
|
{ |
92 |
|
|
if (nb>=NB_MAX_INTER) |
93 |
|
|
{ |
94 |
|
|
*ierr = VRAI ; |
95 |
|
|
if (debug) printf(" Erreur nombre d'intersections R3D_CPFRONT\n ") ; |
96 |
|
|
return(VRAI) ; |
97 |
|
|
} |
98 |
|
|
tab[nb] = courant ; |
99 |
|
|
tab_mark[nb] = courant->mark ; |
100 |
|
|
nb ++ ; |
101 |
|
|
courant->mark=(size_t)face ;/* on flagge la face deja traitee */ |
102 |
|
|
is_inter = m3d_intersection(coord,in0,in1,in2,in3,3*(courant->n1->num),3*(courant->n2->num),3*(courant->n3->num)) ; |
103 |
|
|
/* intersection avec une face non flottante */ |
104 |
|
|
if (is_inter == VRAI) |
105 |
|
|
{ |
106 |
|
|
for (j=0;j<nb;j++) |
107 |
|
|
{ |
108 |
|
|
courant = (FACE*)(tab[j]) ; |
109 |
|
|
courant->mark = tab_mark[j] ; |
110 |
|
|
} |
111 |
|
|
return(VRAI) ;/* intersection */ |
112 |
|
|
} |
113 |
|
|
} |
114 |
|
|
} |
115 |
|
|
for (i=0;i<nb;i++) |
116 |
|
|
{ |
117 |
|
|
courant = (FACE*)(tab[i]) ; |
118 |
|
|
courant->mark = tab_mark[i] ; |
119 |
|
|
} |
120 |
|
|
return(FAUX) ; /* pas d'intersection */ |
121 |
|
|
} |