35 #include <cugar/basic/types.h> 36 #include <cugar/basic/vector.h> 38 #include <thrust/device_vector.h> 47 template <
typename node_type,
typename node_tag>
52 template <
typename node_type>
62 uint2* leaf_ranges = NULL,
63 uint32* leaf_pointers = NULL,
64 uint32* parents = NULL,
65 uint32* skip_nodes = NULL,
66 uint2* node_ranges = NULL) :
67 m_nodes(nodes), m_leaf_ranges(leaf_ranges), m_leaf_pointers(leaf_pointers), m_parents(parents), m_skip_nodes(skip_nodes), m_node_ranges(node_ranges) {}
71 CUGAR_HOST_DEVICE
void write_node(
const uint32 node,
const uint32 parent,
bool p1,
bool p2,
const uint32 offset,
const uint32 skip_node,
const uint32 level,
const uint32
begin,
const uint32 end,
const uint32 split_index)
76 m_parents[ node ] = parent;
79 m_skip_nodes[ node ] = skip_node;
82 m_node_ranges[ node ] = make_uint2( begin, end );
86 CUGAR_HOST_DEVICE
void write_leaf(
const uint32 leaf_index,
const uint32 node_index,
const uint32
begin,
const uint32 end)
89 m_node_ranges[ node_index ] = make_uint2( begin, end );
92 m_leaf_ranges[ leaf_index ] = make_uint2( begin, end );
95 m_leaf_pointers[ leaf_index ] = node_index;
108 template <
typename node_type>
118 uint2* leaf_ranges = NULL,
119 uint32* leaf_pointers = NULL,
120 uint32* parents = NULL,
121 uint32* skip_nodes = NULL,
122 uint2* node_ranges = NULL) :
123 m_nodes(nodes), m_leaf_ranges(leaf_ranges), m_leaf_pointers(leaf_pointers), m_parents(parents), m_skip_nodes(skip_nodes), m_node_ranges(node_ranges) {}
128 CUGAR_HOST_DEVICE
void write_node(
const uint32 node,
const uint32 parent,
bool p1,
bool p2,
const uint32 offset,
const uint32 skip_node,
const uint32 level,
const uint32
begin,
const uint32 end,
const uint32 split_index)
136 m_parents[ node ] = parent;
139 m_skip_nodes[ node ] = skip_node;
142 m_node_ranges[ node ] = make_uint2( begin, end );
146 CUGAR_HOST_DEVICE
void write_leaf(
const uint32 leaf_index,
const uint32 node_index,
const uint32
begin,
const uint32 end)
149 m_leaf_ranges[ leaf_index ] = make_uint2( begin, end );
152 m_leaf_pointers[ leaf_index ] = node_index;
155 m_node_ranges[ node_index ] = make_uint2( begin, end );
179 typedef typename node_type::node_tag node_tag;
187 node_vector* nodes = NULL,
188 range_vector* leaf_ranges = NULL,
189 index_vector* leaf_pointers = NULL,
190 index_vector* parents = NULL,
191 index_vector* skip_nodes = NULL,
192 range_vector* node_ranges = NULL) :
193 m_nodes( nodes ), m_leaf_ranges( m_leaf_ranges ), m_leaf_pointers( NULL ), m_parents( parents ), m_skip_nodes( skip_nodes ), m_node_ranges(node_ranges) {}
195 void set_nodes(node_vector* nodes) { m_nodes = nodes; }
196 void set_parents(index_vector* parents) { m_parents = parents; }
197 void set_skip_nodes(index_vector* skip_nodes) { m_skip_nodes = skip_nodes; }
198 void set_leaf_pointers(index_vector* leaf_pointers) { m_leaf_pointers = leaf_pointers; }
199 void set_leaf_ranges(range_vector* leaf_ranges) { m_leaf_ranges = leaf_ranges; }
200 void set_node_ranges(range_vector* node_ranges) { m_node_ranges = node_ranges; }
207 if (m_nodes->size() < n) m_nodes->resize(n);
208 if (m_parents && m_parents->size() < n) m_parents->resize(n);
209 if (m_skip_nodes && m_skip_nodes->size() < n) m_skip_nodes->resize(n);
210 if (m_node_ranges && m_node_ranges->size() < n) m_node_ranges->resize(n);
218 if (m_leaf_ranges && m_leaf_ranges->size() < n) m_leaf_ranges->resize(n);
219 if (m_leaf_pointers && m_leaf_pointers->size() < n) m_leaf_pointers->resize(n);
228 m_leaf_ranges ?
raw_pointer( *m_leaf_ranges ) : NULL,
229 m_leaf_pointers ?
raw_pointer( *m_leaf_pointers ) : NULL,
231 m_skip_nodes ?
raw_pointer( *m_skip_nodes ) : NULL,
232 m_node_ranges ?
raw_pointer( *m_node_ranges ) : NULL );
235 node_vector* m_nodes;
236 range_vector* m_leaf_ranges;
237 index_vector* m_leaf_pointers;
238 index_vector* m_parents;
239 index_vector* m_skip_nodes;
240 range_vector* m_node_ranges;
uint32 * m_leaf_pointers
leaf pointers
Definition: bintree_writer.h:100
uint32 * m_parents
parent pointers
Definition: bintree_writer.h:161
uint2 * m_leaf_ranges
leaf ranges
Definition: bintree_writer.h:159
node_type * m_nodes
node pointer
Definition: bintree_writer.h:158
thrust::device_vector< T >::iterator begin(thrust::device_vector< T > &vec)
Definition: thrust_view.h:89
Definition: bintree_node.h:56
CUGAR_HOST_DEVICE void write_node(const uint32 node, const uint32 parent, bool p1, bool p2, const uint32 offset, const uint32 skip_node, const uint32 level, const uint32 begin, const uint32 end, const uint32 split_index)
Definition: bintree_writer.h:128
CUGAR_HOST_DEVICE void write_node(const uint32 node, const uint32 parent, bool p1, bool p2, const uint32 offset, const uint32 skip_node, const uint32 level, const uint32 begin, const uint32 end, const uint32 split_index)
Definition: bintree_writer.h:71
uint32 * m_skip_nodes
skip nodes pointer
Definition: bintree_writer.h:162
T * raw_pointer(thrust::device_vector< T, Alloc > &vec)
Definition: thrust_view.h:69
uint2 * m_node_ranges
node ranges
Definition: bintree_writer.h:103
node_type * m_nodes
node pointer
Definition: bintree_writer.h:98
Definition: bintree_writer.h:48
uint32 * m_skip_nodes
skip nodes pointer
Definition: bintree_writer.h:102
Define CUDA based scan primitives.
void reserve_leaves(const uint32 n)
Definition: bintree_writer.h:216
void reserve_nodes(const uint32 n)
Definition: bintree_writer.h:205
Definition: bintree_writer.h:177
uint32 * m_leaf_pointers
leaf pointers
Definition: bintree_writer.h:160
CUGAR_HOST_DEVICE void write_leaf(const uint32 leaf_index, const uint32 node_index, const uint32 begin, const uint32 end)
Definition: bintree_writer.h:86
CUGAR_HOST_DEVICE Bintree_writer_context(node_type *nodes, uint2 *leaf_ranges=NULL, uint32 *leaf_pointers=NULL, uint32 *parents=NULL, uint32 *skip_nodes=NULL, uint2 *node_ranges=NULL)
Definition: bintree_writer.h:60
CUGAR_HOST_DEVICE void write_leaf(const uint32 leaf_index, const uint32 node_index, const uint32 begin, const uint32 end)
Definition: bintree_writer.h:146
uint32 * m_parents
parent pointers
Definition: bintree_writer.h:101
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
Definition: bintree_node.h:60
context_type get_context()
Definition: bintree_writer.h:224
uint2 * m_node_ranges
node ranges
Definition: bintree_writer.h:163
CUGAR_HOST_DEVICE Bintree_writer_context()
Definition: bintree_writer.h:113
Definition: bintree_node.h:73
CUGAR_HOST_DEVICE Bintree_writer_context(node_type *nodes, uint2 *leaf_ranges=NULL, uint32 *leaf_pointers=NULL, uint32 *parents=NULL, uint32 *skip_nodes=NULL, uint2 *node_ranges=NULL)
Definition: bintree_writer.h:116
Bintree_writer(node_vector *nodes=NULL, range_vector *leaf_ranges=NULL, index_vector *leaf_pointers=NULL, index_vector *parents=NULL, index_vector *skip_nodes=NULL, range_vector *node_ranges=NULL)
Definition: bintree_writer.h:186
uint2 * m_leaf_ranges
leaf ranges
Definition: bintree_writer.h:99
CUGAR_HOST_DEVICE Bintree_writer_context()
Definition: bintree_writer.h:57