ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/acismesh/m3d_intersection.cpp
Revision: 1
Committed: Mon Jun 11 22:53:07 2007 UTC (17 years, 11 months ago)
File size: 5005 byte(s)
Log Message:

File Contents

# User Rev Content
1 1 /*****************************************************************
2    
3     m3d_intersection.cpp Type:Func
4    
5     Intersection tetraedre face
6    
7     Date de creation : 15-3-1999 16 :47 :49
8     Derniere version : 15-3-1999 16 :47 :49
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     /* variables globales */
32     extern struct environnement env;
33     extern struct s_mesh *mesh;
34    
35    
36    
37     /**************************/
38     /* programme principal */
39    
40     int m3d_intersection(int n1,int n2,int n3,int n4,int n5,int n6,int n7)
41     {
42     struct s_noeud *no1,*no2,*no3,*no4,*no5,*no6,*no7;
43     float bx1min,by1min,bz1min,bx1max,by1max,bz1max;
44     float bx2min,by2min,bz2min,bx2max,by2max,bz2max;
45     float normal1[4],normal2[4],normal3[4],normal4[4];
46     float n1n2[4],n1n3[4],n1n4[4],n1n5[4],n1n6[4],n1n7[4];
47     float n2n3[4],n2n4[4],n2n5[4],n2n6[4],n2n7[4];
48     float eps;
49     int inter,nb_com;
50     int test1,test2,test3;
51    
52    
53     /* filtre sur numero */
54     nb_com=0;
55     if ((n5==n1) || (n5==n2) || (n5==n3) || (n5==n4)) nb_com++;
56     if ((n6==n1) || (n6==n2) || (n6==n3) || (n6==n4)) nb_com++;
57     if ((n7==n1) || (n7==n2) || (n7==n3) || (n7==n4)) nb_com++;
58     if (nb_com==3) return(FAUX);
59     /* filtres sur position */
60     no1=ADRESSE(n1,noeud,mesh->);
61     no2=ADRESSE(n2,noeud,mesh->);
62     no3=ADRESSE(n3,noeud,mesh->);
63     no4=ADRESSE(n4,noeud,mesh->);
64     no5=ADRESSE(n5,noeud,mesh->);
65     no6=ADRESSE(n6,noeud,mesh->);
66     no7=ADRESSE(n7,noeud,mesh->);
67     MINI(bx1min,no1->x,no2->x);MINI(by1min,no1->y,no2->y);MINI(bz1min,no1->z,no2->z);
68     MINI(bx1min,bx1min,no3->x);MINI(by1min,by1min,no3->y);MINI(bz1min,bz1min,no3->z);
69     MINI(bx1min,bx1min,no4->x);MINI(by1min,by1min,no4->y);MINI(bz1min,bz1min,no4->z);
70     MAXI(bx1max,no1->x,no2->x);MAXI(by1max,no1->y,no2->y);MAXI(bz1max,no1->z,no2->z);
71     MAXI(bx1max,bx1max,no3->x);MAXI(by1max,by1max,no3->y);MAXI(bz1max,bz1max,no3->z);
72     MAXI(bx1max,bx1max,no4->x);MAXI(by1max,by1max,no4->y);MAXI(bz1max,bz1max,no4->z);
73     MINI(bx2min,no5->x,no6->x);MINI(by2min,no5->y,no6->y);MINI(bz2min,no5->z,no6->z);
74     MINI(bx2min,bx2min,no7->x);MINI(by2min,by2min,no7->y);MINI(bz2min,bz2min,no7->z);
75     MAXI(bx2max,no5->x,no6->x);MAXI(by2max,no5->y,no6->y);MAXI(bz2max,no5->z,no6->z);
76     MAXI(bx2max,bx2max,no7->x);MAXI(by2max,by2max,no7->y);MAXI(bz2max,bz2max,no7->z);
77     inter=FAUX;
78     if (bx1max>=bx2min)
79     if (by1max>=by2min)
80     if (bz1max>=bz2min)
81     if (bx1min<=bx2max)
82     if (by1min<=by2max)
83     if (bz1min<=bz2max)
84     inter=VRAI;
85     /* on est oblige de calculer */
86     if (inter==VRAI)
87     {
88     inter=FAUX;
89     if ((n5==n1) || (n5==n2) || (n5==n3) || (n5==n4)) test1=0; else test1=1;
90     if ((n6==n1) || (n6==n2) || (n6==n3) || (n6==n4)) test2=0; else test2=1;
91     if ((n7==n1) || (n7==n2) || (n7==n3) || (n7==n4)) test3=0; else test3=1;
92     VEC(n1n2,no1,no2);
93     VEC(n1n3,no1,no3);
94     VEC(n1n4,no1,no4);
95     VEC(n2n3,no2,no3);
96     VEC(n2n4,no2,no4);
97     VEC(n1n5,no1,no5);
98     VEC(n1n6,no1,no6);
99     VEC(n1n7,no1,no7);
100     VEC(n2n5,no2,no5);
101     VEC(n2n6,no2,no6);
102     VEC(n2n7,no2,no7);
103     PVEC(normal1,n1n3,n1n2);
104     PVEC(normal2,n1n2,n1n4);
105     PVEC(normal3,n2n3,n2n4);
106     PVEC(normal4,n1n4,n1n3);
107     eps=0.333333333*(DIFF(n1n3)+DIFF(n1n2)+DIFF(n1n5));
108     eps=0.0018*eps*eps;
109     if (test1==1)
110     if (PSCA(normal1,n1n5)<eps)
111     if (PSCA(normal2,n1n5)<eps)
112     if (PSCA(normal3,n2n5)<eps)
113     if (PSCA(normal4,n1n5)<eps)
114     return(VRAI);
115     eps=0.333333333*(DIFF(n1n3)+DIFF(n1n2)+DIFF(n1n6));
116     eps=0.0018*eps*eps;
117     if (test2==1)
118     if (PSCA(normal1,n1n6)<eps)
119     if (PSCA(normal2,n1n6)<eps)
120     if (PSCA(normal3,n2n6)<eps)
121     if (PSCA(normal4,n1n6)<eps)
122     return(VRAI);
123     eps=0.333333333*(DIFF(n1n3)+DIFF(n1n2)+DIFF(n1n7));
124     eps=0.0018*eps*eps;
125     if (test3==1)
126     if (PSCA(normal1,n1n7)<eps)
127     if (PSCA(normal2,n1n7)<eps)
128     if (PSCA(normal3,n2n7)<eps)
129     if (PSCA(normal4,n1n7)<eps)
130     return(VRAI);
131     if (m3d_int_faces(n1,n3,n2,n5,n6,n7)==VRAI) return(VRAI);
132     if (m3d_int_faces(n1,n2,n4,n5,n6,n7)==VRAI) return(VRAI);
133     if (m3d_int_faces(n2,n3,n4,n5,n6,n7)==VRAI) return(VRAI);
134     if (m3d_int_faces(n1,n4,n3,n5,n6,n7)==VRAI) return(VRAI);
135     }
136     return(inter);
137     }