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