Template Class Layer

Class Documentation

template <typename VoxelType>
class Layer

A 3D information layer, containing data of type VoxelType stored in blocks.

This class contains functions for manipulating and accessing these blocks.

Public Types

enum BlockMergingStrategy

Values:

kProhibit
kReplace
kDiscard
kMerge
typedef std::shared_ptr<Layer> Ptr
typedef Block<VoxelType> BlockType
typedef AnyIndexHashMapType<typename BlockType::Ptr>::type BlockHashMap
typedef std::pair<BlockIndex, typename BlockType::Ptr> BlockMapPair

Public Functions

Layer(FloatingPoint voxel_size, size_t voxels_per_side)
Layer(const LayerProto &proto)

Create the layer from protobuf layer header.

Layer(const Layer &other)

Deep copy constructor.

virtual ~Layer()
const BlockType &getBlockByIndex(const BlockIndex &index) const
BlockType &getBlockByIndex(const BlockIndex &index)
BlockType::ConstPtr getBlockPtrByIndex(const BlockIndex &index) const
BlockType::Ptr getBlockPtrByIndex(const BlockIndex &index)
BlockType::Ptr allocateBlockPtrByIndex(const BlockIndex &index)

Gets a block by the block index it if already exists, otherwise allocates a new one.

BlockType::ConstPtr getBlockPtrByCoordinates(const Point &coords) const
BlockType::Ptr getBlockPtrByCoordinates(const Point &coords)
BlockType::Ptr allocateBlockPtrByCoordinates(const Point &coords)

Gets a block by the coordinates it if already exists, otherwise allocates a new one.

BlockIndex computeBlockIndexFromCoordinates(const Point &coords) const

IMPORTANT NOTE: Due the limited accuracy of the FloatingPoint type, this function doesn’t always compute the correct block index for coordinates near the block boundaries.

BlockType::Ptr allocateNewBlock(const BlockIndex &index)
BlockType::Ptr allocateNewBlockByCoordinates(const Point &coords)
void insertBlock(const std::pair<const BlockIndex, typename Block<VoxelType>::Ptr> &block_pair)
void removeBlock(const BlockIndex &index)
void removeAllBlocks()
void removeBlockByCoordinates(const Point &coords)
void removeDistantBlocks(const Point &center, const double max_distance)
void getAllAllocatedBlocks(BlockIndexList *blocks) const
void getAllUpdatedBlocks(BlockIndexList *blocks) const
size_t getNumberOfAllocatedBlocks() const
bool hasBlock(const BlockIndex &block_index) const
const VoxelType *getVoxelPtrByGlobalIndex(const GlobalIndex &global_voxel_index) const

Get a pointer to the voxel if its corresponding block is allocated and a nullptr otherwise.

VoxelType *getVoxelPtrByGlobalIndex(const GlobalIndex &global_voxel_index)
const VoxelType *getVoxelPtrByCoordinates(const Point &coords) const
VoxelType *getVoxelPtrByCoordinates(const Point &coords)
FloatingPoint block_size() const
FloatingPoint block_size_inv() const
FloatingPoint voxel_size() const
FloatingPoint voxel_size_inv() const
size_t voxels_per_side() const
FloatingPoint voxels_per_side_inv() const
void getProto(LayerProto *proto) const
bool isCompatible(const LayerProto &layer_proto) const
bool isCompatible(const BlockProto &layer_proto) const
bool saveToFile(const std::string &file_path, bool clear_file = true) const
bool saveSubsetToFile(const std::string &file_path, BlockIndexList blocks_to_include, bool include_all_blocks, bool clear_file = true) const
bool saveBlocksToStream(bool include_all_blocks, BlockIndexList blocks_to_include, std::fstream *outfile_ptr) const
bool addBlockFromProto(const BlockProto &block_proto, BlockMergingStrategy strategy)
size_t getMemorySize() const

Protected Functions

std::string getType() const

Protected Attributes

FloatingPoint voxel_size_
size_t voxels_per_side_
FloatingPoint block_size_
FloatingPoint voxel_size_inv_
FloatingPoint block_size_inv_
FloatingPoint voxels_per_side_inv_
BlockHashMap block_map_