35 #ifndef IECOREHOUDINI_LIVESCENE_H
36 #define IECOREHOUDINI_LIVESCENE_H
38 #include "OP/OP_Node.h"
39 #include "UT/UT_String.h"
41 #include "IECore/SceneInterface.h"
43 #include "IECoreHoudini/DetailSplitter.h"
44 #include "IECoreHoudini/TypeIds.h"
49 IE_CORE_FORWARDDECLARE( LiveScene );
61 LiveScene(
const UT_String &nodePath,
const Path &contentPath,
const Path &
rootPath,
double defaultTime = std::numeric_limits<double>::infinity() );
65 virtual std::string
fileName()
const;
68 virtual void path( Path &p )
const;
70 virtual Imath::Box3d
readBound(
double time )
const;
71 virtual void writeBound(
const Imath::Box3d &bound,
double time );
73 virtual IECore::ConstDataPtr
readTransform(
double time )
const;
77 Imath::M44d readWorldTransformAsMatrix(
double time )
const;
81 virtual void attributeNames( NameList &attrs )
const;
82 virtual IECore::ConstObjectPtr
readAttribute(
const Name &name,
double time )
const;
85 virtual bool hasTag(
const Name &name,
int filter = SceneInterface::LocalTag )
const;
86 virtual void readTags( NameList &tags,
int filter = SceneInterface::LocalTag )
const;
87 virtual void writeTags(
const NameList &tags );
90 virtual IECore::ConstObjectPtr
readObject(
double time )
const;
94 virtual void childNames( NameList &childNames )
const;
96 virtual IECore::SceneInterfacePtr
child(
const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing );
97 virtual IECore::ConstSceneInterfacePtr
child(
const Name &name, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing )
const;
100 virtual IECore::SceneInterfacePtr scene(
const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing );
101 virtual IECore::ConstSceneInterfacePtr scene(
const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing )
const;
107 const OP_Node *
node()
const;
118 void setDefaultTime(
double time );
124 typedef boost::function<bool (const OP_Node *)> HasFn;
125 typedef boost::function<IECore::ConstObjectPtr (const OP_Node *, double &)> ReadFn;
126 typedef boost::function<IECore::ConstObjectPtr (const OP_Node *, const Name &, double &)> ReadAttrFn;
127 typedef boost::function<bool (const OP_Node *, const Name &, int)> HasTagFn;
128 typedef boost::function<void (const OP_Node *, NameList &, int)> ReadTagsFn;
129 typedef boost::function<void (const OP_Node *, NameList &)> ReadNamesFn;
134 static void registerCustomAttributes( ReadNamesFn namesFn, ReadAttrFn readFn );
139 static void registerCustomTags( HasTagFn hasFn, ReadTagsFn readFn );
144 LiveScene(
const UT_String &nodePath,
const Path &contentPath,
const Path &rootPath,
const LiveScene& parent);
146 virtual LiveScenePtr create()
const;
147 virtual LiveScenePtr duplicate(
const UT_String &nodePath,
const Path &contentPath,
const Path &rootPath)
const;
151 void constructCommon(
const UT_String &nodePath,
const Path &contentPath,
const Path &rootPath,
DetailSplitter *splitter );
153 OP_Node *retrieveNode(
bool content =
false, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing )
const;
154 OP_Node *locateContent( OP_Node *node )
const;
155 OP_Node *retrieveChild(
const Name &name, Path &contentPath, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing )
const;
156 IECore::SceneInterfacePtr retrieveScene(
const Path &path, MissingBehaviour missingBehaviour = SceneInterface::ThrowIfMissing )
const;
157 bool hasInput(
const OP_Node *node )
const;
160 double adjustTime(
double time )
const;
161 double adjustedDefaultTime()
const;
163 void calculatePath(
const Path &contentPath,
const Path &rootPath );
164 const char *matchPath(
const char *value )
const;
165 bool matchPattern(
const char *value,
const char *pattern )
const;
166 std::pair<const char *, size_t> nextWord(
const char *value )
const;
167 void relativeContentPath( IECore::SceneInterface::Path &path )
const;
168 GU_DetailHandle contentHandle()
const;
171 struct CustomAttributeReader
178 struct CustomTagReader
184 static std::vector<CustomAttributeReader> &customAttributeReaders();
185 static std::vector<CustomTagReader> &customTagReaders();
187 UT_String m_nodePath;
189 size_t m_contentIndex;
190 IECore::SceneInterface::Path m_path;
193 mutable DetailSplitterPtr m_splitter;
196 double m_defaultTime;
202 #endif // IECOREHOUDINI_LIVESCENE_H
virtual bool hasAttribute(const Name &name) const
Convenience method to determine if an attribute exists without reading it.
double getDefaultTime() const
virtual IECore::PrimitiveVariableMap readObjectPrimitiveVariables(const std::vector< IECore::InternedString > &primVarNames, double time) const
Definition: LiveScene.h:54
The IECoreHoudini namespace holds all the functionality of libIECoreHoudini.
Definition: CoreHoudini.h:51
virtual bool hasChild(const Name &name) const
Convenience method to determine if a child exists.
virtual void writeBound(const Imath::Box3d &bound, double time)
bool embedded() const
Convenience method to determine if this scene refers to hierarchy embedded inside a SOP...
virtual bool hasTag(const Name &name, int filter=SceneInterface::LocalTag) const
const OP_Node * node() const
Convenience method to access the Houdini node this scene refers to.
virtual IECore::ConstObjectPtr readAttribute(const Name &name, double time) const
Returns the attribute value at the given time.
virtual Imath::Box3d readBound(double time) const
virtual Name name() const
Returns the name of the scene location which this instance is referring to. The root path returns "/"...
virtual IECore::ConstDataPtr readTransform(double time) const
IECore::ConstDataPtr readWorldTransform(double time) const
Definition: MurmurHash.h:64
virtual std::string fileName() const
Returns the file that this scene is mapped to. Throws exception if there's no file.
virtual void writeTransform(const IECore::Data *transform, double time)
static PRM_Name pTags
Definition: LiveScene.h:122
virtual void hash(HashType hashType, double time, IECore::MurmurHash &h) const
Currently raises an exception.
HashType
Definition: SceneInterface.h:94
virtual void writeObject(const IECore::Object *object, double time)
Definition: SceneInterface.h:69
virtual IECore::SceneInterfacePtr createChild(const Name &name)
virtual IECore::SceneInterfacePtr child(const Name &name, MissingBehaviour missingBehaviour=SceneInterface::ThrowIfMissing)
Definition: InternedString.h:55
Definition: DetailSplitter.h:52
virtual Imath::M44d readTransformAsMatrix(double time) const
virtual IECore::ConstObjectPtr readObject(double time) const
Reads the object stored at this path in the scene at the given time.
static const Path & rootPath
Utility variable that can be used anytime you want to refer to the root path in the Scene...
Definition: SceneInterface.h:106
virtual void writeAttribute(const Name &name, const IECore::Object *attribute, double time)
virtual bool hasObject() const
Convenience method to determine if a piece of geometry exists without reading it. ...
std::map< std::string, PrimitiveVariable > PrimitiveVariableMap
A simple type to hold named PrimitiveVariables.
Definition: PrimitiveVariable.h:107