Cortex  10.0.0-a4
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
IECore::LinkedScene Class Reference

#include <LinkedScene.h>

+ Inheritance diagram for IECore::LinkedScene:

Public Member Functions

 IE_CORE_DECLARERUNTIMETYPED (LinkedScene, SampledSceneInterface)
 
 LinkedScene (const std::string &fileName, IndexedIO::OpenMode mode)
 
 LinkedScene (ConstSceneInterfacePtr mainScene)
 
void writeLink (const SceneInterface *scene)
 
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.
 
Imath::Box3d readBound (double time) const override
 
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.
 
ConstDataPtr readTransform (double time) const override
 
Imath::M44d readTransformAsMatrix (double time) const override
 
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.
 
ConstObjectPtr readAttribute (const Name &name, double time) const override
 Returns the attribute value at the given time.
 
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
 
ConstObjectPtr readObject (double time) const override
 Reads the object stored at this path in the scene at the given time.
 
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
 
- 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 Member Functions

static IECore::CompoundDataPtr linkAttributeData (const SceneInterface *scene)
 Returns the data that should be stored in a link attribute if we want to map it to the given scene (no time remapping).
 
static IECore::CompoundDataPtr linkAttributeData (const SceneInterface *scene, double time)
 
- 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.
 

Static Public Attributes

static const NamelinkAttribute
 Equals to "SceneInterface:link" and it's the name given to the link attribute that is recognized.
 
static const NamefileNameLinkAttribute
 
static const NamerootLinkAttribute
 
static const NametimeLinkAttribute
 
- 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.
 

Additional Inherited Members

- 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
 
- 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

Implements a scene that have references (links) to external scenes. Links can be created at any location in a scene. When a link is created in a given location, the object, bounds and children will be loaded from the linked scene (with time remapping). The transform, attributes are still loaded from the main scene. Tags defined in the link location will be applied (when read) to all the child transforms from the linked scene. This class wraps another SceneInterface object that is responsible for actually storing the data (we call it the "main scene"). Links are represented as an attribute in the main scene called "SceneInterface:link". When created for reading, this class provides seamless access to the hierarchy inside the linked scenes, concatenating the two hierarchies in a single path that uniquely identify that location. The time is also transparently translated. Tags that were saved in the linked scene are propagated to the main scene, to keep consistent behavior. When writing, there's no access to the contents of the indexed scene. Instead, it creates the links by either (1) calls to the function writeLink() or (2) calls to the function writeAttribute( LinkedScene::linkSceneAttribute, LinkedScene::linkAttributeData(), ... ). Note that the link can be animated, allowing for time remapped animations.

Constructor & Destructor Documentation

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

When the open mode is Read it expands the links and only the const methods may be used and the when the open mode is Write, only the non-const methods may be used and Append mode is not supported.

IECore::LinkedScene::LinkedScene ( ConstSceneInterfacePtr  mainScene)

Constructor for wrapping the given read-only scene and expanding its links. If the scene is not sampled then the sampled-specific functions will raise exceptions.

Member Function Documentation

SceneInterfacePtr IECore::LinkedScene::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::LinkedScene::childNames ( NameList &  childNames) const
overridevirtual

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

Implements IECore::SceneInterface.

SceneInterfacePtr IECore::LinkedScene::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::LinkedScene::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::LinkedScene::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.

static IECore::CompoundDataPtr IECore::LinkedScene::linkAttributeData ( const SceneInterface scene,
double  time 
)
static

Returns the data that should be stored in a link attribute if we want to map it to the given scene (with time remapping).

Parameters
timeSpecifies the time that should be used to query the given scene
Imath::Box3d IECore::LinkedScene::readBound ( double  time) const
overridevirtual

Returns the bounding box for the entire scene contents from path() down, inclusive of the object at this path, but exclusive of the transform at this path.

Implements IECore::SceneInterface.

ConstObjectPtr IECore::LinkedScene::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::LinkedScene::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::LinkedScene::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.

ConstDataPtr IECore::LinkedScene::readTransform ( double  time) const
overridevirtual

Returns the interpolated transform object of this node at the specified point in time.

Implements IECore::SceneInterface.

Imath::M44d IECore::LinkedScene::readTransformAsMatrix ( double  time) const
overridevirtual

Returns the transform of this node at the specified point in time as a matrix.

Implements IECore::SceneInterface.

void IECore::LinkedScene::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::LinkedScene::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::LinkedScene::writeLink ( const SceneInterface scene)

Creates an attribute on the current location of this scene that represents a link to the given scene (no time remapping). This function should only be used once in a given scene location. For more control (and time remapping), use writeAttribute in combination with linkAttributeData.

void IECore::LinkedScene::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::LinkedScene::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: