Ejemplo n.º 1
0
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);
	}
}
Ejemplo 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] );
		}
Ejemplo n.º 3
0
void Display::load( LoadContextPtr context )
{
	PreWorldRenderable::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 );
	container->read( g_dataEntry, m_data );
	m_parameters = context->load<CompoundData>( container.get(), g_parametersEntry );
}
Ejemplo n.º 4
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 );
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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 ) ) )
        );
    }
}
Ejemplo n.º 7
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 );
}
Ejemplo n.º 8
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 );
}
Ejemplo n.º 9
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 );
}
Ejemplo n.º 10
0
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;
	}
}
Ejemplo n.º 11
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 );
		}
	}
}
Ejemplo n.º 12
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 );
}
Ejemplo n.º 13
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 );
	}
}
Ejemplo n.º 14
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 );
	}
}
Ejemplo n.º 15
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 );
}