34 #include <cugar/basic/types.h> 62 template <
typename leaf_type_tag>
77 static const uint32 kInvalid = uint32(-1);
88 CUGAR_HOST_DEVICE
Bintree_node(
bool child0,
bool child1, uint32 index) :
89 m_packed_info( (child0 ? 1u : 0u) | (child1 ? 2u : 0u) | (index << 2) ) {}
95 return (m_packed_info & 3u) == 0u;
101 return m_packed_info >> 2u;
107 return m_packed_info >> 2u;
113 return ((m_packed_info & 1u) ? 1u : 0u) +
114 ((m_packed_info & 2u) ? 1u : 0u);
119 CUGAR_HOST_DEVICE uint32
get_child(
const uint32 i)
const 121 return get_child_index() + i;
128 return m_packed_info & (1u << i) ?
true :
false;
134 return has_child(0) ? get_child_index() : kInvalid;
140 return has_child(1) ? get_child_index() + (has_child(0) ? 1u : 0u) : kInvalid;
143 uint32 m_packed_info;
159 static const uint32 kInvalid = uint32(-1);
170 CUGAR_HOST_DEVICE
Bintree_node(
bool child0,
bool child1, uint32 index,
const uint32 range_size = 0) :
171 m_packed_info( (child0 ? 1u : 0u) | (child1 ? 2u : 0u) | (index << 2) ), m_range_size(range_size) {}
177 CUGAR_HOST_DEVICE Bintree_node(
const uint32 leaf_begin,
const uint32 leaf_end) :
178 m_packed_info( (leaf_begin << 2) ), m_range_size( leaf_end - leaf_begin ) {}
182 CUGAR_HOST_DEVICE uint32 is_leaf()
const 184 return (m_packed_info & 3u) == 0u;
188 CUGAR_HOST_DEVICE uint32 get_child_index()
const 190 return m_packed_info >> 2u;
194 CUGAR_HOST_DEVICE uint32 get_leaf_begin()
const 196 return m_packed_info >> 2u;
200 CUGAR_HOST_DEVICE uint32 get_range_size()
const 206 CUGAR_HOST_DEVICE uint2 get_leaf_range()
const 208 const uint32 leaf_begin = m_packed_info >> 2u;
209 return make_uint2( leaf_begin, leaf_begin + m_range_size );
213 CUGAR_HOST_DEVICE uint32 get_leaf_size()
const 219 CUGAR_HOST_DEVICE uint32 get_child_count()
const 221 return ((m_packed_info & 1u) ? 1u : 0u) +
222 ((m_packed_info & 2u) ? 1u : 0u);
227 CUGAR_HOST_DEVICE uint32 get_child(
const uint32 i)
const 229 return get_child_index() + i;
234 CUGAR_HOST_DEVICE
bool has_child(
const uint32 i)
const 236 return m_packed_info & (1u << i) ?
true :
false;
240 CUGAR_HOST_DEVICE uint32 get_left()
const 242 return has_child(0) ? get_child_index() : kInvalid;
246 CUGAR_HOST_DEVICE uint32 get_right()
const 248 return has_child(1) ? get_child_index() + (has_child(0) ? 1u : 0u) : kInvalid;
251 uint32 m_packed_info;
CUGAR_HOST_DEVICE uint32 get_child_index() const
Definition: bintree_node.h:99
CUGAR_HOST_DEVICE uint32 get_child_count() const
Definition: bintree_node.h:111
Definition: bintree_node.h:56
CUGAR_HOST_DEVICE Bintree_node()
Definition: bintree_node.h:81
CUGAR_HOST_DEVICE Bintree_node(bool child0, bool child1, uint32 index)
Definition: bintree_node.h:88
CUGAR_HOST_DEVICE uint32 get_leaf_index() const
Definition: bintree_node.h:105
CUGAR_HOST_DEVICE uint32 get_left() const
Definition: bintree_node.h:132
CUGAR_HOST_DEVICE bool has_child(const uint32 i) const
Definition: bintree_node.h:126
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
Definition: bintree_node.h:60
CUGAR_HOST_DEVICE uint32 is_leaf() const
Definition: bintree_node.h:93
struct CUGAR_ALIGN_BEGIN(8) Bintree_node< leaf_range_tag >
Definition: bintree_node.h:155
Definition: bintree_node.h:63
CUGAR_HOST_DEVICE uint32 get_right() const
Definition: bintree_node.h:138
CUGAR_HOST_DEVICE uint32 get_child(const uint32 i) const
Definition: bintree_node.h:119