1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
r3d_comp_detruit.c Type:Func
|
4 |
|
|
|
5 |
|
|
Destruction de mailles autour d une octree
|
6 |
|
|
|
7 |
|
|
Date de creation : Thu Jul 24 16:24:33 1997
|
8 |
|
|
|
9 |
|
|
Derniere version : Thu Jul 24 16:24:33 1997
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
Vincent FRANCOIS
|
13 |
|
|
|
14 |
|
|
*****************************************************************/
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
/**************************/
|
21 |
|
|
/* include */
|
22 |
|
|
#include <stdio.h>
|
23 |
|
|
#include <string.h>
|
24 |
|
|
#include <stdlib.h>
|
25 |
|
|
#include <math.h>
|
26 |
|
|
#include "const.h"
|
27 |
|
|
#include "memoire.h"
|
28 |
|
|
#include "struct.h"
|
29 |
|
|
#include "prototype.h"
|
30 |
|
|
|
31 |
|
|
/**************************/
|
32 |
|
|
/* variables globales */
|
33 |
|
|
extern struct s_acis *acis;
|
34 |
|
|
extern struct environnement env;
|
35 |
|
|
extern struct s_mesh *mesh;
|
36 |
|
|
extern struct s_maillage *maillage;
|
37 |
|
|
extern struct s_param *para;
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
/**************************/
|
42 |
|
|
/* programme principal */
|
43 |
|
|
|
44 |
|
|
void r3d_comp_detruit(int type)
|
45 |
|
|
{
|
46 |
|
|
int i,j;
|
47 |
|
|
float norm[4];
|
48 |
|
|
struct s_mnoeud *mnoe;
|
49 |
|
|
struct s_noeud *noe,*no1,*no2,*no3;
|
50 |
|
|
struct s_zone *zone,zone_tmp;
|
51 |
|
|
struct s_octree **liste;
|
52 |
|
|
struct s_triangle *tri;
|
53 |
|
|
float x,y,z,dens,n1n2[4],n1n3[4],n2n3[4];
|
54 |
|
|
|
55 |
|
|
liste=(struct s_octree **)calloc(mesh->nb_octree,sizeof(struct s_octree *));
|
56 |
|
|
ERREUR_ALLOC(liste);
|
57 |
|
|
|
58 |
|
|
for (i=0;i<mesh->nb_zone;i++)
|
59 |
|
|
{
|
60 |
|
|
zone=ADRESSE(i,zone,mesh->);
|
61 |
|
|
if (zone->type==type)
|
62 |
|
|
{
|
63 |
|
|
if (zone->reference==OLD)
|
64 |
|
|
for (j=0;j<zone->oct->nb_mnoeud;j++)
|
65 |
|
|
{
|
66 |
|
|
mnoe=zone->oct->mnoeud[j];
|
67 |
|
|
eval_dens_reel(mnoe);
|
68 |
|
|
if (mnoe->type==zone->type_entite)
|
69 |
|
|
if (mnoe->num_ent==zone->num)
|
70 |
|
|
r3d_comp_detruit2(zone,mnoe->x,mnoe->y,mnoe->z,mnoe->type,mnoe->num_ent,mnoe->dens,mnoe->dens,norm,liste);
|
71 |
|
|
}
|
72 |
|
|
if (zone->reference==NEW)
|
73 |
|
|
for (j=0;j<zone->oct->nb_noeud;j++)
|
74 |
|
|
{
|
75 |
|
|
noe=zone->oct->noeud[j];
|
76 |
|
|
if (noe->type==FACE)
|
77 |
|
|
{
|
78 |
|
|
eval_normal((struct s_face *)(acis->entity[noe->num_ent]),norm,noe->u,noe->v);
|
79 |
|
|
NORME(norm);
|
80 |
|
|
}
|
81 |
|
|
if (noe->type==zone->type_entite)
|
82 |
|
|
if (noe->num_ent==zone->num)
|
83 |
|
|
if (noe->creation==CONSTRUIT)
|
84 |
|
|
r3d_comp_detruit2(zone,noe->x,noe->y,noe->z,noe->type,noe->num_ent,noe->dens,noe->dens,norm,liste);
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
if (type==RETARDE3)
|
89 |
|
|
{
|
90 |
|
|
for (j=0;j<mesh->nb_triangle;j++)
|
91 |
|
|
{
|
92 |
|
|
tri=ADRESSE(j,triangle,mesh->);
|
93 |
|
|
if (tri->creation==CONSTRUIT)
|
94 |
|
|
{
|
95 |
|
|
no1=ADRESSE(tri->n1,noeud,mesh->);
|
96 |
|
|
no2=ADRESSE(tri->n2,noeud,mesh->);
|
97 |
|
|
no3=ADRESSE(tri->n3,noeud,mesh->);
|
98 |
|
|
x=(no1->x+no2->x+no3->x)/3.;
|
99 |
|
|
y=(no1->y+no2->y+no3->y)/3.;
|
100 |
|
|
z=(no1->z+no2->z+no3->z)/3.;
|
101 |
|
|
VEC(n1n2,no1,no2);
|
102 |
|
|
VEC(n1n3,no1,no3);
|
103 |
|
|
VEC(n2n3,no2,no3);
|
104 |
|
|
PVEC(norm,n1n3,n1n2);
|
105 |
|
|
NORME(norm);
|
106 |
|
|
NORME(n1n2);
|
107 |
|
|
NORME(n1n3);
|
108 |
|
|
NORME(n2n3);
|
109 |
|
|
dens=0.35*(n1n2[3]+n2n3[3]+n1n3[3]);
|
110 |
|
|
zone_tmp.reference=VERIFICATION;
|
111 |
|
|
r3d_comp_detruit2(&zone_tmp,x,y,z,tri->type,tri->num_ent,dens,dens,norm,liste);
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
|
|
free(liste);
|
116 |
|
|
}
|