diff --git a/ci/build.sh b/ci/build.sh index b3b318d093..02f4d4c9dd 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -189,6 +189,7 @@ cmake \ -DOPENVDB_BUILD_VDB_PRINT=ON \ -DOPENVDB_BUILD_VDB_LOD=ON \ -DOPENVDB_BUILD_VDB_TOOL=ON \ + -DBUILD_TEST=ON \ -DOPENVDB_TOOL_USE_NANO=OFF \ -DOPENVDB_BUILD_PYTHON_UNITTESTS=ON \ -DMSVC_MP_THREAD_COUNT=${PARMS[-j]} \ diff --git a/openvdb_cmd/vdb_tool/CMakeLists.txt b/openvdb_cmd/vdb_tool/CMakeLists.txt index da1ade24ca..9ed79ff1ea 100644 --- a/openvdb_cmd/vdb_tool/CMakeLists.txt +++ b/openvdb_cmd/vdb_tool/CMakeLists.txt @@ -191,4 +191,5 @@ if(BUILD_TEST) add_executable(vdb_tool_test src/unittest.cpp) target_include_directories(vdb_tool_test PRIVATE vdb_tool_common) target_link_libraries(vdb_tool_test PRIVATE vdb_tool_common GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main) + add_test(vdb_tool_unit_test vdb_tool_test) endif() diff --git a/openvdb_cmd/vdb_tool/include/Geometry.h b/openvdb_cmd/vdb_tool/include/Geometry.h index 8ce2d4f9b0..620aeac3ef 100644 --- a/openvdb_cmd/vdb_tool/include/Geometry.h +++ b/openvdb_cmd/vdb_tool/include/Geometry.h @@ -33,7 +33,7 @@ #ifdef VDB_TOOL_USE_NANO #include -#include +#include #endif #ifdef VDB_TOOL_USE_ABC diff --git a/openvdb_cmd/vdb_tool/include/Tool.h b/openvdb_cmd/vdb_tool/include/Tool.h index 24e947f79b..b24e71696e 100644 --- a/openvdb_cmd/vdb_tool/include/Tool.h +++ b/openvdb_cmd/vdb_tool/include/Tool.h @@ -53,9 +53,9 @@ #ifdef VDB_TOOL_USE_NANO #include -#include -#include -#include +#include +#include +#include #endif #ifdef VDB_TOOL_USE_EXR @@ -1062,7 +1062,7 @@ void Tool::readNVDB(const std::string &fileName) const size_t count = mGrid.size(); if (grids.size()) { for (const auto& gridHandle : grids) { - if (gridNames[0]=="*" || findMatch(gridHandle.gridMetaData()->shortGridName(), gridNames)) mGrid.push_back(nanovdb::nanoToOpenVDB(gridHandle)); + if (gridNames[0]=="*" || findMatch(gridHandle.gridMetaData()->shortGridName(), gridNames)) mGrid.push_back(nanovdb::tools::nanoToOpenVDB(gridHandle)); } } else if (mParser.verbose>0) { std::cerr << "readVDB: no vdb grids in \"" << fileName << "\""; @@ -1262,26 +1262,26 @@ void Tool::writeNVDB(const std::string &fileName) throw std::invalid_argument("writeNVDB: unsupported bits \""+bits+"\""); } - nanovdb::StatsMode sMode = nanovdb::StatsMode::Default; + nanovdb::tools::StatsMode sMode = nanovdb::tools::StatsMode::Default; if (stats == "none") { - sMode = nanovdb::StatsMode::Disable; + sMode = nanovdb::tools::StatsMode::Disable; } else if (stats == "bbox") { - sMode = nanovdb::StatsMode::BBox; + sMode = nanovdb::tools::StatsMode::BBox; } else if (stats == "extrema") { - sMode = nanovdb::StatsMode::MinMax; + sMode = nanovdb::tools::StatsMode::MinMax; } else if (stats == "all") { - sMode = nanovdb::StatsMode::All; + sMode = nanovdb::tools::StatsMode::All; } else if (stats != "") { throw std::invalid_argument("writeNVDB: unsupported stats \""+stats+"\""); } - nanovdb::ChecksumMode cMode = nanovdb::ChecksumMode::Default; + nanovdb::CheckMode cMode = nanovdb::CheckMode::Default; if (checksum == "none") { - cMode = nanovdb::ChecksumMode::Disable; + cMode = nanovdb::CheckMode::Disable; } else if (checksum == "partial") { - cMode = nanovdb::ChecksumMode::Partial; + cMode = nanovdb::CheckMode::Partial; } else if (checksum == "full") { - cMode = nanovdb::ChecksumMode::Full; + cMode = nanovdb::CheckMode::Full; } else if (checksum != "") { throw std::invalid_argument("writeNVDB: unsupported checksum \""+checksum+"\""); } @@ -1302,21 +1302,21 @@ void Tool::writeNVDB(const std::string &fileName) using SrcGridT = openvdb::FloatGrid; switch (qMode){ case nanovdb::GridType::Fp4: - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); case nanovdb::GridType::Fp8: - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); case nanovdb::GridType::Fp16: - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); case nanovdb::GridType::FpN: if (absolute) { - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::AbsDiff(tolerance)); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::tools::AbsDiff(tolerance)); } else { - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::RelDiff(tolerance)); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::tools::RelDiff(tolerance)); } default: break;// 32 bit float grids are handled below }// end of switch } - return nanovdb::openToNanoVDB(base, sMode, cMode, verbose);// float and other grids + return nanovdb::tools::openToNanoVDB(base, sMode, cMode, verbose);// float and other grids };// openToNano if (fileName=="stdout.nvdb") { diff --git a/openvdb_cmd/vdb_tool/src/unittest.cpp b/openvdb_cmd/vdb_tool/src/unittest.cpp index 0510e17412..9ca0f9cbca 100644 --- a/openvdb_cmd/vdb_tool/src/unittest.cpp +++ b/openvdb_cmd/vdb_tool/src/unittest.cpp @@ -411,7 +411,7 @@ TEST_F(Test_vdb_tool, Geometry) {// test readOFF and writeOFF geo.write("data/test.off"); openvdb::vdb_tool::Geometry geo2; - EXPECT_TRUE(geo2.read("data/test.off")); + geo2.read("data/test.off"); EXPECT_EQ(4, geo2.vtxCount()); EXPECT_EQ(2, geo2.triCount()); EXPECT_EQ(1, geo2.quadCount()); @@ -820,7 +820,7 @@ TEST_F(Test_vdb_tool, ToolParser) float beta = 0.0f, beta_sum = 0.0f; std::string path, base, ext; - Parser p({{"alpha", "64"}, {"beta", "4.56"}}); + Parser p({{"alpha", "64", "", ""}, {"beta", "4.56", "", ""}}); p.addAction("process_a", "a", "docs", {{"alpha", "", "", ""},{"beta", "", "", ""}}, [&](){p.setDefaults();}, @@ -843,7 +843,7 @@ TEST_F(Test_vdb_tool, ToolParser) p.finalize(); auto args = getArgs("vdb_tool -quiet -process_a alpha=128 -for v=0.1,0.4,0.1 -b alpha={$#v:++} beta={$v} -end"); - p.parse(args.size(), args.data()); + p.parse(int(args.size()), args.data()); EXPECT_EQ(0, alpha); EXPECT_EQ(0.0f, beta); EXPECT_EQ(0, alpha_sum); @@ -855,7 +855,7 @@ TEST_F(Test_vdb_tool, ToolParser) EXPECT_EQ(0.1f + 0.2f + 0.3f, beta_sum);// derived from loop args = getArgs("vdb_tool -quiet -each file=path1/base1.ext1,path2/base2.ext2 -c alpha={$file:path} beta={$file:name} gamma={$file:ext} -end"); - p.parse(args.size(), args.data()); + p.parse(int(args.size()), args.data()); p.run(); EXPECT_EQ(path, "path1,path2"); EXPECT_EQ(base, "base1,base2"); @@ -875,7 +875,7 @@ TEST_F(Test_vdb_tool, ToolBasic) EXPECT_NO_THROW({ auto args = getArgs("vdb_tool -quiet -sphere r=1.1 -ls2mesh -write data/sphere.ply data/config.txt"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); }); @@ -896,7 +896,7 @@ TEST_F(Test_vdb_tool, Counter) EXPECT_NO_THROW({ auto args = getArgs("vdb_tool -quiet -eval {1:@G} -sphere r=1.1 -ls2mesh -write data/sphere_{$G}.ply data/config_{$G:++}.txt"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); }); @@ -919,7 +919,7 @@ TEST_F(Test_vdb_tool, ToolForLoop) // test single for-loop EXPECT_NO_THROW({ auto args = getArgs("vdb_tool -quiet -for i=0,3 -sphere r=1.{$i} dim=128 name=sphere_{$i} -ls2mesh -write data/sphere_{$#i:++}.ply -end"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); }); @@ -928,7 +928,7 @@ TEST_F(Test_vdb_tool, ToolForLoop) // test two nested for-loops EXPECT_NO_THROW({ auto args = getArgs("vdb_tool -quiet -for v=0.1,0.3,0.1 -each s=sphere_1,sphere_3 -read ./data/{$s}.ply -mesh2ls voxel={$v} -end -end -write data/test.vdb"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); }); @@ -948,7 +948,7 @@ TEST_F(Test_vdb_tool, ToolError) EXPECT_THROW({ auto args = getArgs("vdb_tool -sphere bla=3 -ls2mesh -write data/sphere.ply data/config.txt -quiet"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); }, std::invalid_argument); @@ -971,7 +971,7 @@ TEST_F(Test_vdb_tool, ToolKeep) EXPECT_NO_THROW({ auto args = getArgs("vdb_tool -quiet -default keep=1 -sphere r=2 -ls2mesh vdb=0 -write vdb=0 geo=0 data/sphere.vdb data/sphere.ply data/config.txt"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); }); @@ -994,7 +994,7 @@ TEST_F(Test_vdb_tool, ToolConfig) EXPECT_NO_THROW({ auto args = getArgs("vdb_tool -quiet -config data/config.txt"); - Tool vdb_tool(args.size(), args.data()); + Tool vdb_tool(int(args.size()), args.data()); vdb_tool.run(); });