supereight
Loading...
Searching...
No Matches
node.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016-2019 Emanuele Vespa
3 * SPDX-FileCopyrightText: 2019-2025 Smart Robotics Lab, Imperial College London, Technical University of Munich
4 * SPDX-FileCopyrightText: 2019-2021 Nils Funk
5 * SPDX-FileCopyrightText: 2019-2025 Sotiris Papatheodorou
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef SE_NODE_HPP
10#define SE_NODE_HPP
11
12namespace se {
13
14template<typename DataT, Res ResT>
15class Node;
16
21template<typename DataT, Res ResT>
22struct NodeData {
26 const DataT& data() const
27 {
28 static const DataT default_data;
29 return default_data;
30 }
31
32 protected:
34 {
35 }
36};
37
38
39
43template<Colour ColB, Semantics SemB, Res ResT>
46
51
53 const DataType& data() const
54 {
55 static const DataType default_data = DataType();
56 return (max_data.field.observed && derived()->isLeaf()) ? max_data : default_data;
57 }
58
59 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60
61 protected:
64 {
65 min_data = init_data;
66 max_data = init_data;
67 }
68
69 private:
71 const Node<DataType, ResT>* derived() const
72 {
73 return static_cast<const Node<DataType, ResT>*>(this);
74 }
75};
76
77
78
86template<typename DataT, Res ResT>
87class Node : public OctantBase, public NodeData<DataT, ResT> {
88 public:
89 typedef DataT DataType;
90
97 Node(const Eigen::Vector3i& coord, const int size, const DataT& init_data);
98
102 Node(Node* const parent_ptr, const int child_idx, const DataT& init_data);
103
107 const OctantBase* getChild(const int child_idx) const;
108
111
115 void setChild(const int child_idx, OctantBase* const child_ptr);
116
118 Eigen::Vector3i getChildCoord(const int child_idx) const;
119
126 int getChildIdx(const Eigen::Vector3i& child_coord) const;
127
128 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
129
130 private:
131 // Pointers to the eight node children. Must be nullptr for unallocated children.
132 std::array<OctantBase*, 8> children_ptr_;
133
134 public:
136 const int size;
137};
138
139} // namespace se
140
141#include "impl/node_impl.hpp"
142
143#endif // SE_NODE_HPP
Definition image.hpp:19
An intermediate node of an se::Octree.
Definition node.hpp:87
const int size
The edge length of the node in voxels.
Definition node.hpp:136
DataT DataType
Definition node.hpp:89
OctantBase * getChild(const int child_idx)
A non-const overload of the previous member function.
int getChildIdx(const Eigen::Vector3i &child_coord) const
Return the index of the child of the node with coordinates child_coord.
Node(const Eigen::Vector3i &coord, const int size, const DataT &init_data)
Construct a node at coordinates coord in voxels, with an edge length size in voxels and initialize it...
Node(Node *const parent_ptr, const int child_idx, const DataT &init_data)
Construct the child node of parent_ptr with index child_idx and initialize its data with init_data.
Eigen::Vector3i getChildCoord(const int child_idx) const
Return the coordinates in voxels of the child with index child_idx.
void setChild(const int child_idx, OctantBase *const child_ptr)
Set the node child with index child_idx to child_ptr.
const OctantBase * getChild(const int child_idx) const
Return a pointer to the node child with index child_idx.
The base class of all octants (se::Node and se::Block) in an se::Octree.
Definition octant.hpp:19
const Eigen::Vector3i coord
The coordinates in voxels of the octant's vertex closest to the origin.
Definition octant.hpp:26
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14
Field
Definition setup_util.hpp:18
Definition data.hpp:19
FieldType field
Definition data.hpp:24
DataType max_data
The maximum data among the node's children or the node's data if it's a leaf.
Definition node.hpp:50
Data< Field::Occupancy, ColB, SemB > DataType
Definition node.hpp:45
NodeData(const DataType &init_data)
Construct a node with both its minimum and maximum data initialized to init_data.
Definition node.hpp:63
DataType min_data
The minimum data among the node's children or the node's data if it's a leaf.
Definition node.hpp:48
const DataType & data() const
Return NodeData::max_data if the node is observed and a leaf, the default data otherwise.
Definition node.hpp:53
Contains se::Data stored in se::Node and appropriate methods.
Definition node.hpp:22
NodeData(const DataT &)
Definition node.hpp:33
const DataT & data() const
Always returns the default data.
Definition node.hpp:26