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, Id IdB,
int BlockSize,
typename DerivedT>
66template<Colour ColB, Id IdB,
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, Id IdB,
int BlockSize,
typename DerivedT>
183 int current_scale = max_scale;
262 assert(!block_data_.empty());
263 assert(block_data_.front());
264 return block_data_[0][0];
274 assert(!block_min_data_.empty());
275 assert(block_min_data_.front());
276 return block_min_data_[0][0];
288 assert(!block_max_data_.empty());
289 assert(block_max_data_.front());
290 return block_max_data_[0][0];
303 return curr_integr_count_;
311 return curr_observed_count_;
319 curr_integr_count_++;
346 return buffer_scale_;
350 return buffer_integr_count_;
354 return buffer_observed_count_;
513 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
516 std::vector<DataType*> block_data_;
517 std::vector<DataType*> block_min_data_;
518 std::vector<DataType*> block_max_data_;
521 size_t curr_integr_count_;
522 size_t curr_observed_count_;
548 int buffer_scale_ = -1;
550 buffer_integr_count_;
551 size_t buffer_observed_count_;
553 const DerivedT* underlying()
const
555 return static_cast<const DerivedT*
>(
this);
567template<
typename DataT, Res ResT,
int BlockSize>
569 public std::conditional<
571 BlockSingleRes<DataT, BlockSize, Block<DataT, ResT, BlockSize>>,
572 BlockMultiRes<DataT, BlockSize, Block<DataT, ResT, BlockSize>>>::type
598#include "impl/block_impl.hpp"
int buffer_scale() const
Definition block.hpp:344
DataType & bufferData(const int voxel_idx)
Get a reference to the voxel data in the buffer at the voxel index.
Definition block.hpp:442
const DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
bool switchData()
Check if the scale should be switched from the current scale to the recommended.
void initCurrCout()
When a block is initialised from an observed block (i.e.
void incrCurrIntegrCount()
Increment the number of integrations at the current scale by 1.
Definition block.hpp:317
BlockMultiRes(const Block< Data< Field::Occupancy, ColB, IdB >, Res::Multi, BlockSize > &block)
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale) const
Get data at scale.
DataType & minData(const Eigen::Vector3i &voxel_coord)
DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
void incrCurrObservedCount(bool do_increment=true)
Increment the number of observed voxels in at the current scale by 1.
const DataType & minData() const
Get the block's min data at the coarsest scale.
Definition block.hpp:272
void initBuffer(const int buffer_scale)
Init buffer variables.
const DataType & maxData() const
Get the block's max data at the coarsest scale.
Definition block.hpp:286
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
void operator=(const Block< Data< Field::Occupancy, ColB, IdB >, Res::Multi, BlockSize > &block)
const DataType & data(const Eigen::Vector3i &voxel_coord) const
Get data at current scale.
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 * blockMaxDataAtScale(const int scale)
Get a pointer to the max block data array at a given scale.
BlockMultiRes(const DataType init_data=DataType())
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:425
size_t bufferObservedCount() const
Definition block.hpp:352
DataType * blockDataAtScale(const int scale)
Get a pointer to the mean block data array at a given scale.
int getVoxelIdx(const Eigen::Vector3i &voxel_coord, const int scale) const
size_t currObservedCount() const
Get the number of observed voxels at the current scale.
Definition block.hpp:309
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
Get data at current scale or coarser.
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)
void incrBufferIntegrCount(const bool do_increment=true)
Increment the buffer count if incrementation criterion is met.
DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale)
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale)
DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale)
void resetBufferCount()
Reset the buffer integration and observation count to 0.
const DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale) const
DataType & data(const Eigen::Vector3i &voxel_coord)
void resetBuffer()
Reset buffer variables to the initial values and free the buffer data if applicable.
const DataType & maxData(const Eigen::Vector3i &voxel_coord) const
Data< Field::Occupancy, ColB, IdB > DataType
Definition block.hpp:179
const DataType & minData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out) const
DataType & bufferData(const Eigen::Vector3i &voxel_coord)
Get a reference to the voxel data in the buffer at the voxel coordinates.
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:476
const DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale) const
size_t currIntegrCount() const
Get the number of integrations at the current scale.
Definition block.hpp:301
const std::vector< DataType * > & blockData() const
Definition block.hpp:293
const DataType & minData(const Eigen::Vector3i &voxel_coord) const
DataType * blockMinDataAtScale(const int scale)
Get a pointer to the min block data array at a given scale.
DataType init_data
Definition block.hpp:184
size_t bufferIntegrCount() const
Definition block.hpp:348
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:459
DataType & maxData(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
void deleteUpTo(const int new_min_scale)
Delete the mip-mapped scales up to 'new_min_scale'.
const DataType & data() const
Get the block's data at the coarsest scale.
Definition block.hpp:260
void incrBufferObservedCount(const bool do_increment=true)
Increment the number of observed voxels at the buffers scale by 1.
void resetCurrCount()
Reset the current integration and observation count to 0.
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale_in, int &scale_out)
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 Eigen::Vector3i &voxel_coord)
const DataType & data(const Eigen::Vector3i &voxel_coord, const int scale) const
Get data at scale.
Data< Field::TSDF, ColB, IdB > DataType
Definition block.hpp:69
DataUnion dataUnion(const Eigen::Vector3i &voxel_coord, const int scale)
DataType & data(const int voxel_idx)
BlockMultiRes(const DataType init_data=DataType())
const DataType & data(const int voxel_idx) const
Get data at current scale.
const DataType & data() const
Get coarsest block data.
int getVoxelIdx(const Eigen::Vector3i &voxel_coord, const int scale) const
const DataType & data(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.
DataType & data(const Eigen::Vector3i &voxel_coord, const int scale)
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:574
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition block.hpp:593
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:581
DataT DataType
Definition block.hpp:576
static constexpr int size_cu
The volume of the block in voxels.
Definition block.hpp:583
static constexpr int size
The edge length of the block in voxels.
Definition block.hpp:579
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
const int data_idx
Definition block.hpp:83
PastDataType & past_data
Definition block.hpp:82
DataType & data
Definition block.hpp:81