Exemplo n.º 1
0
ObjectPtr Object::LoadContext::loadObjectOrReference( const IndexedIO *container, const IndexedIO::EntryID &name )
{
	IndexedIO::Entry e = container->entry( name );
	if( e.entryType()==IndexedIO::File )
	{
		IndexedIO::EntryIDList pathParts;
		if ( e.dataType() == IndexedIO::InternedStringArray )
		{
			pathParts.resize( e.arrayLength() );
			InternedString *p = &(pathParts[0]); 
			container->read( name, p, e.arrayLength() );
		}
		else 
		{
			// for backward compatibility...
			string path;
			container->read( name, path );
			typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
			// \todo: this would have trouble if the name of the object contains slashes...
			Tokenizer tokens(path, boost::char_separator<char>("/"));
			Tokenizer::iterator t = tokens.begin();

			for ( ; t != tokens.end(); t++ )
			{
				pathParts.push_back( *t );
			}
		}
		std::pair< LoadedObjectMap::iterator,bool > ret = m_loadedObjects->insert( std::pair<IndexedIO::EntryIDList, ObjectPtr>( pathParts, NULL ) );
		if ( ret.second )
		{
			// jump to the path..
			ConstIndexedIOPtr ioObject = m_ioInterface->directory( pathParts );
			// add the loaded object to the map.
			ret.first->second = loadObject( ioObject.get() );
		}
		return ret.first->second;
	}
	else
	{
		ConstIndexedIOPtr ioObject = container->subdirectory( name );

		IndexedIO::EntryIDList pathParts;
		ioObject->path( pathParts );

		std::pair< LoadedObjectMap::iterator,bool > ret = m_loadedObjects->insert( std::pair<IndexedIO::EntryIDList, ObjectPtr>( pathParts, NULL ) );
		if ( ret.second )
		{
			// add the loaded object to the map.
			ret.first->second = loadObject( ioObject.get() );
		}
		return ret.first->second;
	}
}
Exemplo n.º 2
0
		void load( IECore::Object::LoadContextPtr context )
		{
			unsigned int v = g_ioVersion;
			ConstIndexedIOPtr container = context->container( staticTypeName(), v );

			ConstIndexedIOPtr shaders = container->subdirectory( "shaders" );
			IndexedIO::EntryIDList handles;
			shaders->entryIds( handles, IndexedIO::Directory );
			for( const auto &handle : handles )
			{
				ShaderPtr shader = context->load<Shader>( shaders.get(), handle );
				setShader( handle, shader.get() );
			}

			ConstIndexedIOPtr connections = container->subdirectory( "connections" );
			IndexedIO::EntryIDList connectionIndices;
			for( const auto &connectionIndex : connectionIndices )
			{
				InternedString c[4];
				InternedString *cp = c;
				connections->read( connectionIndex, cp, 4 );
				addConnection(
					Connection( Parameter( cp[0], cp[1] ), Parameter( cp[2], cp[3] ) )
				);
			}

			InternedString o[2];
			InternedString *op = o;
			container->read( "output", op, 2 );
			m_output = Parameter( op[0], op[1] );
		}
Exemplo n.º 3
0
void Options::load( LoadContextPtr context )
{
	PreWorldRenderable::load( context );
	unsigned int v = m_ioVersion;
	ConstIndexedIOPtr container = context->container( staticTypeName(), v );
	m_options = context->load<CompoundData>( container.get(), g_optionsEntry );
}
Exemplo n.º 4
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.º 5
0
void NURBSPrimitive::load( IECore::Object::LoadContextPtr context )
{
	Primitive::load(context);
	unsigned int v = m_ioVersion;

	ConstIndexedIOPtr container = context->container( staticTypeName(), v );

	container->read( g_uOrderEntry, m_uOrder );
	m_uKnot = context->load<FloatVectorData>( container.get(), g_uKnotEntry );
	container->read( g_uMinEntry, m_uMin );
	container->read( g_uMaxEntry, m_uMax );

	container->read( g_vOrderEntry, m_vOrder );
	m_vKnot = context->load<FloatVectorData>( container.get(), g_vKnotEntry );
	container->read( g_vMinEntry, m_vMin );
	container->read( g_vMaxEntry, m_vMax );
}
Exemplo n.º 6
0
void Shader::load( LoadContextPtr context )
{
	StateRenderable::load( context );
	unsigned int v = m_ioVersion;
	ConstIndexedIOPtr container = context->container( staticTypeName(), v );
	container->read( g_nameEntry, m_name );
	container->read( g_typeEntry, m_type );
	m_parameters = context->load<CompoundData>( container.get(), g_parametersEntry );
}
Exemplo n.º 7
0
void CurvesPrimitive::load( IECore::Object::LoadContextPtr context )
{
	Primitive::load( context );
	unsigned int v = m_ioVersion;

	ConstIndexedIOPtr container = context->container( staticTypeName(), v );
	float *f = m_basis.matrix.getValue();
	container->read( g_basisMatrixEntry, f, 16 );
	container->read( g_basisStepEntry, m_basis.step );
	m_linear = m_basis==CubicBasisf::linear();
	int p = 0;
	container->read( g_periodicEntry, p );
	m_periodic = p;
	m_vertsPerCurve = context->load<IntVectorData>( container.get(), g_verticesPerCurveEntry );
	container->read( g_numVertsEntry, m_numVerts );
	container->read( g_numFaceVaryingEntry, m_numFaceVarying );
}
Exemplo n.º 8
0
void SmoothSkinningData::load( IECore::Object::LoadContextPtr context )
{
	Data::load(context);
	unsigned int v = m_ioVersion;

	ConstIndexedIOPtr container = context->container( staticTypeName(), v );

	m_influenceNames = context->load<StringVectorData>( container.get(), g_influenceNamesEntry );
	m_influencePose = context->load<M44fVectorData>( container.get(), g_influencePoseEntry );
	m_pointIndexOffsets = context->load<IntVectorData>( container.get(), g_pointIndexOffsetsEntry );
	m_pointInfluenceCounts = context->load<IntVectorData>( container.get(), g_pointInfluenceCountsEntry );
	m_pointInfluenceIndices = context->load<IntVectorData>( container.get(), g_pointInfluenceIndicesEntry );
	m_pointInfluenceWeights = context->load<FloatVectorData>( container.get(), g_pointInfluenceWeightsEntry );

}
Exemplo n.º 9
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.º 10
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.º 11
0
ObjectPtr Object::load( ConstIndexedIOPtr ioInterface, const IndexedIO::EntryID &name )
{
	LoadContextPtr context( new LoadContext( ioInterface ) );
	ObjectPtr result = context->load<Object>( ioInterface.get(), name );
	return result;
}