Template Class base_grid2D

Inheritance Relationships

Derived Types

Class Documentation

template<typename T>
class base_grid2D

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

Subclassed by rcppsw::ds::grid2D< ral::mt_size_t >, rcppsw::ds::grid2D< T >, rcppsw::ds::grid2D_overlay< T >

Public Types

using const_grid_view = typename grid_type::template const_array_view<2>::type
using coord_type = math::vector2z
using grid_type = typename boost::multi_array<T, 2>
using grid_view = typename grid_type::template array_view<2>::type
using index_range = typename grid_type::index_range
using value_type = T

Public Functions

base_grid2D(void) = default
virtual ~base_grid2D(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) const
virtual T &access(size_t i, size_t j) = 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 (grid2D, grid2D_overlay) can reduce code duplication.

inline bool contains(const coord_type &pt)
inline bool contains(size_t i, size_t j)
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 subcircle gridview from a grid. 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 – Coordinates of center of subcircle.

  • radius – Radius of subcircle.

Returns:

The subcircle (closed interval).

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.

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?)

Protected Functions

virtual const grid_type &grid(void) const = 0
virtual grid_type &grid(void) = 0