3#include <Core/Containers/VectorArray.hpp>
4#include <Core/Geometry/AbstractGeometry.hpp>
5#include <Core/Geometry/StandardAttribNames.hpp>
6#include <Core/RaCore.hpp>
8#include <Core/Utils/Attribs.hpp>
9#include <Core/Utils/Color.hpp>
10#include <Core/Utils/Observable.hpp>
28 using Point = Vector3;
29 using Normal = Vector3;
65 void clear()
override;
68 inline void setVertices( PointAttribHandle::Container&& vertices );
70 inline void setVertices(
const PointAttribHandle::Container& vertices );
73 inline const PointAttribHandle::Container& vertices()
const;
76 inline void setNormals( PointAttribHandle::Container&& normals );
78 inline void setNormals(
const PointAttribHandle::Container& normals );
81 inline const NormalAttribHandle::Container& normals()
const;
100 template <
typename T>
104 template <
typename T>
107 template <
typename T>
111 template <
typename T>
114 template <
typename T>
125 inline bool hasAttrib(
const std::string& name )
const;
132 template <
typename T>
139 template <
typename T>
147 template <
typename T>
154 template <
typename T>
158 inline void clearAttributes();
170 template <
typename... Handles>
180 inline Aabb computeAabb()
const override;
197 inline PointAttribHandle::Container& verticesWithLock();
200 inline void verticesUnlock();
204 inline NormalAttribHandle::Container& normalsWithLock();
207 inline void normalsUnlock();
211 inline void initDefaultAttribs();
216 template <
typename T>
238 m_verticesHandle = other.m_verticesHandle;
239 m_normalsHandle = other.m_normalsHandle;
243 m_vertexAttribs(
std::move( other.m_vertexAttribs ) ),
244 m_verticesHandle(
std::move( other.m_verticesHandle ) ),
245 m_normalsHandle(
std::move( other.m_normalsHandle ) ) {}
248 if (
this != &other ) {
249 m_vertexAttribs.
clear();
251 m_verticesHandle = other.m_verticesHandle;
252 m_normalsHandle = other.m_normalsHandle;
260 if (
this != &other ) {
261 m_vertexAttribs =
std::move( other.m_vertexAttribs );
262 m_verticesHandle =
std::move( other.m_verticesHandle );
263 m_normalsHandle =
std::move( other.m_normalsHandle );
271 m_vertexAttribs.
clear();
273 initDefaultAttribs();
280 other.m_vertexAttribs, other.m_verticesHandle, other.m_normalsHandle );
284template <
typename... Handles>
286 Handles... attribs ) {
289 m_vertexAttribs.
copyAttributes( input.m_vertexAttribs, attribs... );
303 if ( !isAabbValid() ) {
305 for (
const auto& v :
vertices() ) {
320 m_vertexAttribs.
setAttrib<PointAttribHandle::value_type>( m_verticesHandle,
vertices );
324inline const AttribArrayGeometry::PointAttribHandle::Container&
326 return m_vertexAttribs.
getAttrib( m_verticesHandle ).data();
336inline const AttribArrayGeometry::NormalAttribHandle::Container&
338 return m_vertexAttribs.
getAttrib( m_normalsHandle ).data();
349 return m_vertexAttribs.
isValid( h );
373 return m_vertexAttribs.
getAttrib<T>( name );
378 return m_vertexAttribs.
getAttrib<T>( name );
382 return m_vertexAttribs.
contains( name );
388 return m_vertexAttribs.
addAttrib<T>( name );
418 return m_vertexAttribs;
422 return m_vertexAttribs;
426 return m_vertexAttribs.
getAttrib( m_verticesHandle ).getDataWithLock();
430 return m_vertexAttribs.
getAttrib( m_verticesHandle ).unlock();
434 return m_vertexAttribs.
getAttrib( m_normalsHandle ).getDataWithLock();
438 return m_vertexAttribs.
getAttrib( m_normalsHandle ).unlock();
441inline void AttribArrayGeometry::initDefaultAttribs() {
442 m_verticesHandle = m_vertexAttribs.
addAttrib<PointAttribHandle::value_type>(
443 getAttribName( MeshAttrib::VERTEX_POSITION ) );
444 m_normalsHandle = m_vertexAttribs.
addAttrib<NormalAttribHandle::value_type>(
445 getAttribName( MeshAttrib::VERTEX_NORMAL ) );
452 auto& v0 = m_vertexAttribs.
getAttrib( h ).getDataWithLock();
453 const auto& v1 = attr->
cast<T>().data();
454 v0.insert( v0.end(), v1.cbegin(), v1.cend() );
463#include "IndexedGeometry.hpp"
This class represents vertex + attributes per vertex. Toplogy is handled in MultiIndexedGeometry subc...
virtual void copyBaseGeometry(const AttribArrayGeometry &other)
Utils::AttribHandle< T > getAttribHandle(const std::string &name) const
bool isValid(const Utils::AttribHandle< T > &h) const
Return true if h refers to an existing attribute in *this.
const Utils::Attrib< T > * getAttribPtr(const Utils::AttribHandle< T > &h) const
NormalAttribHandle::Container & normalsWithLock()
bool copyAttributes(const AttribArrayGeometry &input, Handles... attribs)
Aabb computeAabb() const override
Compute bounding box.
void setNormals(PointAttribHandle::Container &&normals)
Set normals.
bool hasAttrib(const std::string &name) const
AttribArrayGeometry & operator=(const AttribArrayGeometry &other)
Utils::Attrib< T > * getAttribPtr(const Utils::AttribHandle< T > &h)
void normalsUnlock()
Release lock on vertices normals.
void clear() override
Erases all data, making the AttribArrayGeometry empty.
PointAttribHandle::Container & verticesWithLock()
void verticesUnlock()
Release lock on vertices positions.
void setVertices(PointAttribHandle::Container &&vertices)
Set vertices.
AttribArrayGeometry()
Create an empty geometry.
Utils::AttribBase * getAttribBase(const std::string &name)
bool copyAllAttributes(const AttribArrayGeometry &input)
const NormalAttribHandle::Container & normals() const
Access the vertices normals.
void removeAttrib(Utils::AttribHandle< T > &h)
const PointAttribHandle::Container & vertices() const
Access the vertices positions.
Utils::AttribHandle< T > addAttrib(const std::string &name)
Utils::Attrib< T > & getAttrib(const Utils::AttribHandle< T > &h)
Utils::AttribManager & vertexAttribs()
Attrib< T > & cast()
Downcast from AttribBase to Attrib<T>.
std::string getName() const
Return the attribute's name.
The AttribManager provides attributes management by handles.
void setAttrib(const AttribHandle< T > &h, const typename AttribHandle< T >::Container &data)
void copyAllAttributes(const AttribManager &m)
AttribBase * getAttribBase(const std::string &name)
AttribHandle< T > addAttrib(const std::string &name)
void copyAttributes(const AttribManager &m)
Base copy, does nothing.
bool contains(const std::string &name) const
contains Check if an attribute with the given name exists.
Attrib< T > & getAttrib(const AttribHandle< T > &h)
bool isValid(const AttribHandle< T > &h) const
Return true if h correspond to an existing attribute in *this.
void clear()
clear all attribs, invalidate handles.
void removeAttrib(AttribHandle< T > &h)
AttribHandle< T > findAttrib(const std::string &name) const
findAttrib Grab an attribute handler by name.
This class implements ContainerIntrospectionInterface for AlignedStdVector.
@ Geometry
"Geometry" render objects are those loaded using Radium::IO and generated by GeometrySystem
hepler function to manage enum as underlying types in VariableSet