Cortex  10.0.0-a4
SceneCache.h
1 //
3 // Copyright (c) 2013-2014, 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 IECORE_SCENECACHE_H
36 #define IECORE_SCENECACHE_H
37 
38 #include "IECore/Export.h"
39 #include "IECore/SampledSceneInterface.h"
40 
41 namespace IECore
42 {
43 
44 IE_CORE_FORWARDDECLARE( SceneCache );
45 
53 class IECORE_API SceneCache : public SampledSceneInterface
54 {
55  public :
56 
57  typedef SceneInterface::Name Name;
58  typedef SceneInterface::NameList NameList;
59  typedef SceneInterface::Path Path;
60 
61  IE_CORE_DECLARERUNTIMETYPED( SceneCache, SampledSceneInterface );
62 
69  SceneCache( const std::string &fileName, IndexedIO::OpenMode mode );
76  SceneCache( IECore::IndexedIOPtr indexedIO );
77 
78  ~SceneCache() override;
79 
80  /*
81  * virtual functions defined in SceneInterface.
82  */
83 
84  std::string fileName() const override;
85 
86  Name name() const override;
87  void path( Path &p ) const override;
88 
89  size_t numBoundSamples() const override;
90  double boundSampleTime( size_t sampleIndex ) const override;
91  double boundSampleInterval( double time, size_t &floorIndex, size_t &ceilIndex ) const override;
92  Imath::Box3d readBoundAtSample( size_t sampleIndex ) const override;
93  void writeBound( const Imath::Box3d &bound, double time ) override;
94 
95  size_t numTransformSamples() const override;
96  double transformSampleTime( size_t sampleIndex ) const override;
97  double transformSampleInterval( double time, size_t &floorIndex, size_t &ceilIndex ) const override;
98  ConstDataPtr readTransformAtSample( size_t sampleIndex ) const override;
99  Imath::M44d readTransformAsMatrixAtSample( size_t sampleIndex ) const override;
100  void writeTransform( const Data *transform, double time ) override;
101 
102  bool hasAttribute( const Name &name ) const override;
103  void attributeNames( NameList &attrs ) const override;
104  size_t numAttributeSamples( const Name &name ) const override;
105  double attributeSampleTime( const Name &name, size_t sampleIndex ) const override;
106  double attributeSampleInterval( const Name &name, double time, size_t &floorIndex, size_t &ceilIndex ) const override;
107  ConstObjectPtr readAttributeAtSample( const Name &name, size_t sampleIndex ) const override;
108  void writeAttribute( const Name &name, const Object *attribute, double time ) override;
109 
110  bool hasTag( const Name &name, int filter = SceneInterface::LocalTag ) const override;
111  void readTags( NameList &tags, int filter = SceneInterface::LocalTag ) const override;
112  void writeTags( const NameList &tags ) override;
113 
114  bool hasObject() const override;
115  size_t numObjectSamples() const override;
116  double objectSampleTime( size_t sampleIndex ) const override;
117  double objectSampleInterval( double time, size_t &floorIndex, size_t &ceilIndex ) const override;
118  ConstObjectPtr readObjectAtSample( size_t sampleIndex ) const override;
119  PrimitiveVariableMap readObjectPrimitiveVariables( const std::vector<InternedString> &primVarNames, double time ) const override;
120  void writeObject( const Object *object, double time ) override;
121 
122  bool hasChild( const Name &name ) const override;
123  void childNames( NameList &childNames ) const override;
124  SceneInterfacePtr child( const Name &name, SceneInterface::MissingBehaviour missingBehaviour = ThrowIfMissing ) override;
125  ConstSceneInterfacePtr child( const Name &name, SceneInterface::MissingBehaviour missingBehaviour = ThrowIfMissing ) const override;
126  SceneInterfacePtr createChild( const Name &name ) override;
127  SceneInterfacePtr scene( const Path &path, MissingBehaviour missingBehaviour = ThrowIfMissing ) override;
128  ConstSceneInterfacePtr scene( const Path &path, SceneInterface::MissingBehaviour missingBehaviour = ThrowIfMissing ) const override;
129 
130  void hash( HashType hashType, double time, MurmurHash &h ) const override;
131 
133  bool readOnly() const;
134 
135  // The attribute names used to mark animated topology and primitive variables
136  // when SceneCache objects are Primitives.
137  static const Name &animatedObjectTopologyAttribute;
138  static const Name &animatedObjectPrimVarsAttribute;
139 
140  protected:
141 
142  IE_CORE_FORWARDDECLARE( Implementation );
143  virtual SceneCachePtr duplicate( ImplementationPtr& implementation ) const;
144  SceneCache( ImplementationPtr& implementation );
145 
148  void writeTags( const NameList &tags, bool descendentTags );
149 
150  friend class LinkedScene;
151 
152  private :
153 
154  ImplementationPtr m_implementation;
155 
156  class ReaderImplementation;
157  class WriterImplementation;
158 
159 };
160 
161 } // namespace IECore
162 
163 #endif // IECORE_SCENECACHE_H
Definition: Data.h:46
Definition: SceneCache.h:53
Definition: Object.h:104
Definition: MurmurHash.h:64
HashType
Definition: SceneInterface.h:94
Definition: LinkedScene.h:64
Definition: SampledSceneInterface.h:60
Definition: InternedString.h:55
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43
std::map< std::string, PrimitiveVariable > PrimitiveVariableMap
A simple type to hold named PrimitiveVariables.
Definition: PrimitiveVariable.h:107