T2DDatafield< T > Class Template Reference

A class to hold data on a regular 2D grid. More...

#include <mia/2d/datafield.hh>

Inheritance diagram for T2DDatafield< T >:
[legend]

Data Structures

class  ConstRange
 
class  Range
 

Public Types

typedef ::std::vector< typename __holder_type_dispatch< T >::type > data_array
 type for the flat reprentation of the 2D data field More...
 

Public Member Functions

const_iterator begin () const
 
iterator begin ()
 
const_iterator begin_at (size_t x, size_t y) const
 
iterator begin_at (size_t x, size_t y)
 
range_iterator begin_range (const C2DBounds &begin, const C2DBounds &end)
 
const_range_iterator begin_range (const C2DBounds &begin, const C2DBounds &end) const
 
void clear ()
 
const_iterator end () const
 
iterator end ()
 
range_iterator end_range (const C2DBounds &begin, const C2DBounds &end)
 
const_range_iterator end_range (const C2DBounds &begin, const C2DBounds &end) const
 
void get_data_line_x (size_t y, std::vector< T > &buffer) const
 
void get_data_line_y (size_t x, std::vector< T > &buffer) const
 
Range get_range (const C2DBounds &start, const C2DBounds &end)
 
ConstRange get_range (const C2DBounds &start, const C2DBounds &end) const
 
const C2DBoundsget_size () const
 
void make_single_ref () __attribute__((deprecated))
 
const_reference operator() (size_t x, size_t y) const
 
reference operator() (size_t x, size_t y)
 
const_reference operator() (const C2DBounds &l) const
 
reference operator() (const C2DBounds &l)
 
T2DDatafield< T > & operator= (const T2DDatafield< T > &org)
 
T2DDatafield< T > & operator= (T2DDatafield< T > &&org)
 
const_reference operator[] (size_t idx) const
 
reference operator[] (size_t idx)
 
void put_data_line_x (size_t y, const std::vector< T > &buffer)
 
void put_data_line_y (size_t x, const std::vector< T > &buffer)
 
size_type size () const
 
 T2DDatafield ()
 
 T2DDatafield (const C2DBounds &size)
 
 T2DDatafield (const C2DBounds &size, const T *_data)
 
 T2DDatafield (const C2DBounds &size, const std::vector< T > &data)
 
 T2DDatafield (const T2DDatafield< T > &org)
 
 T2DDatafield (T2DDatafield< T > &&org)
 
virtual ~T2DDatafield ()
 

Detailed Description

template<class T>
class T2DDatafield< T >

A class to hold data on a regular 2D grid.

This class is the base for all kind of 2D data that is stored over a regular grid. The data it hols is stored in a shared pointer.

Template Parameters
Tthe data type of the values hold at the grid points.

Definition at line 89 of file 2d/datafield.hh.

Member Typedef Documentation

◆ data_array

template<class T>
typedef ::std::vector<typename __holder_type_dispatch<T>::type> T2DDatafield< T >::data_array

type for the flat reprentation of the 2D data field

Definition at line 94 of file 2d/datafield.hh.

Constructor & Destructor Documentation

◆ T2DDatafield() [1/6]

template<class T>
T2DDatafield< T >::T2DDatafield ( )

◆ T2DDatafield() [2/6]

template<class T>
T2DDatafield< T >::T2DDatafield ( const C2DBounds size)
explicit

Create a 2D data field with the given size

Parameters
size

◆ T2DDatafield() [3/6]

template<class T>
T2DDatafield< T >::T2DDatafield ( const C2DBounds size,
const T *  _data 
)

Create a 2D data field with the given size and initialize it with the given data

Parameters
size
_datamust at least be of size (size.x*size.y)

◆ T2DDatafield() [4/6]

template<class T>
T2DDatafield< T >::T2DDatafield ( const C2DBounds size,
const std::vector< T > &  data 
)

Create a 2D data field with the given size and initialize it with the given data

Parameters
size
datamust at least be of size (size.x*size.y)

◆ T2DDatafield() [5/6]

template<class T>
T2DDatafield< T >::T2DDatafield ( const T2DDatafield< T > &  org)

copy constructor, it does a deep copy.

◆ T2DDatafield() [6/6]

template<class T>
T2DDatafield< T >::T2DDatafield ( T2DDatafield< T > &&  org)

move constructor

◆ ~T2DDatafield()

template<class T>
virtual T2DDatafield< T >::~T2DDatafield ( )
virtual

Member Function Documentation

◆ begin() [1/2]

template<class T>
const_iterator T2DDatafield< T >::begin ( ) const
inline
Returns
a read-only iterator to the begin of the data field with x being the fastest changing index

Definition at line 298 of file 2d/datafield.hh.

Referenced by T2DDatafield< C2DFVector >::begin_at(), and FDeformer2D::operator()().

◆ begin() [2/2]

template<class T>
iterator T2DDatafield< T >::begin ( )
inline

Get a read-write iterator to iterate over the whole field. The functions ensures that the data will only be referenced by this object.

Returns
a read-write iterator to the begin of the data field

Definition at line 311 of file 2d/datafield.hh.

◆ begin_at() [1/2]

template<class T>
const_iterator T2DDatafield< T >::begin_at ( size_t  x,
size_t  y 
) const
inline

Get a read-write iterator to iterate over the field staring from the given position. The functions ensures that the data will only be referenced by this object.

Parameters
x
y
Returns
a read-write iterator to the given position of the data field

Definition at line 330 of file 2d/datafield.hh.

◆ begin_at() [2/2]

template<class T>
iterator T2DDatafield< T >::begin_at ( size_t  x,
size_t  y 
)
inline

Get a read-only iterator to iterate over the field staring from the given position.

Parameters
x
y
Returns
a read-write iterator to the given position of the data field

Definition at line 343 of file 2d/datafield.hh.

◆ begin_range() [1/2]

template<class T>
range_iterator T2DDatafield< T >::begin_range ( const C2DBounds begin,
const C2DBounds end 
)
Returns
an read/write forward iterator over a subset of the data. The functions ensures, that the field uses a single referenced datafield

Referenced by T2DDatafield< C2DFVector >::begin_at().

◆ begin_range() [2/2]

template<class T>
const_range_iterator T2DDatafield< T >::begin_range ( const C2DBounds begin,
const C2DBounds end 
) const
Returns
an read/write forward iterator over a subset of the data. The functions ensures, that the field uses a single referenced datafield

◆ clear()

template<class T>
void T2DDatafield< T >::clear ( )

This function sets the elements of data to T().

◆ end() [1/2]

template<class T>
const_iterator T2DDatafield< T >::end ( ) const
inline
Returns
a read-only iterator to the end of the data field with x being the fastest changing index

Definition at line 303 of file 2d/datafield.hh.

Referenced by T2DDatafield< C2DFVector >::begin_at().

◆ end() [2/2]

template<class T>
iterator T2DDatafield< T >::end ( )
inline

Get a read-write iterator to iterate over the whole field. The functions ensures that the data will only be referenced by this object.

Returns
a read-write iterator to the end of the data field

Definition at line 320 of file 2d/datafield.hh.

◆ end_range() [1/2]

template<class T>
range_iterator T2DDatafield< T >::end_range ( const C2DBounds begin,
const C2DBounds end 
)
Returns
the end of a read/write forward iterator over a subset of the data.

Referenced by T2DDatafield< C2DFVector >::begin_at().

◆ end_range() [2/2]

template<class T>
const_range_iterator T2DDatafield< T >::end_range ( const C2DBounds begin,
const C2DBounds end 
) const
Returns
the end of a read/write forward iterator over a subset of the data.

◆ get_data_line_x()

template<class T>
void T2DDatafield< T >::get_data_line_x ( size_t  y,
std::vector< T > &  buffer 
) const

Read a data row from the data field to the provided buffer

Parameters
[in]yrow to be copied from
[out]bufferto copy the data to. It will be resized to fit the data

Referenced by T2DDatafield< C2DFVector >::operator[]().

◆ get_data_line_y()

template<class T>
void T2DDatafield< T >::get_data_line_y ( size_t  x,
std::vector< T > &  buffer 
) const

Read a data column from the data field to the provided buffer

Parameters
[in]xcolumn to be copied from
[out]bufferto copy the data to. It will be resized to fit the data

Referenced by T2DDatafield< C2DFVector >::operator[]().

◆ get_range() [1/2]

template<class T>
Range T2DDatafield< T >::get_range ( const C2DBounds start,
const C2DBounds end 
)

◆ get_range() [2/2]

template<class T>
ConstRange T2DDatafield< T >::get_range ( const C2DBounds start,
const C2DBounds end 
) const

◆ get_size()

template<class T>
const C2DBounds& T2DDatafield< T >::get_size ( ) const
Returns
the size of the data field

◆ make_single_ref()

template<class T>
void T2DDatafield< T >::make_single_ref ( )

Since the data is internally stored by a shared pointer, this function ensures that the data is not shared with any other object

◆ operator()() [1/4]

template<class T>
const_reference T2DDatafield< T >::operator() ( size_t  x,
size_t  y 
) const

returns a read-only reference to the data element at (x,y). If the index is outside the image domain, the function returns the Zero element.

Parameters
x
y
Returns
the reference

Referenced by T2DDatafield< C2DFVector >::operator[]().

◆ operator()() [2/4]

template<class T>
reference T2DDatafield< T >::operator() ( size_t  x,
size_t  y 
)

returns a writable reference to the data element at (x,y). If the index is outside the image domain, the function throws a std::invalid_argument exception.

◆ operator()() [3/4]

template<class T>
const_reference T2DDatafield< T >::operator() ( const C2DBounds l) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator()() [4/4]

template<class T>
reference T2DDatafield< T >::operator() ( const C2DBounds l)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator=() [1/2]

template<class T>
T2DDatafield<T>& T2DDatafield< T >::operator= ( const T2DDatafield< T > &  org)

Assignment operator, does a deep copy.

◆ operator=() [2/2]

template<class T>
T2DDatafield<T>& T2DDatafield< T >::operator= ( T2DDatafield< T > &&  org)

Assignment move operator

◆ operator[]() [1/2]

template<class T>
const_reference T2DDatafield< T >::operator[] ( size_t  idx) const
inline

Direct index into the underlying data array - this access is usually faster then calling operator()(size_t x, size_t y) and corresponds to \(idx= x + y * m_size.x\) but is doesn't test whether the index is inside the image domain.

Parameters
idx
Returns
read-only reference to the data

Definition at line 241 of file 2d/datafield.hh.

◆ operator[]() [2/2]

template<class T>
reference T2DDatafield< T >::operator[] ( size_t  idx)
inline

Direct index into the underlying data array - this access is usually faster then calling operator()(size_t x, size_t y) and corresponds to \(idx= x + y * m_size.x\) but is doesn't test whether the index is inside the image domain.

Parameters
idx
Returns
read-write reference to the data

Definition at line 253 of file 2d/datafield.hh.

◆ put_data_line_x()

template<class T>
void T2DDatafield< T >::put_data_line_x ( size_t  y,
const std::vector< T > &  buffer 
)

Write a data row to the data field. The function ensures that tha data is not shared with some other object.

Parameters
[in]yrow to be copied to
[in]bufferdata buffer, must be of the same size as the row size of the data field

Referenced by T2DDatafield< C2DFVector >::operator[]().

◆ put_data_line_y()

template<class T>
void T2DDatafield< T >::put_data_line_y ( size_t  x,
const std::vector< T > &  buffer 
)

Write a data column to the data field. The function ensures that tha data is not shared with some other object.

Parameters
[in]xcolumn to be copied to
[in]bufferdata buffer, must be of the same size as the column size of the data field

Referenced by T2DDatafield< C2DFVector >::operator[]().

◆ size()

template<class T>
size_type T2DDatafield< T >::size ( ) const
Returns
the number of elements in the data field

Referenced by T2DDatafield< C2DFVector >::operator[]().


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