#include <regularData2D.h>
Classes |
||||
struct | BlockValueType | |||
The block data type for reading and
writing binary data.
More... |
||||
class | IndexType | |||
The index type used to refer to a
specific element in the grid (x-, and y-index). More... |
||||
Public Types |
||||
typedef ValueType | value_type | |||
typedef std::vector< ValueType > ::iterator |
iterator | |||
typedef std::vector< ValueType > ::const_iterator |
const_iterator | |||
typedef std::vector< ValueType > ::reference |
reference | |||
typedef std::vector< ValueType > ::const_reference |
const_reference | |||
typedef std::vector< ValueType > ::pointer |
pointer | |||
typedef std::vector< ValueType > ::difference_type |
difference_type | |||
typedef std::vector< ValueType > ::size_type |
size_type | |||
Type Definitions
|
||||
typedef std::vector< ValueType > | VectorType | |||
The type containing an STL vector of
the appropriate type. |
||||
typedef TVector2< float > | CoordinateType | |||
The coordinate type. |
||||
typedef std::vector< ValueType > ::iterator |
Iterator | |||
A mutable iterator. |
||||
typedef std::vector< ValueType > ::const_iterator |
ConstIterator | |||
A nonmutable iterator. |
||||
Public Member Functions |
||||
Constructors and Destructors
|
||||
TRegularData2D () | ||||
Default constructor. |
||||
TRegularData2D (const TRegularData2D< ValueType > &data) throw (Exception::OutOfMemory) | ||||
Copy constructor. |
||||
TRegularData2D (const CoordinateType &origin, const CoordinateType &dimension, const CoordinateType &spacing) throw (Exception::OutOfMemory) | ||||
Constructor. |
||||
TRegularData2D (const IndexType &size, const CoordinateType &origin=CoordinateType(0.0), const CoordinateType &dimension=CoordinateType(1.0)) throw (Exception::OutOfMemory) | ||||
virtual | ~TRegularData2D () | |||
Destructor. |
||||
virtual void | clear () | |||
Clear method. |
||||
Assignment
|
||||
TRegularData2D & | operator= (const TRegularData2D< ValueType > &data) throw (Exception::OutOfMemory) | |||
Assignment operator. |
||||
Predicates
|
||||
bool | operator== (const TRegularData2D< ValueType > &data) const | |||
Equality operator. |
||||
bool | operator!= (const TRegularData2D< ValueType > &data) const | |||
Inequality operator. |
||||
bool | empty () const | |||
Empty predicate. |
||||
bool | isInside (const CoordinateType &x) const | |||
Test if a given point is inside the
grid. |
||||
Iterators
|
||||
ConstIterator | begin () const | |||
ConstIterator | end () const | |||
Iterator | begin () | |||
Iterator | end () | |||
Accessors
|
||||
size_type | size () const | |||
size_type | max_size () const | |||
void | swap (TRegularData2D< ValueType > &data) | |||
const ValueType & | getData (const IndexType &index) const throw (Exception::OutOfGrid) | |||
Return a nonmutable reference to a
specific data element. |
||||
ValueType & | getData (const IndexType &index) throw (Exception::OutOfGrid) | |||
Return a mutable reference to a
specific data element. |
||||
const ValueType & | getData (Position index) const throw (Exception::OutOfGrid) | |||
Return a nonmutable reference to a
specific data element. |
||||
ValueType & | getData (Position index) throw (Exception::OutOfGrid) | |||
Return a mutable reference to a
specific data element. |
||||
const ValueType & | operator[] (const IndexType &index) const | |||
Nonmutable random access operator.
|
||||
ValueType & | operator[] (const IndexType &index) | |||
Mutable random access operator.
|
||||
const ValueType & | operator[] (Position index) const | |||
Nonmutable random access operator.
|
||||
ValueType & | operator[] (Position index) | |||
Mutable random access operator.
|
||||
ValueType | operator() (const CoordinateType &x) const | |||
Function operator. |
||||
ValueType | getInterpolatedValue (const CoordinateType &x) const throw (Exception::OutOfGrid) | |||
Return the linearly interpolated
value of the surrounding two grid points. |
||||
const ValueType & | getClosestValue (const CoordinateType &x) const throw (Exception::OutOfGrid) | |||
Return a nonmutable reference to the
closest non-interpolated value. |
||||
ValueType & | getClosestValue (const CoordinateType &x) throw (Exception::OutOfGrid) | |||
Return a mutable reference to the
closest non-interpolated value. |
||||
IndexType | getLowerIndex (const CoordinateType &v) const throw (Exception::OutOfGrid) | |||
Return the position of the grid
point with coordinates lesser than the given vector.
|
||||
IndexType | getClosestIndex (const CoordinateType &v) const throw (Exception::OutOfGrid) | |||
Return the position of the grid
point closest to the given vector. |
||||
const IndexType & | getSize () const | |||
Return the size of the grid.
|
||||
const CoordinateType & | getOrigin () const | |||
Return the origin of the data.
|
||||
const CoordinateType & | getSpacing () const | |||
Return the spacing of the data.
|
||||
void | setOrigin (const CoordinateType &origin) | |||
Set the origin of the
data. |
||||
const CoordinateType & | getDimension () const | |||
Return the dimension of the data.
|
||||
void | setDimension (const CoordinateType &dimension) | |||
Set the dimension of the data.
|
||||
void | resize (const IndexType &new_size) throw (Exception::OutOfMemory) | |||
Resize the data. |
||||
void | rescale (const IndexType &new_size) throw (Exception::OutOfMemory) | |||
Rescale the data. |
||||
CoordinateType | getCoordinates (const IndexType &index) const throw (Exception::OutOfGrid) | |||
Return the exact coordinates of a
grid point. |
||||
CoordinateType | getCoordinates (Position index) const throw (Exception::OutOfGrid) | |||
Return the exact coordinates of a
grid point. |
||||
void | getEnclosingIndices (const CoordinateType &r, Position &ll, Position &lr, Position &ul, Position &ur) const throw (Exception::OutOfGrid) | |||
Return the indices of the grid
points of the enclosing rectangle. |
||||
void | getEnclosingValues (const CoordinateType &r, ValueType &ll, ValueType &lr, ValueType &ul, ValueType &ur) const throw (Exception::OutOfGrid) | |||
Return the values at the grid points
of the enclosing the spcified position. |
||||
void | binaryWrite (const String &filename) const throw (Exception::FileNotFound) | |||
Write the grid contents in a
(non-portable) binary format. |
||||
void | binaryRead (const String &filename) throw (Exception::FileNotFound) | |||
Read the grid contents from a file written with
binaryWrite
|
||||
Protected Attributes |
||||
VectorType | data_ | |||
The grid data. |
||||
CoordinateType | origin_ | |||
Origin of the grid
(offset). |
||||
CoordinateType | dimension_ | |||
Dimension of the grid. |
||||
CoordinateType | spacing_ | |||
Grid spacing. |
||||
IndexType | size_ | |||
The dimensions in grid
points. |
This class represents a two-dimensional array. An instance of ValueType will be created for each point of the grid upon instantiation of TRegularData2D.
Container
and
Unary Function
requirements. Iteration is along
the x-axis first, then along the y-axis.BALL::TRegularData2D< ValueType >::TRegularData2D | ( | ) |
Default constructor.
Creates an empty TRegularData2D object.
BALL::TRegularData2D< ValueType >::TRegularData2D | ( | const CoordinateType & | origin, | |
const CoordinateType & | dimension, | |||
const CoordinateType & | spacing | |||
) | throw (Exception::OutOfMemory) |
Constructor.
origin | the origin of the grid | |
dimension | the dimension of the grid (extension in x- and y-direction) | |
spacing | the grid spacing along the x- and y-axis |
OutOfMemory | if insufficient memory is available to allocate the grid |
void BALL::TRegularData2D< ValueType >::binaryWrite | ( | const String & | filename | ) | const throw (Exception::FileNotFound) |
Write the grid contents in a (non-portable) binary format.
FileNotFound | thrown if file could not be written |
References BALL::BinaryFileAdaptor< T >::setData().
void BALL::TRegularData2D< ValueType >::clear | ( | ) | [virtual] |
Clear method.
Delete the grid contents and resize it to zero.
Reimplemented in BALL::TFFT2D< ComplexTraits >.
References BALL::TRegularData2D< ValueType >::data_, BALL::TRegularData2D< ValueType >::dimension_, BALL::TRegularData2D< ValueType >::origin_, BALL::TVector2< T >::set(), BALL::TRegularData2D< ValueType >::size_, BALL::TRegularData2D< ValueType >::spacing_, BALL::TRegularData2D< ValueType >::TRegularData2D::IndexType::x, and BALL::TRegularData2D< ValueType >::TRegularData2D::IndexType::y.
IndexType BALL::TRegularData2D< ValueType >::getClosestIndex | ( | const CoordinateType & | v | ) | const throw (Exception::OutOfGrid) |
Return the position of the grid point closest to the given vector.
If there are multiple grid points with equal distance, the grid point with the lowest indices in x, y direction is returned.
OutOfGrid | if the point is outside the grid |
ValueType& BALL::TRegularData2D< ValueType >::getClosestValue | ( | const CoordinateType & | x | ) | throw (Exception::OutOfGrid) |
Return a mutable reference to the closest non-interpolated value.
This method first performs a range check for the
argument x
and then returns the value of the
closest data point to the left or right of
x
.
const ValueType& BALL::TRegularData2D< ValueType >::getClosestValue | ( | const CoordinateType & | x | ) | const throw (Exception::OutOfGrid) |
Return a nonmutable reference to the closest non-interpolated value.
This method first performs a range check for the
argument x
and then returns the value of the
closest data point to the left or right of
x
.
TRegularData2D< ValueType >::CoordinateType BALL::TRegularData2D< ValueType >::getCoordinates | ( | Position | index | ) | const throw (Exception::OutOfGrid) |
Return the exact coordinates of a grid point.
OutOfGrid | if the point is outside the grid |
CoordinateType BALL::TRegularData2D< ValueType >::getCoordinates | ( | const IndexType & | index | ) | const throw (Exception::OutOfGrid) |
Return the exact coordinates of a grid point.
OutOfGrid | if the point is outside the grid |
ValueType & BALL::TRegularData2D< ValueType >::getData | ( | Position | index | ) | throw (Exception::OutOfGrid) |
Return a mutable reference to a specific data element.
This is the range chacking version of operator
[]
.
const ValueType & BALL::TRegularData2D< ValueType >::getData | ( | Position | index | ) | const throw (Exception::OutOfGrid) |
Return a nonmutable reference to a specific data element.
This is the range chacking version of operator
[]
.
ValueType& BALL::TRegularData2D< ValueType >::getData | ( | const IndexType & | index | ) | throw (Exception::OutOfGrid) |
Return a mutable reference to a specific data element.
This is the range chacking version of operator
[]
.
const ValueType& BALL::TRegularData2D< ValueType >::getData | ( | const IndexType & | index | ) | const throw (Exception::OutOfGrid) |
Return a nonmutable reference to a specific data element.
This is the range chacking version of operator
[]
.
const CoordinateType& BALL::TRegularData2D< ValueType >::getDimension | ( | ) | const |
Return the dimension of the data.
The dimension represents the length of the data vector.
Hence, the coordinate of the rightmost element,
data_[getSize() -
1]
is the origin plus the dimension (getOrigin() +
getDimension()
).
void BALL::TRegularData2D< ValueType >::getEnclosingIndices | ( | const CoordinateType & | r, | |
Position & | ll, | |||
Position & | lr, | |||
Position & | ul, | |||
Position & | ur | |||
) | const throw (Exception::OutOfGrid) |
Return the indices of the grid points of the enclosing rectangle.
This method calculates the grid rectangle that contains the given vector and returns the indices of the grid points forming this rectangle. The given point lies either in the rectangle or is the lower left front edge of the rectangle.
OutOfGrid | if the point is outside the grid |
r | a point inside the grid | |
ll | left lower corner of the rectangle | |
lr | right lower corner of the rectangle | |
ul | left upper corner of the rectangle | |
ur | right upper corner of the rectangle |
void BALL::TRegularData2D< ValueType >::getEnclosingValues | ( | const CoordinateType & | r, | |
ValueType & | ll, | |||
ValueType & | lr, | |||
ValueType & | ul, | |||
ValueType & | ur | |||
) | const throw (Exception::OutOfGrid) |
Return the values at the grid points of the enclosing the spcified position.
ValueType BALL::TRegularData2D< ValueType >::getInterpolatedValue | ( | const CoordinateType & | x | ) | const throw (Exception::OutOfGrid) |
Return the linearly interpolated value of the surrounding two grid points.
This method first performs a range check for the
argument x
and then calls operator ()
(x)
to determine an interpolated value at that
position.
Reimplemented in BALL::TFFT2D< ComplexTraits >.
IndexType BALL::TRegularData2D< ValueType >::getLowerIndex | ( | const CoordinateType & | v | ) | const throw (Exception::OutOfGrid) |
Return the position of the grid point with coordinates lesser than the given vector.
OutOfGrid | if the point is outside the grid |
const CoordinateType& BALL::TRegularData2D< ValueType >::getOrigin | ( | ) | const |
Return the origin of the data.
The origin represents the coordinate of the very first
(lower left) element, i.e. data_[0]
.
const IndexType& BALL::TRegularData2D< ValueType >::getSize | ( | ) | const |
Return the size of the grid.
This method yields the number of grid points in x- and y-direction. Use size to obtain the total number of points in the grid.
Referenced by BALL::TContourLine< T >::createContourLine().
const CoordinateType& BALL::TRegularData2D< ValueType >::getSpacing | ( | ) | const |
Return the spacing of the data.
The spacing corresponds to the distance between two adjacent data elements.
ValueType BALL::TRegularData2D< ValueType >::operator() | ( | const CoordinateType & | x | ) | const |
Function operator.
This operator allows the use of a TRegularData1D
instance as a unary function. As required by the STL
Unary Function
concept, the argument
x
is required to be within the correct range.
A more robust (range-checking) version of this operator is
implemented as getInterpolatedValue .
TRegularData2D< ValueType > & BALL::TRegularData2D< ValueType >::operator= | ( | const TRegularData2D< ValueType > & | data | ) | throw (Exception::OutOfMemory) |
Assignment operator.
Copy the data, the origin, and the dimension (spacing is copied implicitly as well).
bool BALL::TRegularData2D< ValueType >::operator== | ( | const TRegularData2D< ValueType > & | data | ) | const |
Equality operator.
Two grids are equal if they have the same number of points in all two dimensions, same origin, spacing and the data fields are equal.
References BALL::TRegularData2D< ValueType >::data_, BALL::TRegularData2D< ValueType >::dimension_, BALL::TRegularData2D< ValueType >::origin_, BALL::TRegularData2D< ValueType >::size_, BALL::TRegularData2D< ValueType >::TRegularData2D::IndexType::x, and BALL::TRegularData2D< ValueType >::TRegularData2D::IndexType::y.
Referenced by BALL::TRegularData2D< float >::operator!=().
ValueType& BALL::TRegularData2D< ValueType >::operator[] | ( | Position | index | ) |
Mutable random access operator.
const ValueType& BALL::TRegularData2D< ValueType >::operator[] | ( | Position | index | ) | const |
Nonmutable random access operator.
ValueType& BALL::TRegularData2D< ValueType >::operator[] | ( | const IndexType & | index | ) |
Mutable random access operator.
const ValueType& BALL::TRegularData2D< ValueType >::operator[] | ( | const IndexType & | index | ) | const |
Nonmutable random access operator.
void BALL::TRegularData2D< ValueType >::rescale | ( | const IndexType & | new_size | ) | throw (Exception::OutOfMemory) |
Rescale the data.
Keep the current boundaries of the data and
reinterpolate the data to reflect the new size. To create a
data set of new_size
data points, the data is
interpolated linearly at the new data points from the
closest points in the old data set.
new_size | the new data set size |
void BALL::TRegularData2D< ValueType >::resize | ( | const IndexType & | new_size | ) | throw (Exception::OutOfMemory) |
Resize the data.
If new_size
is larger than the current
size, the data vector
is extended to the new
size and filled with default constructed items of type
ValueType
. Resizing to a value lesser than the
current size truncates the vector.
new_size | the new size |
void BALL::TRegularData2D< ValueType >::setDimension | ( | const CoordinateType & | dimension | ) |
Set the dimension of the data.
This will affect neither the origin of the data, nor the number of elements stored (in contrast to resize() ). It will just store the appropriate scling factor and affect the spacing.