33#include <NDEVR/Model.h>
34#include <NDEVR/Geometry.h>
40 template<u
int01 t_dims>
51 lib_assert(location <
m_size,
"Out of bounds grid conversion lookup");
54 case 1:
return location[X];
55 case 2:
return m_size[X] * location[Y] + location[X];
56 case 3:
return m_size[X] *
m_size[Y] * location[Z] +
m_size[X] * location[Y] + location[X];
58 return Constant<uint04>::Invalid;
72 vec_location[X] = location;
75 vec_location[Y] = location /
m_size[X];
76 vec_location[X] = location %
m_size[X];
81 vec_location[X] = location %
m_size[X];
84 lib_assert(vec_location <
m_size,
"Out of bounds grid conversion lookup");
103 return Constant<uint01>::Invalid;
122 template<u
int01 t_dims>
146 return m_geo.isValid();
176 m_geo.setupVertexTable(count, position, normal, color, texture, tangent, bitangent, bones);
182 for (
uint04 i = 0; i < count; i++)
187 m_geo.updateVertexColumns();
206 template<
class t_type>
218 template<
class t_type>
230 template<
class t_type>
245 template<
class t_type>
262 template<
class t_type>
266 for (
uint01 dim = 0; dim < t_dims; dim++)
268 if (index[dim] < 0 || index[dim] > size[dim])
269 return Constant<t_type>::Invalid;
278 for (
uint01 i = 0; i < GridIndexing<t_dims>::getNumberOfCorners(); i++)
281 if constexpr (t_dims >= 3)
282 location_sum[Z] = (i / 4) % 2;
283 if constexpr (t_dims >= 2)
284 location_sum[Y] = (i / 2) % 2;
285 if constexpr (t_dims >= 1)
286 location_sum[X] = (i / 1) % 2;
287 if (discrete[X] == size[X] - 1)
289 if (discrete[Y] == size[Y] - 1)
296 return Constant<t_type>::Invalid;
298 else if (interpolation == InterpolationValues::e_linear)
301 for (
uint01 i = 0; i < GridIndexing<t_dims>::getNumberOfCorners(); i++)
304 if constexpr (t_dims >= 3)
305 location_sum[Z] = (i / 4) % 2;
306 if constexpr (t_dims >= 2)
307 location_sum[Y] = (i / 2) % 2;
308 if constexpr (t_dims >= 1)
309 location_sum[X] = (i / 1) % 2;
344 return Constant<t_type>::Invalid;
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
VertexMode
Describes the storage format and coordinate system of vertex data.
@ e_no_vertex
No vertex data present.
Converts 1 dimensional index into N dimensional index based on size of each dimension.
static constexpr uint01 getNumberOfCorners()
Returns the number of corners for a grid cell of the given dimensionality.
void setSize(Vector< t_dims, uint04 > index_size)
Sets the size of the grid in each dimension.
Vector< t_dims, uint04 > convertFromIndex(const uint04 &location) const
Converts a flat 1D index back into an N-dimensional grid coordinate.
Vector< t_dims, uint04 > m_size
The number of elements along each dimension of the grid.
uint04 convertToIndex(const Vector< t_dims, uint04 > &location) const
Converts an N-dimensional grid coordinate into a flat 1D index using row-major ordering.
t_type interpolateVertex(VertexProperty property, const Vector< t_dims, fltp08 > &index, InterpolationValues interpolation=InterpolationValues::e_linear) const
Interpolates a vertex property value at a fractional N-dimensional grid coordinate.
bool isValid() const
Checks whether this GridMesh has a valid underlying Geometry.
Geometry geometry() const
Returns the underlying Geometry object.
GridMesh()
Default constructor.
void setVertex(VertexProperty property, Vector< t_dims, uint04 > index, const t_type &vector)
Sets a vertex property value at the given N-dimensional grid index.
GridMesh(const Geometry &model)
Constructs a GridMesh wrapping the given Geometry object.
Geometry m_geo
The underlying Geometry object that stores the grid vertex data.
void setupVertexTable(Vector< t_dims, uint04 > index_size, Geometry::VertexMode position, Geometry::VertexMode normal=Geometry::VertexMode::e_no_vertex, Geometry::VertexMode color=Geometry::VertexMode::e_no_vertex, Geometry::VertexMode texture=Geometry::VertexMode::e_no_vertex, Geometry::VertexMode tangent=Geometry::VertexMode::e_no_vertex, Geometry::VertexMode bitangent=Geometry::VertexMode::e_no_vertex, Geometry::VertexMode bones=Geometry::VertexMode::e_no_vertex)
Initializes the vertex table for the grid with the specified dimensions and vertex modes.
t_type vertex(VertexProperty property, Vector< t_dims, uint04 > index) const
Retrieves a vertex property value at the given N-dimensional grid index.
t_type getVertexProperty(uint04 property_index, Vector< t_dims, uint04 > index) const
Retrieves a custom vertex property by column index at the given N-dimensional grid index.
const Vector< t_dims, uint04 > & getIndexSize() const
Returns the size of the grid in each dimension.
void setVertexProperty(uint04 property_index, Vector< t_dims, uint04 > index, const t_type &value)
Sets a custom vertex property by column index at the given N-dimensional grid index.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
constexpr t_type product() const
Returns the product, or value of each dimension multiplied together.
Typed vertex iterator providing array-style access to geometry vertex data.
void setFlag(uint04 index, const BitFlag &value)
Sets the flag value for a vertex, creating the flag column if necessary.
void setVertex(uint04 index, const t_type &value)
Sets a vertex value at the given index.
The primary namespace for the NDEVR SDK.
VertexProperty
Per-vertex data channels that can be stored in the vertex table to be used by Geometry.
@ Position
XYZ position of the vertex.
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Changes an input with a negative sign, to a positive sign.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ e_points
Point cloud or discrete points.
double fltp08
Defines an alias representing an 8 byte floating-point number.
InterpolationValues
Values that represent interpolation functions.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
static constexpr Angle< t_type > difference(const Angle< t_type > &angle_a, const Angle< t_type > &angle_b)
Calculates minimal absolute signed angle between two angles.
@ e_is_filtered
Vertex is excluded by a filter.
@ e_is_hidden
Vertex is hidden from display.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.