ug4
|
Generic raster for arbitrary dimensions. More...
#include <raster.h>
Classes | |
class | Coordinate |
class | MultiIndex |
Public Member Functions | |
void | blur (T alpha, size_t iterations) |
blurs (smoothens) the values by repeatedly averaging between direct neighbors More... | |
void | create () |
creates the raster. Call this method after 'set_num_nodes' has been called for each dimension. More... | |
int | dim () const |
const Coordinate & | extension () const |
returns the extension of the raster More... | |
number | extension (int dim) const |
returns the extension of the raster for the given dimension More... | |
T | interpolate (const Coordinate &coord, int order) const |
interpolates the value with the given order at the given coordinate More... | |
T | interpolate_at_cursor (int order) const |
interpolates the value with the given order at the cursor position More... | |
void | load_from_asc (const char *filename) |
const Coordinate & | min_corner () const |
returns the min-corner of the raster More... | |
number | min_corner (int dim) const |
returns the coordinate of the min-corner of the raster for the given dimension More... | |
T | no_data_value () const |
returns the value that shall be considered 'no-data-value' More... | |
T & | node_value (const MultiIndex &mi) |
returns the value at the given multi-index (read/write) More... | |
T | node_value (const MultiIndex &mi) const |
returns the value at the given multi-index (read only) More... | |
const MultiIndex & | num_nodes () const |
returns the number of nodes for each dimension in a multi-index. More... | |
size_t | num_nodes (int dim) const |
returns the number of nodes in the specified dimension More... | |
size_t | num_nodes_total () const |
returns the total number of nodes in the raster More... | |
Raster & | operator= (const Raster &raster) |
Raster () | |
Creates an empty raster that has to be initialized before use. More... | |
Raster (const MultiIndex &numNodes) | |
Creates a new raster with the specified number of nodes. More... | |
Raster (const MultiIndex &numNodes, const Coordinate &extension, const Coordinate &minCorner=Coordinate(0)) | |
Creates a new raster with the specified number of nodes and the specified extension. More... | |
Raster (const Raster &raster) | |
Creates the new raster by copying the contents of the given raster. More... | |
template<class TKernel > | |
TKernel::result_t | run_on_all () |
Creates and runs the specified kernel on all nodes and returns its result. More... | |
template<class TKernel > | |
void | run_on_all (TKernel &kernel) |
Runs the specified kernel on all nodes. More... | |
template<class TKernel > | |
TKernel::result_t | run_on_nbrs (const MultiIndex ¢er) |
Creates and runs the specified kernel on all direct neighbors of a node and returns its result. More... | |
template<class TKernel > | |
void | run_on_nbrs (const MultiIndex ¢er, TKernel &kernel) |
Runs the specified kernel on all direct neighbors of a node. More... | |
void | save_to_asc (const char *filename) const |
T | selected_node_value () const |
returns the value of the selected node More... | |
void | set_no_data_value (T val) |
sets the value that shall be considered as 'no-data-value' More... | |
void | set_num_nodes (const MultiIndex &mi) |
void | set_num_nodes (int dim, size_t num) |
sets the number of nodes that shall be used by the raster. More... | |
void | set_selected_node_value (T val) |
sets the value of the selected node More... | |
~Raster () | |
void | set_min_corner (int dim, number coord) |
sets the min corner of the raster. Used for interpolation at cursor. More... | |
void | set_min_corner (const Coordinate &coord) |
sets the min corner of the raster. Used for interpolation at cursor. More... | |
void | set_extension (int dim, number ext) |
sets the extension of the raster. Used for interpolation at cursor. More... | |
void | set_extension (const Coordinate &coord) |
sets the extension of the raster. Used for interpolation at cursor. More... | |
void | select_node (int dim, size_t index) |
Select a node. 'selected_node_value' provides read/write access to the selected node. More... | |
void | select_node (const MultiIndex &mi) |
Select a node. 'selected_node_value' provides read/write access to the selected node. More... | |
void | set_cursor (int dim, number coord) |
Set the coordinate of the cursor. The cursor can be used to interpolate values. More... | |
void | set_cursor (const Coordinate &coord) |
Set the coordinate of the cursor. The cursor can be used to interpolate values. More... | |
Private Member Functions | |
size_t | data_index (const MultiIndex &mi, int curDim=TDIM - 1, size_t curVal=0) const |
T | interpolate_linear (const MultiIndex &minNodeInd, Coordinate &localCoord, int curDim=TDIM) const |
template<class TKernel > | |
void | run_on_all (const MultiIndex &start, TKernel &kernel, int curDim) |
template<class TKernel > | |
void | run_on_nbrs (const MultiIndex ¢er, TKernel &kernel, int curDim) |
void | update_cell_extension () |
void | update_cell_extension (int dim) |
void | update_num_nodes_total () |
Private Attributes | |
Coordinate | m_cellExtension |
Coordinate | m_cursor |
T * | m_data |
Coordinate | m_extension |
Coordinate | m_minCorner |
T | m_noDataValue |
MultiIndex | m_numNodes |
size_t | m_numNodesTotal |
MultiIndex | m_selNode |
Generic raster for arbitrary dimensions.
The raster provides access to raster-data in arbitrary dimensions. Common use cases are e.g. 1d/2d/3d image data or density distributions.
A raster consists of regularily distributed nodes, which form a structured d-dimensional grid. The space in between those nodes can be interpreted as cells. Through 'min_corner' and 'extension' the spacial properties of the raster are defined. A point in d-dimensional space can thus be mapped to a cell in the raster. This is, e.g., used for interpolation algorithms.
Values are stored in nodes. Direct access to the data in such nodes is provided as well as interpolation algorithms that provide values at arbitrary points in d-dimensional space.
To ease usage, e.g., in scripting languages, the raster provides a 'selected_node' and a 'cursor'. The first is an index to a currently selected node, the latter is a point in space at which interpolation can be performed. The usage of both is of course optional. The value of the selected_node can be accessed through 'selected_node_value'. The value at the cursor can be interpolated through 'interpolate_at_cursor'. Please note, that the more flexible methods 'node_value(MultiIndex)' and 'interpolate(Coordinate)' are recommended for most use cases.
T | The template parameter 'T' specifies the underlying data-type. It has to support the following operations, if 'interpolate' shall be used:
|
ug::Raster< T, TDIM >::Raster |
Creates an empty raster that has to be initialized before use.
Use the methods 'load_from_asc' or instead 'set_num_nodes', 'create', 'set_extension', and 'set_min_corner' to initialize the raster.
References ug::Raster< T, TDIM >::update_cell_extension(), and ug::Raster< T, TDIM >::update_num_nodes_total().
ug::Raster< T, TDIM >::Raster | ( | const Raster< T, TDIM > & | raster | ) |
Creates the new raster by copying the contents of the given raster.
References ug::Raster< T, TDIM >::create(), ug::Raster< T, TDIM >::m_data, ug::Raster< T, TDIM >::num_nodes_total(), ug::Raster< T, TDIM >::update_cell_extension(), and ug::Raster< T, TDIM >::update_num_nodes_total().
ug::Raster< T, TDIM >::Raster | ( | const MultiIndex & | numNodes | ) |
Creates a new raster with the specified number of nodes.
Internally calls 'set_num_nodes' and 'create'. The ruster can thus be used right after construction. The extension is chosen to be numNodes[d]-1 in each dimension, i.e., the distance between neighbored nodes is '1' by default. The min-corner is at the origin. You may change those through 'set_extension' and 'set_min_corner'.
References ug::Raster< T, TDIM >::create(), ug::Raster< T, TDIM >::m_extension, ug::Raster< T, TDIM >::update_cell_extension(), and ug::Raster< T, TDIM >::update_num_nodes_total().
ug::Raster< T, TDIM >::Raster | ( | const MultiIndex & | numNodes, |
const Coordinate & | extension, | ||
const Coordinate & | minCorner = Coordinate(0) |
||
) |
Creates a new raster with the specified number of nodes and the specified extension.
Internally calls 'set_num_nodes', 'create', 'set_extension', and 'set_min_corner. 'minCorner' is optional and defaults to the origin.
References ug::Raster< T, TDIM >::create(), ug::Raster< T, TDIM >::update_cell_extension(), and ug::Raster< T, TDIM >::update_num_nodes_total().
ug::Raster< T, TDIM >::~Raster |
void ug::Raster< T, TDIM >::blur | ( | T | alpha, |
size_t | iterations | ||
) |
blurs (smoothens) the values by repeatedly averaging between direct neighbors
References alpha.
void ug::Raster< T, TDIM >::create |
creates the raster. Call this method after 'set_num_nodes' has been called for each dimension.
Referenced by ug::Raster< T, TDIM >::Raster().
|
private |
int ug::Raster< T, TDIM >::dim |
const Raster< T, TDIM >::Coordinate & ug::Raster< T, TDIM >::extension |
returns the extension of the raster
number ug::Raster< T, TDIM >::extension | ( | int | dim | ) | const |
returns the extension of the raster for the given dimension
References dim.
T ug::Raster< T, TDIM >::interpolate | ( | const Coordinate & | coord, |
int | order | ||
) | const |
interpolates the value with the given order at the given coordinate
References UG_THROW.
T ug::Raster< T, TDIM >::interpolate_at_cursor | ( | int | order | ) | const |
interpolates the value with the given order at the cursor position
|
private |
void ug::Raster< T, TDIM >::load_from_asc | ( | const char * | filename | ) |
References create(), ug::FindFileInStandardPaths(), LFA_CHECK_DIM, LFA_ERR_WHERE, name, ug::ToLower(), UG_COND_THROW, and UG_THROW.
const Raster< T, TDIM >::Coordinate & ug::Raster< T, TDIM >::min_corner |
returns the min-corner of the raster
number ug::Raster< T, TDIM >::min_corner | ( | int | dim | ) | const |
returns the coordinate of the min-corner of the raster for the given dimension
References dim.
T ug::Raster< T, TDIM >::no_data_value |
returns the value that shall be considered 'no-data-value'
Referenced by ug::raster_kernels::Count< T, TDIM >::operator()(), ug::raster_kernels::Sum< T, TDIM >::operator()(), and ug::raster_kernels::Blur< T, TDIM >::operator()().
T & ug::Raster< T, TDIM >::node_value | ( | const MultiIndex & | mi | ) |
returns the value at the given multi-index (read/write)
Referenced by ug::raster_kernels::Count< T, TDIM >::operator()(), ug::raster_kernels::Sum< T, TDIM >::operator()(), and ug::raster_kernels::Blur< T, TDIM >::operator()().
T ug::Raster< T, TDIM >::node_value | ( | const MultiIndex & | mi | ) | const |
returns the value at the given multi-index (read only)
const Raster< T, TDIM >::MultiIndex & ug::Raster< T, TDIM >::num_nodes |
returns the number of nodes for each dimension in a multi-index.
size_t ug::Raster< T, TDIM >::num_nodes | ( | int | dim | ) | const |
returns the number of nodes in the specified dimension
References dim.
size_t ug::Raster< T, TDIM >::num_nodes_total |
returns the total number of nodes in the raster
Referenced by ug::Raster< T, TDIM >::Raster().
Raster< T, TDIM > & ug::Raster< T, TDIM >::operator= | ( | const Raster< T, TDIM > & | raster | ) |
TKernel::result_t ug::Raster< T, TDIM >::run_on_all |
Creates and runs the specified kernel on all nodes and returns its result.
The class TKernel has to feature a default constructor, a typedef 'result_t', and a method 'result_t result() const'.
Like all kernels, it furthermore has to specify a method
|
private |
void ug::Raster< T, TDIM >::run_on_all | ( | TKernel & | kernel | ) |
Runs the specified kernel on all nodes.
TKernel can either be a function or a class with an 'operator()'. The signature should be as follows:
or
TKernel::result_t ug::Raster< T, TDIM >::run_on_nbrs | ( | const MultiIndex & | center | ) |
Creates and runs the specified kernel on all direct neighbors of a node and returns its result.
The class TKernel has to feature a default constructor, a typedef 'result_t', and a method 'result_t result() const'.
Like all kernels, it furthermore has to specify a method
void ug::Raster< T, TDIM >::run_on_nbrs | ( | const MultiIndex & | center, |
TKernel & | kernel | ||
) |
Runs the specified kernel on all direct neighbors of a node.
TKernel can either be a function or a class with an 'operator()'. The signature should be as follows:
or
|
private |
void ug::Raster< T, TDIM >::save_to_asc | ( | const char * | filename | ) | const |
References STA_ERR_WHERE, and UG_COND_THROW.
void ug::Raster< T, TDIM >::select_node | ( | const MultiIndex & | mi | ) |
Select a node. 'selected_node_value' provides read/write access to the selected node.
void ug::Raster< T, TDIM >::select_node | ( | int | dim, |
size_t | index | ||
) |
Select a node. 'selected_node_value' provides read/write access to the selected node.
References dim.
T ug::Raster< T, TDIM >::selected_node_value |
returns the value of the selected node
void ug::Raster< T, TDIM >::set_cursor | ( | const Coordinate & | coord | ) |
Set the coordinate of the cursor. The cursor can be used to interpolate values.
void ug::Raster< T, TDIM >::set_cursor | ( | int | dim, |
number | coord | ||
) |
Set the coordinate of the cursor. The cursor can be used to interpolate values.
References dim.
void ug::Raster< T, TDIM >::set_extension | ( | const Coordinate & | coord | ) |
sets the extension of the raster. Used for interpolation at cursor.
void ug::Raster< T, TDIM >::set_extension | ( | int | dim, |
number | ext | ||
) |
sets the extension of the raster. Used for interpolation at cursor.
References dim.
void ug::Raster< T, TDIM >::set_min_corner | ( | const Coordinate & | coord | ) |
sets the min corner of the raster. Used for interpolation at cursor.
void ug::Raster< T, TDIM >::set_min_corner | ( | int | dim, |
number | coord | ||
) |
sets the min corner of the raster. Used for interpolation at cursor.
References dim.
void ug::Raster< T, TDIM >::set_no_data_value | ( | T | val | ) |
sets the value that shall be considered as 'no-data-value'
void ug::Raster< T, TDIM >::set_num_nodes | ( | const MultiIndex & | mi | ) |
void ug::Raster< T, TDIM >::set_num_nodes | ( | int | dim, |
size_t | num | ||
) |
sets the number of nodes that shall be used by the raster.
At least one node is required per dimension. After having set all node-numbers, one should call 'create' to actually create the grid.
References dim.
void ug::Raster< T, TDIM >::set_selected_node_value | ( | T | val | ) |
sets the value of the selected node
|
private |
Referenced by ug::Raster< T, TDIM >::Raster().
|
private |
References dim.
|
private |
Referenced by ug::Raster< T, TDIM >::Raster().
|
private |
|
private |
Referenced by ug::Raster< T, TDIM >::operator=().
|
private |
Referenced by ug::Raster< T, TDIM >::operator=(), and ug::Raster< T, TDIM >::Raster().
|
private |
Referenced by ug::Raster< T, TDIM >::operator=(), and ug::Raster< T, TDIM >::Raster().
|
private |
Referenced by ug::Raster< T, TDIM >::operator=().
|
private |
Referenced by ug::Raster< T, TDIM >::operator=().
|
private |
Referenced by ug::Raster< T, TDIM >::operator=().
|
private |
|
private |
Referenced by ug::Raster< T, TDIM >::operator=().