Skip to content

Commit 27f9e3d

Browse files
authored
Merge pull request #1472 from kmuseth/vdb_tool
vdb_tool
2 parents 849d38e + e4bcc51 commit 27f9e3d

29 files changed

+7563
-13
lines changed

openvdb_cmd/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ option(OPENVDB_BUILD_VDB_PRINT "Build vdb_print" ON)
1818
option(OPENVDB_BUILD_VDB_LOD "Build vdb_lod" OFF)
1919
option(OPENVDB_BUILD_VDB_RENDER "Build vdb_render" OFF)
2020
option(OPENVDB_BUILD_VDB_VIEW "Build vdb_view" OFF)
21+
option(OPENVDB_BUILD_VDB_TOOL "Build vdb_tool" OFF)
2122
option(OPENVDB_BUILD_VDB_AX "Build the OpenVDB AX command line binary" OFF)
2223

2324
if(OPENVDB_BUILD_AX_BINARIES)
@@ -70,6 +71,10 @@ if (OPENVDB_BUILD_VDB_RENDER)
7071
add_subdirectory(vdb_render)
7172
endif()
7273

74+
if (OPENVDB_BUILD_VDB_TOOL)
75+
add_subdirectory(vdb_tool)
76+
endif()
77+
7378
if (OPENVDB_BUILD_VDB_VIEW)
7479
add_subdirectory(vdb_view)
7580
endif()

openvdb_cmd/vdb_tool/CHANGES.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
2+
# Changes and to-dos:
3+
4+
- [X] vdb_tool::readGeo
5+
- [X] vdb_tool::readVDB
6+
- [X] vdb_tool::particlesToLevelSet
7+
- [X] vdb_tool::processLevelSet
8+
- [X] vdb_tool::offsetLevelSet
9+
- [X] vdb_tool::filterLevelSet
10+
- [X] vdb_tool::levelSetToMesh
11+
- [X] vdb_tool::writeGeo
12+
- [X] vdb_tool::writeVDB
13+
- [X] read ASCI obj particle files
14+
- [X] read ASCI ply particle files
15+
- [X] read binary ply particle files
16+
- [X] write binary ply mesh files
17+
- [X] write ascii obj mesh files
18+
- [X] Geometry::readVdb
19+
- [X] Geometry::readPts
20+
- [X] define time and space order
21+
- [X] Mesh::readPly
22+
- [X] vdb_tool::readMesh
23+
- [X] vdb_tool::meshToLevelSet
24+
- [X] Geometry::readObj
25+
- [X] Geometry::readPly
26+
- [X] Geometry::readNvdb
27+
- [X] vdb_tool::writeVDB
28+
- [X] allow actions to have multiple "-"
29+
- [X] add "-sphere"
30+
- [X] add volume/geometry ages to all actions
31+
- [X] add CSG operations
32+
- [X] "-read" supports multiple files
33+
- [X] "-write" supports multiple files
34+
- [X] added "-print"
35+
- [X] works with tcsh, sh, ksh, and zsh shells
36+
- [X] added "-default"
37+
- [X] cache a list of base grids instead of FloatGrids
38+
- [X] -points2vdb : points -> PointDataGrid
39+
- [X] -vdb2points : PointDataGrid -> points
40+
- [X] -write geo=1 vdb=1,3 file.ply file.vdb
41+
- [X] -iso2ls, convert scalar field to level set
42+
- [X] -ls2fog, convert level set to fog volume
43+
- [X] -scatter, scatter points
44+
- [X] -prune, prune level set
45+
- [X] -flood, signed flood fill of level set
46+
- [X] -multires, generate multi-resolution grids
47+
- [X] -expand, expand narrow band of level set
48+
- [X] -cpt, generate closest-point transfer
49+
- [X] -grad, generate gradient field
50+
- [X] -div, generate divergence from vector field
51+
- [X] -curl, generate curl from vector field
52+
- [X] -curvature, generate mean curvature from scalar field
53+
- [X] -length, generate length of vector field
54+
- [X] -render, render level set and fog volumes
55+
- [X] -enright, performs advection test on level set
56+
- [X] -for i=0,10,1 -end
57+
- [X] -each s=str1,str2 -end
58+
- [X] -read grids=sphere file_%4i.vdb
59+
- [X] Geometry::readSTL
60+
- [X] Geometry::writeSTL
61+
- [X] -clip against either a mask grid, bbox or frustum
62+
- [X] Added local counter "%I" to for-loops
63+
- [X] Added global counter "%G"
64+
- [X] add Tool::savePNG
65+
- [X] add Tool::saveEXR
66+
- [X] -platonic faces=4
67+
- [X] -segment vdb=0 keep=0
68+
- [X] -resample vdb=0[,1] scale=0 translate=0,0,0 order=1[0|2] keep=0
69+
- [X] add Geometry::readABC
70+
- [X] add support for unix pipelining
71+
- [X] add Tool::saveJPG
72+
- [X] add Geometry::read/write to support streaming
73+
- [X] -read stdin.[ply,obj,stl,geo,vdb]
74+
- [X] -write stdout.[ply,obj,stl,geo,vdb]
75+
- [X] actions can now have an optional alias, e.g. -read, -i
76+
- [X] -write file.nvdb stdout.nvdb
77+
- [X] -write bits=32|16|8|N codec=blosc|zip|active
78+
- [X] -help read,write,ls2mesh brief=true
79+
- [X] use openvdb namespace
80+
- [X] Major revision with Parser.h
81+
- [X] -read delayed=false file.vdb
82+
- [X] -clear vdb=1,2,3 geo=*
83+
- [X] -config update=false execute=true configure.txt
84+
- [X] -each f=*.vdb
85+
- [X] add stack-based translator and storage
86+
- [X] -eval '{1:@G}'
87+
- [X] add if-statement: {$x:0:==:if(0.5)} equals if (x==0) 0.5 and {\$x:1:>:if(0.5:sin?0.3:cos)} equals if (x>1) sin(0.5) else cos(0.3)
88+
- [X] add switch-statement: {\$i:switch(1:A?2:B?3:C)} equals switch(x) case 1: A; break; case 2: B; break; case 3: C
89+
- [X] Added numerous methods to scripting language
90+
- [X] -mesh2ls vdb=0 (use another vdb to defined the transform)
91+
- [X] -iso2ls vdb=0,1 (use another vdb to defined the transform)
92+
- [X] loops will now skip, instead of throw, if its initial condition is invalid
93+
- [X] -for i=1,9 (third argument defaults to 1, i.e. i=1,9,1)
94+
- [X] -if 0|1|false|true ... -end (if statement)
95+
- [X] -eval help="*" or -eval help=if,switch
96+
- [X] {date}, {uuid}, {1:a:set}, {a:get}, {a:is_set}, {sphere:sp:match}
97+
- [X] composite: -min, -max, -sum
98+
- [X] -transform vdb=0,3 geo=5 (scale -> rotate -> translate of VDB grids and geometry)
99+
- [X] -print mem=1 prints variables saved to memory, e.g. loop variables
100+
- [X] use cmake (thanks to Greg Klar!)
101+
- [X] read NanoVDB voxel volumes (thanks to Greg Klar)
102+
- [X] -ls2mesh iso=0.1 mask=1 invert=true
103+
- [X] -write binary abc mesh files (thanks to Alexandre Sirois-Vigneux)
104+
- [x] -write keep=false (by default grids and geometries written are also removed)
105+
- [ ] -merge
106+
- [ ] -points2mask
107+
- [ ] -erodeTopology
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
3+
# CMP0091 allows for MSVC ABI targetting via CMAKE_MSVC_RUNTIME_LIBRARY
4+
# from CMake 3.15 and above. Must come before project().
5+
if(POLICY CMP0091)
6+
cmake_policy(SET CMP0091 NEW)
7+
endif()
8+
9+
if(POLICY CMP0074)
10+
cmake_policy(SET CMP0074 NEW)
11+
endif()
12+
13+
#project(vdb_tool LANGUAGES CXX)
14+
15+
#set(CMAKE_CXX_STANDARD 14)
16+
17+
if(NOT CMAKE_BUILD_TYPE)
18+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
19+
"Choose the type of build, supported options are: Debug Release."
20+
FORCE)
21+
endif()
22+
23+
list(APPEND CMAKE_MODULE_PATH ${OPENVDB_CMAKE_PATH})
24+
25+
# Pseudo library to manage dependencies
26+
add_library(vdb_tool_common INTERFACE)
27+
28+
# Optional components
29+
option(BUILD_TEST "Build unit tests" OFF)
30+
31+
option(VDB_TOOL_USE_NANO "Compile with NanoVDB support" ON)
32+
option(VDB_TOOL_NANO_USE_ZIP "Compile NanoVDB with zip compression support. Requires VDB_TOOL_USE_NANO=ON to have effect" ON)
33+
option(VDB_TOOL_NANO_USE_BLOSC "Compile NanoVDB with Blosc compression support. Requires VDB_TOOL_USE_NANO=ON to have effect" ON)
34+
option(VDB_TOOL_USE_PNG "Compile with PNG support" OFF)
35+
option(VDB_TOOL_USE_EXR "Compile with EXR support" OFF)
36+
option(VDB_TOOL_USE_JPG "Compile with JPG support" OFF)
37+
option(VDB_TOOL_USE_ABC "Compile with Alembic support" OFF)
38+
option(VDB_TOOL_USE_ALL "Compile with all optional components" OFF)
39+
if(VDB_TOOL_USE_ALL)
40+
set(VDB_TOOL_USE_NANO ON)
41+
set(VDB_TOOL_USE_PNG ON)
42+
set(VDB_TOOL_USE_EXR ON)
43+
set(VDB_TOOL_USE_JPG ON)
44+
set(VDB_TOOL_USE_ABC ON)
45+
endif()
46+
47+
if(VDB_TOOL_USE_NANO)
48+
add_compile_definitions("VDB_TOOL_USE_NANO")
49+
if(VDB_TOOL_NANO_USE_ZIP)
50+
add_compile_definitions("NANOVDB_USE_ZIP")
51+
find_package(ZLIB REQUIRED)
52+
target_link_libraries(vdb_tool_common INTERFACE ZLIB::ZLIB)
53+
endif()
54+
if(VDB_TOOL_NANO_USE_BLOSC)
55+
add_compile_definitions("NANOVDB_USE_BLOSC")
56+
find_package(Blosc REQUIRED)
57+
target_link_libraries(vdb_tool_common INTERFACE blosc)
58+
endif()
59+
if(OPENVDB_BUILD_NANOVDB)
60+
target_include_directories(vdb_tool_common INTERFACE ../../nanovdb/)
61+
endif()
62+
endif()
63+
64+
if(VDB_TOOL_USE_PNG)
65+
add_compile_definitions("VDB_TOOL_USE_PNG")
66+
if(WIN32)
67+
find_package(libpng CONFIG REQUIRED)
68+
else()
69+
find_package(PNG REQUIRED)
70+
endif()
71+
target_link_libraries(vdb_tool_common INTERFACE png)
72+
endif()
73+
74+
if(VDB_TOOL_USE_JPG)
75+
add_compile_definitions("VDB_TOOL_USE_JPG")
76+
find_package(JPEG REQUIRED)
77+
target_link_libraries(vdb_tool_common INTERFACE ${JPEG_LIBRARIES})
78+
target_include_directories(vdb_tool_common INTERFACE ${JPEG_INCLUDE_DIR})
79+
endif()
80+
81+
if(VDB_TOOL_USE_EXR)
82+
add_compile_definitions("VDB_TOOL_USE_EXR")
83+
find_package(OpenEXR REQUIRED)
84+
target_link_libraries(vdb_tool_common INTERFACE OpenEXR::IlmImf)
85+
endif()
86+
87+
if(VDB_TOOL_USE_ABC)
88+
add_compile_definitions("VDB_TOOL_USE_ABC")
89+
find_package(Alembic CONFIG REQUIRED)
90+
target_link_libraries(vdb_tool_common INTERFACE Alembic::Alembic)
91+
endif()
92+
93+
if(WIN32 AND (VDB_TOOL_USE_ALL OR (VDB_TOOL_USE_ABC AND VDB_TOOL_USE_EXR)))
94+
message(WARNING
95+
" The OpenEXR and Alembic VCPKG packages are using conflicting Imath versions.\n"
96+
" Disable one, if you encounter unresolved external symbols")
97+
endif()
98+
99+
# Compiler flags
100+
101+
# GCC flags
102+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
103+
add_compile_options(-Wno-invalid-offsetof -pthread -lpthread)
104+
add_compile_options("$<$<CONFIG:DEBUG>:-O1>")
105+
endif()
106+
107+
108+
# MSVC flags
109+
# Increase the number of sections that an object file can contain
110+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/bigobj>")
111+
# Excludes APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets
112+
add_compile_definitions("$<$<CXX_COMPILER_ID:MSVC>:WIN32_LEAN_AND_MEAN>")
113+
# Disable non-secure CRT library function warnings
114+
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/
115+
# compiler-warning-level-3-c4996?view=vs-2019#unsafe-crt-library-functions
116+
add_compile_definitions("$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>")
117+
# Disable POSIX function name warnings
118+
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/
119+
# compiler-warning-level-3-c4996?view=vs-2019#posix-function-names
120+
add_compile_definitions("$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_WARNINGS>")
121+
122+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
123+
add_compile_options("$<$<CONFIG:RELEASE>:/Oi>")
124+
125+
message(STATUS "Suppressing some noisy MSVC CXX warnings.")
126+
endif()
127+
# Conversion from int64_t to long
128+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4244>")
129+
# It's not possible to use STL types in DLL interfaces in a portable and
130+
# reliable way so disable this warning
131+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4251>")
132+
# Conversion from size_t to uLong
133+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4267>")
134+
# Non dll-interface class used as base for dll-interface class
135+
#add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4275>")
136+
# Truncation from 'int' to 'bool'
137+
#add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4305>")
138+
139+
if(OPENVDB_BUILD_CORE)
140+
target_link_libraries(vdb_tool_common INTERFACE ${OPENVDB_BINARIES_DEPENDENT_LIBS})
141+
else()
142+
find_package(OpenVDB)
143+
if(NOT OpenVDB_FOUND)
144+
message(FATAL_ERROR
145+
" Couldn't find OpenVDB\n"
146+
" Set OPENVDB_CMAKE_PATH to <OpenVDB install path>/lib/cmake/OpenVDB")
147+
endif()
148+
target_link_libraries(vdb_tool_common INTERFACE TBB::tbb OpenVDB::openvdb)
149+
endif()
150+
151+
target_include_directories(vdb_tool_common INTERFACE "${Boost_INCLUDE_DIRS}" "${OpenVDB_INCLUDE_DIRS}" "include")
152+
153+
# vdb_tool
154+
add_executable(vdb_tool src/main.cpp)
155+
target_include_directories(vdb_tool PRIVATE vdb_tool_common)
156+
target_link_libraries(vdb_tool PRIVATE vdb_tool_common)
157+
158+
159+
# unit test
160+
if(BUILD_TEST)
161+
find_package(GTest CONFIG REQUIRED)
162+
163+
add_executable(vdb_tool_test src/unittest.cpp)
164+
target_include_directories(vdb_tool_test PRIVATE vdb_tool_common)
165+
target_link_libraries(vdb_tool_test PRIVATE vdb_tool_common GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main)
166+
endif()

0 commit comments

Comments
 (0)