Voxvision  1
Creating and manipulating voxel octrees
tree.h
Go to the documentation of this file.
1 
8 #ifndef _TREE_H_
9 #define _TREE_H_
10 
11 #include "params.h"
12 
13 #ifdef VOXTREES_SOURCE
14 
15 #define VOX_LEAF 1
16 #define VOX_DENSE_LEAF 2
17 #define VOX_LEAF_MASK 3
18 #define VOX_OVERFLOW 4
19 #define VOX_LEAFP(node) (!(node) || ((node)->flags & VOX_LEAF_MASK))
20 #define VOX_FULLP(node) ((node))
21 
22 typedef struct
23 {
24  vox_dot center;
25  struct vox_node *children[VOX_NS];
26 } vox_inner_data;
27 
28 struct vox_node
29 {
30  struct vox_box bounding_box;
31  unsigned int flags;
32  unsigned int dots_num;
33  union
34  {
35  vox_dot *dots;
36  vox_inner_data inner;
37  } data;
38 };
39 #else /* VOXTREES_SOURCE */
47 struct vox_node;
48 #endif /* VOXTREES_SOURCE */
49 
60 VOX_EXPORT struct vox_node* vox_make_tree (vox_dot set[], size_t n);
61 
67 VOX_EXPORT void vox_destroy_tree (struct vox_node *tree);
68 
72 VOX_EXPORT size_t vox_voxels_in_tree (const struct vox_node *tree);
73 
77 VOX_EXPORT void vox_bounding_box (const struct vox_node *tree, struct vox_box *box);
78 
86 VOX_EXPORT struct vox_node* vox_rebuild_tree (const struct vox_node *tree);
87 
96 VOX_EXPORT int vox_insert_voxel (struct vox_node **tree_ptr, vox_dot voxel);
97 
104 VOX_EXPORT int vox_insert_voxel_coord (struct vox_node **tree_ptr, float x, float y, float z);
105 
114 VOX_EXPORT int vox_delete_voxel (struct vox_node **tree_ptr, vox_dot voxel);
115 
122 VOX_EXPORT int vox_delete_voxel_coord (struct vox_node **tree_ptr, float x, float y, float z);
123 
130 VOX_EXPORT void vox_dump_tree (const struct vox_node *tree);
131 
140 VOX_EXPORT struct vox_node* vox_make_dense_leaf (const struct vox_box *box);
141 
149 VOX_EXPORT void vox_set_voxel_size (float x, float y, float z);
150 
151 #endif
Global parameters used by the library.
Structure representing a box.
Definition: voxvision.h:80
Voxel tree/node data structure.
VOX_EXPORT void vox_bounding_box(const struct vox_node *tree, struct vox_box *box)
Get the bounding box for voxels in the tree.
VOX_EXPORT struct vox_node * vox_rebuild_tree(const struct vox_node *tree)
Rebuild a tree.
VOX_EXPORT struct vox_node * vox_make_tree(vox_dot set[], size_t n)
Turn a set of voxels into a tree.
VOX_EXPORT void vox_set_voxel_size(float x, float y, float z)
Set global voxel size.
VOX_EXPORT int vox_delete_voxel(struct vox_node **tree_ptr, vox_dot voxel)
Delete a voxel from the tree on the fly.
VOX_EXPORT int vox_delete_voxel_coord(struct vox_node **tree_ptr, float x, float y, float z)
Delete a voxel from the tree on the fly.
VOX_EXPORT struct vox_node * vox_make_dense_leaf(const struct vox_box *box)
Create a cuboid tree.
VOX_EXPORT void vox_destroy_tree(struct vox_node *tree)
Free resources used by a tree.
VOX_EXPORT void vox_dump_tree(const struct vox_node *tree)
Dump a tree to standard output stream.
VOX_EXPORT size_t vox_voxels_in_tree(const struct vox_node *tree)
Return number of voxels in the tree.
VOX_EXPORT int vox_insert_voxel_coord(struct vox_node **tree_ptr, float x, float y, float z)
Insert a voxel in the tree on the fly.
VOX_EXPORT int vox_insert_voxel(struct vox_node **tree_ptr, vox_dot voxel)
Insert a voxel in the tree on the fly.