[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58777] branches/soc-2013-cycles_volume/ intern/cycles/kernel/textures/openvdb_volume.cpp: - added a map to keep track of open volume files;
Rafael Campos
rafaelcdn at gmail.com
Wed Jul 31 22:44:41 CEST 2013
Revision: 58777
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58777
Author: jehuty
Date: 2013-07-31 20:44:41 +0000 (Wed, 31 Jul 2013)
Log Message:
-----------
- added a map to keep track of open volume files;
Modified Paths:
--------------
branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/openvdb_volume.cpp
Modified: branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/openvdb_volume.cpp
===================================================================
--- branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/openvdb_volume.cpp 2013-07-31 20:30:37 UTC (rev 58776)
+++ branches/soc-2013-cycles_volume/intern/cycles/kernel/textures/openvdb_volume.cpp 2013-07-31 20:44:41 UTC (rev 58777)
@@ -49,9 +49,10 @@
static ustring u_openvdb_file_extension;
static void initialize_library();
- static bool open_file(OIIO::ustring filename, VDBVolumeFile &vdb_volume);
+ static bool open_file(OIIO::ustring filename, VDBVolumeFile *vdb_volume);
static bool is_vdb_volume_file(OIIO::ustring filename);
static VDBVolumeFile *get_volume_from_file(OIIO::ustring filename);
+ static int get_number_of_grids(VDBVolumeFile *vdb_volume);
private:
static bool vdb_file_check_extension(ustring filename);
@@ -66,7 +67,7 @@
public:
private:
openvdb::GridBase::Ptr grid;
- eOpenVDBGridType grid_type; // Is this really necessary? Check OpenVDB's generic programming guidelines.
+ eOpenVDBGridType grid_type; // This is needed because it's impossible to know the grid value type beforehand;
};
@@ -76,22 +77,6 @@
openvdb::initialize();
}
-
-bool OpenVDBUtil::open_file(OIIO::ustring filename, VDBVolumeFile &vdb_volume)
-{
- // Assumes file has been checked for existence and integrity.
- VDBVolumeFile myFileHandle(filename);
-
-
- //openvdb::GridPtrVecPtr grids = file.getGrids();
-
- // Build OpenVDBVolume
- //OpenVDBVolume vdb_volume(file, grids);
-
- //return vdb_volume;
- return true;
-}
-
bool OpenVDBUtil::vdb_file_check_valid_header(ustring filename)
{
OpenVDBUtil::initialize_library();
@@ -139,6 +124,12 @@
return &vdb_volume;
}
+int OpenVDBUtil::get_number_of_grids(VDBVolumeFile *vdb_volume)
+{
+ return vdb_volume->grids->size();
+}
+
+
// VDBTextureSystem
VDBTextureSystem *VDBTextureSystem::init() {
OpenVDBUtil::initialize_library();
@@ -160,20 +151,33 @@
const Imath::V3f &dPdy, const Imath::V3f &dPdz,
float *result)
{
- // TODO:
- // - check if file is open and mapped;
+ // - check if file is open;
OpenVDBMap::const_iterator open_file = vdb_files.find(filename);
if (open_file == vdb_files.end())
{
- // open file;
+ VDBVolumeFile file(filename);
+
// add it to map
+ open_file = (vdb_files.insert(std::make_pair(filename, &file))).first;
}
+
+ VDBVolumeFile *myVDB = open_file->second;
+ openvdb::GridPtrVecIter iter = myVDB->grids->begin();
+
+ if (OpenVDBUtil::get_number_of_grids(myVDB) == 1) {
+
+ // Name of the grid will be unimportant if it's the only one present in the file.
+ }
else
{
- // file is open;
+ for(iter = myVDB->grids->begin(); iter != myVDB->grids->end(); ++iter)
+ {
+ openvdb::GridBase::Ptr grid = *iter;
+ // Traversal is needed to find the correct grid by name;
+ }
}
-
+
// perform lookup.
return false;
More information about the Bf-blender-cvs
mailing list