Program Listing for File base_grid_overlay.hpp
↰ Return to documentation for file (rcppsw/ds/base_grid_overlay.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include "rcppsw/er/client.hpp"
#include "rcppsw/math/vector2.hpp"
#include "rcppsw/math/vector3.hpp"
#include "rcppsw/types/discretize_ratio.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace rcppsw::ds {
/*******************************************************************************
* Class Definitions
******************************************************************************/
template <typename TOriginType>
class base_grid_overlay : public er::client<base_grid_overlay<TOriginType>> {
public:
static_assert(std::is_same<TOriginType, math::vector2d>::value ||
std::is_same<TOriginType, math::vector3d>::value,
"Bad origin type: not 2D or 3D vector");
using origin_rtype =
typename std::conditional<std::is_same<TOriginType, math::vector2d>::value,
math::vector2d,
math::vector3d>::type;
using origin_dtype =
typename std::conditional<std::is_same<TOriginType, math::vector2z>::value,
math::vector2z,
math::vector3z>::type;
base_grid_overlay(const origin_rtype& origin,
const types::discretize_ratio& grid_resolution,
const types::discretize_ratio& field_resolution)
: ER_CLIENT_INIT(),
mc_resolution(grid_resolution),
mc_originr(origin),
mc_origind(math::dvec2zvec(origin, field_resolution.v())) {}
virtual ~base_grid_overlay(void) = default;
const types::discretize_ratio& resolution(void) const { return mc_resolution; }
const origin_rtype& originr(void) const { return mc_originr; }
const origin_dtype& origind(void) const { return mc_origind; }
private:
/* clang-format off */
const types::discretize_ratio mc_resolution;
const origin_rtype mc_originr;
const origin_dtype mc_origind;
/* clang-format on */
};
} /* namespace rcppsw::ds */