Skip to content

Commit

Permalink
Update TestTree.cc
Browse files Browse the repository at this point in the history
Remove migrated tests.

Signed-off-by: ghurstunither <[email protected]>
  • Loading branch information
ghurstunither committed Oct 30, 2024
1 parent 4853738 commit 11686a8
Showing 1 changed file with 0 additions and 201 deletions.
201 changes: 0 additions & 201 deletions openvdb/openvdb/unittest/TestTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2756,204 +2756,3 @@ TEST_F(TestTree, testNodeCount)
EXPECT_EQ(tree.leafCount(), nodeCount2.front());// leaf nodes
for (size_t i=0; i<nodeCount2.size(); ++i) EXPECT_EQ( nodeCount1[i], nodeCount2[i]);
}

TEST_F(TestTree, testRootNode)
{
using ChildType = RootNodeType::ChildNodeType;
const openvdb::Coord c0(0,0,0), c1(49152, 16384, 28672);

{ // test inserting child nodes directly and indirectly
RootNodeType root(0.0f);
EXPECT_TRUE(root.empty());
EXPECT_EQ(openvdb::Index32(0), root.childCount());

// populate the tree by inserting the two leaf nodes containing c0 and c1
root.touchLeaf(c0);
root.touchLeaf(c1);
EXPECT_EQ(openvdb::Index(2), root.getTableSize());
EXPECT_EQ(openvdb::Index32(2), root.childCount());
EXPECT_TRUE(!root.hasActiveTiles());

{ // verify c0 and c1 are the root node coordinates
auto rootIter = root.cbeginChildOn();
EXPECT_EQ(c0, rootIter.getCoord());
++rootIter;
EXPECT_EQ(c1, rootIter.getCoord());
}

// copy the root node
RootNodeType rootCopy(root);

// steal the root node children leaving the root node empty again
std::vector<ChildType*> children;
root.stealNodes(children);
EXPECT_TRUE(root.empty());

// insert the root node children directly
for (ChildType* child : children) {
root.addChild(child);
}
EXPECT_EQ(openvdb::Index(2), root.getTableSize());
EXPECT_EQ(openvdb::Index32(2), root.childCount());

{ // verify the coordinates of the root node children
auto rootIter = root.cbeginChildOn();
EXPECT_EQ(c0, rootIter.getCoord());
++rootIter;
EXPECT_EQ(c1, rootIter.getCoord());
}
}

{ // test inserting tiles and replacing them with child nodes
RootNodeType root(0.0f);
EXPECT_TRUE(root.empty());

// no-op
root.addChild(nullptr);

// populate the root node by inserting tiles
root.addTile(c0, /*value=*/1.0f, /*state=*/true);
root.addTile(c1, /*value=*/2.0f, /*state=*/true);
EXPECT_EQ(openvdb::Index(2), root.getTableSize());
EXPECT_EQ(openvdb::Index32(0), root.childCount());
EXPECT_TRUE(root.hasActiveTiles());
ASSERT_DOUBLES_EXACTLY_EQUAL(1.0f, root.getValue(c0));
ASSERT_DOUBLES_EXACTLY_EQUAL(2.0f, root.getValue(c1));

// insert child nodes with the same coordinates
root.addChild(new ChildType(c0, 3.0f));
root.addChild(new ChildType(c1, 4.0f));

// insert a new child at c0
root.addChild(new ChildType(c0, 5.0f));

// verify active tiles have been replaced by child nodes
EXPECT_EQ(openvdb::Index(2), root.getTableSize());
EXPECT_EQ(openvdb::Index32(2), root.childCount());
EXPECT_TRUE(!root.hasActiveTiles());

{ // verify the coordinates of the root node children
auto rootIter = root.cbeginChildOn();
EXPECT_EQ(c0, rootIter.getCoord());
ASSERT_DOUBLES_EXACTLY_EQUAL(5.0f, root.getValue(c0));
++rootIter;
EXPECT_EQ(c1, rootIter.getCoord());
}
}

{ // test transient data
RootNodeType rootNode(0.0f);
EXPECT_EQ(openvdb::Index32(0), rootNode.transientData());
rootNode.setTransientData(openvdb::Index32(5));
EXPECT_EQ(openvdb::Index32(5), rootNode.transientData());
RootNodeType rootNode2(rootNode);
EXPECT_EQ(openvdb::Index32(5), rootNode2.transientData());
RootNodeType rootNode3 = rootNode;
EXPECT_EQ(openvdb::Index32(5), rootNode3.transientData());
}
}

TEST_F(TestTree, testInternalNode)
{
const openvdb::Coord c0(1000, 1000, 1000);
const openvdb::Coord c1(896, 896, 896);

using InternalNodeType = InternalNodeType1;
using ChildType = LeafNodeType;

{ // test inserting child nodes directly and indirectly
openvdb::Coord c2 = c1.offsetBy(8,0,0);
openvdb::Coord c3 = c1.offsetBy(16,16,16);

InternalNodeType internalNode(c1, 0.0f);
internalNode.touchLeaf(c2);
internalNode.touchLeaf(c3);

EXPECT_EQ(openvdb::Index64(2), internalNode.leafCount());
EXPECT_EQ(openvdb::Index32(2), internalNode.childCount());
EXPECT_TRUE(!internalNode.hasActiveTiles());

{ // verify c0 and c1 are the root node coordinates
auto childIter = internalNode.cbeginChildOn();
EXPECT_EQ(c2, childIter.getCoord());
++childIter;
EXPECT_EQ(c3, childIter.getCoord());
}

// copy the internal node
InternalNodeType internalNodeCopy(internalNode);

// steal the internal node children leaving it empty again
std::vector<ChildType*> children;
internalNode.stealNodes(children, 0.0f, false);
EXPECT_EQ(openvdb::Index64(0), internalNode.leafCount());
EXPECT_EQ(openvdb::Index32(0), internalNode.childCount());

// insert the root node children directly
for (ChildType* child : children) {
internalNode.addChild(child);
}
EXPECT_EQ(openvdb::Index64(2), internalNode.leafCount());
EXPECT_EQ(openvdb::Index32(2), internalNode.childCount());

{ // verify the coordinates of the root node children
auto childIter = internalNode.cbeginChildOn();
EXPECT_EQ(c2, childIter.getCoord());
++childIter;
EXPECT_EQ(c3, childIter.getCoord());
}
}

{ // test inserting a tile and replacing with a child node
InternalNodeType internalNode(c1, 0.0f);
EXPECT_TRUE(!internalNode.hasActiveTiles());
EXPECT_EQ(openvdb::Index64(0), internalNode.leafCount());
EXPECT_EQ(openvdb::Index32(0), internalNode.childCount());

// add a tile
internalNode.addTile(openvdb::Index(0), /*value=*/1.0f, /*state=*/true);
EXPECT_TRUE(internalNode.hasActiveTiles());
EXPECT_EQ(openvdb::Index64(0), internalNode.leafCount());
EXPECT_EQ(openvdb::Index32(0), internalNode.childCount());

// replace the tile with a child node
EXPECT_TRUE(internalNode.addChild(new ChildType(c1, 2.0f)));
EXPECT_TRUE(!internalNode.hasActiveTiles());
EXPECT_EQ(openvdb::Index64(1), internalNode.leafCount());
EXPECT_EQ(openvdb::Index32(1), internalNode.childCount());
EXPECT_EQ(c1, internalNode.cbeginChildOn().getCoord());
ASSERT_DOUBLES_EXACTLY_EQUAL(2.0f, internalNode.cbeginChildOn()->getValue(0));

// replace the child node with another child node
EXPECT_TRUE(internalNode.addChild(new ChildType(c1, 3.0f)));
ASSERT_DOUBLES_EXACTLY_EQUAL(3.0f, internalNode.cbeginChildOn()->getValue(0));
}

{ // test inserting child nodes that do and do not belong to the internal node
InternalNodeType internalNode(c1, 0.0f);

// succeed if child belongs to this internal node
EXPECT_TRUE(internalNode.addChild(new ChildType(c0.offsetBy(8,0,0))));
EXPECT_TRUE(internalNode.probeLeaf(c0.offsetBy(8,0,0)));
openvdb::Index index1 = internalNode.coordToOffset(c0);
openvdb::Index index2 = internalNode.coordToOffset(c0.offsetBy(8,0,0));
EXPECT_TRUE(!internalNode.isChildMaskOn(index1));
EXPECT_TRUE(internalNode.isChildMaskOn(index2));

// fail otherwise
auto* child = new ChildType(c0.offsetBy(8000,0,0));
EXPECT_TRUE(!internalNode.addChild(child));
delete child;
}

{ // test transient data
InternalNodeType internalNode(c1, 0.0f);
EXPECT_EQ(openvdb::Index32(0), internalNode.transientData());
internalNode.setTransientData(openvdb::Index32(5));
EXPECT_EQ(openvdb::Index32(5), internalNode.transientData());
InternalNodeType internalNode2(internalNode);
EXPECT_EQ(openvdb::Index32(5), internalNode2.transientData());
InternalNodeType internalNode3 = internalNode;
EXPECT_EQ(openvdb::Index32(5), internalNode3.transientData());
}
}

0 comments on commit 11686a8

Please sign in to comment.