Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Core::Grid< T, D > Class Template Reference

#include <Core/Containers/Grid.hpp>

+ Inheritance diagram for Ra::Core::Grid< T, D >:
+ Collaboration diagram for Ra::Core::Grid< T, D >:

Classes

class  Iterator
 A vector of signed offsets. More...
 

Public Types

using IdxVector
 Dimension of our grid.
 
using OffsetVector = Eigen::Matrix<int, D, 1>
 A vector of the size of the grid along each dimension.
 

Public Member Functions

 Grid (const IdxVector &size=IdxVector::Zero(), const T &val=T())
 Construct a grid of a given size and fill it with the given value.
 
 Grid (const IdxVector &size, const T *values)
 Construct a grid of a given size with values in ()-major format.
 
 Grid (const Grid< T, D > &other)=default
 Copy constructor and assignment operator.
 
Gridoperator= (const Grid< T, D > &other)=default
 
uint size () const
 Returns the number of elements stored.
 
const IdxVectorsizeVector () const
 Returns the size vector (a D-dimensional vector with the size along each dimension).
 
bool empty () const
 Returns true if the grid is empty (i.e. if size() ==0).
 
void clear ()
 Erases all data and makes the grid empty.
 
const T & at (const IdxVector &idx) const
 Access an element with a D-dimensional index.
 
T & at (const IdxVector &idx)
 
const T & at (uint idx) const
 Access an element with a linear index.
 
T & at (uint idx)
 
const T & at (const Iterator &it) const
 Access an element with an iterator.
 
T & at (const Iterator &it)
 
const T * data () const
 Read only access to the underlying data.
 
T * data ()
 Read-write access to the underlying data.
 
Iterator begin ()
 Get an iterator on this grid at the first element.
 
Iterator begin () const
 
Iterator end ()
 Get an iterator on this grid past the last element.
 
Iterator end () const
 

Static Public Attributes

static const uint Dimension = D
 

Protected Attributes

IdxVector m_size
 Indicate the extends of the grid along each dimension.
 
std::vector< T > m_data
 Storage for the grid data.
 

Detailed Description

template<typename T, uint D>
class Ra::Core::Grid< T, D >

This class stores a D-dimensional grid of elements of arbitrary type. in a contiguous memory block. Elements are stored in column-major order. e.g. for a 3x3x3 array the element vector looks like [A000, A100, A200, A010,... A222]. Elements are accessible with a D-dimensional Vector, or linearly with iterators, thanks to the std-like interface provided.

Definition at line 17 of file Grid.hpp.

Member Typedef Documentation

◆ IdxVector

template<typename T , uint D>
using Ra::Core::Grid< T, D >::IdxVector
Initial value:
Eigen::Matrix<uint, D, 1>

Dimension of our grid.

Definition at line 23 of file Grid.hpp.

◆ OffsetVector

template<typename T , uint D>
using Ra::Core::Grid< T, D >::OffsetVector = Eigen::Matrix<int, D, 1>

A vector of the size of the grid along each dimension.

Definition at line 25 of file Grid.hpp.

Constructor & Destructor Documentation

◆ Grid() [1/2]

template<typename T , uint D>
Ra::Core::Grid< T, D >::Grid ( const IdxVector & size = IdxVector::Zero(),
const T & val = T() )
inline

Construct a grid of a given size and fill it with the given value.

Definition at line 172 of file Grid.hpp.

◆ Grid() [2/2]

template<typename T , uint D>
Ra::Core::Grid< T, D >::Grid ( const IdxVector & size,
const T * values )
inline

Construct a grid of a given size with values in ()-major format.

Definition at line 176 of file Grid.hpp.

Member Function Documentation

◆ at() [1/2]

template<typename T , uint D>
T & Ra::Core::Grid< T, D >::at ( uint idx)
inline

Definition at line 332 of file Grid.hpp.

◆ at() [2/2]

template<typename T , uint D>
const T & Ra::Core::Grid< T, D >::at ( uint idx) const
inline

Access an element with a linear index.

Definition at line 326 of file Grid.hpp.

◆ begin() [1/2]

template<typename T , uint D>
Grid< T, D >::Iterator Ra::Core::Grid< T, D >::begin ( )
inline

Get an iterator on this grid at the first element.

Definition at line 354 of file Grid.hpp.

◆ begin() [2/2]

template<typename T , uint D>
Grid< T, D >::Iterator Ra::Core::Grid< T, D >::begin ( ) const
inline

Definition at line 359 of file Grid.hpp.

◆ clear()

template<typename T , uint D>
void Ra::Core::Grid< T, D >::clear ( )
inline

Erases all data and makes the grid empty.

Definition at line 291 of file Grid.hpp.

◆ data() [1/2]

template<typename T , uint D>
T * Ra::Core::Grid< T, D >::data ( )
inline

Read-write access to the underlying data.

Definition at line 303 of file Grid.hpp.

◆ data() [2/2]

template<typename T , uint D>
const T * Ra::Core::Grid< T, D >::data ( ) const
inline

Read only access to the underlying data.

Definition at line 298 of file Grid.hpp.

◆ empty()

template<typename T , uint D>
bool Ra::Core::Grid< T, D >::empty ( ) const
inline

Returns true if the grid is empty (i.e. if size() ==0).

Definition at line 285 of file Grid.hpp.

◆ end() [1/2]

template<typename T , uint D>
Grid< T, D >::Iterator Ra::Core::Grid< T, D >::end ( )
inline

Get an iterator on this grid past the last element.

Definition at line 364 of file Grid.hpp.

◆ end() [2/2]

template<typename T , uint D>
Grid< T, D >::Iterator Ra::Core::Grid< T, D >::end ( ) const
inline

Definition at line 369 of file Grid.hpp.

◆ size()

template<typename T , uint D>
uint Ra::Core::Grid< T, D >::size ( ) const
inline

Returns the number of elements stored.

Definition at line 273 of file Grid.hpp.

◆ sizeVector()

template<typename T , uint D>
const Grid< T, D >::IdxVector & Ra::Core::Grid< T, D >::sizeVector ( ) const
inline

Returns the size vector (a D-dimensional vector with the size along each dimension).

Definition at line 279 of file Grid.hpp.

Member Data Documentation

◆ Dimension

template<typename T , uint D>
const uint Ra::Core::Grid< T, D >::Dimension = D
static

Definition at line 22 of file Grid.hpp.

◆ m_data

template<typename T , uint D>
std::vector<T> Ra::Core::Grid< T, D >::m_data
protected

Storage for the grid data.

Definition at line 236 of file Grid.hpp.

◆ m_size

template<typename T , uint D>
IdxVector Ra::Core::Grid< T, D >::m_size
protected

Indicate the extends of the grid along each dimension.

Definition at line 234 of file Grid.hpp.


The documentation for this class was generated from the following file: