12 #ifndef EBGeometry_Octree
13 #define EBGeometry_Octree
74 template <
typename Meta,
typename Data =
void>
75 class Node :
public std::enable_shared_from_this<Node<Meta, Data>>
98 std::function<std::shared_ptr<Data>(
const OctantIndex& a_index,
const std::shared_ptr<Data>& a_parentData)>;
133 inline const std::array<std::shared_ptr<Node<Meta, Data>>, 8>&
140 inline std::array<std::shared_ptr<
Node<Meta, Data>>, 8>&
161 inline std::shared_ptr<Data>&
168 inline const std::shared_ptr<Data>&
209 const
Sorter& a_sorter = [](std::array<std::shared_ptr<const
Node<Meta, Data>>, 8>& a_children) ->
void {
234 #include "EBGeometry_OctreeImplem.hpp"
Declaration of 2D and 3D point/vector classes with templated precision. Used with DCEL tools.
Octree class without anything special (this uses full tree representation rather than linear/pointerl...
Definition: EBGeometry_Octree.hpp:76
const std::array< std::shared_ptr< Node< Meta, Data > >, 8 > & getChildren() const noexcept
Get children.
std::function< void(std::array< std::shared_ptr< const Node< Meta, Data > >, 8 > &a_children)> Sorter
Sorter for traverse pattern. This is called on interior nodes for deciding which sub-tree to visit fi...
Definition: EBGeometry_Octree.hpp:117
std::function< void(const Node< Meta, Data > &a_node)> Updater
Updater pattern for Node::traverse. This is called when visiting a leaf node.
Definition: EBGeometry_Octree.hpp:104
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,...
Node()
Default constructor.
std::function< bool(const Node< Meta, Data > &a_node)> StopFunction
Function for deciding whether or not to split a node.
Definition: EBGeometry_Octree.hpp:83
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.
std::function< bool(const Node< Meta, Data > &a_node)> Visiter
Visiter pattern for Node::traverse. This is called on interior and leaf nodes. Must return true if we...
Definition: EBGeometry_Octree.hpp:111
Meta & getMetaData() noexcept
Get node meta-data.
virtual ~Node()
Destructor.
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.
std::function< std::shared_ptr< Data >(const OctantIndex &a_index, const std::shared_ptr< Data > &a_parentData)> DataConstructor
For assigning data to child octs during the build process.
Definition: EBGeometry_Octree.hpp:98
std::shared_ptr< Data > m_data
Node contents.
Definition: EBGeometry_Octree.hpp:223
std::function< Meta(const OctantIndex &a_index, const Meta &a_parentMeta)> MetaConstructor
For assigning meta-data to the child octs during the build process.
Definition: EBGeometry_Octree.hpp:90
Meta m_meta
Meta-data for the node. This is typically the lower-left and upper-right corners of the node,...
Definition: EBGeometry_Octree.hpp:218
std::array< std::shared_ptr< Node< Meta, Data > >, 8 > m_children
Node children.
Definition: EBGeometry_Octree.hpp:228
std::shared_ptr< Data > & getData() noexcept
Get node data.
Three-dimensional vector class with arithmetic operators.
Definition: EBGeometry_Vec.hpp:218
static constexpr Vec3T< T > one() noexcept
Return av vector with x = y = z = 1.
Namespace for octree functionality.
Definition: EBGeometry_Octree.hpp:27
constexpr std::array< Vec3T< T >, 8 > LowCorner
Lower-left corners of the octants on the unit cube, indexed lexicographically in x-y-z.
Definition: EBGeometry_Octree.hpp:47
constexpr std::array< Vec3T< T >, 8 > HighCorner
Upper-right corners of the octants on the unit cube, indexed lexicographically in x-y-z.
Definition: EBGeometry_Octree.hpp:60
OctantIndex
Lexicographical x-y-z octant indexing.
Definition: EBGeometry_Octree.hpp:32