ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/diamesh/src/m3d_cpfront.cpp
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
File size: 8519 byte(s)
Log Message:
structure de l'écriture

File Contents

# User Rev Content
1 francois 283 #include <stdio.h>
2     #include <math.h>
3     #include "m3d_struct.h"
4     #include "m3d_const.h"
5     #include "m3d_hotes.h"
6     #include "m3d_macro.h"
7     #include "prototype.h"
8     extern GEST_MEM *gest ;
9     /* face existante */
10     extern int debug ;
11     extern int check ;
12     extern float dimp ;
13     extern float eps, eps2, eps3, eps4 ;
14     extern int tab_plan[4] ;
15     extern float tab_vn[5][3] ;/* normales entieres du tetra */
16     int m3d_cpfront(float *coord,FACE *face,NOEUD *noe_p,int *ierr)
17     {
18     FACE *courant, *tab_face[4] ;
19     FACE *face1, *face2, *face3 ;
20     NOEUD *nj1, *nj2, *nj3, *n1, *n2, *n3, *nzero ;
21     int i, j, k, is_inter, min_j ;
22     OBJET *tete, *obj ;
23     int nb;
24     FACE *tab[NB_MAX_INTER] ;
25     int tab_mark[NB_MAX_INTER] ;
26     float vmin[3], vmax[3] ;
27     CONNEC *connec ;
28     int nb_noeud = 0 ;
29     float delta_x, delta_y, delta_z, coeff;
30     int ii, ij ;
31     float v01[3] , v12[3], v02[3], v03[3], v13[3], v23[3] ;
32     float v45[3], v56[3], v46[3] ;
33     int in0 , in1 , in2 , in3 ;
34     float vmin2[3], vmax2[3] ;
35     int j1, j2, j3, num_c, nb_oct ;
36     OCT *tab_oct[NB_MAX_CONNEC] ;
37    
38     nb = 0 ;
39    
40     nzero = NULL ;
41     face1 = NULL ;
42     face2 = NULL ;
43     face3 = NULL ;
44    
45     nj1 = face->n1 ;
46     nj2 = face->n2 ;
47     nj3 = face->n3 ;
48     num_c = noe_p->num ;
49    
50     j1 = nj1->num ;
51     j2 = nj2->num ;
52     j3 = nj3->num ;
53    
54     in0 = 3 * j1 ;
55     in1 = 3 * j2 ;
56     in2 = 3 * j3 ;
57     in3 = 3 * num_c ;
58    
59     nb = 1;
60     tab[0] = face ;
61     tab_mark[0] = face->mark ;
62     face->mark = (size_t)face ;
63    
64     tab_plan[0] = FAUX ;
65     tab_plan[1] = FAUX ;
66     tab_plan[2] = FAUX ;
67     tab_plan[3] = FAUX ;
68    
69     /* recherche des faces */
70     min_j = min(j3,j2) ;
71     min_j = min(min_j,num_c) ;
72     if (min_j==j3)
73     {
74     n1 = nj3 ;
75     n2 = nj2 ;
76     n3 = noe_p ;
77     }
78     else if (min_j==j2)
79     {
80     n1 = nj2 ;
81     n2 = noe_p ;
82     n3 = nj3 ;
83     }
84     else
85     {
86     n1 = noe_p ;
87     n2 = nj3 ;
88     n3 = nj2 ;
89     }
90     /* recherche de la face n1,n2,n3 */
91     face2 = m3d_recface(coord,n1,n2,n3) ;
92     if (face2 != NULL) tab_plan[2] = VRAI ;
93     /* recherche de la face j1 j3 num_c */
94     min_j = min(j1,j3) ;
95     min_j = min(min_j,num_c) ;
96     if (min_j==j1)
97     {
98     n1 = nj1 ;
99     n2 = nj3 ;
100     n3 = noe_p ;
101     }
102     else if (min_j==j3)
103     {
104     n1 = nj3 ;
105     n2 = noe_p ;
106     n3 = nj1 ;
107     }
108     else
109     {
110     n1 = noe_p ;
111     n2 = nj1 ;
112     n3 = nj3 ;
113     }
114     /* recherche de la face n1,n2,n3 */
115     face3 = m3d_recface(coord,n1,n2,n3) ;
116     if (face3 != NULL) tab_plan[3] = VRAI ;
117     /* recherche de la face j2 j1 num_c */
118     min_j = min(j2,j1) ;
119     min_j = min(min_j,num_c) ;
120     if (min_j==j2)
121     {
122     n1 = nj2 ;
123     n2 = nj1 ;
124     n3 = noe_p ;
125     }
126     else if (min_j==j1)
127     {
128     n1 = nj1 ;
129     n2 = noe_p ;
130     n3 = nj2 ;
131     }
132     else
133     {
134     n1 = noe_p ;
135     n2 = nj2 ;
136     n3 = nj1 ;
137     }
138     /* recherche de la face n1,n2,n3 */
139     face1 = m3d_recface(coord,n1,n2,n3) ;
140     if (face1 != NULL) tab_plan[1] = VRAI ;
141    
142    
143     /* donnees communes */
144    
145     VECTEUR(v01,(coord+in0),(coord+in1))
146     VECTEUR(v12,(coord+in1),(coord+in2))
147     VECTEUR(v02,(coord+in0),(coord+in2))
148     VECTEUR(v03,(coord+in0),(coord+in3))
149     VECTEUR(v13,(coord+in1),(coord+in3))
150     VECTEUR(v23,(coord+in2),(coord+in3))
151    
152     /* calcul des normales exterieures */
153     /* face 0 2 1 */
154    
155     tab_vn[0][0] = PVECX(v02,v01) ;
156     tab_vn[0][1] = PVECY(v02,v01) ;
157     tab_vn[0][2] = PVECZ(v02,v01) ;
158     /* face 0 1 3 */
159     tab_vn[1][0] = PVECX(v01,v03) ;
160     tab_vn[1][1] = PVECY(v01,v03) ;
161     tab_vn[1][2] = PVECZ(v01,v03) ;
162     /* face 1 2 3 */
163     tab_vn[2][0] = PVECX(v12,v13) ;
164     tab_vn[2][1] = PVECY(v12,v13) ;
165     tab_vn[2][2] = PVECZ(v12,v13) ;
166     /* face 0 3 2 */
167     tab_vn[3][0] = PVECX(v03,v02) ;
168     tab_vn[3][1] = PVECY(v03,v02) ;
169     tab_vn[3][2] = PVECZ(v03,v02) ;
170    
171     /* recherche des faces avec lesquelles il peut y avoir intersection */
172     BOITE(nj1,nj2,nj3,noe_p,vmin,vmax)
173    
174     eps = max(vmax[0]-vmin[0],vmax[1]-vmin[1]) ;
175     eps = max(eps,vmax[2]-vmin[2]) ;
176    
177     eps = eps * 0.001 ;
178     eps2 = eps * eps ;
179     eps3 = eps2 * eps ;
180     eps4 = eps3 * eps ;
181     nb_oct = 0 ;
182     *ierr = FAUX ;
183    
184     m3d_rec_oct(vmin,vmax,gest->root,&nb_oct,tab_oct,ierr) ;
185     if (*ierr == VRAI) return(VRAI) ;
186    
187     for (i=0;i<nb_oct;i++)
188     {
189     /* faces de peau stockees en tant qu'objet */
190     obj = tab_oct[i]->lis_obj ;
191     /* parcours de la liste des objets */
192     while (obj !=NULL)
193     {
194     courant = obj->ref;/* adresse de l'adresse de la structure face */
195     if (courant!=NULL)
196     if (courant->mark!=DESTROYED)
197     {
198     /* face */
199     if (courant->mark!=(size_t)face)
200     {
201     tab[nb] = courant ;
202     tab_mark[nb] = courant->mark ;
203     nb++ ;
204     courant->mark = (size_t)face ;
205    
206     is_inter = 1 ;
207     /* test sur les boites englobantes */
208    
209     BOITE(courant->n1,courant->n2,courant->n3,nzero,vmin2,vmax2)
210     if (vmin2[2]>vmax[2] + 2.) is_inter = 0 ;
211     if (vmax2[2]<vmin[2] - 2.) is_inter = 0 ;
212    
213     if (vmin2[1]>vmax[1] + 2.) is_inter = 0 ;
214     if (vmax2[1]<vmin[1] - 2.) is_inter = 0 ;
215    
216     if (vmin2[0]>vmax[0] + 2.) is_inter = 0 ;
217     if (vmax2[0]<vmin[0] - 2.) is_inter = 0 ;
218    
219     if (is_inter)
220     if (m3d_intersection(coord,in0,in1,in2,in3,3*(courant->n1->num),3*(courant->n2->num),3*(courant->n3->num)))
221     {
222     /* reset des flags */
223     for (k=0;k<nb;k++)
224     {
225     courant = (FACE*)(tab[k]) ;
226     courant->mark = tab_mark[k] ;
227     }
228     return(VRAI) ;
229     }
230     }
231     }
232     obj = obj->suivant ;/* passer au suivant dans la liste */
233     }
234     /* faces crees */
235     /* autres faces lies aux tetraedres */
236     connec = tab_oct[i]->lis_con ;
237     while (connec != NULL)
238     {
239     if ((connec->tetra)->mark != KILLED)
240     {
241     tab_face[0] = (connec->tetra)->face1 ;
242     tab_face[1] = (connec->tetra)->face2 ;
243     tab_face[2] = (connec->tetra)->face3 ;
244     tab_face[3] = (connec->tetra)->face4 ;
245     for (k=0;k<4;k++)
246     {
247     courant = tab_face[k] ;
248     if ((courant->mark!=(size_t)face)&&(courant!=face))
249     {
250     tab[nb] = courant ;
251     tab_mark[nb] = courant->mark ;
252     nb++ ;
253     courant->mark = (size_t)face ;
254    
255     is_inter = 1 ;
256     /* test sur les boites englobantes */
257    
258     BOITE(courant->n1,courant->n2,courant->n3,nzero,vmin2,vmax2)
259     if (vmin2[2]>vmax[2] + 2.) is_inter = 0 ;
260     if (vmax2[2]<vmin[2] - 2.) is_inter = 0 ;
261    
262     if (vmin2[1]>vmax[1] + 2.) is_inter = 0 ;
263     if (vmax2[1]<vmin[1] - 2.) is_inter = 0 ;
264    
265     if (vmin2[0]>vmax[0] + 2.) is_inter = 0 ;
266     if (vmax2[0]<vmin[0] - 2.) is_inter = 0 ;
267    
268     if (is_inter)
269     if (m3d_intersection(coord,in0,in1,in2,in3,3*(courant->n1->num),3*(courant->n2->num),3*(courant->n3->num)))
270     {
271     /* reset des flags */
272     for (k=0;k<nb;k++)
273     {
274     courant = (FACE*)(tab[k]) ;
275     courant->mark = tab_mark[k] ;
276     }
277     return(VRAI) ;
278     }
279     }
280     }
281     }
282     connec = connec->suivant ;
283     }
284     }
285     /* reset des flags */
286     for (i=0;i<nb;i++)
287     {
288     courant = (FACE*)(tab[i]) ;
289     courant->mark = tab_mark[i] ;
290     }
291     return(FAUX) ;
292     }