This module defines utility functions to operate with generic trees, such as tree reductions
|
| template<typename Tree_visitor , typename Input_iterator , typename Output_iterator , typename Operator , typename Value_type > |
| void | cugar::cuda::tree_reduce (const Tree_visitor tree, const Input_iterator in_values, Output_iterator node_values, const Operator op, const Value_type def_value) |
| |
| template<typename Tree_visitor , typename Value_iterator , typename Operator > |
| void | cugar::cuda::tree_reduce (const Tree_visitor tree, Value_iterator values, const Operator op) |
| |
| template<typename Tree_visitor , typename Input_iterator , typename Output_iterator , typename Operator , typename Value_type > |
| void | cugar::tree_reduce (const Tree_visitor tree, const Input_iterator in_values, Output_iterator node_values, const Operator op, const Value_type def_value) |
| |
| template<typename Tree_visitor , typename Value_iterator , typename Operator > |
| void | cugar::tree_reduce (const Tree_visitor tree, Value_iterator values, const Operator op) |
| |
◆ tree_reduce() [1/4]
template<typename Tree_visitor , typename Input_iterator , typename Output_iterator , typename Operator , typename Value_type >
| void cugar::cuda::tree_reduce |
( |
const Tree_visitor |
tree, |
|
|
const Input_iterator |
in_values, |
|
|
Output_iterator |
node_values, |
|
|
const Operator |
op, |
|
|
const Value_type |
def_value |
|
) |
| |
Reduce a bunch of values attached to the elemens in the leaves of a tree. The Tree_visitor template type has to provide the following interface:
struct Tree_visitor
{
uint32 get_node_count() const;
uint32 get_leaf_count() const;
uint32 get_child_count(const uint32 node) const;
uint32 get_child(const uint32 node, const uint32 i) const;
uint32 get_parent(const uint32 node) const;
uint2 get_leaf_range(const uint32 node) const;
uint2 get_range_size(const uint32 node) const;
bool has_leaf_pointers() const;
uint32 get_leaf_node(const uint32 i) const;
};
The following code snippet illustrates an example usage:
#include <cugar/tree/cuda/tree_reduce.h>
#include <cugar/tree/model.h>
struct merge_op
{
CUGAR_HOST_DEVICE Bbox4f operator() (
const Bbox4f op1,
const Bbox4f op2) const { return Bbox4f( op1, op2 ); }
};
void compute_bboxes(
uint32 node_count,
uint32 leaf_count,
Bvh_node* nodes,
uint32* parents,
Bbox4f* prim_bboxes,
Bbox4f* node_bboxes)
{
Bintree_visitor<Bvh_node> bvh(
node_count,
leaf_count,
nodes,
parents,
NULL,
NULL );
bvh,
prim_bboxes,
node_bboxes,
merge_op(),
Bbox4f() );
}
◆ tree_reduce() [2/4]
template<typename Tree_visitor , typename Input_iterator , typename Output_iterator , typename Operator , typename Value_type >
| void cugar::tree_reduce |
( |
const Tree_visitor |
tree, |
|
|
const Input_iterator |
in_values, |
|
|
Output_iterator |
node_values, |
|
|
const Operator |
op, |
|
|
const Value_type |
def_value |
|
) |
| |
Reduce a bunch of values attached to the elemens in the leaves of a tree. The Tree_visitor template type has to provide the following interface:
struct Tree_visitor
{
uint32 get_node_count() const;
uint32 get_leaf_count() const;
uint32 get_child_count(const uint32 node) const;
uint32 get_child(const uint32 node, const uint32 i) const;
uint32 get_parent(const uint32 node) const;
uint2 get_leaf_range(const uint32 node) const;
uint2 get_range_size(const uint32 node) const;
bool has_leaf_pointers() const;
uint32 get_leaf_node(const uint32 i) const;
};
The following code snippet illustrates an example usage:
#include <cugar/tree/cuda/tree_reduce.h>
#include <cugar/tree/model.h>
struct merge_op
{
CUGAR_HOST_DEVICE Bbox4f operator() (
const Bbox4f op1,
const Bbox4f op2) const { return Bbox4f( op1, op2 ); }
};
void compute_bboxes(
uint32 node_count,
uint32 leaf_count,
Bvh_node* nodes,
uint32* parents,
Bbox4f* prim_bboxes,
Bbox4f* node_bboxes)
{
Bintree_visitor<Bvh_node>(
node_count,
leaf_count,
nodes,
parents,
NULL,
NULL );
bvh,
prim_bboxes,
node_bboxes,
merge_op(),
Bbox4f() );
}
◆ tree_reduce() [3/4]
template<typename Tree_visitor , typename Value_iterator , typename Operator >
| void cugar::tree_reduce |
( |
const Tree_visitor |
tree, |
|
|
Value_iterator |
values, |
|
|
const Operator |
op |
|
) |
| |
Reduce a bunch of values attached to the leaves of a tree, with a simple bottom-up propagation.
◆ tree_reduce() [4/4]
template<typename Tree_visitor , typename Value_iterator , typename Operator >
| void cugar::cuda::tree_reduce |
( |
const Tree_visitor |
tree, |
|
|
Value_iterator |
values, |
|
|
const Operator |
op |
|
) |
| |
Reduce a bunch of values attached to the leaves of a tree, with a simple bottom-up propagation.