void save( IECore::Object::SaveContext *context ) const { IndexedIOPtr container = context->container( ShaderNetwork::staticTypeName(), g_ioVersion ); IndexedIOPtr shaders = container->subdirectory( "shaders", IndexedIO::CreateIfMissing ); IndexedIOPtr connections = container->subdirectory( "connections", IndexedIO::CreateIfMissing ); int connectionIndex = 0; for( const Node &node : m_nodes ) { context->save( node.shader.get(), shaders.get(), node.handle ); for( const Connection &connection : node.inputConnections ) { InternedString c[4] = { connection.source.shader, connection.source.name, connection.destination.shader, connection.destination.name }; connections->write( std::to_string( connectionIndex ), c, 4 ); connectionIndex++; } } InternedString o[2] = { m_output.shader, m_output.name }; container->write( "output", o, 2 ); }
void TypedData< TimePeriod >::save( SaveContext *context ) const { Data::save( context ); IndexedIOPtr container = context->container( staticTypeName(), 0 ); container->write( g_beginEntry, boost::posix_time::to_iso_string( readable().begin() ) ); container->write( g_endEntry, boost::posix_time::to_iso_string( readable().end() ) ); }
void Display::save( SaveContext *context ) const { PreWorldRenderable::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); container->write( g_nameEntry, m_name ); container->write( g_typeEntry, m_type ); container->write( g_dataEntry, m_data ); context->save( m_parameters.get(), container.get(), g_parametersEntry ); }
void MeshPrimitive::save( IECore::Object::SaveContext *context ) const { Primitive::save(context); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); context->save( m_verticesPerFace, container, g_verticesPerFaceEntry ); context->save( m_vertexIds, container, g_vertexIdsEntry ); /// \todo: mac has problems with the size_t type, resulting in the write() call being /// ambiguous to the compiler unsigned int numVertices = m_numVertices; container->write( g_numVerticesEntry, numVertices ); container->write( g_interpolationEntry, m_interpolation ); }
void MatrixMotionTransform::save( SaveContext *context ) const { Transform::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); container = container->subdirectory( g_snapshotsEntry, IndexedIO::CreateIfMissing ); int i = 0; for( SnapshotMap::const_iterator it=m_snapshots.begin(); it!=m_snapshots.end(); it++ ) { string is = str( boost::format( "%d" ) % i ); IndexedIOPtr snapshotContainer = container->subdirectory( is, IndexedIO::CreateIfMissing ); snapshotContainer->write( g_timeEntry, it->first ); snapshotContainer->write( g_matrixEntry, it->second.getValue(), 16 ); i++; } }
void CurvesPrimitive::save( IECore::Object::SaveContext *context ) const { Primitive::save(context); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); container->write( g_basisMatrixEntry, m_basis.matrix.getValue(), 16 ); container->write( g_basisStepEntry, m_basis.step ); int p = m_periodic; container->write( g_periodicEntry, p ); context->save( m_vertsPerCurve.get(), container.get(), g_verticesPerCurveEntry ); // we could recompute these on loading, but it'd take a while and the overhead // of storing them isn't great. container->write( g_numVertsEntry, m_numVerts ); container->write( g_numFaceVaryingEntry, m_numFaceVarying ); }
void NURBSPrimitive::save( IECore::Object::SaveContext *context ) const { Primitive::save(context); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); container->write( g_uOrderEntry, m_uOrder ); context->save( m_uKnot.get(), container.get(), g_uKnotEntry ); container->write( g_uMinEntry, m_uMin ); container->write( g_uMaxEntry, m_uMax ); container->write( g_vOrderEntry, m_vOrder ); context->save( m_vKnot.get(), container.get(), g_vKnotEntry ); container->write( g_vMinEntry, m_vMin ); container->write( g_vMaxEntry, m_vMax ); }
void ImagePrimitive::save(IECore::Object::SaveContext *context) const { assert( context ); Primitive::save(context); IndexedIOPtr container = context->container(staticTypeName(), m_ioVersion); container->write(g_displayWindowMinXEntry, m_displayWindow.min.x); container->write(g_displayWindowMinYEntry, m_displayWindow.min.y); container->write(g_displayWindowMaxXEntry, m_displayWindow.max.x); container->write(g_displayWindowMaxYEntry, m_displayWindow.max.y); container->write(g_dataWindowMinXEntry, m_dataWindow.min.x); container->write(g_dataWindowMinYEntry, m_dataWindow.min.y); container->write(g_dataWindowMaxXEntry, m_dataWindow.max.x); container->write(g_dataWindowMaxYEntry, m_dataWindow.max.y); }
void Shader::save( SaveContext *context ) const { StateRenderable::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); container->write( g_nameEntry, m_name ); container->write( g_typeEntry, m_type ); context->save( m_parameters.get(), container.get(), g_parametersEntry ); }
IndexedIOPtr Object::SaveContext::container( const std::string &typeName, unsigned int ioVersion ) { IndexedIOPtr typeIO = m_ioInterface->subdirectory( typeName, IndexedIO::CreateIfMissing ); typeIO->write( g_ioVersionEntry, ioVersion ); IndexedIOPtr dataIO = typeIO->subdirectory( g_dataEntry, IndexedIO::CreateIfMissing ); dataIO->removeAll(); return dataIO; }
void Primitive::save( IECore::Object::SaveContext *context ) const { VisibleRenderable::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); IndexedIOPtr ioVariables = container->subdirectory( g_variablesEntry, IndexedIO::CreateIfMissing ); for( PrimitiveVariableMap::const_iterator it=variables.begin(); it!=variables.end(); it++ ) { IndexedIOPtr ioPrimVar = ioVariables->subdirectory( it->first, IndexedIO::CreateIfMissing ); const int i = it->second.interpolation; ioPrimVar->write( g_interpolationEntry, i ); context->save( it->second.data.get(), ioPrimVar.get(), g_dataEntry ); } }
void PathMatcherData::save( SaveContext *context ) const { Data::save( context ); IndexedIOPtr container = context->container( staticTypeName(), g_ioVersion ); std::vector<InternedString> strings; std::vector<unsigned int> pathLengths; std::vector<unsigned char> exactMatches; for( PathMatcher::RawIterator it = readable().begin(), eIt = readable().end(); it != eIt; ++it ) { pathLengths.push_back( it->size() ); if( it->size() ) { strings.push_back( it->back() ); } exactMatches.push_back( it.exactMatch() ); } container->write( "strings", strings.data(), strings.size() ); container->write( "pathLengths", pathLengths.data(), pathLengths.size() ); container->write( "exactMatches", exactMatches.data(), exactMatches.size() ); }
void MotionPrimitive::save( IECore::Object::SaveContext *context ) const { VisibleRenderable::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); IndexedIOPtr snapshots = container->subdirectory( g_snapshotsEntry, IndexedIO::CreateIfMissing ); int i = 0; for( SnapshotMap::const_iterator it=m_snapshots.begin(); it!=m_snapshots.end(); it++ ) { string is = str( boost::format( "%d" ) % i ); IndexedIOPtr snapshot = snapshots->subdirectory( is, IndexedIO::CreateIfMissing ); snapshot->write( g_timeEntry, it->first ); context->save( it->second, snapshot, g_primitiveEntry ); i++; } }
void Object::SaveContext::save( const Object *toSave, IndexedIO *container, const IndexedIO::EntryID &name ) { if ( !toSave ) { throw Exception( "Error trying to save NULL pointer object!" ); } SavedObjectMap::const_iterator it = m_savedObjects->find( toSave ); if( it!=m_savedObjects->end() ) { container->write( name, &(it->second[0]), it->second.size() ); } else { bool rootObject = ( m_savedObjects->size() == 0 ); if ( rootObject ) { if ( container->hasEntry( name ) ) { container->remove( name ); } } IndexedIOPtr nameIO = container->createSubdirectory( name ); IndexedIO::EntryIDList pathParts; nameIO->path( pathParts ); (*m_savedObjects)[toSave] = pathParts; nameIO->write( g_typeEntry, toSave->typeName() ); IndexedIOPtr dataIO = nameIO->createSubdirectory( g_dataEntry ); dataIO->removeAll(); SaveContext context( dataIO, m_savedObjects ); toSave->save( &context ); // Objects saved on a file can be committed to disk to free memory. if ( rootObject ) { nameIO->commit(); } } }
void ObjectVector::save( SaveContext *context ) const { Object::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); unsigned int size = m_members.size(); container->write( g_sizeEntry, size ); IndexedIOPtr ioMembers = container->subdirectory( g_membersEntry, IndexedIO::CreateIfMissing ); unsigned i=0; for( MemberContainer::const_iterator it=m_members.begin(); it!=m_members.end(); it++ ) { if( *it ) { std::string name = str( boost::format( "%d" ) % i ); context->save( *it, ioMembers, name ); } i++; } }
void MatrixTransform::save( SaveContext *context ) const { Transform::save( context ); IndexedIOPtr container = context->container( staticTypeName(), m_ioVersion ); container->write( g_matrixEntry, matrix.getValue(), 16 ); }