Skip to content

Commit

Permalink
Update crop method argument names to be consistent with sum
Browse files Browse the repository at this point in the history
  • Loading branch information
victorreijgwart committed Dec 18, 2024
1 parent c19f5bb commit 345f198
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions library/cpp/include/wavemap/core/utils/edit/crop.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ namespace detail {
template <typename MapT, typename ShapeT>
void cropLeavesBatch(typename MapT::Block::OctreeType::NodeRefType node,
const OctreeIndex& node_index, FloatingPoint& node_value,
ShapeT&& shape, FloatingPoint min_cell_width);
ShapeT&& mask, FloatingPoint min_cell_width);

template <typename MapT, typename ShapeT>
void cropNodeRecursive(typename MapT::Block::OctreeType::NodeRefType node,
const OctreeIndex& node_index, FloatingPoint& node_value,
ShapeT&& shape, FloatingPoint min_cell_width,
ShapeT&& mask, FloatingPoint min_cell_width,
IndexElement termination_height = 0);
} // namespace detail

template <typename MapT, typename ShapeT>
void crop(MapT& map, ShapeT shape, IndexElement termination_height = 0,
void crop(MapT& map, ShapeT mask, IndexElement termination_height = 0,
const std::shared_ptr<ThreadPool>& thread_pool = nullptr);
} // namespace wavemap::edit

Expand Down
26 changes: 13 additions & 13 deletions library/cpp/include/wavemap/core/utils/edit/impl/crop_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace detail {
template <typename MapT, typename ShapeT>
void cropLeavesBatch(typename MapT::Block::OctreeType::NodeRefType node,
const OctreeIndex& node_index, FloatingPoint& node_value,
ShapeT&& shape, FloatingPoint min_cell_width) {
ShapeT&& mask, FloatingPoint min_cell_width) {
// Decompress child values
using Transform = typename MapT::Block::Transform;
auto& node_details = node.data();
Expand All @@ -23,7 +23,7 @@ void cropLeavesBatch(typename MapT::Block::OctreeType::NodeRefType node,
const OctreeIndex child_index = node_index.computeChildIndex(child_idx);
const Point3D t_W_child =
convert::nodeIndexToCenterPoint(child_index, min_cell_width);
if (!shape::is_inside(t_W_child, shape)) {
if (!shape::is_inside(t_W_child, mask)) {
child_values[child_idx] = 0.f;
if (0 < child_index.height) {
node.eraseChild(child_idx);
Expand All @@ -41,7 +41,7 @@ void cropLeavesBatch(typename MapT::Block::OctreeType::NodeRefType node,
template <typename MapT, typename ShapeT>
void cropNodeRecursive(typename MapT::Block::OctreeType::NodeRefType node,
const OctreeIndex& node_index, FloatingPoint& node_value,
ShapeT&& shape, FloatingPoint min_cell_width,
ShapeT&& mask, FloatingPoint min_cell_width,
IndexElement termination_height) {
using NodeRefType = decltype(node);

Expand All @@ -57,13 +57,13 @@ void cropNodeRecursive(typename MapT::Block::OctreeType::NodeRefType node,
const OctreeIndex child_index = node_index.computeChildIndex(child_idx);
const AABB<Point3D> child_aabb =
convert::nodeIndexToAABB(child_index, min_cell_width);
if (shape::is_inside(child_aabb, shape)) {
if (shape::is_inside(child_aabb, mask)) {
continue;
}

// If the node is fully outside the cropping shape, set it to zero
auto& child_value = child_values[child_idx];
if (!shape::overlaps(child_aabb, shape)) {
if (!shape::overlaps(child_aabb, mask)) {
child_value = 0.f;
node.eraseChild(child_idx);
continue;
Expand All @@ -72,10 +72,10 @@ void cropNodeRecursive(typename MapT::Block::OctreeType::NodeRefType node,
// Otherwise, continue at a higher resolution
NodeRefType child_node = node.getOrAllocateChild(child_idx);
if (child_index.height <= termination_height + 1) {
cropLeavesBatch<MapT>(child_node, child_index, child_value, shape,
cropLeavesBatch<MapT>(child_node, child_index, child_value, mask,
min_cell_width);
} else {
cropNodeRecursive<MapT>(child_node, child_index, child_value, shape,
cropNodeRecursive<MapT>(child_node, child_index, child_value, mask,
min_cell_width, termination_height);
}
}
Expand All @@ -88,7 +88,7 @@ void cropNodeRecursive(typename MapT::Block::OctreeType::NodeRefType node,
} // namespace detail

template <typename MapT, typename ShapeT>
void crop(MapT& map, ShapeT shape, IndexElement termination_height,
void crop(MapT& map, ShapeT mask, IndexElement termination_height,
const std::shared_ptr<ThreadPool>& thread_pool) {
using NodePtrType = typename MapT::Block::OctreeType::NodePtrType;
const IndexElement tree_height = map.getTreeHeight();
Expand All @@ -102,12 +102,12 @@ void crop(MapT& map, ShapeT shape, IndexElement termination_height,
const auto block_aabb =
convert::nodeIndexToAABB(block_node_index, min_cell_width);
// If the block is fully inside the cropping shape, do nothing
if (shape::is_inside(block_aabb, shape)) {
if (shape::is_inside(block_aabb, mask)) {
++it;
continue;
}
// If the block is fully outside the cropping shape, erase it entirely
if (!shape::overlaps(block_aabb, shape)) {
if (!shape::overlaps(block_aabb, mask)) {
it = map.getHashMap().erase(it);
continue;
}
Expand All @@ -123,16 +123,16 @@ void crop(MapT& map, ShapeT shape, IndexElement termination_height,
NodePtrType root_node_ptr = &block.getRootNode();
// Recursively crop all nodes
if (thread_pool) {
thread_pool->add_task([&shape, root_node_ptr, block_node_index,
thread_pool->add_task([&mask, root_node_ptr, block_node_index,
root_value_ptr, min_cell_width,
termination_height]() {
detail::cropNodeRecursive<MapT>(*root_node_ptr, block_node_index,
*root_value_ptr, shape, min_cell_width,
*root_value_ptr, mask, min_cell_width,
termination_height);
});
} else {
detail::cropNodeRecursive<MapT>(*root_node_ptr, block_node_index,
*root_value_ptr, shape, min_cell_width,
*root_value_ptr, mask, min_cell_width,
termination_height);
}
// Advance to the next block
Expand Down

0 comments on commit 345f198

Please sign in to comment.