From a85ce2dc45dd318cf0e6df1fa707ec3372a9fd72 Mon Sep 17 00:00:00 2001 From: Lukas Schmid Date: Wed, 10 Mar 2021 15:41:26 +0100 Subject: [PATCH] refactor interfaces for getting/setting the updated bits --- voxblox/include/voxblox/core/block.h | 9 ++++----- voxblox/include/voxblox/core/block_inl.h | 2 +- voxblox/include/voxblox/core/layer.h | 2 +- voxblox/include/voxblox/core/layer_inl.h | 2 +- .../include/voxblox/integrator/occupancy_integrator.h | 4 ++-- voxblox/include/voxblox/mesh/mesh_integrator.h | 2 +- voxblox/src/integrator/esdf_integrator.cc | 5 ++--- voxblox/src/integrator/tsdf_integrator.cc | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/voxblox/include/voxblox/core/block.h b/voxblox/include/voxblox/core/block.h index 42abb6dd5..969604cd0 100644 --- a/voxblox/include/voxblox/core/block.h +++ b/voxblox/include/voxblox/core/block.h @@ -167,15 +167,14 @@ class Block { void setOrigin(const Point& new_origin) { origin_ = new_origin; } FloatingPoint block_size() const { return block_size_; } + bool updated(Update::Status status) const { return updated_[status]; } bool has_data() const { return has_data_; } - - const std::bitset& updated() const { return updated_; } - std::bitset& updated() { return updated_; } bool& has_data() { return has_data_; } - void set_updated(const std::bitset& updated) { - updated_ = updated; + void setUpdated(Update::Status status, bool value) { + updated_[status] = value; } + void setUpdatedAll() { updated_.set(); } void set_has_data(bool has_data) { has_data_ = has_data; } // Serialization. diff --git a/voxblox/include/voxblox/core/block_inl.h b/voxblox/include/voxblox/core/block_inl.h index 27dc87024..0477d646a 100644 --- a/voxblox/include/voxblox/core/block_inl.h +++ b/voxblox/include/voxblox/core/block_inl.h @@ -117,7 +117,7 @@ void Block::mergeBlock(const Block& other_block) { return; } else { has_data() = true; - updated().set(); + setUpdatedAll(); for (IndexElement voxel_idx = 0; voxel_idx < static_cast(num_voxels()); ++voxel_idx) { diff --git a/voxblox/include/voxblox/core/layer.h b/voxblox/include/voxblox/core/layer.h index 18b64cb22..4f0929fd0 100644 --- a/voxblox/include/voxblox/core/layer.h +++ b/voxblox/include/voxblox/core/layer.h @@ -196,7 +196,7 @@ class Layer { blocks->clear(); for (const std::pair& kv : block_map_) { - if (kv.second->updated()[bit]) { + if (kv.second->updated(bit)) { blocks->emplace_back(kv.first); } } diff --git a/voxblox/include/voxblox/core/layer_inl.h b/voxblox/include/voxblox/core/layer_inl.h index de041d5c3..cf5ae7569 100644 --- a/voxblox/include/voxblox/core/layer_inl.h +++ b/voxblox/include/voxblox/core/layer_inl.h @@ -224,7 +224,7 @@ bool Layer::addBlockFromProto(const BlockProto& block_proto, return false; } // Mark that this block has been updated. - block_map_[block_index]->updated().set(); + block_map_[block_index]->setUpdatedAll(); } else { LOG(ERROR) << "The blocks from this protobuf are not compatible with this layer!"; diff --git a/voxblox/include/voxblox/integrator/occupancy_integrator.h b/voxblox/include/voxblox/integrator/occupancy_integrator.h index 4a5082a2a..a99840465 100644 --- a/voxblox/include/voxblox/integrator/occupancy_integrator.h +++ b/voxblox/include/voxblox/integrator/occupancy_integrator.h @@ -147,7 +147,7 @@ class OccupancyIntegrator { if (!block || block_idx != last_block_idx) { block = layer_->allocateBlockPtrByIndex(block_idx); - block->updated().set(); + block->setUpdatedAll(); last_block_idx = block_idx; } @@ -165,7 +165,7 @@ class OccupancyIntegrator { if (!block || block_idx != last_block_idx) { block = layer_->allocateBlockPtrByIndex(block_idx); - block->updated().set(); + block->setUpdatedAll(); last_block_idx = block_idx; } diff --git a/voxblox/include/voxblox/mesh/mesh_integrator.h b/voxblox/include/voxblox/mesh/mesh_integrator.h index ce820df2e..d97264493 100644 --- a/voxblox/include/voxblox/mesh/mesh_integrator.h +++ b/voxblox/include/voxblox/mesh/mesh_integrator.h @@ -178,7 +178,7 @@ class MeshIntegrator { if (clear_updated_flag) { typename Block::Ptr block = sdf_layer_mutable_->getBlockPtrByIndex(block_idx); - block->updated().reset(Update::kMesh); + block->setUpdated(Update::kMesh, false); } } } diff --git a/voxblox/src/integrator/esdf_integrator.cc b/voxblox/src/integrator/esdf_integrator.cc index c7f187aae..e11bd41e4 100644 --- a/voxblox/src/integrator/esdf_integrator.cc +++ b/voxblox/src/integrator/esdf_integrator.cc @@ -114,8 +114,7 @@ void EsdfIntegrator::updateFromTsdfLayer(bool clear_updated_flag) { for (const BlockIndex& block_index : tsdf_blocks) { if (tsdf_layer_->hasBlock(block_index)) { tsdf_layer_->getBlockByIndex(block_index) - .updated() - .reset(Update::kEsdf); + .setUpdated(Update::kEsdf, false); } } } @@ -144,7 +143,7 @@ void EsdfIntegrator::updateFromTsdfBlocks(const BlockIndexList& tsdf_blocks, // Block indices are the same across all layers. Block::Ptr esdf_block = esdf_layer_->allocateBlockPtrByIndex(block_index); - esdf_block->set_updated(true); + esdf_block->setUpdated(Update::kEsdf, true); const size_t num_voxels_per_block = tsdf_block->num_voxels(); for (size_t lin_index = 0u; lin_index < num_voxels_per_block; ++lin_index) { diff --git a/voxblox/src/integrator/tsdf_integrator.cc b/voxblox/src/integrator/tsdf_integrator.cc index 40bf72249..28f733ecc 100644 --- a/voxblox/src/integrator/tsdf_integrator.cc +++ b/voxblox/src/integrator/tsdf_integrator.cc @@ -125,7 +125,7 @@ TsdfVoxel* TsdfIntegratorBase::allocateStorageAndGetVoxelPtr( } } - (*last_block)->updated().set(); + (*last_block)->setUpdatedAll(); const VoxelIndex local_voxel_idx = getLocalFromGlobalVoxelIndex(global_voxel_idx, voxels_per_side_);