EBGeometry  1.0
Public Types | Public Member Functions | Protected Attributes | List of all members
Octree::Node< Meta, Data > Class Template Reference

Octree class without anything special (this uses full tree representation rather than linear/pointerless). More...

#include <EBGeometry_Octree.hpp>

Inheritance diagram for Octree::Node< Meta, Data >:
Inheritance graph
[legend]
Collaboration diagram for Octree::Node< Meta, Data >:
Collaboration graph
[legend]

Public Types

using StopFunction = std::function< bool(const Node< Meta, Data > &a_node)>
 Function for deciding whether or not to split a node. More...
 
using MetaConstructor = std::function< Meta(const OctantIndex &a_index, const Meta &a_parentMeta)>
 For assigning meta-data to the child octs during the build process. More...
 
using DataConstructor = std::function< std::shared_ptr< Data >(const OctantIndex &a_index, const std::shared_ptr< Data > &a_parentData)>
 For assigning data to child octs during the build process. More...
 
using Updater = std::function< void(const Node< Meta, Data > &a_node)>
 Updater pattern for Node::traverse. This is called when visiting a leaf node. More...
 
using Visiter = std::function< bool(const Node< Meta, Data > &a_node)>
 Visiter pattern for Node::traverse. This is called on interior and leaf nodes. Must return true if we should query the node and false otherwise. More...
 
using Sorter = std::function< void(std::array< std::shared_ptr< const Node< Meta, Data > >, 8 > &a_children)>
 Sorter for traverse pattern. This is called on interior nodes for deciding which sub-tree to visit first. More...
 

Public Member Functions

 Node ()
 Default constructor.
 
virtual ~Node ()
 Destructor.
 
const std::array< std::shared_ptr< Node< Meta, Data > >, 8 > & getChildren () const noexcept
 Get children. More...
 
std::array< std::shared_ptr< Node< Meta, Data > >, 8 > & getChildren () noexcept
 Get children. More...
 
Meta & getMetaData () noexcept
 Get node meta-data. More...
 
const Meta & getMetaData () const noexcept
 Get node meta-data. More...
 
std::shared_ptr< Data > & getData () noexcept
 Get node data. More...
 
const std::shared_ptr< Data > & getData () const noexcept
 Get node data. More...
 
bool isLeaf () const noexcept
 Check if this is a leaf node.
 
void buildDepthFirst (const StopFunction &a_stopFunction, const MetaConstructor &a_metaConstructor, const DataConstructor &a_dataConstructor) noexcept
 Build the octree in depth-first order. User decides if the node should be split, and how to split it. More...
 
void buildBreadthFirst (const StopFunction &a_stopFunction, const MetaConstructor &a_metaConstructor, const DataConstructor &a_dataConstructor) noexcept
 Build the octree in breadth-first order. User decides if the node should be split, and how to split it. More...
 
void traverse (const Updater &a_updater, const Visiter &a_visiter, const Sorter &a_sorter=[](std::array< std::shared_ptr< const Node< Meta, Data >>, 8 > &a_children) -> void { return;}) const noexcept
 Traverse the tree. More...
 

Protected Attributes

Meta m_meta
 Meta-data for the node. This is typically the lower-left and upper-right corners of the node, but it's the users' responsibility to fill this with the meta-information they need for the tree.
 
std::shared_ptr< Data > m_data
 Node contents.
 
std::array< std::shared_ptr< Node< Meta, Data > >, 8 > m_children
 Node children.
 

Detailed Description

template<typename Meta, typename Data = void>
class Octree::Node< Meta, Data >

Octree class without anything special (this uses full tree representation rather than linear/pointerless).

Meta is the meta-data for the node (user can put in e.g. level, volume, etc) and Data is the leaf node contents.

Note
This class should only be used with smart pointers. I.e. std::shared_ptr<Node> rather than Node.

Member Typedef Documentation

◆ DataConstructor

template<typename Meta , typename Data = void>
using Octree::Node< Meta, Data >::DataConstructor = std::function<std::shared_ptr<Data>(const OctantIndex& a_index, const std::shared_ptr<Data>& a_parentData)>

For assigning data to child octs during the build process.

Parameters
[in]a_indexOctant index
[in]a_parentDataParent data.

◆ MetaConstructor

template<typename Meta , typename Data = void>
using Octree::Node< Meta, Data >::MetaConstructor = std::function<Meta(const OctantIndex& a_index, const Meta& a_parentMeta)>

For assigning meta-data to the child octs during the build process.

Parameters
[in]a_indexOctant index
[in]a_parentMetaParent meta data

◆ Sorter

template<typename Meta , typename Data = void>
using Octree::Node< Meta, Data >::Sorter = std::function<void(std::array<std::shared_ptr<const Node<Meta, Data> >, 8>& a_children)>

Sorter for traverse pattern. This is called on interior nodes for deciding which sub-tree to visit first.

Parameters
[in,out]a_childrenSortable children nodes, first node is visited first, then the second, etc.

◆ StopFunction

template<typename Meta , typename Data = void>
using Octree::Node< Meta, Data >::StopFunction = std::function<bool(const Node<Meta, Data>& a_node)>

Function for deciding whether or not to split a node.

This is called on leaf nodes – if the function returns true the node will be split.

Parameters
[in]a_nodeNode to split.

◆ Updater

template<typename Meta , typename Data = void>
using Octree::Node< Meta, Data >::Updater = std::function<void(const Node<Meta, Data>& a_node)>

Updater pattern for Node::traverse. This is called when visiting a leaf node.

Parameters
[in]a_nodeLeaf node that is visited.

◆ Visiter

template<typename Meta , typename Data = void>
using Octree::Node< Meta, Data >::Visiter = std::function<bool(const Node<Meta, Data>& a_node)>

Visiter pattern for Node::traverse. This is called on interior and leaf nodes. Must return true if we should query the node and false otherwise.

Parameters
[in]a_nodeNode to visit or not.

Member Function Documentation

◆ buildBreadthFirst()

template<typename Meta , typename Data = void>
void Octree::Node< Meta, Data >::buildBreadthFirst ( const StopFunction a_stopFunction,
const MetaConstructor a_metaConstructor,
const DataConstructor a_dataConstructor 
)
inlinenoexcept

Build the octree in breadth-first order. User decides if the node should be split, and how to split it.

Parameters
[in]a_stopFunctionFunction for deciding whether or not to split a node.
[in]a_metaConstructorConstructor for node meta-data
[in]a_dataConstructorConstructor for node data

◆ buildDepthFirst()

template<typename Meta , typename Data = void>
void Octree::Node< Meta, Data >::buildDepthFirst ( const StopFunction a_stopFunction,
const MetaConstructor a_metaConstructor,
const DataConstructor a_dataConstructor 
)
inlinenoexcept

Build the octree in depth-first order. User decides if the node should be split, and how to split it.

Parameters
[in]a_stopFunctionFunction for deciding whether or not to split a node.
[in]a_metaConstructorConstructor for node meta-data
[in]a_dataConstructorConstructor for node data

◆ getChildren() [1/2]

template<typename Meta , typename Data = void>
const std::array<std::shared_ptr<Node<Meta, Data> >, 8>& Octree::Node< Meta, Data >::getChildren ( ) const
inlinenoexcept

Get children.

Returns
m_children

◆ getChildren() [2/2]

template<typename Meta , typename Data = void>
std::array<std::shared_ptr<Node<Meta, Data> >, 8>& Octree::Node< Meta, Data >::getChildren ( )
inlinenoexcept

Get children.

Returns
m_children

◆ getData() [1/2]

template<typename Meta , typename Data = void>
const std::shared_ptr<Data>& Octree::Node< Meta, Data >::getData ( ) const
inlinenoexcept

Get node data.

Returns
m_data

◆ getData() [2/2]

template<typename Meta , typename Data = void>
std::shared_ptr<Data>& Octree::Node< Meta, Data >::getData ( )
inlinenoexcept

Get node data.

Returns
m_data

◆ getMetaData() [1/2]

template<typename Meta , typename Data = void>
const Meta& Octree::Node< Meta, Data >::getMetaData ( ) const
inlinenoexcept

Get node meta-data.

Returns
m_meta

◆ getMetaData() [2/2]

template<typename Meta , typename Data = void>
Meta& Octree::Node< Meta, Data >::getMetaData ( )
inlinenoexcept

Get node meta-data.

Returns
m_meta

◆ traverse()

template<typename Meta , typename Data = void>
void Octree::Node< Meta, Data >::traverse ( const Updater a_updater,
const Visiter a_visiter,
const Sorter a_sorter = [](std::array< std::shared_ptr< const Node< Meta, Data >>, 8 > &a_children) -> void { return;} 
) const
inlinenoexcept

Traverse the tree.

Parameters
[in]a_updaterUpdater when visiting leaf nodes.
[in]a_visiterVisiter for deciding to visit a node.
[in]a_sorterSorter method for deciding which subtree to investigate first.

The documentation for this class was generated from the following file: