Cortex  10.0.0-a4
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
IECore::SceneCache Class Reference

#include <SceneCache.h>

+ Inheritance diagram for IECore::SceneCache:

Public Types

typedef SceneInterface::Name Name
 
typedef SceneInterface::NameList NameList
 
typedef SceneInterface::Path Path
 
- Public Types inherited from IECore::SceneInterface
enum  MissingBehaviour { ThrowIfMissing = IndexedIO::ThrowIfMissing, NullIfMissing = IndexedIO::NullIfMissing, CreateIfMissing = IndexedIO::CreateIfMissing }
 
enum  TagFilter { DescendantTag = 1, LocalTag = 2, AncestorTag = 4, EveryTag = DescendantTag | LocalTag | AncestorTag }
 
enum  HashType {
  TransformHash, AttributesHash, BoundHash, ObjectHash,
  ChildNamesHash, HierarchyHash
}
 
typedef IndexedIO::EntryID Name
 
typedef IndexedIO::EntryIDList NameList
 
typedef IndexedIO::EntryIDList Path
 
- Public Types inherited from IECore::RunTimeTyped
typedef RefCounted BaseClass
 A typedef for the class this class derives from. All RunTimeTyped classes define this typedef.
 
- Public Types inherited from IECore::RefCounted
typedef size_t RefCount
 

Public Member Functions

 IE_CORE_DECLARERUNTIMETYPED (SceneCache, SampledSceneInterface)
 
 SceneCache (const std::string &fileName, IndexedIO::OpenMode mode)
 
 SceneCache (IECore::IndexedIOPtr indexedIO)
 
std::string fileName () const override
 Returns the file that this scene is mapped to. Throws exception if there's no file.
 
Name name () const override
 Returns the name of the scene location which this instance is referring to. The root path returns "/".
 
void path (Path &p) const override
 Returns the path scene this instance is referring to.
 
size_t numBoundSamples () const override
 Returns the number of bounding box samples are available for reading.
 
double boundSampleTime (size_t sampleIndex) const override
 Returns the time associated with the specified bounding box sample.
 
double boundSampleInterval (double time, size_t &floorIndex, size_t &ceilIndex) const override
 Computes a sample interval suitable for use in producing interpolated bounding box values.
 
Imath::Box3d readBoundAtSample (size_t sampleIndex) const override
 Returns the local bounding box of this node stored for the specified sample.
 
void writeBound (const Imath::Box3d &bound, double time) override
 
size_t numTransformSamples () const override
 Returns the number of transform samples are available for reading.
 
double transformSampleTime (size_t sampleIndex) const override
 Returns the time associated with the specified transform sample.
 
double transformSampleInterval (double time, size_t &floorIndex, size_t &ceilIndex) const override
 Computes a sample interval suitable for use in producing interpolated transform values.
 
ConstDataPtr readTransformAtSample (size_t sampleIndex) const override
 Returns the transform applied to this path within the scene.
 
Imath::M44d readTransformAsMatrixAtSample (size_t sampleIndex) const override
 Returns the transform applied to this path within the scene as a matrix.
 
void writeTransform (const Data *transform, double time) override
 
bool hasAttribute (const Name &name) const override
 Convenience method to determine if an attribute exists without reading it.
 
void attributeNames (NameList &attrs) const override
 Fills attrs with the names of all attributes available in the current directory.
 
size_t numAttributeSamples (const Name &name) const override
 Returns the number of attribute samples are available for reading.
 
double attributeSampleTime (const Name &name, size_t sampleIndex) const override
 Returns the time associated with the specified attribute sample.
 
double attributeSampleInterval (const Name &name, double time, size_t &floorIndex, size_t &ceilIndex) const override
 Computes a sample interval suitable for use in producing interpolated attribute values.
 
ConstObjectPtr readAttributeAtSample (const Name &name, size_t sampleIndex) const override
 Reads the named attribute applied to this path within the scene.
 
void writeAttribute (const Name &name, const Object *attribute, double time) override
 
bool hasTag (const Name &name, int filter=SceneInterface::LocalTag) const override
 
void readTags (NameList &tags, int filter=SceneInterface::LocalTag) const override
 
void writeTags (const NameList &tags) override
 Adds tags to the current scene location.
 
bool hasObject () const override
 Convenience method to determine if a piece of geometry exists without reading it.
 
size_t numObjectSamples () const override
 Returns the number of object samples are available for reading.
 
double objectSampleTime (size_t sampleIndex) const override
 Returns the time associated with the specified object sample.
 
double objectSampleInterval (double time, size_t &floorIndex, size_t &ceilIndex) const override
 Computes a sample interval suitable for use in producing interpolated objects.
 
ConstObjectPtr readObjectAtSample (size_t sampleIndex) const override
 
PrimitiveVariableMap readObjectPrimitiveVariables (const std::vector< InternedString > &primVarNames, double time) const override
 
void writeObject (const Object *object, double time) override
 
bool hasChild (const Name &name) const override
 Convenience method to determine if a child exists.
 
void childNames (NameList &childNames) const override
 
SceneInterfacePtr child (const Name &name, SceneInterface::MissingBehaviour missingBehaviour=ThrowIfMissing) override
 
ConstSceneInterfacePtr child (const Name &name, SceneInterface::MissingBehaviour missingBehaviour=ThrowIfMissing) const override
 Returns a read-only interface for a child location in the scene.
 
SceneInterfacePtr createChild (const Name &name) override
 
SceneInterfacePtr scene (const Path &path, MissingBehaviour missingBehaviour=ThrowIfMissing) override
 Returns a interface for querying the scene at the given path (full path).
 
ConstSceneInterfacePtr scene (const Path &path, SceneInterface::MissingBehaviour missingBehaviour=ThrowIfMissing) const override
 Returns a const interface for querying the scene at the given path (full path).
 
void hash (HashType hashType, double time, MurmurHash &h) const override
 
bool readOnly () const
 tells you if this scene cache is read only or writable:
 
- Public Member Functions inherited from IECore::SampledSceneInterface
 IE_CORE_DECLARERUNTIMETYPED (SampledSceneInterface, SceneInterface)
 
Imath::Box3d readBound (double time) const override
 
ConstDataPtr readTransform (double time) const override
 
Imath::M44d readTransformAsMatrix (double time) const override
 
ConstObjectPtr readAttribute (const Name &name, double time) const override
 Returns the attribute value at the given time.
 
ConstObjectPtr readObject (double time) const override
 Reads the object stored at this path in the scene at the given time.
 
- Public Member Functions inherited from IECore::SceneInterface
 IE_CORE_DECLARERUNTIMETYPED (SceneInterface, RunTimeTyped)
 
virtual bool hasBound () const
 
- Public Member Functions inherited from IECore::RunTimeTyped
 IE_CORE_DECLAREMEMBERPTR (RunTimeTyped)
 
virtual TypeId typeId () const
 
virtual const char * typeName () const
 
virtual bool isInstanceOf (TypeId typeId) const
 
virtual bool isInstanceOf (const char *typeName) const
 
- Public Member Functions inherited from IECore::RefCounted
 IE_CORE_DECLAREMEMBERPTR (RefCounted)
 
void addRef () const
 Add a reference to the current object.
 
void removeRef () const
 Remove a reference from the current object.
 
RefCount refCount () const
 Returns the current reference count.
 

Static Public Attributes

static const NameanimatedObjectTopologyAttribute
 
static const NameanimatedObjectPrimVarsAttribute
 
- Static Public Attributes inherited from IECore::SceneInterface
static const NamerootName
 Constant name assigned to the root location "/".
 
static const Path & rootPath
 Utility variable that can be used anytime you want to refer to the root path in the Scene.
 
static const NamevisibilityName
 Name of the visibility attribute.
 

Protected Member Functions

 IE_CORE_FORWARDDECLARE (Implementation)
 
virtual SceneCachePtr duplicate (ImplementationPtr &implementation) const
 
 SceneCache (ImplementationPtr &implementation)
 
void writeTags (const NameList &tags, bool descendentTags)
 

Friends

class LinkedScene
 

Additional Inherited Members

- Static Public Member Functions inherited from IECore::SceneInterface
static SceneInterfacePtr create (const std::string &path, IndexedIO::OpenMode mode)
 
static std::vector< std::string > supportedExtensions (IndexedIO::OpenMode modes=IndexedIO::Read|IndexedIO::Write|IndexedIO::Append)
 
static void pathToString (const Path &p, std::string &path)
 Converts a internal Path to a path-like string. The root path results in "/".
 
static void stringToPath (const std::string &path, Path &p)
 
- Static Public Member Functions inherited from IECore::RunTimeTyped
static TypeId staticTypeId ()
 Returns the TypeId for this class, without needing an instance.
 
static const char * staticTypeName ()
 Returns the type name for this class, without needing an instance.
 
static TypeId baseTypeId ()
 
static const char * baseTypeName ()
 
static bool inheritsFrom (TypeId typeId)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (const char *typeName)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (TypeId type, TypeId baseType)
 Returns true if type inherits from baseType.
 
static bool inheritsFrom (const char *typeName, const char *baseTypeName)
 Returns true if typeName inherits from baseTypeName.
 
static TypeId baseTypeId (TypeId typeId)
 Returns the base type of the given type, or InvalidTypeId if no such base exists.
 
static const std::vector< TypeId > & baseTypeIds (TypeId typeId)
 
static const std::set< TypeId > & derivedTypeIds (TypeId typeId)
 
static TypeId typeIdFromTypeName (const char *typeName)
 
static const char * typeNameFromTypeId (TypeId typeId)
 
static void registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId)
 Allows external modules to register their own type ids.
 
- Protected Types inherited from IECore::SceneInterface
typedef SceneInterfacePtr(* CreatorFn) (const std::string &, IndexedIO::OpenMode)
 
- Protected Types inherited from IECore::RunTimeTyped
typedef std::map< TypeId, TypeIdBaseTypeRegistryMap
 
typedef std::map< TypeId, std::vector< TypeId > > BaseTypesRegistryMap
 
typedef std::map< TypeId, std::set< TypeId > > DerivedTypesRegistryMap
 
typedef tbb::spin_rw_mutex Mutex
 
typedef std::map< TypeId, std::string > TypeIdsToTypeNamesMap
 
typedef std::map< std::string, TypeIdTypeNamesToTypeIdsMap
 
- Static Protected Member Functions inherited from IECore::SceneInterface
static CreatorMap & fileCreators ()
 
static void registerCreator (const std::string &extension, IndexedIO::OpenMode modes, CreatorFn f)
 
- Static Protected Member Functions inherited from IECore::RunTimeTyped
static BaseTypeRegistryMap & baseTypeRegistry ()
 
static DerivedTypesRegistryMap & derivedTypesRegistry ()
 
static BaseTypesRegistryMap & completeBaseTypesRegistry ()
 
static DerivedTypesRegistryMap & completeDerivedTypesRegistry ()
 
static void derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &)
 
static TypeIdsToTypeNamesMap & typeIdsToTypeNames ()
 
static TypeNamesToTypeIdsMap & typeNamesToTypeIds ()
 
- Static Protected Attributes inherited from IECore::RunTimeTyped
static Mutex g_baseTypeIdsMutex
 
static Mutex g_derivedTypeIdsMutex
 

Detailed Description

A simple means of saving and loading hierarchical descriptions of animated scene, with the ability to traverse the scene and perform partial loading on demand. When saving, it's important to keep the initial root SceneCache object alive until the very end. The destruction of the root scene will trigger the recursive computation of the bounding boxes for all the locations that no bounds were written. It will also store (without duplication) all the sample times used by objects, transforms, bounds and attributes.

Constructor & Destructor Documentation

IECore::SceneCache::SceneCache ( const std::string &  fileName,
IndexedIO::OpenMode  mode 
)

Opens the cache, using the specified open mode, and setting the current object path to "/". Depending on what mode is chosen, different subsets of the methods below are available. When the open mode is Read, only the const methods may be used and when the open mode is Write, the non-const methods may be used in addition. Append mode is currently not supported.

IECore::SceneCache::SceneCache ( IECore::IndexedIOPtr  indexedIO)

Constructor which uses an already-opened IndexedIO, this can be used if you wish to use an alternative IndexedIO implementation for the backend. The given IndexedIO should be pointing to the root location on the file. The open mode will be the same from the given IndexedIO object. Append mode is not supported.

Member Function Documentation

SceneInterfacePtr IECore::SceneCache::child ( const Name name,
SceneInterface::MissingBehaviour  missingBehaviour = ThrowIfMissing 
)
overridevirtual

Returns an object for the specified child location in the scene. If the child does not exist then it will behave according to the missingBehavior parameter. May throw and exception, may return a NULL pointer, or may create the child (if that is possible). Bounding boxes will be automatically propagated up from the children to the parent as it is written.

Implements IECore::SceneInterface.

void IECore::SceneCache::childNames ( NameList &  childNames) const
overridevirtual

Queries the names of any existing children of path() within the scene.

Implements IECore::SceneInterface.

SceneInterfacePtr IECore::SceneCache::createChild ( const Name name)
overridevirtual

Returns a writable interface to a new child. Throws an exception if it already exists. Bounding boxes will be automatically propagated up from the children to the parent as it is written.

Implements IECore::SceneInterface.

Referenced by IECoreMaya.FnSceneShape::expandOnce().

void IECore::SceneCache::hash ( HashType  hashType,
double  time,
MurmurHash h 
) const
overridevirtual

Computes the requested type of hash for the current location on the scene at the given time. The hash returned is not content-based, but it uniquely identifies the queried information so that it can be used for memory caches, for example, used by ComputationCache objects. This function is only available when reading scenes and it raises an exception otherwise. The base class implementation only adds the class typeId information to garantee that the hash won't collide with other Cortex objects and derived classes are responsible to call the base class implementation as well as add the time dependency as applicable.

Reimplemented from IECore::SceneInterface.

bool IECore::SceneCache::hasTag ( const Name name,
int  filter = SceneInterface::LocalTag 
) const
overridevirtual

Utility function that quickly checks for the existence of one tag relative to the current scene location and the given filter.

Parameters
filterWill filter the results based on a combination of flags DescendantTag, LocalTag and AncestorTag. Use LocalTag for tags stored in the current scene location (default). DescendantTags for tags stored in child locations and AncestorTags for tags stored in parent locations. Some implementations may not support all combinations of these flags and will ignore them.

Implements IECore::SceneInterface.

ConstObjectPtr IECore::SceneCache::readObjectAtSample ( size_t  sampleIndex) const
overridevirtual

Reads the object stored at this path in the scene - may return 0 when no object has been stored.

Implements IECore::SampledSceneInterface.

PrimitiveVariableMap IECore::SceneCache::readObjectPrimitiveVariables ( const std::vector< InternedString > &  primVarNames,
double  time 
) const
overridevirtual

Reads primitive variables from the object of type Primitive stored at this path in the scene at the given time. Raises exception if it turns out not to be a Primitive object.

Implements IECore::SceneInterface.

void IECore::SceneCache::readTags ( NameList &  tags,
int  filter = SceneInterface::LocalTag 
) const
overridevirtual

Reads all the tags relative to the current scene location and the filter. Does not guarantee unique set of tags to be returned.

Parameters
filterWill filter the results based on a combination of flags DescendantTag, LocalTag and AncestorTag. Use LocalTag for tags stored in the current scene location (default). DescendantTags for tags stored in child locations and AncestorTags for tags stored in parent locations. Some implementations may not support all combinations of these flags and will ignore them.

Implements IECore::SceneInterface.

void IECore::SceneCache::writeAttribute ( const Name name,
const Object attribute,
double  time 
)
overridevirtual

Writers the attribute to this path within the scene Raises an exception if you try to write an attribute in the root path with a time different than 0.

Implements IECore::SceneInterface.

void IECore::SceneCache::writeBound ( const Imath::Box3d &  bound,
double  time 
)
overridevirtual

Writes the bound for this path, overriding the default bound that would be written automatically. Note that it might be useful when writing objects which conceptually have a bound but don't derive from VisibleRenderable.

Implements IECore::SceneInterface.

void IECore::SceneCache::writeObject ( const Object object,
double  time 
)
overridevirtual

Writes a geometry to this path in the scene. Raises an exception if you try to write an object in the root path.

Implements IECore::SceneInterface.

void IECore::SceneCache::writeTags ( const NameList &  tags,
bool  descendentTags 
)
protected

LinkedScene need to specify whether the tag is supposed to be saved as a local tag or a tag that was artificially inherited from the child transforms.

void IECore::SceneCache::writeTransform ( const Data transform,
double  time 
)
overridevirtual

Writes the transform applied to this path within the scene. Raises an exception if you try to write transform in the root path Currently it only accepts M44dData or TransformationMatrixdData.

Implements IECore::SceneInterface.


The documentation for this class was generated from the following file: