|
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,36 @@ 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 | + |
| 327 | + // Add 20 leaf nodes and make sure they are parsed correctly |
| 328 | + constexpr int64_t Count = 20; |
| 329 | + std::array<LeafNodeType*, Count> ptrs; |
| 330 | + |
| 331 | + const int64_t start = -(Count/2)*LeafNodeType::DIM; |
| 332 | + const int64_t end = (Count/2)*LeafNodeType::DIM; |
| 333 | + for (int64_t idx = start; idx < end; idx+=LeafNodeType::DIM) { |
| 334 | + ptrs[idx] = tree.touchLeaf(openvdb::math::Coord(idx)); |
| 335 | + } |
| 336 | + EXPECT_EQ(tree.leafCount(), Count); |
| 337 | + LeafManagerT manager(tree); |
| 338 | + EXPECT_EQ(manager.leafCount(), Count); |
| 339 | + }); |
| 340 | +} |
0 commit comments