geomc 1.0
A c++ linear algebra template library
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Raster< I, O, M, N > Class Template Reference

An M-dimensional grid of interpolated data which can be continuously sampled. More...

#include <geomc/function/Raster.h>

Public Types

typedef PointType< I, M >::point_t coord_t
 Type of sample location. I if M is 1, otherwise Vec<I,M>.
 
typedef PointType< index_t, M >::point_t grid_t
 Type for indexing data, i.e. a grid coordinate. index_t if M is 1, Vec<index_t,M> otherwise.
 
typedef PointType< O, N >::point_t sample_t
 Type of resultant data. O if N is 1, otherwise Vec<O,N>.
 

Public Member Functions

 Raster (const grid_t &dims)
 
 Raster (const grid_t &dims, const Rect< I, M > &domain)
 
 Raster (const grid_t &dims, const O *src_data)
 
 Raster (const grid_t &dims, const O *src_data, const Rect< I, M > &domain)
 
void setAbyss (sample_t val)
 
void set (const grid_t &idx, const sample_t &val)
 
template<EdgeBehavior Edge>
void copy (sample_t *dest, const Rect< index_t, M > &region) const
 
void copy (sample_t *dest, const Rect< index_t, M > &region, EdgeBehavior edge) const
 
template<EdgeBehavior Edge, Interpolation Interp>
sample_t sample (const coord_t &pt) const
 
sample_t sample (const coord_t &pt, EdgeBehavior edge=EDGE_CLAMP, Interpolation interp=INTERP_LINEAR) const
 
template<EdgeBehavior Edge>
sample_t sample_discrete (const grid_t &pt) const
 
sample_t sample_discrete (const grid_t &pt, EdgeBehavior edge) const
 
bool contains_gridpt (const grid_t &idx) const
 
grid_t dataExtents () const
 
Rect< I, M > domain () const
 
index_t inputDimension () const
 
index_t outputDimension () const
 
index_t samplecount () const
 

Protected Member Functions

coord_t toGridSpace (const coord_t &pt) const
 
template<EdgeBehavior Edge>
index_t index (const grid_t &c) const
 

Protected Attributes

grid_t m_extent
 
index_t m_size
 
boost::shared_array< O > m_data
 
sample_t m_abyss
 
Rect< I, M > m_domain
 

Detailed Description

template<typename I, typename O, index_t M, index_t N>
class geom::Raster< I, O, M, N >

An M-dimensional grid of interpolated data which can be continuously sampled.

Template Parameters
IDomain data type.
ORange data type.
MDomain dimension.
NRange dimension.

In other words, a function of IM → ON.

Coordinates

Rasters have two coordinate systems: Indexing space and sampling space. In indexing space, the stored sample values may be accessed and changed using integer grid coordinates, analogous to a multi-dimensional array.

Rasters may also be sampled continuously, and intermediate values between sample points will be generated via interpolation. The domain of sampling space may be specified by the user, and sampling coordinates will be renormalized to this region. If no domain is specified, sampling space is equal to indexing space (with the addition that intermediate values may be sampled). The user-specified domain has no effect on indexing space.

Sampling functions

Some functions are overloaded to have some arguments as template parameters. This allows some low-level sampling code to be inlined which can improve speed by as much as 15%. The traditional function-argument versions are available for when the parameters must be chosen at runtime.

Constructor & Destructor Documentation

◆ Raster() [1/4]

Raster ( const grid_t dims)
inline

Construct a raster with dims elements along each axis. The sampling domain will be constructed such that the lower extreme is at the origin and sample points are placed at integer coordinates.

Parameters
dimsNumber of samples along each axis.

◆ Raster() [2/4]

Raster ( const grid_t dims,
const Rect< I, M > &  domain 
)
inline

Construct a raster with dims elements along each axis.

Parameters
dimsNumber of samples along each axis.
domainDesired boundary of the data region. The lower and upper coordinates correspond to the exact coordinates of the most extreme data points along each axis.

◆ Raster() [3/4]

Raster ( const grid_t dims,
const O *  src_data 
)
inline

Construct a Raster with dims elements along each axis. Fill the raster with the data in src_data. src_data must have enough elements to fill the raster completely; in other words, the length of src_data must be the product of the elements of dims. The domain will be constructed to align with the sample grid coordinates; in other words, the lowest extreme is at the origin and sample points are placed at integer coordinates.

Parameters
dimsNumber of samples along each axis.
src_dataData to copy into this raster.

◆ Raster() [4/4]

Raster ( const grid_t dims,
const O *  src_data,
const Rect< I, M > &  domain 
)
inline

Construct a Raster with dims elements along each axis. Fill the raster with the data in src_data. src_data must have enough elements to fill the raster completely; in other words, the length of src_data must be the product of the elements of dims.

Parameters
dimsNumber of samples along each axis.
src_dataData to copy into this raster.
domainDesired boundary of the data region. The lower and upper coordinates correspond to the exact coordinates of the most extreme data points along each axis.

Member Function Documentation

◆ contains_gridpt()

bool contains_gridpt ( const grid_t idx) const
inline
Returns
true if the grid location idx is within the bounds of this raster and has data, false otherwise.

◆ copy() [1/2]

void copy ( sample_t dest,
const Rect< index_t, M > &  region 
) const
inline

Copy the data in region into the array dest, in row-major (first dimension consecutive) order. Templated over edge sampling behavior.

Template Parameters
EdgeEdge sampling behavior.
Parameters
destDestination array.
regionGrid region of this Raster to copy from.

◆ copy() [2/2]

void copy ( sample_t dest,
const Rect< index_t, M > &  region,
EdgeBehavior  edge 
) const
inline

Copy the data in region into the array dest, in row-major (first dimension consecutive) order. Dynamic edge sampling behavior.

Parameters
destDestination array.
regionGrid region of this raster to copy from.
edgeEdge sampling behavior.

◆ dataExtents()

grid_t dataExtents ( ) const
inline

Number of samples along each axis.

◆ domain()

Rect< I, M > domain ( ) const
inline

Boundary of the data region; upper and lower coordinates correspond exactly to the coordinates of the most extreme sample positions along each axis.

◆ inputDimension()

index_t inputDimension ( ) const
inline

Number of input dimensions.

◆ outputDimension()

index_t outputDimension ( ) const
inline

Number of output dimensions.

◆ sample() [1/2]

sample_t sample ( const coord_t pt) const
inline

Sample this Raster at pt.

Template Parameters
EdgeEdge sampling behavior.
InterpSample interpolation strategy.
Parameters
ptPoint to sample.
Returns
Sampled data.

◆ sample() [2/2]

sample_t sample ( const coord_t pt,
EdgeBehavior  edge = EDGE_CLAMP,
Interpolation  interp = INTERP_LINEAR 
) const
inline

Sample this Raster at pt.

Parameters
ptPoint to sample.
edgeEdge sampling behavior.
interpSample interpolation strategy.
Returns
Sampled data.

◆ sample_discrete() [1/2]

sample_t sample_discrete ( const grid_t pt) const
inline

Retrieve the data at discrete grid location pt.

Template Parameters
Edgesampling behavior.
Parameters
ptGrid location to sample.
Returns
Data at pt.

◆ sample_discrete() [2/2]

sample_t sample_discrete ( const grid_t pt,
EdgeBehavior  edge 
) const
inline

Retrieve the data at discrete grid location pt.

Parameters
ptGrid location to sample.
edgeEdge sampling behavior.
Returns
Data at pt.

◆ samplecount()

index_t samplecount ( ) const
inline

Number of grid sample points in this raster.

◆ set()

void set ( const grid_t idx,
const sample_t val 
)
inline

Set the value of the raster at the grid coordinate idx.

Parameters
idxCoordinate of datapoint to set.
valNew value of datapoint.

◆ setAbyss()

void setAbyss ( sample_t  val)
inline

Set the sample value to be used for "out-of-bounds" samples when EDGE_CONSTANT behavior is used.


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