|
2 | 2 | // SPDX-License-Identifier: MPL-2.0 |
3 | 3 |
|
4 | 4 | #include <openvdb/Types.h> |
| 5 | +#include <openvdb/TypeList.h> |
5 | 6 | #include <openvdb/tree/LeafManager.h> |
6 | 7 | #include <openvdb/util/CpuTimer.h> |
7 | 8 | #include "util.h" // for unittest_util::makeSphere() |
@@ -304,3 +305,39 @@ TEST_F(TestLeafManager, testReduce) |
304 | 305 | } |
305 | 306 | EXPECT_EQ(FloatTree::LeafNodeType::numValues(), n); |
306 | 307 | } |
| 308 | + |
| 309 | +TEST_F(TestLeafManager, testTreeConfigurations) |
| 310 | +{ |
| 311 | + using Tree2Type = openvdb::tree::Tree< |
| 312 | + openvdb::tree::RootNode< |
| 313 | + openvdb::tree::LeafNode<float, 3> > >; |
| 314 | + using Tree3Type = openvdb::tree::Tree3<float, 4, 3>::Type; |
| 315 | + using Tree4Type = openvdb::tree::Tree4<float, 5, 4, 3>::Type; |
| 316 | + using Tree5Type = openvdb::tree::Tree5<float, 5, 5, 4, 3>::Type; |
| 317 | + |
| 318 | + using TestConfigurations = openvdb::TypeList< |
| 319 | + Tree2Type, Tree3Type, Tree4Type, Tree5Type |
| 320 | + >; |
| 321 | + |
| 322 | + TestConfigurations::foreach([](auto tree) { |
| 323 | + using TreeType = typename std::decay<decltype(tree)>::type; |
| 324 | + using LeafNodeType = typename TreeType::LeafNodeType; |
| 325 | + using LeafManagerT = openvdb::tree::LeafManager<TreeType>; |
| 326 | + using ConstLeafManagerT = openvdb::tree::LeafManager<const TreeType>; |
| 327 | + |
| 328 | + // Add 20 leaf nodes and make sure they are constructed correctly |
| 329 | + constexpr openvdb::Int32 Count = 20; |
| 330 | + |
| 331 | + const openvdb::Int32 start = -(Count/2)*openvdb::Int32(LeafNodeType::DIM); |
| 332 | + const openvdb::Int32 end = (Count/2)*openvdb::Int32(LeafNodeType::DIM); |
| 333 | + for (openvdb::Int32 idx = start; idx < end; idx+=openvdb::Int32(LeafNodeType::DIM)) { |
| 334 | + tree.touchLeaf(openvdb::math::Coord(idx)); |
| 335 | + } |
| 336 | + |
| 337 | + EXPECT_EQ(tree.leafCount(), Count); |
| 338 | + LeafManagerT manager(tree); |
| 339 | + EXPECT_EQ(manager.leafCount(), Count); |
| 340 | + ConstLeafManagerT cmanager(tree); |
| 341 | + EXPECT_EQ(cmanager.leafCount(), Count); |
| 342 | + }); |
| 343 | +} |
0 commit comments