//-***************************************************************************** void getABCTimeSpan(IArchive archive, chrono_t& first, chrono_t& last) { // TO DO: Is the childBounds property reliable to get the full archive's span? if (!archive.valid()) return; IObject archiveTop = archive.getTop(); if ( archiveTop.getProperties().getPropertyHeader( ".childBnds" ) != NULL ) { // Try to get timing from childBounds first IBox3dProperty childbnds = Alembic::Abc::IBox3dProperty( archive.getTop().getProperties(), ".childBnds", ErrorHandler::kQuietNoopPolicy); TimeSamplingPtr ts = childbnds.getTimeSampling(); first = std::min(first, ts->getSampleTime(0) ); last = std::max(last, ts->getSampleTime(childbnds.getNumSamples()-1) ); return; } unsigned int numChildren = archiveTop.getNumChildren(); for (unsigned i=0; i<numChildren; ++i) // Visit every object to get its first and last sample { IObject obj( archiveTop.getChild( i )); getObjectTimeSpan(obj, first, last, true); } }
void scopingTest(bool useOgawa) { { OObject top; { OArchive archive; if (useOgawa) { archive = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), "archiveScopeTest.abc", "Alembic test", "", MetaData() ); } else { archive = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), "archiveScopeTest.abc", "Alembic test", "", MetaData() ); } top = archive.getTop(); } OObject childA( top, "a"); OObject childB( top, "b"); ODoubleProperty prop(top.getProperties(), "prop", 0); TESTING_ASSERT(prop.getObject().getArchive().getName() == "archiveScopeTest.abc"); } { IObject top; { AbcF::IFactory factory; AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive("archiveScopeTest.abc", coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); top = archive.getTop(); double start, end; GetArchiveStartAndEndTime( archive, start, end ); TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX ); } TESTING_ASSERT(top.getNumChildren() == 2 ); TESTING_ASSERT(top.getChildHeader("a") != NULL); TESTING_ASSERT(top.getChildHeader("b") != NULL); TESTING_ASSERT( ! top.getParent().valid() ); TESTING_ASSERT( top.getArchive().getName() == "archiveScopeTest.abc"); IScalarProperty prop(top.getProperties(), "prop"); TESTING_ASSERT(prop.valid()); TESTING_ASSERT(prop.getObject().getArchive().getName() == "archiveScopeTest.abc"); } }
// Read side -------------------------------------- IVisibilityProperty GetVisibilityProperty ( IObject & iObject ) { ICompoundProperty prop = iObject.getProperties(); if ( prop.getPropertyHeader (kVisibilityPropertyName) ) { IVisibilityProperty visibilityProperty ( prop, kVisibilityPropertyName ); return visibilityProperty; } return IVisibilityProperty(); }
//-***************************************************************************** void ICompoundProperty::init ( const IObject & iObject, const Argument &iArg0, const Argument &iArg1 ) { getErrorHandler().setPolicy( GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::init( IObject )" ); m_property = iObject.getProperties().getPtr(); ALEMBIC_ABC_SAFE_CALL_END_RESET(); }
//-***************************************************************************** void readDeepHierarchy( IObject parent, const int level, const IObject& orig ) { if ( level > DEPTH ) { ICompoundProperty p = parent.getProperties(); IInt32ArrayProperty iap( p, "intArrayProp" ); std::string fullName = const_cast<std::string&>( iap.getObject().getFullName() ); PATH_PAIR ret = PATHS.insert( fullName ); Int32ArraySamplePtr sampPtr = iap.getValue(); TESTING_ASSERT( sampPtr->get()[5] == 5 ); TESTING_ASSERT( sampPtr->get()[99] == 99 ); TESTING_ASSERT( sampPtr->size() == ( size_t ) HIGHVAL ); TESTING_ASSERT( ret.second ); TESTING_ASSERT( fullName == parent.getFullName() ); // walk back up the tree until you find the first child object // under the top object, and check that it's the one we started // with. IObject _p = parent; while ( _p.getParent().getParent() ) { _p = _p.getParent(); } TESTING_ASSERT( _p.getFullName() == orig.getFullName() ); return; } std::ostringstream strm; strm << level; std::string levelName = strm.str(); readDeepHierarchy( IObject( parent, levelName ), level + 1, orig ); }
//-***************************************************************************** void visitObject( IObject iObj, std::string iIndent ) { // Object has a name, a full name, some meta data, // and then it has a compound property full of properties. std::string path = iObj.getFullName(); if ( path != "/" ) { std::cout << "Object " << "name=" << path << std::endl; } // Get the properties. ICompoundProperty props = iObj.getProperties(); visitProperties( props, iIndent ); // now the child objects for ( size_t i = 0 ; i < iObj.getNumChildren() ; i++ ) { visitObject( IObject( iObj, iObj.getChildHeader( i ).getName() ), iIndent ); } }