Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | List of all members
CDPL::Grid::RegularGrid< T, CVT > Class Template Reference

Implementation of the Grid::SpatialGrid interface for regular spatial grids. More...

#include <RegularGrid.hpp>

+ Inheritance diagram for CDPL::Grid::RegularGrid< T, CVT >:

Public Types

typedef std::shared_ptr< RegularGridSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated RegularGrid instances. More...
 
typedef SpatialGrid< T, CVT >::ValueType ValueType
 
typedef SpatialGrid< T, CVT >::CoordinatesValueType CoordinatesValueType
 
typedef SpatialGrid< T, CVT >::CoordinatesType CoordinatesType
 
typedef Math::RegularSpatialGrid< T, CVT >::GridDataType GridDataType
 
- Public Types inherited from CDPL::Grid::SpatialGrid< T, T >
typedef std::shared_ptr< SpatialGridSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated SpatialGrid instances. More...
 
typedef T ValueType
 The grid element value type. More...
 
typedef T CoordinatesValueType
 The coordinate value type. More...
 
typedef Math::CVector< T, 3 > CoordinatesType
 The fixed-size 3D coordinate vector type. More...
 
- Public Types inherited from CDPL::Grid::AttributedGrid
typedef std::shared_ptr< AttributedGridSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated AttributedGrid instances. More...
 
- Public Types inherited from CDPL::Base::PropertyContainer
typedef PropertyMap::value_type PropertyEntry
 A Base::LookupKey / Base::Any pair that stores the property value for a given property key. More...
 
typedef PropertyMap::const_iterator ConstPropertyIterator
 A constant iterator used to iterate over the property entries. More...
 
- Public Types inherited from CDPL::Math::RegularSpatialGrid< T, T >
typedef T ValueType
 The grid cell value type. More...
 
typedef T CoordinatesValueType
 The coordinate (real) value type used in the world frame. More...
 
typedef Grid< T > GridDataType
 The underlying grid data container type. More...
 
typedef CMatrix< T, 4, 4 > CoordinatesTransformType
 The coordinate transformation type mapping cell indices to world coordinates. More...
 
typedef CoordinatesTransformType::MatrixTemporaryType InvCoordinatesTransformType
 The inverse coordinate transformation type. More...
 
typedef std::conditional< std::is_const< Grid< T > >::value, typename GD::ConstReference, typename GD::Reference >::type Reference
 Mutable reference type to a grid cell (degrades to ConstReference when the data container is const). More...
 
typedef GD::ConstReference ConstReference
 Constant reference type to a grid cell. More...
 
typedef GD::SizeType SizeType
 The unsigned size type used by the grid data container. More...
 
typedef std::ptrdiff_t SSizeType
 A signed size type used for offset arithmetic. More...
 
typedef GD::DifferenceType DifferenceType
 The signed difference type used by the grid data container. More...
 
typedef SelfType ClosureType
 Closure type used when this grid appears inside another expression. More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this grid appears inside another expression. More...
 
typedef std::shared_ptr< SelfTypeSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated RegularSpatialGrid instances. More...
 
- Public Types inherited from CDPL::Math::GridExpression< E >
typedef E ExpressionType
 The derived grid expression type. More...
 
- Public Types inherited from CDPL::Math::Expression< E >
typedef E ExpressionType
 The derived expression type (made available to expression-template machinery). More...
 

Public Member Functions

 RegularGrid (const CoordinatesValueType &xs, const CoordinatesValueType &ys, const CoordinatesValueType &zs)
 Constructs an empty RegularGrid with the given grid spacing in x, y and z direction. More...
 
 RegularGrid (const GridDataType &data, const CoordinatesValueType &xs, const CoordinatesValueType &ys, const CoordinatesValueType &zs)
 Constructs a RegularGrid initialized from data, with the given grid spacing in x, y and z direction. More...
 
 RegularGrid (const CoordinatesValueType &s)
 Constructs an empty RegularGrid with isotropic grid spacing. More...
 
 RegularGrid (const GridDataType &data, const CoordinatesValueType &s)
 Constructs a RegularGrid initialized from data with isotropic grid spacing. More...
 
ValueTypeoperator() (std::size_t i)
 Returns a reference to the grid element at linear index i. More...
 
const ValueTypeoperator() (std::size_t i) const
 Returns a const reference to the grid element at linear index i. More...
 
std::size_t getNumElements () const
 Returns the total number of grid elements. More...
 
void getCoordinates (std::size_t i, CoordinatesType &coords) const
 Returns the 3D coordinates of the grid element at linear index i. More...
 
bool isEmpty () const
 Tells whether the grid is empty. More...
 
- Public Member Functions inherited from CDPL::Grid::SpatialGrid< T, T >
virtual void getCoordinates (std::size_t i, CoordinatesType &coords) const=0
 Returns the 3D coordinates of the grid element at linear index i. More...
 
- Public Member Functions inherited from CDPL::Grid::AttributedGrid
virtual ~AttributedGrid ()
 Virtual destructor. More...
 
- Public Member Functions inherited from CDPL::Base::PropertyContainer
std::size_t getNumProperties () const
 Returns the number of property entries. More...
 
template<typename T >
void setProperty (const LookupKey &key, T &&val)
 Sets the value of the property specified by key to val. More...
 
template<typename T >
const T & getProperty (const LookupKey &key) const
 Returns the value of the property specified by key as a const reference to an object of type T. More...
 
template<typename T >
const T & getPropertyOrDefault (const LookupKey &key, const T &def_val) const
 Returns the value of the property specified by key as a const reference to an object of type T, or the default value def_val if a stored value does not exist. More...
 
const AnygetProperty (const LookupKey &key, bool throw_=false) const
 Returns the value of the property specified by key. More...
 
bool isPropertySet (const LookupKey &key) const
 Tells whether or not a value has been assigned to the property specified by key. More...
 
ConstPropertyIterator getPropertiesBegin () const
 Returns a constant iterator pointing to the beginning of the property entries. More...
 
ConstPropertyIterator getPropertiesEnd () const
 Returns a constant iterator pointing to the end of the property entries. More...
 
ConstPropertyIterator begin () const
 Returns a constant iterator pointing to the beginning of the property entries. More...
 
ConstPropertyIterator end () const
 Returns a constant iterator pointing to the end of the property entries. More...
 
bool removeProperty (const LookupKey &key)
 Clears the value of the property specified by key. More...
 
void clearProperties ()
 Clears all property values. More...
 
void addProperties (const PropertyContainer &cntnr)
 Adds the property value entries in the PropertyContainer instance cntnr. More...
 
void copyProperties (const PropertyContainer &cntnr)
 Replaces the current set of properties by a copy of the entries in cntnr. More...
 
void swap (PropertyContainer &cntnr)
 Exchanges the properties of this container with the properties of the container cntnr. More...
 
const PropertyContainergetProperties () const
 Returns a const reference to itself. More...
 
- Public Member Functions inherited from CDPL::Math::RegularSpatialGrid< T, T >
 RegularSpatialGrid (const CoordinatesValueType &xs, const CoordinatesValueType &ys, const CoordinatesValueType &zs)
 Constructs an empty grid with anisotropic per-axis step sizes. More...
 
 RegularSpatialGrid (const GridDataType &data, const CoordinatesValueType &xs, const CoordinatesValueType &ys, const CoordinatesValueType &zs)
 Constructs the grid with anisotropic per-axis step sizes initialized to the supplied grid data. More...
 
 RegularSpatialGrid (const CoordinatesValueType &s)
 Constructs an empty grid with isotropic step size s on all three axes. More...
 
 RegularSpatialGrid (const GridDataType &data, const CoordinatesValueType &s)
 Constructs the grid with isotropic step size s and the supplied grid data. More...
 
 RegularSpatialGrid (const RegularSpatialGrid &usg)
 Constructs a copy of the RegularSpatialGrid instance usg. More...
 
 RegularSpatialGrid (RegularSpatialGrid &&usg)
 Move-constructs the grid by moving usg. More...
 
virtual ~RegularSpatialGrid ()
 Virtual destructor. More...
 
Reference operator() (SizeType i)
 Returns a mutable reference to the cell at the linear index i. More...
 
ConstReference operator() (SizeType i) const
 Returns a const reference to the cell at the linear index i. More...
 
Reference operator() (SizeType i, SizeType j, SizeType k)
 Returns a mutable reference to the cell at the (i, j, k) position. More...
 
ConstReference operator() (SizeType i, SizeType j, SizeType k) const
 Returns a const reference to the cell at the (i, j, k) position. More...
 
SizeType getSize () const
 Returns the total number of cells of the grid. More...
 
SizeType getSize1 () const
 Returns the size of the grid along the first dimension. More...
 
SizeType getSize2 () const
 Returns the size of the grid along the second dimension. More...
 
SizeType getSize3 () const
 Returns the size of the grid along the third dimension. More...
 
SizeType getMaxSize () const
 Returns the maximum total number of cells the grid can hold. More...
 
SizeType getMaxSize1 () const
 Returns the maximum size of the grid along the first dimension. More...
 
SizeType getMaxSize2 () const
 Returns the maximum size of the grid along the second dimension. More...
 
SizeType getMaxSize3 () const
 Returns the maximum size of the grid along the third dimension. More...
 
CoordinatesValueType getXStepSize () const
 Returns the per-cell step size along the X axis. More...
 
CoordinatesValueType getYStepSize () const
 Returns the per-cell step size along the Y axis. More...
 
CoordinatesValueType getZStepSize () const
 Returns the per-cell step size along the Z axis. More...
 
void setXStepSize (const CoordinatesValueType &xs)
 Sets the per-cell step size along the X axis to xs. More...
 
void setYStepSize (const CoordinatesValueType &ys)
 Sets the per-cell step size along the Y axis to ys. More...
 
void setZStepSize (const CoordinatesValueType &zs)
 Sets the per-cell step size along the Z axis to zs. More...
 
CoordinatesValueType getXExtent () const
 Returns the spatial extent of the grid along the X axis ( \( (\mathrm{size}_1 - 1) \cdot \mathrm{xStep} \) for non-empty grids). More...
 
CoordinatesValueType getYExtent () const
 Returns the spatial extent of the grid along the Y axis. More...
 
CoordinatesValueType getZExtent () const
 Returns the spatial extent of the grid along the Z axis. More...
 
void getCoordinates (SizeType i, V &coords) const
 Writes the world-space 3D position of the cell with linear index i into coords. More...
 
void getCoordinates (SSizeType i, SSizeType j, SSizeType k, V &coords) const
 Writes the world-space 3D position of the cell at (i, j, k) into coords. More...
 
void getLocalCoordinates (SSizeType i, SSizeType j, SSizeType k, V &coords) const
 Writes the local-space 3D position of the cell at (i, j, k) into coords. More...
 
void getLocalCoordinates (const V1 &world_coords, V2 &local_coords) const
 Transforms the world-space point world_coords into the grid's local coordinate frame and stores the result in local_coords. More...
 
bool containsPoint (const V &pos) const
 Tells whether the world-space point pos lies within the grid bounds. More...
 
bool containsLocalPoint (const V &pos) const
 Tells whether the local-space point pos lies within the grid bounds. More...
 
void getContainingCell (const V1 &pos, V2 &indices) const
 Writes the (i, j, k) cell indices of the cell containing the world-space point pos into indices. More...
 
void getLocalContainingCell (const V1 &pos, V2 &indices) const
 Writes the (i, j, k) cell indices of the cell containing the local-space point pos into indices. More...
 
bool isEmpty () const
 Tells whether the grid is empty (zero cells along any dimension). More...
 
const GridDataTypegetData () const
 Returns a const reference to the underlying grid data container. More...
 
GridDataTypegetData ()
 Returns a mutable reference to the underlying grid data container. More...
 
const CoordinatesTransformTypegetCoordinatesTransform () const
 Returns the coordinate transformation mapping cell-index coordinates to world coordinates. More...
 
void setCoordinatesTransform (const T1 &xform)
 Sets the cell-index to world-coordinate transformation to xform and caches its inverse. More...
 
RegularSpatialGridoperator= (const RegularSpatialGrid &usg)
 Copy-assigns from usg. More...
 
RegularSpatialGridoperator= (RegularSpatialGrid &&usg)
 Move-assigns from usg. More...
 
RegularSpatialGridoperator= (const GridExpression< E > &e)
 Assigns the grid expression e to the underlying grid data (the spatial parameters are left unchanged). More...
 
RegularSpatialGridoperator+= (const GridExpression< E > &e)
 Adds the grid expression e cell-wise to the underlying grid data. More...
 
RegularSpatialGridoperator-= (const GridExpression< E > &e)
 Subtracts the grid expression e cell-wise from the underlying grid data. More...
 
std::enable_if< IsScalar< T >::value, RegularSpatialGrid >::type & operator*= (const T1 &t)
 Multiplies every cell by the scalar t. More...
 
std::enable_if< IsScalar< T >::value, RegularSpatialGrid >::type & operator/= (const T1 &t)
 Divides every cell by the scalar t. More...
 
RegularSpatialGridassign (const GridExpression< E > &e)
 Assigns the grid expression e to the underlying grid data without intermediate temporary. More...
 
RegularSpatialGridplusAssign (const GridExpression< E > &e)
 Adds the grid expression e to the underlying grid data without intermediate temporary. More...
 
RegularSpatialGridminusAssign (const GridExpression< E > &e)
 Subtracts the grid expression e from the underlying grid data without intermediate temporary. More...
 
void swap (RegularSpatialGrid &usg)
 Swaps the contents of this grid with those of usg. More...
 
void clear (const ValueType &v=ValueType())
 Sets every cell of the grid to the value v. More...
 
void resize (SizeType m, SizeType n, SizeType o, bool preserve=true, const ValueType &v=ValueType())
 Resizes the grid to \( m \times n \times o \) cells. More...
 
- Public Member Functions inherited from CDPL::Math::GridExpression< E >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived grid expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived grid expression. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Grid::SpatialGrid< T, T >
SpatialGridoperator= (const SpatialGrid &grid)
 
- Protected Member Functions inherited from CDPL::Grid::AttributedGrid
AttributedGridoperator= (const AttributedGrid &grid)
 Assignment operator. More...
 
- Protected Member Functions inherited from CDPL::Base::PropertyContainer
 PropertyContainer ()
 Constructs an empty PropertyContainer instance. More...
 
 PropertyContainer (const PropertyContainer &cntnr)
 Constructs a copy of the PropertyContainer instance cntnr. More...
 
virtual ~PropertyContainer ()
 Virtual destructor. More...
 
PropertyContaineroperator= (const PropertyContainer &cntnr)
 Assignment operator. More...
 
- Protected Member Functions inherited from CDPL::Math::GridExpression< E >
 GridExpression ()
 
 ~GridExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename T, typename CVT = T>
class CDPL::Grid::RegularGrid< T, CVT >

Implementation of the Grid::SpatialGrid interface for regular spatial grids.

RegularGrid combines the property-bag/grid interface inherited from Grid::SpatialGrid with the data storage and coordinate handling of Math::RegularSpatialGrid. The grid spacing can be specified separately for each spatial dimension or jointly via a single value.

Template Parameters
TThe grid element value type.
CVTThe coordinates value type (defaults to T).

Member Typedef Documentation

◆ SharedPointer

template<typename T , typename CVT = T>
typedef std::shared_ptr<RegularGrid> CDPL::Grid::RegularGrid< T, CVT >::SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated RegularGrid instances.

◆ ValueType

template<typename T , typename CVT = T>
typedef SpatialGrid<T, CVT>::ValueType CDPL::Grid::RegularGrid< T, CVT >::ValueType

◆ CoordinatesValueType

template<typename T , typename CVT = T>
typedef SpatialGrid<T, CVT>::CoordinatesValueType CDPL::Grid::RegularGrid< T, CVT >::CoordinatesValueType

◆ CoordinatesType

template<typename T , typename CVT = T>
typedef SpatialGrid<T, CVT>::CoordinatesType CDPL::Grid::RegularGrid< T, CVT >::CoordinatesType

◆ GridDataType

template<typename T , typename CVT = T>
typedef Math::RegularSpatialGrid<T, CVT>::GridDataType CDPL::Grid::RegularGrid< T, CVT >::GridDataType

Constructor & Destructor Documentation

◆ RegularGrid() [1/4]

template<typename T , typename CVT = T>
CDPL::Grid::RegularGrid< T, CVT >::RegularGrid ( const CoordinatesValueType xs,
const CoordinatesValueType ys,
const CoordinatesValueType zs 
)
inline

Constructs an empty RegularGrid with the given grid spacing in x, y and z direction.

Parameters
xsThe grid spacing in the x direction.
ysThe grid spacing in the y direction.
zsThe grid spacing in the z direction.

◆ RegularGrid() [2/4]

template<typename T , typename CVT = T>
CDPL::Grid::RegularGrid< T, CVT >::RegularGrid ( const GridDataType data,
const CoordinatesValueType xs,
const CoordinatesValueType ys,
const CoordinatesValueType zs 
)
inline

Constructs a RegularGrid initialized from data, with the given grid spacing in x, y and z direction.

Parameters
dataThe initial grid data.
xsThe grid spacing in the x direction.
ysThe grid spacing in the y direction.
zsThe grid spacing in the z direction.

◆ RegularGrid() [3/4]

template<typename T , typename CVT = T>
CDPL::Grid::RegularGrid< T, CVT >::RegularGrid ( const CoordinatesValueType s)
inlineexplicit

Constructs an empty RegularGrid with isotropic grid spacing.

Parameters
sThe isotropic grid spacing applied to all three spatial dimensions.

◆ RegularGrid() [4/4]

template<typename T , typename CVT = T>
CDPL::Grid::RegularGrid< T, CVT >::RegularGrid ( const GridDataType data,
const CoordinatesValueType s 
)
inline

Constructs a RegularGrid initialized from data with isotropic grid spacing.

Parameters
dataThe initial grid data.
sThe isotropic grid spacing applied to all three spatial dimensions.

Member Function Documentation

◆ operator()() [1/2]

template<typename T , typename CVT = T>
ValueType& CDPL::Grid::RegularGrid< T, CVT >::operator() ( std::size_t  i)
inlinevirtual

Returns a reference to the grid element at linear index i.

Parameters
iThe linear element index.
Returns
A reference to the grid element.

Implements CDPL::Grid::SpatialGrid< T, T >.

◆ operator()() [2/2]

template<typename T , typename CVT = T>
const ValueType& CDPL::Grid::RegularGrid< T, CVT >::operator() ( std::size_t  i) const
inlinevirtual

Returns a const reference to the grid element at linear index i.

Parameters
iThe linear element index.
Returns
A const reference to the grid element.

Implements CDPL::Grid::SpatialGrid< T, T >.

◆ getNumElements()

template<typename T , typename CVT = T>
std::size_t CDPL::Grid::RegularGrid< T, CVT >::getNumElements ( ) const
inlinevirtual

Returns the total number of grid elements.

Returns
The total number of grid elements.

Implements CDPL::Grid::AttributedGrid.

◆ getCoordinates()

template<typename T , typename CVT = T>
void CDPL::Grid::RegularGrid< T, CVT >::getCoordinates ( std::size_t  i,
CoordinatesType coords 
) const
inline

Returns the 3D coordinates of the grid element at linear index i.

Parameters
iThe linear element index.
coordsThe output coordinates.

◆ isEmpty()

template<typename T , typename CVT = T>
bool CDPL::Grid::RegularGrid< T, CVT >::isEmpty ( ) const
inlinevirtual

Tells whether the grid is empty.

Returns
true if the grid is empty, and false otherwise.

Implements CDPL::Grid::AttributedGrid.


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