1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
m3d_c_octree.c Type:Func
|
4 |
|
|
|
5 |
|
|
creation de l arbre octal
|
6 |
|
|
|
7 |
|
|
Date de creation : Tue Jun 17 10:39:26 1997
|
8 |
|
|
|
9 |
|
|
Derniere version : Fri Aug 1 11:06:49 1997
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
Vincent FRANCOIS
|
18 |
|
|
|
19 |
|
|
*****************************************************************/
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/**************************/
|
26 |
|
|
/* include */
|
27 |
|
|
#include <stdio.h>
|
28 |
|
|
#include <string.h>
|
29 |
|
|
#include <stdlib.h>
|
30 |
|
|
#include "const.h"
|
31 |
|
|
#include "memoire.h"
|
32 |
|
|
#include "struct.h"
|
33 |
|
|
#include "prototype.h"
|
34 |
|
|
|
35 |
|
|
/**************************/
|
36 |
|
|
/* variables globales */
|
37 |
|
|
extern struct s_acis *acis;
|
38 |
|
|
extern struct environnement env;
|
39 |
|
|
extern struct s_mesh *mesh;
|
40 |
|
|
extern struct s_param *para;
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
/**************************/
|
45 |
|
|
/* programme principal */
|
46 |
|
|
|
47 |
|
|
void m3d_c_octree(void)
|
48 |
|
|
{
|
49 |
|
|
struct s_noeud *no;
|
50 |
|
|
struct s_octree *oct;
|
51 |
|
|
float xmin,ymin,zmin,xmax,ymax,zmax,taille;
|
52 |
|
|
int i,num;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
for (i=0;i<mesh->nb_noeud;i++)
|
57 |
|
|
{
|
58 |
|
|
no=ADRESSE(i,noeud,mesh->);
|
59 |
|
|
if (i==0)
|
60 |
|
|
{
|
61 |
|
|
xmin=no->x;
|
62 |
|
|
ymin=no->y;
|
63 |
|
|
zmin=no->z;
|
64 |
|
|
xmax=no->x;
|
65 |
|
|
ymax=no->y;
|
66 |
|
|
zmax=no->z;
|
67 |
|
|
}
|
68 |
|
|
if (no->x<xmin) xmin=no->x;
|
69 |
|
|
if (no->x>xmax) xmax=no->x;
|
70 |
|
|
if (no->y<ymin) ymin=no->y;
|
71 |
|
|
if (no->y>ymax) ymax=no->y;
|
72 |
|
|
if (no->z<zmin) zmin=no->z;
|
73 |
|
|
if (no->z>zmax) zmax=no->z;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
MAXI(taille,(xmax-xmin),(ymax-ymin));
|
77 |
|
|
MAXI(taille,taille,(zmax-zmin));
|
78 |
|
|
xmin=xmin-0.25*taille;
|
79 |
|
|
ymin=ymin-0.25*taille;
|
80 |
|
|
zmin=zmin-0.25*taille;
|
81 |
|
|
taille=taille*1.5;
|
82 |
|
|
NEW_ENTITE(mesh->first,octree,mesh->);
|
83 |
|
|
mesh->first->num=mesh->nb_octree-1;
|
84 |
|
|
mesh->first->x=xmin;
|
85 |
|
|
mesh->first->y=ymin;
|
86 |
|
|
mesh->first->z=zmin;
|
87 |
|
|
mesh->first->taille=taille;
|
88 |
|
|
for (i=0;i<mesh->nb_noeud;i++)
|
89 |
|
|
{
|
90 |
|
|
no=ADRESSE(i,noeud,mesh->);
|
91 |
|
|
if ((no->type==EDGE)||(no->type==VERTEX))
|
92 |
|
|
{
|
93 |
|
|
NEW_POINTEUR(num,noeud,mesh->first->);
|
94 |
|
|
mesh->first->noeud[num]=no;
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
oct=mesh->first;
|
98 |
|
|
oct->fils[0]=oc_ins(oct->x,oct->y,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
99 |
|
|
oct->fils[1]=oc_ins(oct->x+taille/2.,oct->y,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
100 |
|
|
oct->fils[2]=oc_ins(oct->x,oct->y+taille/2.,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
101 |
|
|
oct->fils[3]=oc_ins(oct->x+taille/2.,oct->y+taille/2.,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
102 |
|
|
oct->fils[4]=oc_ins(oct->x,oct->y,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
103 |
|
|
oct->fils[5]=oc_ins(oct->x+taille/2.,oct->y,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
104 |
|
|
oct->fils[6]=oc_ins(oct->x,oct->y+taille/2.,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
105 |
|
|
oct->fils[7]=oc_ins(oct->x+taille/2.,oct->y+taille/2.,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
|
106 |
|
|
|
107 |
|
|
/* remplissage de l arbre */
|
108 |
|
|
|
109 |
|
|
for (i=0;i<acis->nb_vertex;i++)
|
110 |
|
|
oc_ins_obj(VERTEX,i,mesh->first);
|
111 |
|
|
for (i=0;i<acis->nb_edge;i++)
|
112 |
|
|
oc_ins_obj(EDGE,i,mesh->first);
|
113 |
|
|
for (i=0;i<acis->nb_face;i++)
|
114 |
|
|
oc_ins_obj(FACE,i,mesh->first);
|
115 |
|
|
for (i=0;i<mesh->nb_noeud;i++)
|
116 |
|
|
oc_ins_obj(NOEUD,i,mesh->first);
|
117 |
|
|
for (i=0;i<mesh->nb_triangle;i++)
|
118 |
|
|
oc_ins_obj(TRIANGLE,i,mesh->first);
|
119 |
|
|
for (i=0;i<mesh->nb_tetra;i++)
|
120 |
|
|
oc_ins_obj(TETRA,i,mesh->first);
|
121 |
|
|
}
|