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

File Contents

# User Rev Content
1 1 /*****************************************************************
2    
3     oc_ins.c Type:Func
4    
5     Creation de l arbre octal
6    
7     Date de creation : Tue Jun 17 14:09:16 1997
8    
9     Derniere version : Tue Jun 17 14:09:16 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 "const.h"
26     #include "memoire.h"
27     #include "struct.h"
28     #include "prototype.h"
29    
30     /**************************/
31     /* variables globales */
32     extern struct s_acis *acis;
33     extern struct environnement env;
34     extern struct s_mesh *mesh;
35     extern struct s_param *para;
36    
37    
38    
39     /**************************/
40     /* programme principal */
41    
42     struct s_octree *oc_ins(float x,float y, float z,float taille,struct s_noeud **tab_noeud,int nb_noeud)
43     {
44     struct s_octree *oct;
45     int i,num;
46     struct s_noeud *no;
47    
48     NEW_ENTITE(oct,octree,mesh->);
49     oct->num=mesh->nb_octree-1;
50     oct->x=x;
51     oct->y=y;
52     oct->z=z;
53     oct->taille=taille;
54     for (i=0;i<nb_noeud;i++)
55     {
56     no=tab_noeud[i];
57     if ( (no->x>=x) && (no->y>=y) && (no->z>=z) && (no->x<x+taille) && (no->y<y+taille) && (no->z<z+taille) )
58     {
59     NEW_POINTEUR(num,noeud,oct->);
60     oct->noeud[num]=no;
61     }
62    
63     }
64    
65     if (oct->nb_noeud<2) {oct->feuille=1;mesh->nb_feuille++;}
66     else
67     {
68     oct->fils[0]=oc_ins(oct->x,oct->y,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
69     oct->fils[1]=oc_ins(oct->x+taille/2.,oct->y,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
70     oct->fils[2]=oc_ins(oct->x,oct->y+taille/2.,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
71     oct->fils[3]=oc_ins(oct->x+taille/2.,oct->y+taille/2.,oct->z,oct->taille/2.,oct->noeud,oct->nb_noeud);
72     oct->fils[4]=oc_ins(oct->x,oct->y,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
73     oct->fils[5]=oc_ins(oct->x+taille/2.,oct->y,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
74     oct->fils[6]=oc_ins(oct->x,oct->y+taille/2.,oct->z+taille/2.,oct->taille/2.,oct->noeud,oct->nb_noeud);
75     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);
76     }
77    
78     return(oct);
79     }