Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.5.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
FileData.hpp
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <vector>
6 
7 #include <Core/Asset/AnimationData.hpp>
8 #include <Core/Asset/Camera.hpp>
9 #include <Core/Asset/GeometryData.hpp>
10 #include <Core/Asset/HandleData.hpp>
11 #include <Core/Asset/LightData.hpp>
12 #include <Core/Asset/VolumeData.hpp>
13 #include <Core/RaCore.hpp>
14 #include <Core/Utils/Log.hpp>
15 
16 namespace Ra {
17 namespace Core {
18 namespace Asset {
19 
20 class RA_CORE_API FileData final
21 {
22  public:
24  FileData( const std::string& filename = "", const bool VERBOSE_MODE = false );
25 
26  FileData( FileData&& data ) = default;
27 
29  ~FileData();
30 
32  inline std::string getFileName() const;
33 
34  inline void setFileName( const std::string& filename );
35 
37  inline Scalar getLoadingTime() const;
38 
40  inline std::vector<GeometryData*> getGeometryData() const;
41  inline std::vector<VolumeData*> getVolumeData() const;
42  inline std::vector<HandleData*> getHandleData() const;
43  inline std::vector<AnimationData*> getAnimationData() const;
44  inline std::vector<LightData*> getLightData() const;
45  inline std::vector<Camera*> getCameraData() const;
46 
47  inline void setVerbose( const bool VERBOSE_MODE );
48 
50  inline bool isInitialized() const;
51  inline bool isProcessed() const;
52  inline bool hasGeometry() const;
53  inline bool hasHandle() const;
54  inline bool hasAnimation() const;
55  inline bool hasLight() const;
56  inline bool hasCamera() const;
57  inline bool isVerbose() const;
58 
60  inline void reset();
61 
62  inline void displayInfo() const;
63 
64  // TODO(Matthieu) : handle attributes in a better way than "public:"
65  public:
67  std::string m_filename;
68  Scalar m_loadingTime;
69  std::vector<std::unique_ptr<GeometryData>> m_geometryData;
70  std::vector<std::unique_ptr<VolumeData>> m_volumeData;
71  std::vector<std::unique_ptr<HandleData>> m_handleData;
72  std::vector<std::unique_ptr<AnimationData>> m_animationData;
73  std::vector<std::unique_ptr<LightData>> m_lightData;
74  std::vector<std::unique_ptr<Camera>> m_cameraData;
75  bool m_processed;
76  bool m_verbose;
77 };
78 
80 inline std::string FileData::getFileName() const {
81  return m_filename;
82 }
83 
84 inline void FileData::setFileName( const std::string& filename ) {
85  m_filename = filename;
86 }
87 
89 inline Scalar FileData::getLoadingTime() const {
90  return m_loadingTime;
91 }
92 
94 inline std::vector<GeometryData*> FileData::getGeometryData() const {
95  std::vector<GeometryData*> list;
96  list.reserve( m_geometryData.size() );
97  for ( const auto& item : m_geometryData ) {
98  list.push_back( item.get() );
99  }
100  return list;
101 }
102 
103 inline std::vector<VolumeData*> FileData::getVolumeData() const {
104  std::vector<VolumeData*> list;
105  list.reserve( m_volumeData.size() );
106  for ( const auto& item : m_volumeData ) {
107  list.push_back( item.get() );
108  }
109  return list;
110 }
111 
112 inline std::vector<HandleData*> FileData::getHandleData() const {
113  std::vector<HandleData*> list;
114  list.reserve( m_handleData.size() );
115  for ( const auto& item : m_handleData ) {
116  list.push_back( item.get() );
117  }
118  return list;
119 }
120 
121 inline std::vector<AnimationData*> FileData::getAnimationData() const {
122  std::vector<AnimationData*> list;
123  list.reserve( m_animationData.size() );
124  for ( const auto& item : m_animationData ) {
125  list.push_back( item.get() );
126  }
127  return list;
128 }
129 
130 inline std::vector<LightData*> FileData::getLightData() const {
131  std::vector<LightData*> list;
132  list.reserve( m_lightData.size() );
133  for ( const auto& item : m_lightData ) {
134  list.push_back( item.get() );
135  }
136  return list;
137 }
138 
139 inline std::vector<Camera*> FileData::getCameraData() const {
140  std::vector<Camera*> list;
141  list.reserve( m_cameraData.size() );
142  for ( const auto& item : m_cameraData ) {
143  list.push_back( item.get() );
144  }
145  return list;
146 }
147 
148 inline void FileData::setVerbose( const bool VERBOSE_MODE ) {
149  m_verbose = VERBOSE_MODE;
150 }
151 
153 inline bool FileData::isInitialized() const {
154  return ( ( m_filename != "" ) && !m_processed );
155 }
156 
157 inline bool FileData::isProcessed() const {
158  return m_processed;
159 }
160 
161 inline bool FileData::hasGeometry() const {
162  return ( !m_geometryData.empty() );
163 }
164 
165 inline bool FileData::hasHandle() const {
166  return ( !m_handleData.empty() );
167 }
168 
169 inline bool FileData::hasAnimation() const {
170  return ( !m_animationData.empty() );
171 }
172 
173 inline bool FileData::hasLight() const {
174  return ( !m_lightData.empty() );
175 }
176 
177 inline bool FileData::isVerbose() const {
178  return m_verbose;
179 }
180 
182 inline void FileData::reset() {
183  m_filename = "";
184  m_geometryData.clear();
185  m_handleData.clear();
186  m_animationData.clear();
187  m_processed = false;
188 }
189 
190 inline void FileData::displayInfo() const {
191  using namespace Core::Utils; // log
192  uint64_t vtxCount = 0;
193  for ( const auto& geom : m_geometryData ) {
194  vtxCount += geom->getGeometry().vertices().size();
195  }
196  LOG( logINFO ) << "======== LOADING SUMMARY ========";
197  LOG( logINFO ) << "Mesh loaded : " << m_geometryData.size();
198  LOG( logINFO ) << "Total vertex count : " << vtxCount;
199  LOG( logINFO ) << "Handle loaded : " << m_handleData.size();
200  LOG( logINFO ) << "Animation loaded : " << m_animationData.size();
201  LOG( logINFO ) << "Volume loaded : " << m_volumeData.size();
202  LOG( logINFO ) << "Loading Time (sec) : " << m_loadingTime;
203 }
204 
205 } // namespace Asset
206 } // namespace Core
207 } // namespace Ra
Definition: Cage.cpp:3