liba2ri  0.2
 All Data Structures
space_partition.h
1 /*************************************/
2 /* Auteur : Rémi Synave */
3 /* Date de création : 01/11/07 */
4 /* Date de modification : 08/01/10 */
5 /* Version : 0.2 */
6 /*************************************/
7 
8 /*************************************/
9 /* Auteur : Romain Leguay */
10 /* Nguyen Haiduong */
11 /* Marianne Fichoux */
12 /* Date de modification : 06/06/09 */
13 /* Version : 0.2 */
14 /*************************************/
15 
16 /***************************************************************************/
17 /* This file is part of a2ri. */
18 /* */
19 /* a2ri is free software: you can redistribute it and/or modify it */
20 /* under the terms of the GNU Lesser General Public License as published */
21 /* by the Free Software Foundation, either version 3 of the License, or */
22 /* (at your option) any later version. */
23 /* */
24 /* a2ri is distributed in the hope that it will be useful, */
25 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
26 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
27 /* GNU Lesser General Public License for more details. */
28 /* */
29 /* You should have received a copy of the GNU Lesser General Public */
30 /* License along with a2ri. */
31 /* If not, see <http://www.gnu.org/licenses/>. */
32 /***************************************************************************/
33 
34 #ifndef SPACE_PARTITION__H
35 #define SPACE_PARTITION__H
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include "point.h"
40 #include "geometry.h"
41 #include "util.h"
42 
43 #define REJECT_ZERO_LENGTH 0
44 #define ACCEPT_ZERO_LENGTH 1
45 
46 typedef struct
47 {
48  point3d *list_point;
49  int nb_point;
50 } sp_depth,
51  *pt_sp_depth;
52 
53 typedef struct
54 {
55  sp_depth *z;
56 } sp_height;
57 
58 typedef struct
59 {
60  sp_height *y;
61 } sp_width;
62 
66 typedef struct
67 {
68  point3d ptmin,
69  ptmax;
70  int nb_part_x,
71  nb_part_y,
72  nb_part_z;
73  sp_width *x;
75 
81 void space_partition_init (
82  space_partition * sp);
83 
94 void space_partition_new (
95  space_partition * sp,
96  point3d min,
97  point3d max,
98  int nbpartx,
99  int nbparty,
100  int nbpartz);
101 
107 void space_partition_free (
108  space_partition * sp);
109 
115 void space_partition_display (
116  space_partition * sp);
117 
123 void space_partition_display_detail (
124  space_partition * sp);
125 
131 void space_partition_display_high_detail (
132  space_partition * sp);
133 
143 void space_partition_get_XYZ (
144  space_partition * sp,
145  point3d p,
146  int *x,
147  int *y,
148  int *z);
149 
156 void space_partition_add_point (
157  space_partition * sp,
158  point3d p);
159 
168 point3d space_partition_get_average (
169  space_partition * sp,
170  int cell_x,
171  int cell_y,
172  int cell_z);
173 
182 point3d space_partition_get_middle (
183  space_partition * sp,
184  int cell_x,
185  int cell_y,
186  int cell_z);
187 
193 int space_partition_nb_points (
194  space_partition * sp);
195 
205 void space_partition_get_neighbour (
206  space_partition * sp,
207  point3d pt,
208  int distance,
209  pt_sp_depth ** list,
210  int *size);
211 
220 point3d *space_partition_nearest_point (
221  space_partition * sp,
222  point3d pt,
223  point3d * near_pt,
224  double *length,
225  int acceptzerolength);
226 
235 point3d *space_partition_contains_point (
236  space_partition * sp,
237  point3d pt);
238 
244 void space_partition_remove_outliers (
245  space_partition * sp);
246 
258 void space_partition_get_points_cells (
259  space_partition * sp,
260  int *listcellx,
261  int *listcelly,
262  int *listcellz,
263  int sizelist,
264  pt_point3d ** listpoint,
265  int *sizelistpoint);
266 
267 
280 void space_partition_bounding_box (
281  space_partition * sp,
282  point3d * list,
283  int size,
284  int *xmin,
285  int *ymin,
286  int *zmin,
287  int *xmax,
288  int *ymax,
289  int *zmax);
290 
299 void space_partition_get_list_near_point (
300  space_partition * sp,
301  point3d pt,
302  pt_sp_depth ** list,
303  int *size);
304 
305 #endif