Cortex  10.0.0-a4
NParticleReader.h
1 //
3 // Copyright (c) 2009-2011, 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 IE_CORE_NPARTICLEREADER_H
36 #define IE_CORE_NPARTICLEREADER_H
37 
38 #include <vector>
39 
40 #include "IECore/Export.h"
41 #include "IECore/ParticleReader.h"
42 #include "IECore/SimpleTypedData.h"
43 #include "IECore/IFFFile.h"
44 
45 namespace IECore
46 {
47 
50 class IECORE_API NParticleReader : public ParticleReader
51 {
52  public:
53 
54  IE_CORE_DECLARERUNTIMETYPED( NParticleReader, ParticleReader );
55 
56  NParticleReader( );
57  NParticleReader( const std::string &fileName );
58  ~NParticleReader() override;
59 
60  static bool canRead( const std::string &filename );
61 
62  unsigned long numParticles() override;
63  void attributeNames( std::vector<std::string> &names ) override;
64  DataPtr readAttribute( const std::string &name ) override;
65 
68  const IntVectorData * frameTimes();
69 
70  protected:
71 
72  // Returns the name of the position primVar
73  std::string positionPrimVarName() override;
74 
75  private:
76 
77  static const ReaderDescription<NParticleReader> m_readerDescription;
78 
79  // makes sure that m_iffFile is open and that m_header is full.
80  // returns true on success and false on failure.
81  bool open();
82  IFFFilePtr m_iffFile;
83  std::string m_iffFileName;
84  IntParameterPtr m_frameParameter;
85 
86  enum NCacheTagID
87  {
88  // header tags
89  kCACH = 1128350536,
90  kVRSN = 1448235854,
91  kSTIM = 1398032717,
92  kETIM = 1163151693,
93 
94  // body tags
95  kMYCH = 1297695560,
96  kTIME = 1414090053,
97  kCHNM = 1128812109,
98  kSIZE = 1397316165,
99  kDBLA = 1145195585,
100  kDVCA = 1146504001,
101  kFVCA = 1180058433,
102  };
103 
104  struct
105  {
106  bool valid;
107  std::string version;
108  int startTime;
109  int endTime;
110  } m_header;
111 
112  IntVectorDataPtr m_frames;
113  std::map<int, IFFFile::Chunk::ChunkIterator> frameToRootChildren;
114 
115  template<typename T, typename F>
116  typename T::Ptr filterAttr( const F * attr, float percentage );
117 };
118 
119 IE_CORE_DECLAREPTR( NParticleReader );
120 
121 } // namespace IECore
122 
123 #endif // IE_CORE_NPARTICLEREADER_H
Definition: Reader.h:128
Definition: ParticleReader.h:52
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43
Definition: NParticleReader.h:50