[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58317] branches/soc-2013-cycles_volume: - added early versions of OpenVDBVolume, OpenVDBUtil and OpenVDBVolumeAccessor to openvdb_volume.h;
Rafael Campos
rafaelcdn at gmail.com
Tue Jul 16 22:06:22 CEST 2013
Revision: 58317
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58317
Author: jehuty
Date: 2013-07-16 20:06:22 +0000 (Tue, 16 Jul 2013)
Log Message:
-----------
- added early versions of OpenVDBVolume, OpenVDBUtil and OpenVDBVolumeAccessor to openvdb_volume.h;
- added a version of vdb_print as an executable target of /cycles/app to aid in testing;
Modified Paths:
--------------
branches/soc-2013-cycles_volume/CMakeLists.txt
branches/soc-2013-cycles_volume/intern/cycles/CMakeLists.txt
branches/soc-2013-cycles_volume/intern/cycles/app/CMakeLists.txt
branches/soc-2013-cycles_volume/intern/cycles/kernel/osl/CMakeLists.txt
branches/soc-2013-cycles_volume/intern/cycles/kernel/osl/osl_services.cpp
Added Paths:
-----------
branches/soc-2013-cycles_volume/intern/cycles/app/cycles_openvdb_test.cpp
branches/soc-2013-cycles_volume/intern/cycles/kernel/osl/openvdb_volume.cpp
branches/soc-2013-cycles_volume/intern/cycles/kernel/osl/openvdb_volume.h
Modified: branches/soc-2013-cycles_volume/CMakeLists.txt
===================================================================
--- branches/soc-2013-cycles_volume/CMakeLists.txt 2013-07-16 13:12:58 UTC (rev 58316)
+++ branches/soc-2013-cycles_volume/CMakeLists.txt 2013-07-16 20:06:22 UTC (rev 58317)
@@ -1259,17 +1259,12 @@
set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
endif()
- if(WITH_CYCLES_OPENVDB) #requires tbb and glfw
+ if(WITH_CYCLES_OPENVDB) #requires tbb
set(TBB ${LIBDIR}/tbb)
set(TBB_INCLUDE_DIRS ${TBB}/include)
- #set(TBB_LIBRARIES optimized OpenImageIO debug OpenImageIO_d)
+ set(TBB_LIBRARIES tbb tbb_debug)
set(TBB_LIBPATH ${TBB}/lib)
set(TBB_DEFINITIONS "")
-
- set(GLFW ${LIBDIR}/glfw)
- set(GLFW_INCLUDE_DIRS ${GLFW}/include)
- set(GLFW_LIBPATH ${GLFW}/lib)
- set(GLFW_DEFINITIONS "")
endif()
if(WITH_LLVM)
Modified: branches/soc-2013-cycles_volume/intern/cycles/CMakeLists.txt
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/CMakeLists.txt 2013-07-16 13:12:58 UTC (rev 58316)
+++ branches/soc-2013-cycles_volume/intern/cycles/CMakeLists.txt 2013-07-16 20:06:22 UTC (rev 58317)
@@ -82,7 +82,7 @@
add_subdirectory(blender)
endif()
-if(WITH_CYCLES_TEST OR WITH_CYCLES_NETWORK)
+if(WITH_CYCLES_TEST OR WITH_CYCLES_NETWORK OR WITH_CYCLES_OPENVDB)
add_subdirectory(app)
endif()
@@ -93,4 +93,3 @@
add_subdirectory(render)
add_subdirectory(subd)
add_subdirectory(util)
-
Modified: branches/soc-2013-cycles_volume/intern/cycles/app/CMakeLists.txt
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/app/CMakeLists.txt 2013-07-16 13:12:58 UTC (rev 58316)
+++ branches/soc-2013-cycles_volume/intern/cycles/app/CMakeLists.txt 2013-07-16 20:06:22 UTC (rev 58317)
@@ -23,9 +23,11 @@
${OPENGL_LIBRARIES}
${CYCLES_GLEW_LIBRARY}
${OPENIMAGEIO_LIBRARIES}
+ ${OPENEXR_LIBRARIES}
+ ${ZLIB_LIBRARIES}
)
-link_directories(${OPENIMAGEIO_LIBPATH} ${BOOST_LIBPATH})
+link_directories(${OPENIMAGEIO_LIBPATH} ${BOOST_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH} ${TBB_LIBPATH})
if(WITH_CYCLES_TEST)
list(APPEND LIBRARIES ${GLUT_LIBRARIES})
@@ -66,3 +68,19 @@
unset(SRC)
endif()
+if (WITH_CYCLES_OPENVDB)
+ set(SRC
+ cycles_openvdb_test.cpp
+ )
+ add_executable(cycles_openvdb_test ${SRC})
+
+ list(
+ APPEND LIBRARIES
+ ${TBB_LIBRARIES}
+ extern_openvdb
+ )
+
+ target_link_libraries(cycles_openvdb_test ${LIBRARIES})
+ unset(SRC)
+endif()
+
Added: branches/soc-2013-cycles_volume/intern/cycles/app/cycles_openvdb_test.cpp
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/app/cycles_openvdb_test.cpp (rev 0)
+++ branches/soc-2013-cycles_volume/intern/cycles/app/cycles_openvdb_test.cpp 2013-07-16 20:06:22 UTC (rev 58317)
@@ -0,0 +1,394 @@
+///////////////////////////////////////////////////////////////////////////
+//
+// Adapted from OpenVDB with this license:
+//
+// Copyright (c) 2012-2013 DreamWorks Animation LLC
+//
+// All rights reserved. This software is distributed under the
+// Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
+//
+// Redistributions of source code must retain the above copyright
+// and license notice and the following restrictions and disclaimer.
+//
+// * Neither the name of DreamWorks Animation nor the names of
+// its contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
+// LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
+//
+///////////////////////////////////////////////////////////////////////////
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <openvdb/openvdb.h>
+#ifdef DWA_OPENVDB
+#include <arg.h>
+#include <logging/logging.h>
+#include <except/catchall.h>
+#include <pdi.h>
+#endif
+#ifdef _WIN32
+#include <XGetopt.h>
+#else
+#include <unistd.h> // for getopt(), optarg
+#endif
+
+#include <osl/openvdb_volume.h>
+#include <OSL/oslexec.h>
+
+namespace {
+
+const char* INDENT = " ";
+
+typedef std::vector<std::string> StringVec;
+
+StringVec sFilenames;
+
+
+void
+usage(const char* progName)
+{
+ std::cerr <<
+"Usage: " << progName << " in.vdb [in.vdb ...] [options]\n" <<
+"Which: prints information about OpenVDB grids\n" <<
+"Options:\n" <<
+#ifdef DWA_OPENVDB
+" -l, -stats long printout, including grid statistics\n" <<
+" -m, -metadata print per-file and per-grid metadata\n";
+#else
+" -l long printout, including grid statistics\n" <<
+" -m print per-file and per-grid metadata\n";
+#endif
+ exit(EXIT_FAILURE);
+}
+
+
+std::string
+sizeAsString(openvdb::Index64 n, const std::string& units)
+{
+ std::ostringstream ostr;
+ ostr << std::setprecision(3);
+ if (n < 1000) {
+ ostr << n;
+ } else if (n < 1000000) {
+ ostr << (n / 1.0e3) << "K";
+ } else if (n < 1000000000) {
+ ostr << (n / 1.0e6) << "M";
+ } else {
+ ostr << (n / 1.0e9) << "G";
+ }
+ ostr << units;
+ return ostr.str();
+}
+
+
+std::string
+bytesAsString(openvdb::Index64 n)
+{
+ std::ostringstream ostr;
+ ostr << std::setprecision(3);
+ if (n >> 30) {
+ ostr << (n / double(uint64_t(1) << 30)) << "GB";
+ } else if (n >> 20) {
+ ostr << (n / double(uint64_t(1) << 20)) << "MB";
+ } else if (n >> 10) {
+ ostr << (n / double(uint64_t(1) << 10)) << "KB";
+ } else {
+ ostr << n << "B";
+ }
+ return ostr.str();
+}
+
+
+std::string
+coordAsString(const openvdb::Coord ijk, const std::string& sep)
+{
+ std::ostringstream ostr;
+ ostr << ijk[0] << sep << ijk[1] << sep << ijk[2];
+ return ostr.str();
+}
+
+
+/// Return a string representation of the given metadata key, value pairs
+std::string
+metadataAsString(
+ const openvdb::MetaMap::ConstMetaIterator& begin,
+ const openvdb::MetaMap::ConstMetaIterator& end,
+ const std::string& indent = "")
+{
+ std::ostringstream ostr;
+ char sep[2] = { 0, 0 };
+ for (openvdb::MetaMap::ConstMetaIterator it = begin; it != end; ++it) {
+ ostr << sep << indent << it->first;
+ if (it->second) {
+ const std::string value = it->second->str();
+ if (!value.empty()) ostr << ": " << value;
+ }
+ sep[0] = '\n';
+ }
+ return ostr.str();
+}
+
+
+std::string
+bkgdValueAsString(const openvdb::GridBase::ConstPtr& grid)
+{
+ std::ostringstream ostr;
+ if (grid) {
+ const openvdb::TreeBase& tree = grid->baseTree();
+ ostr << "background: ";
+ openvdb::Metadata::Ptr background = tree.getBackgroundValue();
+ if (background) ostr << background->str();
+ }
+ return ostr.str();
+}
+
+
+/// Print detailed information about the given VDB files.
+/// If @a metadata is true, include file-level metadata key, value pairs.
+void
+printLongListing(const StringVec& filenames)
+{
+ bool oneFile = (filenames.size() == 1), firstFile = true;
+
+ for (size_t i = 0, N = filenames.size(); i < N; ++i, firstFile = false) {
+ openvdb::io::File file(filenames[i]);
+ std::string version;
+ openvdb::GridPtrVecPtr grids;
+ openvdb::MetaMap::Ptr meta;
+ try {
+ file.open();
+ grids = file.getGrids();
+ meta = file.getMetadata();
+ version = file.version();
+ file.close();
+ } catch (openvdb::Exception& e) {
+ OPENVDB_LOG_ERROR(e.what() << " (" << filenames[i] << ")");
+ }
+ if (!grids) continue;
+
+ if (!oneFile) {
+ if (!firstFile) {
+ std::cout << "\n" << std::string(40, '-') << "\n\n";
+ }
+ std::cout << filenames[i] << "\n\n";
+ }
+
+ // Print file-level metadata.
+ std::cout << "VDB version: " << version << "\n";
+ if (meta) {
+ std::string str = metadataAsString(meta->beginMeta(), meta->endMeta());
+ if (!str.empty()) std::cout << str << "\n";
+ }
+ std::cout << "\n";
+
+ // For each grid in the file...
+ bool firstGrid = true;
+ for (openvdb::GridPtrVec::const_iterator it = grids->begin(); it != grids->end(); ++it) {
+ if (openvdb::GridBase::ConstPtr grid = *it) {
+ if (!firstGrid) std::cout << "\n\n";
+ std::cout << "Name: " << grid->getName() << std::endl;
+ grid->print(std::cout, /*verboseLevel=*/3);
+ firstGrid = false;
+ }
+ }
+ }
+}
+
+
+/// Print condensed information about the given VDB files.
+/// If @a metadata is true, include file- and grid-level metadata.
+void
+printShortListing(const StringVec& filenames, bool metadata)
+{
+ bool oneFile = (filenames.size() == 1), firstFile = true;
+
+ for (size_t i = 0, N = filenames.size(); i < N; ++i, firstFile = false) {
+ const std::string
+ indent(oneFile ? "": INDENT),
+ indent2(indent + INDENT);
+
+ if (!oneFile) {
+ if (metadata && !firstFile) std::cout << "\n";
+ std::cout << filenames[i] << ":\n";
+ }
+
+ openvdb::GridPtrVecPtr grids;
+ openvdb::MetaMap::Ptr meta;
+
+ openvdb::io::File file(filenames[i]);
+ try {
+ file.open();
+ grids = file.getGrids();
+ meta = file.getMetadata();
+ file.close();
+ } catch (openvdb::Exception& e) {
+ OPENVDB_LOG_ERROR(e.what() << " (" << filenames[i] << ")");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list