Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a compilation issue with min() and max() methods on the stencils #1673

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions openvdb/openvdb/math/Stencils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class BaseStencil
typedef typename GridT::ValueType ValueType;
typedef tree::ValueAccessor<const TreeType, IsSafe> AccessorType;
typedef std::vector<ValueType> BufferType;
typedef typename BufferType::iterator IterType;

/// @brief Initialize the stencil buffer with the values of voxel (i, j, k)
/// and its neighbors.
Expand Down Expand Up @@ -146,14 +145,14 @@ class BaseStencil
/// @brief Return the smallest value in the stencil buffer.
inline ValueType min() const
{
IterType iter = std::min_element(mValues.begin(), mValues.end());
const auto iter = std::min_element(mValues.begin(), mValues.end());
return *iter;
}

/// @brief Return the largest value in the stencil buffer.
inline ValueType max() const
{
IterType iter = std::max_element(mValues.begin(), mValues.end());
const auto iter = std::max_element(mValues.begin(), mValues.end());
return *iter;
}

Expand Down
1 change: 1 addition & 0 deletions openvdb/openvdb/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ else()
TestQuat.cc
TestRay.cc
TestStats.cc
TestStencils.cc
TestStream.cc
TestStreamCompression.cc
TestStringMetadata.cc
Expand Down
40 changes: 40 additions & 0 deletions openvdb/openvdb/unittest/TestStencils.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0

#include <openvdb/openvdb.h>
#include <openvdb/math/Stencils.h>

#include <gtest/gtest.h>


class TestStencils : public ::testing::Test
{
};

TEST_F(TestStencils, testMinMax)
{
using namespace openvdb;

Int32Grid grid;
grid.tree().setValue(math::Coord(0,0,0), -3);
grid.tree().setValue(math::Coord(0,0,1), -2);
grid.tree().setValue(math::Coord(0,1,0), -1);
grid.tree().setValue(math::Coord(1,0,0), 0);
grid.tree().setValue(math::Coord(1,1,0), 1);
grid.tree().setValue(math::Coord(0,1,1), 2);
grid.tree().setValue(math::Coord(1,0,1), 3);
grid.tree().setValue(math::Coord(1,1,1), 4);
math::BoxStencil<Int32Grid> stencil(grid);

stencil.moveTo(Coord(0,0,0));
EXPECT_EQ(stencil.min(), -3);
EXPECT_EQ(stencil.max(), 4);

stencil.moveTo(Coord(1,1,1));
EXPECT_EQ(stencil.min(), 0);
EXPECT_EQ(stencil.max(), 4);

stencil.moveTo(Coord(0,0,1));
EXPECT_EQ(stencil.min(), -2);
EXPECT_EQ(stencil.max(), 4);
}
5 changes: 5 additions & 0 deletions pendingchanges/stencil_minmax.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
OpenVDB:
- Bug Fixes:
Fixed a compilation issue with the min() and max() methods on Stencils
in openvdb/math/Stencils.h
[Reported by Samuel Mauch]
Loading