Commit: 4b451838ede700d48ceaf0b7d93cd737808f9bc5
Author: Lukas Tönne
Date:   Sun Mar 22 14:23:33 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB4b451838ede700d48ceaf0b7d93cd737808f9bc5

More control over verbosity with Alembic archive info printing.

===================================================================

M       intern/cycles/app/cycles_alembic.cpp
M       intern/cycles/app/cycles_alembic.h
M       intern/cycles/app/cycles_xml.cpp

===================================================================

diff --git a/intern/cycles/app/cycles_alembic.cpp 
b/intern/cycles/app/cycles_alembic.cpp
index c801dd4..5bae8ee 100644
--- a/intern/cycles/app/cycles_alembic.cpp
+++ b/intern/cycles/app/cycles_alembic.cpp
@@ -186,7 +186,7 @@ static void visitProperties(std::stringstream &ss, 
ICompoundProperty iParent, st
        ioIndent = oldIndent;
 }
 
-static void visitObject(std::stringstream &ss, IObject iObj, std::string 
iIndent)
+static void visitObject(std::stringstream &ss, IObject iObj, std::string 
iIndent, AbcArchiveInfoLevel info_level)
 {
        // Object has a name, a full name, some meta data,
        // and then it has a compound property full of properties.
@@ -208,18 +208,20 @@ static void visitObject(std::stringstream &ss, IObject 
iObj, std::string iIndent
                        ss << "Object " << "name=" << path << std::endl;
                }
                
-               // Get the properties.
-               ICompoundProperty props = iObj.getProperties();
-               visitProperties(ss, props, iIndent);
+               if (info_level >= ABC_INFO_PROPERTIES) {
+                       // Get the properties.
+                       ICompoundProperty props = iObj.getProperties();
+                       visitProperties(ss, props, iIndent);
+               }
                
                // now the child objects
                for (size_t i = 0 ; i < iObj.getNumChildren() ; i++) {
-                       visitObject(ss, IObject(iObj, 
iObj.getChildHeader(i).getName()), iIndent);
+                       visitObject(ss, IObject(iObj, 
iObj.getChildHeader(i).getName()), iIndent, info_level);
                }
        }
 }
 
-static std::string abc_archive_info(IArchive &archive)
+static std::string abc_archive_info(IArchive &archive, AbcArchiveInfoLevel 
info_level)
 {
        std::stringstream ss;
        
@@ -253,12 +255,15 @@ static std::string abc_archive_info(IArchive &archive)
                ss << std::endl;
        }
        
-       visitObject(ss, archive.getTop(), "");
+       if (info_level >= ABC_INFO_OBJECTS)
+               visitObject(ss, archive.getTop(), "", info_level);
        
        return ss.str();
 }
 
-void abc_read_ogawa_file(Scene *scene, const char *filepath)
+/* ========================================================================= */
+
+void abc_read_ogawa_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level)
 {
        IArchive archive;
        ABC_SAFE_CALL_BEGIN
@@ -266,11 +271,12 @@ void abc_read_ogawa_file(Scene *scene, const char 
*filepath)
        ABC_SAFE_CALL_END
        
        if (archive) {
-               printf("%s", abc_archive_info(archive).c_str());
+               if (info_level >= ABC_INFO_BASIC)
+                       printf("%s", abc_archive_info(archive, 
info_level).c_str());
        }
 }
 
-void abc_read_hdf5_file(Scene *scene, const char *filepath)
+void abc_read_hdf5_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level)
 {
 #ifdef WITH_HDF5
        IArchive archive;
@@ -279,7 +285,8 @@ void abc_read_hdf5_file(Scene *scene, const char *filepath)
        ABC_SAFE_CALL_END
        
        if (archive) {
-               printf(abc_archive_info(archive));
+               if (info_level >= ABC_INFO_BASIC)
+                       printf("%s", abc_archive_info(archive, 
info_level).c_str());
        }
 #endif
 }
diff --git a/intern/cycles/app/cycles_alembic.h 
b/intern/cycles/app/cycles_alembic.h
index 761058b..df17f8b 100644
--- a/intern/cycles/app/cycles_alembic.h
+++ b/intern/cycles/app/cycles_alembic.h
@@ -21,8 +21,15 @@ CCL_NAMESPACE_BEGIN
 
 class Scene;
 
-void abc_read_ogawa_file(Scene *scene, const char *filepath);
-void abc_read_hdf5_file(Scene *scene, const char *filepath);
+enum AbcArchiveInfoLevel {
+       ABC_INFO_NONE = 0,
+       ABC_INFO_BASIC,
+       ABC_INFO_OBJECTS,
+       ABC_INFO_PROPERTIES,
+};
+
+void abc_read_ogawa_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level = ABC_INFO_NONE);
+void abc_read_hdf5_file(Scene *scene, const char *filepath, 
AbcArchiveInfoLevel info_level = ABC_INFO_NONE);
 
 CCL_NAMESPACE_END
 
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 471f08e..a0a9b9e 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -1122,11 +1122,11 @@ static void xml_read_alembic(const XMLReadState& state, 
pugi::xml_node node)
                filepath = path_join(state.base, filepath);
                
                if(xml_equal_string(node, "type", "hdf5"))
-                       abc_read_hdf5_file(state.scene, filepath.c_str());
+                       abc_read_hdf5_file(state.scene, filepath.c_str(), 
ABC_INFO_BASIC);
                else if(xml_equal_string(node, "type", "ogawa"))
-                       abc_read_ogawa_file(state.scene, filepath.c_str());
+                       abc_read_ogawa_file(state.scene, filepath.c_str(), 
ABC_INFO_BASIC);
                else
-                       abc_read_ogawa_file(state.scene, filepath.c_str()); /* 
default */
+                       abc_read_ogawa_file(state.scene, filepath.c_str(), 
ABC_INFO_BASIC); /* default */
        }
 #endif
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to