Beispiel #1
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 );
}
void ImagePrimitive::load(IECore::Object::LoadContextPtr context)
{
	assert( context );

	Primitive::load(context);
	unsigned int v = m_ioVersion;

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

	container->read(g_displayWindowMinXEntry, m_displayWindow.min.x);
	container->read(g_displayWindowMinYEntry, m_displayWindow.min.y);
	container->read(g_displayWindowMaxXEntry, m_displayWindow.max.x);
	container->read(g_displayWindowMaxYEntry, m_displayWindow.max.y);

	if ( v < 1 )
	{
		m_dataWindow = m_displayWindow;
	}
	else
	{
		container->read(g_dataWindowMinXEntry, m_dataWindow.min.x);
		container->read(g_dataWindowMinYEntry, m_dataWindow.min.y);
		container->read(g_dataWindowMaxXEntry, m_dataWindow.max.x);
		container->read(g_dataWindowMaxYEntry, m_dataWindow.max.y);
	}
}
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 );
	}
}
Beispiel #4
0
void MatrixTransform::load( LoadContextPtr context )
{
	Transform::load( context );
	unsigned int v = m_ioVersion;
	ConstIndexedIOPtr container = context->container( staticTypeName(), v );
	float *f = matrix.getValue();
	container->read( g_matrixEntry, f, 16 );
}
Beispiel #5
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 );
}
Beispiel #6
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] );
		}
Beispiel #7
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 );
		}
		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 );
		}
		return ret.first->second;
	}
}
Beispiel #8
0
void MeshPrimitive::load( IECore::Object::LoadContextPtr context )
{
    Primitive::load(context);
    unsigned int v = m_ioVersion;

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

    m_verticesPerFace = context->load<IntVectorData>( container, g_verticesPerFaceEntry );
    m_vertexIds = context->load<IntVectorData>( container, g_vertexIdsEntry );

    unsigned int numVertices;
    container->read( g_numVerticesEntry, numVertices );
    m_numVertices = numVertices;

    container->read( g_interpolationEntry, m_interpolation );
}
Beispiel #9
0
ConstIndexedIOPtr Object::LoadContext::container( const std::string &typeName, unsigned int &ioVersion, bool throwIfMissing )
{
	ConstIndexedIOPtr typeIO = m_ioInterface->subdirectory( typeName, throwIfMissing ? IndexedIO::ThrowIfMissing : IndexedIO::NullIfMissing );
	if ( !typeIO )
	{
		return 0;
	}
	unsigned int v;
	typeIO->read( g_ioVersionEntry, v );
	if( v > ioVersion )
	{
		throw( IOException( "File version greater than library version." ) );
	}
	ioVersion = v;
	return typeIO->subdirectory( g_dataEntry, throwIfMissing ? IndexedIO::ThrowIfMissing : IndexedIO::NullIfMissing );
}
Beispiel #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 ) ) )
        );
    }
}
Beispiel #11
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;
}
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 );
	}
}
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 );

}
Beispiel #14
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 );
}
Beispiel #15
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 );
}
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 );
	}
}
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;
	}
}
Beispiel #18
0
void PathMatcherData::load( LoadContextPtr context )
{
	Data::load( context );
	unsigned int v = g_ioVersion;
	ConstIndexedIOPtr container = context->container( staticTypeName(), v );

	const IndexedIO::Entry stringsEntry = container->entry( "strings" );
	std::vector<InternedString> strings;
	strings.resize( stringsEntry.arrayLength() );
	InternedString *stringsPtr = strings.data();
	container->read( "strings", stringsPtr, stringsEntry.arrayLength() );

	const IndexedIO::Entry pathLengthsEntry = container->entry( "pathLengths" );
	std::vector<unsigned int> pathLengths;
	pathLengths.resize( pathLengthsEntry.arrayLength() );
	unsigned int *pathLengthsPtr = pathLengths.data();
	container->read( "pathLengths", pathLengthsPtr, pathLengthsEntry.arrayLength() );

	const IndexedIO::Entry exactMatchesEntry = container->entry( "exactMatches" );
	std::vector<unsigned char> exactMatches;
	exactMatches.resize( exactMatchesEntry.arrayLength() );
	unsigned char *exactMatchesPtr = exactMatches.data();
	container->read( "exactMatches", exactMatchesPtr, exactMatchesEntry.arrayLength() );

	std::vector<InternedString> path;
	for( size_t i = 0, e = pathLengths.size(); i < e; ++i )
	{
		path.resize( pathLengths[i] );
		if( pathLengths[i] )
		{
			path.back() = *stringsPtr++;
		}
		if( exactMatches[i] )
		{
			writable().addPath( path );
		}
	}
}
Beispiel #19
0
void TypedData< TimePeriod >::load( LoadContextPtr context )
{
	Data::load( context );

	unsigned int v = 0;

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

	std::string beginStr;
	container->read( g_beginEntry, beginStr );
	boost::posix_time::ptime begin;
	try
	{
		begin = boost::posix_time::from_iso_string( beginStr );
	}
	catch ( boost::bad_lexical_cast )
	{
		/// Do these checks here instead of first as they're likely to be the least-used cases.
		if ( beginStr == "not-a-date-time" )
		{
			begin = boost::posix_time::not_a_date_time;
		}
		else if ( beginStr == "+infinity" )
		{
			begin = boost::posix_time::pos_infin;
		}
		else if ( beginStr == "-infinity" )
		{
			begin = boost::posix_time::neg_infin;
		}
		else
		{
			throw;
		}
	}

	std::string endStr;
	container->read( g_endEntry, endStr );
	boost::posix_time::ptime end;
	try
	{
		end = boost::posix_time::from_iso_string( endStr );
	}
	catch ( boost::bad_lexical_cast )
	{
		/// Do these checks here instead of first as they're likely to be the least-used cases.
		if ( endStr == "not-a-date-time" )
		{
			end = boost::posix_time::not_a_date_time;
		}
		else if ( endStr == "+infinity" )
		{
			end = boost::posix_time::pos_infin;
		}
		else if ( endStr == "-infinity" )
		{
			end = boost::posix_time::neg_infin;
		}
		else
		{
			throw;
		}
	}

	writable() = boost::posix_time::time_period( begin, end );
}
Beispiel #20
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;
}