1 |
/*****************************************************************
|
2 |
|
3 |
m3d_update_front.cpp Type:Func
|
4 |
|
5 |
Mise a jour du front 3D
|
6 |
|
7 |
Date de creation : 12-3-1999 15 :42 :58
|
8 |
Derniere version : 12-3-1999 15 :42 :58
|
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 "memoire.h"
|
24 |
#include "struct.h"
|
25 |
#include "struct3d.h"
|
26 |
#include "const.h"
|
27 |
#include "prototype.h"
|
28 |
|
29 |
/**************************/
|
30 |
/* variables globales */
|
31 |
extern struct s_mesh *mesh;
|
32 |
extern struct environnement env;
|
33 |
|
34 |
|
35 |
|
36 |
/**************************/
|
37 |
/* programme principal */
|
38 |
|
39 |
void m3d_update_front(struct s_front3d **ft,struct s_front3d *ftbase,struct s_tetra *tet,int type)
|
40 |
{
|
41 |
struct s_front3d *ftn;
|
42 |
struct s_noeud *no1,*no2,*no3;
|
43 |
int j,k;
|
44 |
float angle;
|
45 |
int pass1,pass2,pass3;
|
46 |
char mess[255];
|
47 |
|
48 |
switch (type)
|
49 |
{
|
50 |
case NEW0:
|
51 |
case NEW1:
|
52 |
case NEW2:
|
53 |
case NEW3:
|
54 |
m3d_ac_front(&ftn,NEW);
|
55 |
if (type==NEW0)
|
56 |
{
|
57 |
ftn->n1=tet->n1;
|
58 |
ftn->n2=tet->n3;
|
59 |
ftn->n3=tet->n2;
|
60 |
ftn->tri=tet->triangle[0];
|
61 |
}
|
62 |
if (type==NEW1)
|
63 |
{
|
64 |
ftn->n1=tet->n1;
|
65 |
ftn->n2=tet->n2;
|
66 |
ftn->n3=tet->n4;
|
67 |
ftn->tri=tet->triangle[1];
|
68 |
}
|
69 |
if (type==NEW2)
|
70 |
{
|
71 |
ftn->n1=tet->n2;
|
72 |
ftn->n2=tet->n3;
|
73 |
ftn->n3=tet->n4;
|
74 |
ftn->tri=tet->triangle[2];
|
75 |
}
|
76 |
if (type==NEW3)
|
77 |
{
|
78 |
ftn->n1=tet->n1;
|
79 |
ftn->n2=tet->n4;
|
80 |
ftn->n3=tet->n3;
|
81 |
ftn->tri=tet->triangle[3];
|
82 |
}
|
83 |
|
84 |
ftn->tri->front=ftn->tri->front+1;
|
85 |
ftn->tri->ft=ftn;
|
86 |
*ft=ftn;
|
87 |
m3d_ord_front(*ft,ATTENTE);
|
88 |
oc_ins_obj(FRONT3D,ftn->num,mesh->first);
|
89 |
break;
|
90 |
case LIAISON: no1=ADRESSE((*ft)->n1,noeud,mesh->);
|
91 |
no2=ADRESSE((*ft)->n2,noeud,mesh->);
|
92 |
no3=ADRESSE((*ft)->n3,noeud,mesh->);
|
93 |
pass1=0;
|
94 |
pass2=0;
|
95 |
pass3=0;
|
96 |
if ((ftbase==NULL)|| (((*ft)->voisin[0].ft)==ftbase))
|
97 |
{
|
98 |
for (j=0;j<no1->nb_triangle;j++)
|
99 |
for (k=0;k<no2->nb_triangle;k++)
|
100 |
if ((no1->triangle[j]==no2->triangle[k])&&(no1->triangle[j]!=((*ft)->tri))&&(no1->triangle[j]->front==1))
|
101 |
if (pass1==0)
|
102 |
{
|
103 |
pass1=1;
|
104 |
(*ft)->voisin[0].ft=no1->triangle[j]->ft;
|
105 |
(*ft)->voisin[0].angle=m3d_angle_front(*ft,(*ft)->voisin[0].ft);
|
106 |
}
|
107 |
else
|
108 |
{
|
109 |
angle=m3d_angle_front(*ft,no1->triangle[j]->ft);
|
110 |
if (angle<(*ft)->voisin[0].angle)
|
111 |
{
|
112 |
(*ft)->voisin[0].ft=no1->triangle[j]->ft;
|
113 |
(*ft)->voisin[0].angle=angle;
|
114 |
}
|
115 |
}
|
116 |
}
|
117 |
else pass1=1;
|
118 |
if ((ftbase==NULL)|| (((*ft)->voisin[1].ft)==ftbase))
|
119 |
{
|
120 |
for (j=0;j<no1->nb_triangle;j++)
|
121 |
for (k=0;k<no3->nb_triangle;k++)
|
122 |
if ((no1->triangle[j]==no3->triangle[k])&&(no1->triangle[j]!=((*ft)->tri))&&(no1->triangle[j]->front==1))
|
123 |
if (pass2==0)
|
124 |
{
|
125 |
pass2=1;
|
126 |
(*ft)->voisin[1].ft=no1->triangle[j]->ft;
|
127 |
(*ft)->voisin[1].angle=m3d_angle_front(*ft,(*ft)->voisin[1].ft);
|
128 |
}
|
129 |
else
|
130 |
{
|
131 |
angle=m3d_angle_front(*ft,no1->triangle[j]->ft);
|
132 |
if (angle<(*ft)->voisin[1].angle)
|
133 |
{
|
134 |
(*ft)->voisin[1].ft=no1->triangle[j]->ft;
|
135 |
(*ft)->voisin[1].angle=angle;
|
136 |
}
|
137 |
}
|
138 |
}
|
139 |
else pass2=1;
|
140 |
if ((ftbase==NULL)|| (((*ft)->voisin[2].ft)==ftbase))
|
141 |
{
|
142 |
for (j=0;j<no2->nb_triangle;j++)
|
143 |
for (k=0;k<no3->nb_triangle;k++)
|
144 |
if ((no2->triangle[j]==no3->triangle[k])&&(no2->triangle[j]!=((*ft)->tri))&&(no2->triangle[j]->front==1))
|
145 |
if (pass3==0)
|
146 |
{
|
147 |
pass3=1;
|
148 |
(*ft)->voisin[2].ft=no2->triangle[j]->ft;
|
149 |
(*ft)->voisin[2].angle=m3d_angle_front(*ft,(*ft)->voisin[2].ft);
|
150 |
}
|
151 |
else
|
152 |
{
|
153 |
angle=m3d_angle_front(*ft,no2->triangle[j]->ft);
|
154 |
if (angle<(*ft)->voisin[2].angle)
|
155 |
{
|
156 |
(*ft)->voisin[2].ft=no2->triangle[j]->ft;
|
157 |
(*ft)->voisin[2].angle=angle;
|
158 |
}
|
159 |
}
|
160 |
}
|
161 |
else pass3=1;
|
162 |
|
163 |
if (pass1==0)
|
164 |
{
|
165 |
sprintf(mess,"Etape numero %d. Big problem : Pas de voisin 0",mesh->nb_tetra);
|
166 |
aff_text(mess);
|
167 |
}
|
168 |
if (pass2==0)
|
169 |
{
|
170 |
sprintf(mess,"Etape numero %d. Big problem : Pas de voisin 1",mesh->nb_tetra);
|
171 |
aff_text(mess);
|
172 |
}
|
173 |
if (pass3==0)
|
174 |
{
|
175 |
sprintf(mess,"Etape numero %d. Big problem : Pas de voisin 2",mesh->nb_tetra);
|
176 |
aff_text(mess);
|
177 |
}
|
178 |
break;
|
179 |
|
180 |
}
|
181 |
|
182 |
|
183 |
}
|