Exemplo n.º 1
0
void Primitive::load( IECore::Object::LoadContextPtr context )
{
    unsigned int v = m_ioVersion;
    ConstIndexedIOPtr container = context->container( staticTypeName(), v );

    // we changed the inheritance hierarchy at io version 1
    if( v==0 )
    {
        Renderable::load( context );
    }
    else
    {
        VisibleRenderable::load( context );
    }

    ConstIndexedIOPtr ioVariables = container->subdirectory( g_variablesEntry );

    variables.clear();
    IndexedIO::EntryIDList names;
    ioVariables->entryIds( names, IndexedIO::Directory );
    IndexedIO::EntryIDList::const_iterator it;
    for( it=names.begin(); it!=names.end(); it++ )
    {
        ConstIndexedIOPtr ioPrimVar = ioVariables->subdirectory( *it );
        int i;
        ioPrimVar->read( g_interpolationEntry, i );
        variables.insert(
            PrimitiveVariableMap::value_type( *it, PrimitiveVariable( (PrimitiveVariable::Interpolation)i, context->load<Data>( ioPrimVar.get(), g_dataEntry ) ) )
        );
    }
}
Exemplo n.º 2
0
PrimitiveVariableMap Primitive::loadPrimitiveVariables( const IndexedIO *ioInterface, const IndexedIO::EntryID &name, const IndexedIO::EntryIDList &primVarNames )
{
    IECore::Object::LoadContextPtr context = new Object::LoadContext( ioInterface->subdirectory( name )->subdirectory( g_dataEntry ) );

    unsigned int v = m_ioVersion;
    ConstIndexedIOPtr container = context->container( Primitive::staticTypeName(), v );
    if ( !container )
    {
        throw Exception( "Could not find Primitive entry in the file!" );
    }
    ConstIndexedIOPtr ioVariables = container->subdirectory( g_variablesEntry );

    PrimitiveVariableMap variables;
    IndexedIO::EntryIDList::const_iterator it;
    for( it=primVarNames.begin(); it!=primVarNames.end(); it++ )
    {
        ConstIndexedIOPtr ioPrimVar = ioVariables->subdirectory( *it, IndexedIO::NullIfMissing );
        if ( !ioPrimVar )
        {
            continue;
        }
        int i;
        ioPrimVar->read( g_interpolationEntry, i );
        variables.insert(
            PrimitiveVariableMap::value_type( *it, PrimitiveVariable( (PrimitiveVariable::Interpolation)i, context->load<Data>( ioPrimVar.get(), g_dataEntry ) ) )
        );
    }

    return variables;
}
Exemplo n.º 3
0
void CompoundDataBase::load( LoadContextPtr context )
{
	Data::load( context );
	unsigned int v = 0;
	ConstIndexedIOPtr container = nullptr;

	try
	{
		container = context->container( staticTypeName(), v );
	}
	catch( const IOException &e )
	{
		// probably a file with CORTEX_MAJOR_VERSION < 5, get the
		// data from CompoundData container instead.
		container = context->container( "CompoundData", v );
	}

	CompoundDataMap &m = writable();
	m.clear();
	container = container->subdirectory( g_membersEntry );

	IndexedIO::EntryIDList memberNames;
	container->entryIds( memberNames );
	IndexedIO::EntryIDList::const_iterator it;
	for( it=memberNames.begin(); it!=memberNames.end(); it++ )
	{
		m[*it] = context->load<Data>( container.get(), *it );
	}
}
Exemplo n.º 4
0
CompoundObjectPtr AttributeCache::readHeader( )
{
	CompoundObjectPtr dict = new CompoundObject();

	IndexedIO::EntryIDList directories;
	m_headersIO->entryIds( directories, IndexedIO::Directory );

	for (IndexedIO::EntryIDList::const_iterator it = directories.begin(); it != directories.end(); ++it)
	{
		ObjectPtr data = Object::load( m_headersIO, *it );
		dict->members()[ *it ] = data;
	}

	return dict;
}
Exemplo n.º 5
0
CompoundObjectPtr AttributeCache::read( const ObjectHandle &obj )
{
	CompoundObjectPtr dict = new CompoundObject();

	IndexedIO::EntryIDList directories;
	IndexedIOPtr object = m_objectsIO->subdirectory( obj );
	object->entryIds( directories, IndexedIO::Directory );

	for (IndexedIO::EntryIDList::const_iterator it = directories.begin(); it != directories.end(); ++it)
	{
		ObjectPtr data = Object::load( object, *it );
		dict->members()[ *it ] = data;
	}

	return dict;
}
Exemplo n.º 6
0
void MotionPrimitive::load( IECore::Object::LoadContextPtr context )
{
	VisibleRenderable::load( context );
	unsigned int v = m_ioVersion;
	ConstIndexedIOPtr container = context->container( staticTypeName(), v );
	ConstIndexedIOPtr snapshots = container->subdirectory( g_snapshotsEntry );
	m_snapshots.clear();
	IndexedIO::EntryIDList names;
	snapshots->entryIds( names, IndexedIO::Directory );
	IndexedIO::EntryIDList::const_iterator it;
	for( it=names.begin(); it!=names.end(); it++ )
	{
		ConstIndexedIOPtr snapshot = snapshots->subdirectory( *it );
		float t; 
		snapshot->read( g_timeEntry, t );
		m_snapshots[t] = context->load<Primitive>( snapshot, g_primitiveEntry );
	}
}
Exemplo n.º 7
0
void AttributeCache::attributes(const ObjectHandle &obj, const std::string regex, std::vector<AttributeHandle> &attrs)
{
	IndexedIO::EntryIDList directories;
	attributes( obj, directories );

	boost::regex regexTest(regex);
	boost::cmatch what;

	attrs.clear();
	attrs.reserve( directories.size() );
	for (IndexedIO::EntryIDList::const_iterator it = directories.begin(); it != directories.end(); ++it)
	{
		if ( regex_match( (*it).value().c_str(), what, regexTest) )
		{
			attrs.push_back( *it );
		}
	}
}
void MatrixMotionTransform::load( LoadContextPtr context )
{
	Transform::load( context );
	unsigned int v = m_ioVersion;

	ConstIndexedIOPtr container = context->container( staticTypeName(), v );
	container = container->subdirectory( g_snapshotsEntry );
	m_snapshots.clear();
	IndexedIO::EntryIDList names;
	container->entryIds( names, IndexedIO::Directory );
	IndexedIO::EntryIDList::const_iterator it;
	for( it=names.begin(); it!=names.end(); it++ )
	{
		ConstIndexedIOPtr snapshotContainer = container->subdirectory( *it );
		float t; snapshotContainer->read( g_timeEntry, t );
		M44f m;
		float *f = m.getValue();
		snapshotContainer->read( g_matrixEntry, f, 16 );
		m_snapshots[t] = m;
	}
}
Exemplo n.º 9
0
void ObjectVector::load( LoadContextPtr context )
{
	Object::load( context );
	unsigned int v = m_ioVersion;
	ConstIndexedIOPtr container = context->container( staticTypeName(), v );

	unsigned int size = 0;
	container->read( g_sizeEntry, size );

	m_members.resize( size );
	std::fill( m_members.begin(), m_members.end(), (IECore::Object*)0 );

	ConstIndexedIOPtr ioMembers = container->subdirectory( g_membersEntry );

	IndexedIO::EntryIDList l;
	ioMembers->entryIds(l);
	for( IndexedIO::EntryIDList::const_iterator it=l.begin(); it!=l.end(); it++ )
	{
		MemberContainer::size_type i = boost::lexical_cast<MemberContainer::size_type>( (*it).value() );
		m_members[i] = context->load<Object>( ioMembers, *it );
	}
}