15template<
typename DataT, Res ResT>
23template<
typename DataT,
int BlockSize,
typename DerivedT>
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
44 std::array<DataType, BlockSize * BlockSize * BlockSize> block_data_;
46 const DerivedT* underlying()
const
48 return static_cast<const DerivedT*
>(
this);
54template<
typename DataT,
int BlockSize,
typename DerivedT>
60template<Field FldT, Colour ColB, Semantics SemB,
int BlockSize,
typename DerivedT>
66template<Colour ColB, Semantics SemB,
int BlockSize,
typename DerivedT>
88 int current_scale = -1;
123 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
126 static constexpr int compute_num_voxels()
135 static constexpr std::array<int, max_scale + 1> compute_size_at_scales()
137 std::array<int, max_scale + 1> size_at_scales{};
138 for (
int size_at_scale = BlockSize, scale = 0; size_at_scale > 0;
139 size_at_scale /= 2, scale++) {
140 size_at_scales[scale] = size_at_scale;
142 return size_at_scales;
145 static constexpr std::array<int, max_scale + 1> compute_scale_offsets()
147 std::array<int, max_scale + 1> scale_offsets{0};
148 for (
int size_at_scale = BlockSize, scale = 1; size_at_scale > 1;
149 size_at_scale /= 2, scale++) {
150 scale_offsets[scale] = scale_offsets[scale - 1] +
math::cu(size_at_scale);
152 return scale_offsets;
155 static constexpr int num_voxels_ = compute_num_voxels();
156 static constexpr std::array<int, max_scale + 1> size_at_scales_ = compute_size_at_scales();
157 static constexpr std::array<int, max_scale + 1> scale_offsets_ = compute_scale_offsets();
159 std::array<DataType, num_voxels_> block_data_;
160 std::array<PastDataType, num_voxels_> block_past_data_;
162 const DerivedT* underlying()
const
164 return static_cast<const DerivedT*
>(
this);
171template<
typename DataT, Res ResT,
int BlockSize>
176template<Colour ColB, Semantics SemB,
int BlockSize,
typename DerivedT>
183 int current_scale = max_scale;
273 assert(!block_data_.empty());
274 assert(block_data_.front());
275 return block_data_[0][0];
285 assert(!block_min_data_.empty());
286 assert(block_min_data_.front());
287 return block_min_data_[0][0];
299 assert(!block_max_data_.empty());
300 assert(block_max_data_.front());
301 return block_max_data_[0][0];
316 return block_min_data_;
321 return block_min_data_;
326 return block_max_data_;
331 return block_max_data_;
339 return curr_integr_count_;
347 return curr_observed_count_;
355 curr_integr_count_++;
382 return buffer_scale_;
386 return buffer_integr_count_;
390 return buffer_observed_count_;
549 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
560 std::vector<DataType*> block_data_;
561 std::vector<DataType*> block_min_data_;
562 std::vector<DataType*> block_max_data_;
564 DataType* curr_data_ =
nullptr;
565 size_t curr_integr_count_;
566 size_t curr_observed_count_;
591 DataType* buffer_data_ =
nullptr;
592 int buffer_scale_ = -1;
594 buffer_integr_count_;
595 size_t buffer_observed_count_;
599 const DerivedT* underlying()
const
601 return static_cast<const DerivedT*
>(
this);
613template<
typename DataT, Res ResT,
int BlockSize>
615 public std::conditional<
617 BlockSingleRes<DataT, BlockSize, Block<DataT, ResT, BlockSize>>,
618 BlockMultiRes<DataT, BlockSize, Block<DataT, ResT, BlockSize>>>::type
644#include "impl/block_impl.hpp"
const std::vector< DataType * > & blockMinData() const
Definition block.hpp:314
const DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale) const
const DataType & bufferData(const int voxel_idx) const
Get a const reference to the voxel data in the buffer at the voxel index.
Definition block.hpp:461
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale) const
Get data at scale.
std::vector< DataType * > & blockData()
Definition block.hpp:309
DataType * blockMinDataAtScale(const int scale)
Get a pointer to the min block data array at a given scale.
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
const std::vector< DataType * > & blockMaxData() const
Definition block.hpp:324
void incrBufferObservedCount(const bool do_increment=true)
Increment the number of observed voxels at the buffers scale by 1.
const DataType & minData() const
Get the block's min data at the coarsest scale.
Definition block.hpp:283
DataType & currData(const int voxel_idx)
Get a reference to the mean voxel data at the current scale via the voxel index.
Definition block.hpp:512
Data< Field::Occupancy, ColB, SemB > DataType
Definition block.hpp:179
void incrCurrObservedCount(bool do_increment=true)
Increment the number of observed voxels in at the current scale by 1.
void incrCurrIntegrCount()
Increment the number of integrations at the current scale by 1.
Definition block.hpp:353
DataType & maxData(const Eigen::Vector3i &voxel_coord)
const DataType & initData() const
Get init block data.
Definition block.hpp:195
const DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
const DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale)
void resetBuffer()
Reset buffer variables to the initial values and free the buffer data if applicable.
const DataType & maxData() const
Get the block's max data at the coarsest scale.
Definition block.hpp:297
DataType & minData(const Eigen::Vector3i &voxel_coord)
void resetCurrCount()
Reset the current integration and observation count to 0.
int buffer_scale() const
Definition block.hpp:380
BlockMultiRes(const Block< Data< Field::Occupancy, ColB, SemB >, Res::Multi, BlockSize > &block)
size_t currIntegrCount() const
Get the number of integrations at the current scale.
Definition block.hpp:337
void initBuffer(const int buffer_scale)
Init buffer variables.
size_t bufferIntegrCount() const
Definition block.hpp:384
int getVoxelIdx(const Eigen::Vector3i &voxel_coord, const int scale) const
DataType & bufferData(const int voxel_idx)
Get a reference to the voxel data in the buffer at the voxel index.
Definition block.hpp:478
std::vector< DataType * > & blockMinData()
Definition block.hpp:319
void initCurrCout()
When a block is initialised from an observed block (i.e.
const std::vector< DataType * > & blockData() const
Definition block.hpp:304
void resetBufferCount()
Reset the buffer integration and observation count to 0.
void incrBufferIntegrCount(const bool do_increment=true)
Increment the buffer count if incrementation criterion is met.
const DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale) const
void deleteUpTo(const int new_min_scale)
Delete the mip-mapped scales up to 'new_min_scale'.
DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale)
std::vector< DataType * > & blockMaxData()
Definition block.hpp:329
size_t currObservedCount() const
Get the number of observed voxels at the current scale.
Definition block.hpp:345
size_t bufferObservedCount() const
Definition block.hpp:388
const DataType & currData(const int voxel_idx) const
Get a const reference to the mean voxel data at the current scale via the voxel index.
Definition block.hpp:495
bool switchData()
Check if the scale should be switched from the current scale to the recommended.
DataType & initData()
Definition block.hpp:200
DataType * blockDataAtScale(const int scale)
Get a pointer to the mean block data array at a given scale.
const DataType & data() const
Get the block's data at the coarsest scale.
Definition block.hpp:271
void allocateDownTo(const int new_min_scale=0)
Allocate the mip-mapped scales down to 'new_min_scale'.
DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale)
DataType & data(const Eigen::Vector3i &voxel_coord)
DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
const DataType & data(const Eigen::Vector3i &voxel_coord) const
Get data at current scale.
const DataType & maxData(const Eigen::Vector3i &voxel_coord) const
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
Get data at current scale or coarser.
void operator=(const Block< Data< Field::Occupancy, ColB, SemB >, Res::Multi, BlockSize > &block)
DataType * blockMaxDataAtScale(const int scale)
Get a pointer to the max block data array at a given scale.
DataType & bufferData(const Eigen::Vector3i &voxel_coord)
Get a reference to the voxel data in the buffer at the voxel coordinates.
BlockMultiRes(const DataType init_data=DataType())
DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
const DataType & minData(const Eigen::Vector3i &voxel_coord) const
const DataType & bufferData(const Eigen::Vector3i &voxel_coord) const
Get a const reference to the voxel data in the buffer at the voxel coordinates.
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale)
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale) const
Get data at scale.
int getVoxelIdx(const Eigen::Vector3i &voxel_coord, const int scale) const
DataType & data(const Eigen::Vector3i &voxel_coord)
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
const DataType & data(const Eigen::Vector3i &voxel_coord) const
BlockMultiRes(const DataType init_data=DataType())
const DataType & data() const
Get coarsest block data.
Data< Field::TSDF, ColB, SemB > DataType
Definition block.hpp:69
const DataType & data(const int voxel_idx) const
Get data at current scale.
DataUnion dataUnion(const Eigen::Vector3i &voxel_coord, const int scale)
DataType PastDataType
Contains data from a previous point in time which is used to compute changes over time for delta down...
Definition block.hpp:74
DataType & data(const int voxel_idx)
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
Get data at current scale or coarser.
The base used for single-resolution blocks.
Definition block.hpp:24
DataType & data(const Eigen::Vector3i &voxel_coord)
const DataType & data(const Eigen::Vector3i &voxel_coord) const
DataT DataType
Definition block.hpp:26
DataType & data(const int voxel_idx)
static constexpr int min_scale
Definition block.hpp:28
BlockSingleRes(const DataType init_data=DataType())
const DataType & data(const int voxel_idx) const
static constexpr int current_scale
Definition block.hpp:29
A leaf node of an se::Octree.
Definition block.hpp:620
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition block.hpp:639
Block(Node< DataT, ResT > *parent_ptr, const int child_idx, const DataT init_data)
Construct the child block of parent_ptr with index child_idx and initialize its data at the coarsest ...
static constexpr int size_sq
The face area of the block in voxels.
Definition block.hpp:627
DataT DataType
Definition block.hpp:622
static constexpr int size_cu
The volume of the block in voxels.
Definition block.hpp:629
static constexpr int size
The edge length of the block in voxels.
Definition block.hpp:625
The base class of all octants (se::Node and se::Block) in an se::Octree.
Definition octant.hpp:19
constexpr Scalar cu(Scalar a)
constexpr bool is_power_of_two(const T x)
constexpr int log2_const(int n)
constexpr Scalar sq(Scalar a)
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14
Field
Definition setup_util.hpp:18
const Eigen::Vector3i coord
Definition block.hpp:79
const int scale
Definition block.hpp:80
PastDataType & past_data
Definition block.hpp:82
DataType & data
Definition block.hpp:81
const int data_idx
Definition block.hpp:83