Public Types | Public Member Functions
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 >:
T2DVectorfield< T >

Public Types

typedef ::std::vector< T > data_array
 type for the flat reprentation of the 2D data field More...
 
typedef std::shared_ptr
< data_array
data_pointer
 pointer type 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
 
get_interpol_val_at (const C2DFVector &p) const
 This function should really go away. More...
 
const C2DBoundsget_size () const
 
void make_single_ref ()
 
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)
 
T2DDatafieldoperator= (const T2DDatafield &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 data_array &data)
 
 T2DDatafield (const 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 52 of file 2d/datafield.hh.

Member Typedef Documentation

template<class T>
typedef ::std::vector<T> T2DDatafield< T >::data_array

type for the flat reprentation of the 2D data field

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

template<class T>
typedef std::shared_ptr<data_array > T2DDatafield< T >::data_pointer

pointer type

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

Constructor & Destructor Documentation

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

Create a 2D data field with the given size

Parameters
size
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)
template<class T>
T2DDatafield< T >::T2DDatafield ( const C2DBounds size,
const data_array 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)
template<class T>
T2DDatafield< T >::T2DDatafield ( const T2DDatafield< T > &  org)

copy constructor, it does a shallow copy of the original, i.e. the data is not copied, only the shared pointer increases its reference count. If you want a truely unique copy, call make_single_ref() afterwards.

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

Member Function Documentation

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 216 of file 2d/datafield.hh.

Referenced by FDeformer2D::operator()().

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 231 of file 2d/datafield.hh.

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 252 of file 2d/datafield.hh.

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 265 of file 2d/datafield.hh.

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
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
template<class T>
void T2DDatafield< T >::clear ( )

This function first ensures that the copy of the data is unique by calling make_single_ref() and then sets the elements of data to T().

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 222 of file 2d/datafield.hh.

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 241 of file 2d/datafield.hh.

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.
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.
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
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
template<class T>
T T2DDatafield< T >::get_interpol_val_at ( const C2DFVector p) const

This function should really go away.

template<class T>
const C2DBounds& T2DDatafield< T >::get_size ( ) const
Returns
the size of the data field
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

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
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.

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.

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.

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

Assignment operator, Just like the copy constructor this call does only increment the reference count to the data. If you want a truely unique copy, call make_single_ref() afterwards.

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 159 of file 2d/datafield.hh.

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 171 of file 2d/datafield.hh.

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
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
template<class T>
size_type T2DDatafield< T >::size ( ) const
Returns
the number of elements in the data field

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