Radium Engine  1.5.20
Loading...
Searching...
No Matches
GeometryData.hpp
1#pragma once
2
3#include <Core/Asset/AssetData.hpp>
4#include <Core/Asset/MaterialData.hpp>
5#include <Core/Containers/VectorArray.hpp>
6#include <Core/Geometry/StandardAttribNames.hpp>
7#include <Core/Geometry/TriangleMesh.hpp>
8#include <Core/RaCore.hpp>
9#include <Core/Types.hpp>
10#include <Core/Utils/Attribs.hpp>
11#include <Core/Utils/Index.hpp>
12
13#include <memory>
14#include <string>
15#include <vector>
16
17#include <algorithm> //std::transform
18
19namespace Ra {
20namespace Core {
21namespace Asset {
22
23class MaterialData;
24
28class RA_CORE_API GeometryData : public AssetData
29{
30 public:
31 using ColorArray = Vector4Array;
32
33 public:
38 UNKNOWN = 1 << 0,
39 POINT_CLOUD = 1 << 1,
40 LINE_MESH = 1 << 2,
41 TRI_MESH = 1 << 3,
42 QUAD_MESH = 1 << 4,
43 POLY_MESH = 1 << 5,
44 TETRA_MESH = 1 << 6,
45 HEX_MESH = 1 << 7
46 };
47
48 GeometryData( const std::string& name = "", const GeometryType& type = UNKNOWN );
49
50 GeometryData( const GeometryData& data ) = delete;
51
53
56
58 inline void setName( const std::string& name );
59
61 inline GeometryType getType() const;
62
64 inline void setType( const GeometryType& type );
65
67 inline Transform getFrame() const;
68
70 inline void setFrame( const Transform& frame );
71
73 inline const MaterialData& getMaterial() const;
74
76 inline void setMaterial( MaterialData* material );
77
79 inline Geometry::MultiIndexedGeometry& getGeometry();
80
82 inline const Geometry::MultiIndexedGeometry& getGeometry() const;
83
85
88
90 inline bool isPointCloud() const;
91
93 inline bool isLineMesh() const;
94
96 inline bool isTriMesh() const;
97
99 inline bool isQuadMesh() const;
100
103 inline bool isPolyMesh() const;
104
106 inline bool isTetraMesh() const;
107
109 inline bool isHexMesh() const;
110
112 inline bool hasEdges() const;
113
115 inline bool hasFaces() const;
116
118 inline bool hasPolyhedra() const;
119
121 inline bool hasMaterial() const;
122
124 inline void setPrimitiveCount( int n );
125
127 inline int getPrimitiveCount() const;
128
130
132 void displayInfo() const;
133
134 protected:
136 Transform m_frame;
137
140
143
145 int m_primitiveCount { -1 };
146
149};
150
151inline void GeometryData::setName( const std::string& name ) {
152 m_name = name;
153}
154
158
159inline void GeometryData::setType( const GeometryType& type ) {
160 m_type = type;
161}
162
163inline Transform GeometryData::getFrame() const {
164 return m_frame;
165}
166
167inline void GeometryData::setFrame( const Transform& frame ) {
168 m_frame = frame;
169}
170
172 return *( m_material.get() );
173}
174
175inline void GeometryData::setMaterial( MaterialData* material ) {
176 m_material.reset( material );
177}
178
179inline bool GeometryData::isPointCloud() const {
180 return ( m_type == POINT_CLOUD );
181}
182
183inline bool GeometryData::isLineMesh() const {
184 return ( m_type == LINE_MESH );
185}
186
187inline bool GeometryData::isTriMesh() const {
188 return ( m_type == TRI_MESH );
189}
190
191inline bool GeometryData::isQuadMesh() const {
192 return ( m_type == QUAD_MESH );
193}
194
195inline bool GeometryData::isPolyMesh() const {
196 return ( m_type == POLY_MESH );
197}
198
199inline bool GeometryData::isTetraMesh() const {
200 return ( m_type == TETRA_MESH );
201}
202
203inline bool GeometryData::isHexMesh() const {
204 return ( m_type == HEX_MESH );
205}
206
207inline bool GeometryData::hasEdges() const {
208 return m_geometry.containsLayer( { Geometry::LineIndexLayer::staticSemanticName }, "indices" );
209}
210
211inline bool GeometryData::hasFaces() const {
212 std::string layerSemanticName;
213 switch ( m_type ) {
214 case TRI_MESH:
215 layerSemanticName = std::string( Geometry::TriangleIndexLayer::staticSemanticName );
216 break;
217 case QUAD_MESH:
218 layerSemanticName = std::string( Geometry::QuadIndexLayer::staticSemanticName );
219 break;
220 case POLY_MESH:
221 layerSemanticName = std::string( Geometry::PolyIndexLayer::staticSemanticName );
222 break;
223 default:
224 return false;
225 }
226 return m_geometry.containsLayer( { layerSemanticName }, "indices" );
227}
228
229inline bool GeometryData::hasPolyhedra() const {
230 return m_geometry.containsLayer( { Geometry::PolyIndexLayer::staticSemanticName }, "indices" );
231}
232
233inline bool GeometryData::hasMaterial() const {
234 return m_material != nullptr;
235}
236
240
244
247}
249 return m_primitiveCount;
250}
251
252} // namespace Asset
253} // namespace Core
254} // namespace Ra
int getPrimitiveCount() const
Return the number of primitives in the geometry data.
bool isLineMesh() const
Return true if the object is a Line Mesh.
int m_primitiveCount
Simple tracking of geometric primitive number.
bool isTetraMesh() const
Return true if the object is a Tetrahedron Mesh.
bool isTriMesh() const
Return true if the object is a Triangle Mesh.
bool hasFaces() const
Return true if the object has faces.
Transform m_frame
The transformation of the object.
GeometryType m_type
The type of geometry for the object.
bool isQuadMesh() const
Return true if the object is a Quadrangle Mesh.
bool isHexMesh() const
Return true if the object is a Hexahedron Mesh.
const MaterialData & getMaterial() const
Return the MaterialData associated to the objet.
void setMaterial(MaterialData *material)
Set the MaterialData for the object.
void setPrimitiveCount(int n)
Used to track easily the number of primitives in the geometry data.
void setType(const GeometryType &type)
Set the type of geometry.
GeometryType getType() const
Return the type of geometry.
Geometry::MultiIndexedGeometry & getGeometry()
Read/write access to the multiIndexedGeometry;.
std::shared_ptr< MaterialData > m_material
The MaterialData for the object.
bool hasPolyhedra() const
Return true if the object has polyhedra.
Core::Geometry::MultiIndexedGeometry m_geometry
Named attributes.
void setFrame(const Transform &frame)
Set the Transform of the object.
void setName(const std::string &name)
Return the name of the object.
Transform getFrame() const
Return the Transform of the object.
bool hasMaterial() const
Return true if the object has MaterialData.
bool isPointCloud() const
Return true if the object is a Point Cloud.
bool hasEdges() const
Return true if the object has lines.
represent material data loaded by a file loader. Material data must be identified by a unique name....
AbstractGeometry with per-vertex attributes and layers of indices. Each layer represents a different ...
bool containsLayer(const LayerKeyType &layerKey) const
Check if at least one layer with such properties exists.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3