Skip to content

Commit a7fd213

Browse files
committed
Fixed a compilation issue with min() and max() methods on the stencils
Signed-off-by: Nick Avramoussis <4256455+Idclip@users.noreply.github.com>
1 parent a46f498 commit a7fd213

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

openvdb/openvdb/math/Stencils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class BaseStencil
4040
typedef typename GridT::ValueType ValueType;
4141
typedef tree::ValueAccessor<const TreeType, IsSafe> AccessorType;
4242
typedef std::vector<ValueType> BufferType;
43-
typedef typename BufferType::iterator IterType;
4443

4544
/// @brief Initialize the stencil buffer with the values of voxel (i, j, k)
4645
/// and its neighbors.
@@ -146,14 +145,14 @@ class BaseStencil
146145
/// @brief Return the smallest value in the stencil buffer.
147146
inline ValueType min() const
148147
{
149-
IterType iter = std::min_element(mValues.begin(), mValues.end());
148+
const auto iter = std::min_element(mValues.begin(), mValues.end());
150149
return *iter;
151150
}
152151

153152
/// @brief Return the largest value in the stencil buffer.
154153
inline ValueType max() const
155154
{
156-
IterType iter = std::max_element(mValues.begin(), mValues.end());
155+
const auto iter = std::max_element(mValues.begin(), mValues.end());
157156
return *iter;
158157
}
159158

openvdb/openvdb/unittest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ else()
162162
TestQuat.cc
163163
TestRay.cc
164164
TestStats.cc
165+
TestStencils.cc
165166
TestStream.cc
166167
TestStreamCompression.cc
167168
TestStringMetadata.cc
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright Contributors to the OpenVDB Project
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
#include <openvdb/openvdb.h>
5+
#include <openvdb/math/Stencils.h>
6+
7+
#include <gtest/gtest.h>
8+
9+
10+
class TestStencils : public ::testing::Test
11+
{
12+
};
13+
14+
TEST_F(TestStencils, testMinMax)
15+
{
16+
using namespace openvdb;
17+
18+
Int32Grid grid;
19+
grid.tree().setValue(math::Coord(0,0,0), -3);
20+
grid.tree().setValue(math::Coord(0,0,1), -2);
21+
grid.tree().setValue(math::Coord(0,1,0), -1);
22+
grid.tree().setValue(math::Coord(1,0,0), 0);
23+
grid.tree().setValue(math::Coord(1,1,0), 1);
24+
grid.tree().setValue(math::Coord(0,1,1), 2);
25+
grid.tree().setValue(math::Coord(1,0,1), 3);
26+
grid.tree().setValue(math::Coord(1,1,1), 4);
27+
math::BoxStencil<Int32Grid> stencil(grid);
28+
29+
stencil.moveTo(Coord(0,0,0));
30+
EXPECT_EQ(stencil.min(), -3);
31+
EXPECT_EQ(stencil.max(), 4);
32+
33+
stencil.moveTo(Coord(1,1,1));
34+
EXPECT_EQ(stencil.min(), 0);
35+
EXPECT_EQ(stencil.max(), 4);
36+
37+
stencil.moveTo(Coord(0,0,1));
38+
EXPECT_EQ(stencil.min(), -2);
39+
EXPECT_EQ(stencil.max(), 4);
40+
}

pendingchanges/stencil_minmax.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
OpenVDB:
2+
- Bug Fixes:
3+
Fixed a compilation issue with the min() and max() methods on Stencils
4+
in openvdb/math/Stencils.h
5+
[Reported by Samuel Mauch]

0 commit comments

Comments
 (0)