-
Notifications
You must be signed in to change notification settings - Fork 5
/
spatialgrid.h
57 lines (49 loc) · 1.7 KB
/
spatialgrid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "cthing.h"
#include "math/math.h"
#include "mem/mpool.h"
CT_BEGIN_DECLS
typedef struct CT_SPCell CT_SPCell;
typedef struct CT_SpatialGrid CT_SpatialGrid;
struct CT_SpatialGrid {
CT_MPool pool;
CT_SPCell **cells;
size_t numCells;
size_t dims;
size_t stride[3];
size_t size[3];
float offset[3];
float limit[3];
float invWidth[3];
int (*find_cell)(const CT_SpatialGrid *, const float *);
};
int ct_spgrid_init(CT_SpatialGrid *grid,
const float *start,
const float *end,
const size_t *strides,
size_t dims,
size_t poolSize);
void ct_spgrid_free(CT_SpatialGrid *grid);
int ct_spgrid_insert(CT_SpatialGrid *grid, const float *p, const void *item);
int ct_spgrid_remove(CT_SpatialGrid *grid, const float *p, const void *item);
int ct_spgrid_update(CT_SpatialGrid *grid,
const float *p1,
const float *p2,
const void *item);
size_t ct_spgrid_select1d(const CT_SpatialGrid *grid,
float p,
float eps,
void **results,
size_t len);
size_t ct_spgrid_select2d(const CT_SpatialGrid *grid,
const float *p,
const float *eps,
void **results,
size_t len);
size_t ct_spgrid_select3d(const CT_SpatialGrid *grid,
const float *p,
const float *eps,
void **results,
size_t len);
void ct_spgrid_trace(const CT_SpatialGrid *grid);
CT_END_DECLS