1 |
/*****************************************************************
|
2 |
|
3 |
m3d_int_faces Type:func
|
4 |
|
5 |
Intersection entre faces triangulaires
|
6 |
|
7 |
Date de creation : 16-3-1999 14 :1 :50
|
8 |
Derniere version : 16-3-1999 14 :1 :50
|
9 |
|
10 |
Vincent FRANCOIS
|
11 |
|
12 |
*****************************************************************/
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
/**************************/
|
19 |
/* include */
|
20 |
#include <stdio.h>
|
21 |
#include <string.h>
|
22 |
#include <stdlib.h>
|
23 |
#include <math.h>
|
24 |
#include "const.h"
|
25 |
#include "memoire.h"
|
26 |
#include "struct.h"
|
27 |
#include "struct3d.h"
|
28 |
#include "prototype.h"
|
29 |
|
30 |
|
31 |
/**************************/
|
32 |
/* variables globales */
|
33 |
extern struct environnment env;
|
34 |
extern struct s_mesh *mesh;
|
35 |
|
36 |
|
37 |
|
38 |
/**************************/
|
39 |
/* programme principal */
|
40 |
|
41 |
int m3d_int_faces(int n1, int n2, int n3, int n4, int n5, int n6)
|
42 |
{
|
43 |
int inter,nb_com;
|
44 |
struct s_noeud *no1,*no2,*no3,*no4,*no5,*no6;
|
45 |
float bx1min,by1min,bz1min,bx1max,by1max,bz1max;
|
46 |
float bx2min,by2min,bz2min,bx2max,by2max,bz2max;
|
47 |
float n1n2[4],n1n3[4],n1n4[4],n1n5[4],n1n6[6],normal[4];
|
48 |
float ps1,ps2,ps3;
|
49 |
float eps1,eps2,eps3;
|
50 |
|
51 |
|
52 |
/* filtrage */
|
53 |
nb_com=0;
|
54 |
if ((n4==n1) || (n4==n2) || (n4==n3)) nb_com++;
|
55 |
if ((n5==n1) || (n5==n2) || (n5==n3)) nb_com++;
|
56 |
if ((n6==n1) || (n6==n2) || (n6==n3)) nb_com++;
|
57 |
if (nb_com==3) return(FAUX);
|
58 |
|
59 |
no1=ADRESSE(n1,noeud,mesh->);
|
60 |
no2=ADRESSE(n2,noeud,mesh->);
|
61 |
no3=ADRESSE(n3,noeud,mesh->);
|
62 |
no4=ADRESSE(n4,noeud,mesh->);
|
63 |
no5=ADRESSE(n5,noeud,mesh->);
|
64 |
no6=ADRESSE(n6,noeud,mesh->);
|
65 |
MINI(bx1min,no1->x,no2->x);MINI(by1min,no1->y,no2->y);MINI(bz1min,no1->z,no2->z);
|
66 |
MINI(bx1min,bx1min,no3->x);MINI(by1min,by1min,no3->y);MINI(bz1min,bz1min,no3->z);
|
67 |
MAXI(bx1max,no1->x,no2->x);MAXI(by1max,no1->y,no2->y);MAXI(bz1max,no1->z,no2->z);
|
68 |
MAXI(bx1max,bx1max,no3->x);MAXI(by1max,by1max,no3->y);MAXI(bz1max,bz1max,no3->z);
|
69 |
MINI(bx2min,no4->x,no5->x);MINI(by2min,no4->y,no5->y);MINI(bz2min,no4->z,no5->z);
|
70 |
MINI(bx2min,bx2min,no6->x);MINI(by2min,by2min,no6->y);MINI(bz2min,bz2min,no6->z);
|
71 |
MAXI(bx2max,no4->x,no5->x);MAXI(by2max,no4->y,no5->y);MAXI(bz2max,no4->z,no5->z);
|
72 |
MAXI(bx2max,bx2max,no6->x);MAXI(by2max,by2max,no6->y);MAXI(bz2max,bz2max,no6->z);
|
73 |
inter=FAUX;
|
74 |
if (bx1max>=bx2min)
|
75 |
if (by1max>=by2min)
|
76 |
if (bz1max>=bz2min)
|
77 |
if (bx1min<=bx2max)
|
78 |
if (by1min<=by2max)
|
79 |
if (bz1min<=bz2max)
|
80 |
inter=VRAI;
|
81 |
if (inter==VRAI)
|
82 |
{
|
83 |
inter=FAUX;
|
84 |
VEC(n1n2,no1,no2);
|
85 |
VEC(n1n3,no1,no3);
|
86 |
VEC(n1n4,no1,no4);
|
87 |
VEC(n1n5,no1,no5);
|
88 |
VEC(n1n6,no1,no6);
|
89 |
PVEC(normal,n1n2,n1n3);
|
90 |
ps1=PSCA(normal,n1n4);
|
91 |
ps2=PSCA(normal,n1n5);
|
92 |
ps3=PSCA(normal,n1n6);
|
93 |
eps1=0.33333333*(DIFF(n1n2)+DIFF(n1n3)+DIFF(n1n4));
|
94 |
eps2=0.33333333*(DIFF(n1n2)+DIFF(n1n3)+DIFF(n1n5));
|
95 |
eps3=0.33333333*(DIFF(n1n2)+DIFF(n1n3)+DIFF(n1n6));
|
96 |
eps1=0.0018*eps1*eps1;
|
97 |
eps2=0.0018*eps2*eps2;
|
98 |
eps3=0.0018*eps3*eps3;
|
99 |
if ((ps1<-eps1)&&(ps2<-eps2)&&(ps3<-eps3)) return(FAUX);
|
100 |
if ((ps1>eps1)&&(ps2>eps2)&&(ps3>eps3)) return(FAUX);
|
101 |
if (m3d_int_seg_face(n1,n2,n3,n4,n5)==VRAI) return(VRAI);
|
102 |
if (m3d_int_seg_face(n1,n2,n3,n5,n6)==VRAI) return(VRAI);
|
103 |
if (m3d_int_seg_face(n1,n2,n3,n4,n6)==VRAI) return(VRAI);
|
104 |
if (m3d_int_seg_face(n4,n5,n6,n1,n2)==VRAI) return(VRAI);
|
105 |
if (m3d_int_seg_face(n4,n5,n6,n1,n3)==VRAI) return(VRAI);
|
106 |
if (m3d_int_seg_face(n4,n5,n6,n2,n3)==VRAI) return(VRAI);
|
107 |
}
|
108 |
return(inter);
|
109 |
}
|