Voxvision  1
Creating and manipulating voxel octrees
geom.h
Go to the documentation of this file.
1 
6 #ifndef __GEOM_H_
7 #define __GEOM_H_
8 
9 #include "params.h"
10 
14 #ifdef SSE_INTRIN
15 #define vox_dot_add(a,b,res) _mm_store_ps ((res), _mm_load_ps (a) + _mm_load_ps (b))
16 #else
17 #define vox_dot_add(a,b,res) do { \
18  res[0] = a[0] + b[0]; \
19  res[1] = a[1] + b[1]; \
20  res[2] = a[2] + b[2]; \
21  } \
22  while (0);
23 #endif
24 
28 #ifdef SSE_INTRIN
29 #define vox_dot_sub(a,b,res) _mm_store_ps ((res), _mm_load_ps (a) - _mm_load_ps (b))
30 #else
31 #define vox_dot_sub(a,b,res) do { \
32  res[0] = a[0] - b[0]; \
33  res[1] = a[1] - b[1]; \
34  res[2] = a[2] - b[2]; \
35  } \
36  while (0);
37 #endif
38 
42 #ifdef SSE_INTRIN
43 #define vox_dot_scmul(d,sc,res) _mm_store_ps ((res), _mm_load_ps (d) * _mm_set_ps1 (sc))
44 #else
45 #define vox_dot_scmul(d,sc,res) do { \
46  res[0] = sc * d[0]; \
47  res[1] = sc * d[1]; \
48  res[2] = sc * d[2]; \
49  } \
50  while (0);
51 #endif
52 
59 VOX_EXPORT float vox_abs_metric (const vox_dot dot1, const vox_dot dot2);
60 
66 VOX_EXPORT float vox_sqr_metric (const vox_dot dot1, const vox_dot dot2);
67 
73 VOX_EXPORT float vox_sqr_norm (const vox_dot dot);
74 
75 #ifdef VOXTREES_SOURCE
76 
87 VOX_EXPORT int get_subspace_idx (const vox_dot center, const vox_dot dot); // KLUDGE: needed for tests
88 
89 /*
90  * Generally this works like get_subspace_idx () but corrects subspace
91  * index if center[i] == dot[i]. In this case, direction[i] is used to
92  * choose the index at i-th coordinate.
93  */
94 int get_corrected_subspace_idx (const vox_dot center, const vox_dot dot, const vox_dot direction);
95 
96 
106 int hit_box (const struct vox_box *box, const vox_dot origin, const vox_dot dir, vox_dot res);
107 
122 int hit_plane_within_box (const vox_dot origin, const vox_dot dir, const vox_dot planedot,
123  int planenum, vox_dot res, const struct vox_box *box);
124 
130 int box_ball_interp (const struct vox_box *box, const vox_dot center, float radius);
131 int dense_set_p (const struct vox_box *box, size_t n);
132 int voxel_in_box (const struct vox_box *box, const vox_dot dot);
133 void closest_vertex (const struct vox_box *box, const vox_dot dot, vox_dot res);
134 int divide_box (const struct vox_box *box, const vox_dot center, struct vox_box *res, int idx);
135 void get_dimensions (const struct vox_box *box, size_t dim[]);
136 int stripep (const struct vox_box *box, int *which);
137 #endif
138 
139 #endif
VOX_EXPORT float vox_sqr_metric(const vox_dot dot1, const vox_dot dot2)
Calculate metric between two dots.
VOX_EXPORT float vox_abs_metric(const vox_dot dot1, const vox_dot dot2)
Calculate fast metric between two dots.
VOX_EXPORT float vox_sqr_norm(const vox_dot dot)
Calculate norm of a vector.
Global parameters used by the library.
Structure representing a box.
Definition: voxvision.h:80