Cortex  10.0.0-a4
SceneCacheNode.h
1 //
3 // Copyright (c) 2013-2015, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IECOREHOUDINI_SCENECACHENODE_H
36 #define IECOREHOUDINI_SCENECACHENODE_H
37 
38 #include "boost/logic/tribool.hpp"
39 
40 #include "tbb/mutex.h"
41 
42 #include "OP/OP_Operator.h"
43 #include "PRM/PRM_Name.h"
44 
45 #include "IECore/LRUCache.h"
46 #include "IECore/SceneCache.h"
47 
48 namespace IECoreHoudini
49 {
50 
53 template<typename BaseType>
54 class SceneCacheNode : public BaseType
55 {
56  public :
57 
58  SceneCacheNode( OP_Network *net, const char *name, OP_Operator *op );
59  virtual ~SceneCacheNode();
60 
61  static PRM_Name pFile;
62  static PRM_Name pRoot;
63  static PRM_Name pSpace;
64  static PRM_Name pReload;
65  static PRM_Name pGeometryType;
66  static PRM_Name pAttributeFilter;
67  static PRM_Name pAttributeCopy;
68  static PRM_Name pTagFilter;
69  static PRM_Name pTagGroups;
70  static PRM_Name pShapeFilter;
71  static PRM_Name pFullPathName;
72 
73  static PRM_Default rootDefault;
74  static PRM_Default spaceDefault;
75  static PRM_Default filterDefault;
76  static PRM_Default geometryTypeDefault;
77 
78  static PRM_ChoiceList rootMenu;
79  static PRM_ChoiceList spaceList;
80  static PRM_ChoiceList geometryTypeList;
81  static PRM_ChoiceList attributeCopyMenu;
82  static PRM_ChoiceList tagFilterMenu;
83  static PRM_ChoiceList shapeFilterMenu;
84 
85  static int sceneParmChangedCallback( void *data, int index, float time, const PRM_Template *tplate );
86  static int reloadButtonCallback( void *data, int index, float time, const PRM_Template *tplate );
87  static void buildRootMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * );
88  static void buildTagFilterMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * );
89  static void buildShapeFilterMenu( void *data, PRM_Name *menu, int maxSize, const PRM_SpareData *, const PRM_Parm * );
90 
91  enum Space
92  {
93  World,
94  Path,
95  Local,
96  Object
97  };
98 
99  enum GeometryType
100  {
101  Cortex,
102  Houdini,
103  BoundingBox,
104  PointCloud
105  };
106 
108  std::string getFile() const;
109  void setFile( std::string file );
110  std::string getPath() const;
111  void setPath( const IECore::SceneInterface *scene );
112  Space getSpace() const;
113  void setSpace( Space space );
114  GeometryType getGeometryType() const;
115  void setGeometryType( GeometryType type );
116  void getAttributeFilter( UT_String &filter ) const;
117  void getAttributeFilter( UT_StringMMPattern &filter ) const;
118  void setAttributeFilter( const UT_String &filter );
119  void getAttributeCopy( UT_String &value ) const;
120  void setAttributeCopy( const UT_String &value );
121  void getTagFilter( UT_String &filter ) const;
122  void getTagFilter( UT_StringMMPattern &filter ) const;
123  void setTagFilter( const UT_String &filter );
124  bool getTagGroups() const;
125  void setTagGroups( bool tagGroups );
126  void getShapeFilter( UT_String &filter ) const;
127  void getShapeFilter( UT_StringMMPattern &filter ) const;
128  void setShapeFilter( const UT_String &filter );
129  void getFullPathName( UT_String &name ) const;
130  void setFullPathName( const UT_String &name );
131  void referenceParent( const char *parmName );
132 
135  IECore::ConstSceneInterfacePtr scene() const;
136 
142  double time( OP_Context context ) const;
143 
145  static bool tagged( const IECore::SceneInterface *scene, const UT_StringMMPattern &filter );
146 
147  protected :
148 
151  static IECore::ConstSceneInterfacePtr scene( const std::string &fileName, const std::string &path );
152 
154  Imath::M44d worldTransform( const std::string &fileName, const std::string &path, double time );
155 
158  virtual void sceneChanged();
160  bool ensureFile( std::string &file );
161 
163  void descendantNames( const IECore::SceneInterface *scene, std::vector<std::string> &descendants );
165  void objectNames( const IECore::SceneInterface *scene, std::vector<std::string> &objects );
167  static std::string getFullScenePath( const IECore::SceneInterface *scene );
169  void createMenu( PRM_Name *menu, const std::vector<std::string> &values );
170 
171  static OP_TemplatePair *buildMainParameters();
172  static OP_TemplatePair *buildOptionParameters();
173 
174  bool m_loaded;
175  boost::tribool m_static;
176  IECore::MurmurHash m_hash;
177 
178 };
179 
180 } // namespace IECoreHoudini
181 
182 #endif // IECOREHOUDINI_SCENECACHENODE_H
void objectNames(const IECore::SceneInterface *scene, std::vector< std::string > &objects)
get a depth first list of all object names
void descendantNames(const IECore::SceneInterface *scene, std::vector< std::string > &descendants)
get a breadth first list of all descendant paths
The IECoreHoudini namespace holds all the functionality of libIECoreHoudini.
Definition: CoreHoudini.h:51
double time(OP_Context context) const
Definition: MurmurHash.h:64
static std::string getFullScenePath(const IECore::SceneInterface *scene)
get the full path to a scene including the name
Definition: SceneCacheNode.h:54
Definition: SceneInterface.h:69
Imath::M44d worldTransform(const std::string &fileName, const std::string &path, double time)
Computes the worldTransform for the specified path.
IECore::ConstSceneInterfacePtr scene() const
void createMenu(PRM_Name *menu, const std::vector< std::string > &values)
utility method to build a UI menu from one of the previous lists
static bool tagged(const IECore::SceneInterface *scene, const UT_StringMMPattern &filter)
Determine if the given scene has any tag matching the filter.
bool ensureFile(std::string &file)
get the file and ensure it is a valid SCC
std::string getFile() const
convenience methods for the common parameters;