25#include "ElementsKernel/Exception.h"
32template <
typename GridCellManager,
typename... AxesTypes>
33template <
typename CellType,
typename Po
interType,
typename ReferenceType>
38template <
typename GridCellManager,
typename... AxesTypes>
39template <
typename CellType,
typename Po
interType,
typename ReferenceType>
47template <
typename GridCellManager,
typename... AxesTypes>
48template <
typename CellType,
typename Po
interType,
typename ReferenceType>
53 size_t axis = fixed_index_pair.first;
54 size_t fixed_index = fixed_index_pair.second;
67template <
typename GridCellManager,
typename... AxesTypes>
68template <
typename CellType,
typename Po
interType,
typename ReferenceType>
74template <
typename GridCellManager,
typename... AxesTypes>
75template <
typename CellType,
typename Po
interType,
typename ReferenceType>
77 typename
std::add_const<ReferenceType>::type {
81template <
typename GridCellManager,
typename... AxesTypes>
82template <
typename CellType,
typename Po
interType,
typename ReferenceType>
88template <
typename GridCellManager,
typename... AxesTypes>
89template <
typename CellType,
typename Po
interType,
typename ReferenceType>
91 typename
std::add_const<PointerType>::type {
95template <
typename GridCellManager,
typename... AxesTypes>
96template <
typename CellType,
typename Po
interType,
typename ReferenceType>
98 const iter& other)
const {
102template <
typename GridCellManager,
typename... AxesTypes>
103template <
typename CellType,
typename Po
interType,
typename ReferenceType>
105 const iter& other)
const {
109template <
typename GridCellManager,
typename... AxesTypes>
110template <
typename CellType,
typename Po
interType,
typename ReferenceType>
114 return m_owner.m_index_helper.axisIndex(I, index);
117template <
typename GridCellManager,
typename... AxesTypes>
118template <
typename CellType,
typename Po
interType,
typename ReferenceType>
123 return std::get<I>(
m_owner.m_axes)[index];
126template <
typename GridCellManager,
typename... AxesTypes>
127template <
typename CellType,
typename Po
interType,
typename ReferenceType>
130 size_t index) ->
iter& {
132 if (fixed_index !=
m_fixed_indices.end() && fixed_index->second != index) {
135 if (index >=
m_owner.getOriginalAxis<I>().size()) {
137 <<
" size (" <<
m_owner.getOriginalAxis<I>().
size() <<
")";
144template <
typename GridCellManager,
typename... AxesTypes>
145template <
typename CellType,
typename Po
interType,
typename ReferenceType>
149 auto& axis =
m_owner.getOriginalAxis<I>();
150 auto found_axis =
std::find(axis.begin(), axis.end(), value);
151 if (found_axis == axis.end()) {
153 <<
" (given value not found)";
155 size_t index = found_axis - axis.begin();
159template <
typename GridCellManager,
typename... AxesTypes>
160template <
typename CellType,
typename Po
interType,
typename ReferenceType>
162 size_t axis,
size_t fixed_index) {
164 size_t current_index =
m_owner.m_index_helper.axisIndex(axis, current_size);
165 if (fixed_index != current_index) {
166 size_t axis_factor =
m_owner.m_index_helper.m_axes_index_factors[axis];
167 size_t distance = (fixed_index > current_index)
168 ? fixed_index - current_index
169 :
m_owner.m_index_helper.m_axes_sizes[axis] + fixed_index - current_index;
174template <
typename IterFrom,
typename IterTo,
int I>
180template <
typename IterFrom,
typename IterTo>
183template <
typename GridCellManager,
typename... AxesTypes>
184template <
typename CellType,
typename Po
interType,
typename ReferenceType>
185template <
typename OtherIter>
187 const OtherIter& other) ->
iter& {
const axis_type< I > & axisValue() const
void forwardToIndex(size_t axis, size_t fixed_index)
bool operator!=(const iter &other) const
iter & fixAllAxes(const OtherIter &other)
iter(const GridContainer< GridCellManager, AxesTypes... > &owner, const cell_manager_iter_type &data_iter)
Constructs a new iterator for the given grid.
cell_manager_iter_type m_data_iter
const GridContainer< GridCellManager, AxesTypes... > & m_owner
std::map< size_t, size_t > m_fixed_indices
ReferenceType operator*()
Returns a reference to the cell value.
PointerType operator->()
Returns a pointer to the cell value.
bool operator==(const iter &other) const
iter & operator++()
Moves the iterator to the next grid cell.
GridContainer< GridCellManager, AxesTypes... > fixAxisByValue(const axis_type< I > &value)
Returns a slice of the grid based on an axis value.
GridContainer & operator=(GridContainer< GridCellManager, AxesTypes... > &&)=default
GridCellManagerTraits< GridCellManager >::iterator cell_manager_iter_type
size_t size() const
Returns the total number of cells of the grid.
typename std::tuple_element< I, std::tuple< AxesTypes... > >::type axis_type
GridContainer(GridAxis< AxesTypes >... axes)
Constructs a GridContainer with the given axes.
GridContainer< GridCellManager, AxesTypes... > fixAxisByIndex(size_t index)
Returns a slice of the grid based on an axis index.
static void fixSameAxes(IterFrom &from, IterTo &to, const TemplateLoopCounter< I > &)
static iterator end(GridCellManager &cell_manager)
static iterator begin(GridCellManager &cell_manager)