Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.5.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HandleData.hpp
1#pragma once
2
3#include <Core/Asset/AssetData.hpp>
4#include <Core/Containers/AlignedStdVector.hpp>
5#include <Core/CoreMacros.hpp>
6#include <Core/RaCore.hpp>
7#include <Core/Types.hpp>
8#include <Core/Utils/Log.hpp>
9#include <Eigen/Geometry>
10#include <map>
11#include <memory>
12#include <ostream>
13#include <set>
14#include <string>
15#include <utility>
16#include <vector>
17
18namespace Ra {
19namespace Core {
20namespace Asset {
21
41
45class RA_CORE_API HandleData : public AssetData
46{
47 public:
51 enum HandleType { UNKNOWN = 1 << 0, POINT_CLOUD = 1 << 1, SKELETON = 1 << 2, CAGE = 1 << 3 };
52
53 HandleData( const std::string& name = "", const HandleType& type = UNKNOWN );
54
55 HandleData( const HandleData& data ) = default;
56
58
61
65 inline void setName( const std::string& name );
66
70 inline HandleType getType() const;
71
75 inline void setType( const HandleType& type );
76
80 inline Core::Transform getFrame() const;
81
85 inline void setFrame( const Core::Transform& frame );
86
90 inline void addBindMesh( const std::string& name );
91
95 inline const std::set<std::string>& getBindMeshes() const;
97
101 inline uint getVertexSize() const;
102
106 inline void setVertexSize( uint size );
107
111 inline void setNameTable( const std::map<std::string, uint>& nameTable );
112
116 inline void recomputeAllIndices();
117
120
124 inline uint getComponentDataSize() const;
125
129 inline const Core::AlignedStdVector<HandleComponentData>& getComponentData() const;
130
134 inline Core::AlignedStdVector<HandleComponentData>& getComponentData();
135
139 inline const HandleComponentData& getComponent( const uint i ) const;
140
144 inline HandleComponentData& getComponent( const uint i );
145
149 inline void setComponents( const Core::AlignedStdVector<HandleComponentData>& components );
150
154 inline const Core::AlignedStdVector<Core::Vector2ui>& getEdgeData() const;
155
159 inline Core::AlignedStdVector<Core::Vector2ui>& getEdgeData();
160
164 inline void setEdges( const Core::AlignedStdVector<Core::Vector2ui>& edgeList );
165
169 inline const Core::AlignedStdVector<Core::VectorNui>& getFaceData() const;
170
174 inline Core::AlignedStdVector<Core::VectorNui>& getFaceData();
175
179 inline void setFaces( const Core::AlignedStdVector<Core::VectorNui>& faceList );
180
184 inline void needEndNodes( bool need );
186
189
193 inline bool isPointCloud() const;
194
198 inline bool isSkeleton() const;
199
203 inline bool isCage() const;
204
208 inline bool hasComponents() const;
209
213 inline bool hasEdges() const;
214
218 inline bool hasFaces() const;
219
223 inline bool needsEndNodes() const;
224
229 inline int getIndexOf( const std::string& name ) const;
231
235 inline void displayInfo() const;
236
237 private:
239 HandleType m_type;
240
242 Core::Transform m_frame { Core::Transform::Identity() };
243
245 bool m_endNode { false };
246
248 uint m_vertexSize { 0 };
249
251 std::map<std::string, uint> m_nameTable;
252
254 std::set<std::string> m_bindMeshes;
255
257 Core::AlignedStdVector<HandleComponentData> m_component;
258
260 Core::AlignedStdVector<Core::Vector2ui> m_edge;
261
263 Core::AlignedStdVector<Core::VectorNui> m_face;
264};
265
266inline void HandleData::setName( const std::string& name ) {
267 m_name = name;
268}
269
271 return m_type;
272}
273
274inline void HandleData::setType( const HandleType& type ) {
275 m_type = type;
276}
277
278inline Core::Transform HandleData::getFrame() const {
279 return m_frame;
280}
281
282inline void HandleData::setFrame( const Core::Transform& frame ) {
283 m_frame = frame;
284}
285
286inline uint HandleData::getVertexSize() const {
287 return m_vertexSize;
288}
289inline void HandleData::setVertexSize( uint size ) {
290 m_vertexSize = size;
291}
292
294 m_nameTable = nameTable;
295}
296
298 return m_component.size();
299}
300
302 return m_component;
303}
304
308
309inline void
311 const uint size = components.size();
312 m_component.resize( size );
313#pragma omp parallel for
314 for ( int i = 0; i < int( size ); ++i ) {
315 m_component[i] = components[i];
316 }
317}
318
319inline const HandleComponentData& HandleData::getComponent( const uint i ) const {
320 CORE_ASSERT( ( i < m_component.size() ), "Index i out of bound" );
321 return m_component[i];
322}
323
325 CORE_ASSERT( ( i < m_component.size() ), "Index i out of bound" );
326 return m_component[i];
327}
328
330 return m_edge;
331}
332
336
338 const uint size = edgeList.size();
339 m_edge.resize( size );
340#pragma omp parallel for
341 for ( int i = 0; i < int( size ); ++i ) {
342 m_edge[i] = edgeList[i];
343 }
344}
345
347 return m_face;
348}
349
353
355 const uint size = faceList.size();
356 m_face.resize( size );
357#pragma omp parallel for
358 for ( int i = 0; i < int( size ); ++i ) {
359 m_face[i] = faceList[i];
360 }
361}
362
364 m_nameTable.clear();
365 for ( uint i = 0; i < getComponentDataSize(); ++i ) {
366 m_nameTable[m_component[i].m_name] = i;
367 }
368}
369
370inline bool HandleData::isPointCloud() const {
371 return ( m_type == POINT_CLOUD );
372}
373
374inline bool HandleData::isSkeleton() const {
375 return ( m_type == SKELETON );
376}
377
378inline bool HandleData::isCage() const {
379 return ( m_type == CAGE );
380}
381
382inline bool HandleData::hasComponents() const {
383 return !m_component.empty();
384}
385
386inline bool HandleData::hasEdges() const {
387 return !m_edge.empty();
388}
389
390inline bool HandleData::hasFaces() const {
391 return !m_face.empty();
392}
393
394inline bool HandleData::needsEndNodes() const {
395 return m_endNode;
396}
397
398inline int HandleData::getIndexOf( const std::string& name ) const {
399 auto it = m_nameTable.find( name );
400 if ( it == m_nameTable.end() ) { return -1; }
401 return it->second;
402}
403
404inline void HandleData::needEndNodes( bool need ) {
405 m_endNode = need;
406}
407
408inline void HandleData::addBindMesh( const std::string& name ) {
409 m_bindMeshes.insert( name );
410}
411
413 return m_bindMeshes;
414}
415
416inline void HandleData::displayInfo() const {
417 using namespace Core::Utils; // log
418 std::string type;
419 switch ( m_type ) {
420 case POINT_CLOUD:
421 type = "POINT CLOUD";
422 break;
423 case SKELETON:
424 type = "SKELETON";
425 break;
426 case CAGE:
427 type = "CAGE";
428 break;
429 case UNKNOWN:
430 default:
431 type = "UNKNOWN";
432 break;
433 }
434 LOG( logINFO ) << "======== HANDLE INFO ========";
435 LOG( logINFO ) << " Name : " << m_name;
436 LOG( logINFO ) << " Type : " << type;
437 LOG( logINFO ) << " Element # : " << m_component.size();
438 LOG( logINFO ) << " Edge # : " << m_edge.size();
439 LOG( logINFO ) << " Face # : " << m_face.size();
440 LOG( logINFO ) << " Need EndNodes ? : " << ( ( m_endNode ) ? "YES" : "NO" );
441}
442
443} // namespace Asset
444} // namespace Core
445} // namespace Ra
void setNameTable(const std::map< std::string, uint > &nameTable)
const Core::AlignedStdVector< HandleComponentData > & getComponentData() const
int getIndexOf(const std::string &name) const
void setFrame(const Core::Transform &frame)
void setEdges(const Core::AlignedStdVector< Core::Vector2ui > &edgeList)
const Core::AlignedStdVector< Core::VectorNui > & getFaceData() const
void setType(const HandleType &type)
const std::set< std::string > & getBindMeshes() const
const Core::AlignedStdVector< Core::Vector2ui > & getEdgeData() const
HandleType getType() const
void addBindMesh(const std::string &name)
void setFaces(const Core::AlignedStdVector< Core::VectorNui > &faceList)
const HandleComponentData & getComponent(const uint i) const
Core::Transform getFrame() const
void setComponents(const Core::AlignedStdVector< HandleComponentData > &components)
void setVertexSize(uint size)
void setName(const std::string &name)
T clear(T... args)
T end(T... args)
T find(T... args)
T insert(T... args)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:4
T size(T... args)
std::map< std::string, Core::Transform > m_bindMatrices
Per skinned-mesh matrix from mesh space to bone space (local).
std::map< std::string, std::vector< std::pair< uint, Scalar > > > m_weights
Per skinned-mesh vertex weigths.
std::string m_name
Handle name.