Cortex  10.0.0-a4
SOP_SceneCacheSource.h
1 //
3 // Copyright (c) 2012-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_SOPSCENECACHESOURCE_H
36 #define IECOREHOUDINI_SOPSCENECACHESOURCE_H
37 
38 #include "SOP/SOP_Node.h"
39 #include "UT/UT_StringMMPattern.h"
40 
41 #include "IECore/SceneCache.h"
42 #include "IECore/MatrixTransform.h"
43 
44 #include "IECoreHoudini/SceneCacheNode.h"
45 
46 namespace IECoreHoudini
47 {
48 
50 class SOP_SceneCacheSource : public SceneCacheNode<SOP_Node>
51 {
52  public :
53 
54  SOP_SceneCacheSource( OP_Network *net, const char *name, OP_Operator *op );
55  virtual ~SOP_SceneCacheSource();
56 
57  static const char *typeName;
58 
59  static OP_Node *create( OP_Network *net, const char *name, OP_Operator *op );
60  static OP_TemplatePair *buildParameters();
61 
62  static PRM_Name pObjectOnly;
63 
64  bool getObjectOnly() const;
65  void setObjectOnly( bool objectOnly );
66 
67  virtual void getNodeSpecificInfoText( OP_Context &context, OP_NodeInfoParms &parms );
68 
69  protected :
70 
71  virtual OP_ERROR cookMySop( OP_Context &context );
72 
73  virtual void sceneChanged();
74 
75  private :
76 
77  struct Parameters
78  {
79  GeometryType geometryType;
80  std::string attributeFilter;
81  std::string attributeCopy;
82  std::string fullPathName;
83  UT_StringMMPattern shapeFilter;
84  UT_StringMMPattern tagFilter;
85  bool tagGroups;
86  bool hasAnimatedTopology;
87  bool hasAnimatedPrimVars;
88  std::vector<IECore::InternedString> animatedPrimVars;
89  std::map<std::string, GA_Range> namedRanges;
90  };
91 
92  // Modify the object according the parameters, copying if neccessary.
93  IECore::ConstObjectPtr modifyObject( const IECore::Object *object, Parameters &params );
94  // Transform the object, copying if neccessary. Transforms Primitives (using IECore::TransformOp),
95  // Groups, and CoordinateSystems. Updates animatedTopology and animatedPrimVars if appropriate.
96  IECore::ConstObjectPtr transformObject( const IECore::Object *object, const Imath::M44d &transform, Parameters &params );
97  // Convert the object to Houdini, optimizing for animated primitive variables if possible.
98  bool convertObject( const IECore::Object *object, const std::string &name, const IECore::SceneInterface *scene, Parameters &params );
99 
100  void loadObjects( const IECore::SceneInterface *scene, Imath::M44d transform, double time, Space space, Parameters &params, size_t rootSize, std::string currentPath );
101  IECore::MatrixTransformPtr matrixTransform( Imath::M44d t );
102  std::string relativePath( const IECore::SceneInterface *scene, size_t rootSize );
103 
104  struct InternedStringSort
105  {
106  bool operator() ( const IECore::SceneInterface::Name &i, const IECore::SceneInterface::Name &j );
107  };
108 
110  struct TransformGeometricData
111  {
112  typedef bool ReturnType;
113 
114  template<typename T>
115  ReturnType operator()( const T *data ) const;
116  };
117 
118 };
119 
120 } // namespace IECoreHoudini
121 
122 #endif // IECOREHOUDINI_SOPSCENECACHESOURCE_H
The IECoreHoudini namespace holds all the functionality of libIECoreHoudini.
Definition: CoreHoudini.h:51
double time(OP_Context context) const
SOP for loading an IECore::SceneCache from disk.
Definition: SOP_SceneCacheSource.h:50
Definition: Object.h:104
Definition: SceneCacheNode.h:54
Definition: SceneInterface.h:69
Definition: InternedString.h:55
IECore::ConstSceneInterfacePtr scene() const