Template Class base_grid3D

Inheritance Relationships

Derived Types

Class Documentation

template<typename T>
class base_grid3D

Base class containing functionality common to all types of 3D grids.

Subclassed by rcppsw::ds::grid3D< ral::mt_size_t >, rcppsw::ds::grid3D< T >, rcppsw::ds::grid3D_overlay< T >

Public Types

using const_grid_view = typename grid_type::template const_array_view<3>::type
using coord_type = rmath::vector3z
using grid_type = typename boost::multi_array<T, 3>
using grid_view = typename grid_type::template array_view<3>::type
using index_range = typename grid_type::index_range
using value_type = T

Public Functions

base_grid3D(void) = default
virtual ~base_grid3D(void) = default
inline T &access(const coord_type &c)
inline const T &access(const coord_type &c) const
inline const T &access(size_t i, size_t j, size_t k) const
virtual T &access(size_t i, size_t j, size_t k) = 0

Return a reference to the element at position (i, j) in the grid.

This is provided in the base class so that the pointer/object variants of the grid (grid3D, etc.) can reduce code duplication.

inline bool contains(const coord_type &pt)
inline bool contains(size_t i, size_t j, size_t k)
inline grid_view layer(size_t z)

Get a view of a single layer within the grid.

Parameters:

z – 0-based index of layer within the grid.

Returns:

The layer.

inline const_grid_view layer(size_t z) const
inline T &operator[](const coord_type &c)
inline const T &operator[](const coord_type &c) const
inline grid_view subcircle(const coord_type &c, size_t radius)

Get a 2D subcircle gridview from a 3D grid (i.e. always has height 1 in Z). The subcircle extent is cropped to the maximum boundaries of the parent grid.

This means that rather than getting a 2 x 2 subgrid centered at 0 with the out-of-bounds elements zeroed if you request a subcircle on the boundary of the overall grid, you will get a 1 x 2 subgrid (a lopsided circle).

Parameters:
  • c – The X,Y,Z coordinates of the center of the subcircle.

  • radius – Radius of subcircle.

Returns:

The subcircle.

inline const_grid_view subcircle(const coord_type &c, size_t radius) const
inline grid_view subgrid(const coord_type &ll, const coord_type &ur)

Create a subgrid from a grid. The specified coordinates are inclusive.

Parameters:
  • ll – Lower left of the subgrid, inclusive.

  • ur – Upper right of the subgrid, inclusive.

Returns:

The subgrid (closed interval).

inline const_grid_view subgrid(const coord_type &ll, const coord_type &ur) const
virtual size_t xsize(void) const = 0

Get the size of the X dimension of the grid (i.e. what is the array index in X?)

virtual size_t ysize(void) const = 0

Get the size of the Y dimension of the grid (i.e. what is the array index in Y?)

virtual size_t zsize(void) const = 0

Get the size of the Z dimension of the grid (i.e. what is the array index in Z?)

Protected Functions

virtual const grid_type &grid(void) const = 0

Return a reference to the underlying grid, defined by derived classes.

virtual grid_type &grid(void) = 0