30 namespace GridContainer {
32 template <
typename GridCellManager,
typename... AxesTypes>
33 template <
typename CellType>
36 : m_owner(owner), m_data_iter{data_iter} {}
38 template <
typename GridCellManager,
typename... AxesTypes>
39 template <
typename CellType>
46 template <
typename GridCellManager,
typename... AxesTypes>
47 template <
typename CellType>
52 size_t axis = fixed_index_pair.first;
53 size_t fixed_index = fixed_index_pair.second;
54 forwardToIndex(axis, fixed_index);
59 if (m_data_iter > end_iter) {
60 m_data_iter = end_iter;
66 template <
typename GridCellManager,
typename... AxesTypes>
67 template <
typename CellType>
72 template <
typename GridCellManager,
typename... AxesTypes>
73 template <
typename CellType>
78 template <
typename GridCellManager,
typename... AxesTypes>
79 template <
typename CellType>
81 return &(*m_data_iter);
84 template <
typename GridCellManager,
typename... AxesTypes>
85 template <
typename CellType>
87 return &(*m_data_iter);
90 template <
typename GridCellManager,
typename... AxesTypes>
91 template <
typename CellType>
96 template <
typename GridCellManager,
typename... AxesTypes>
97 template <
typename CellType>
102 template <
typename GridCellManager,
typename... AxesTypes>
103 template <
typename CellType>
107 return m_owner.m_index_helper.axisIndex(I, index);
110 template <
typename GridCellManager,
typename... AxesTypes>
111 template <
typename CellType>
114 size_t index = axisIndex<I>();
115 return std::get<I>(m_owner.m_axes)[index];
118 template <
typename GridCellManager,
typename... AxesTypes>
119 template <
typename CellType>
124 throw Elements::Exception() <<
"Axis " << m_owner.getOriginalAxis<I>().name() <<
" is already fixed";
126 if (index >= m_owner.getOriginalAxis<I>().size()) {
127 throw Elements::Exception() <<
"Index (" << index <<
") out of axis " << m_owner.getOriginalAxis<I>().name() <<
" size ("
128 << m_owner.getOriginalAxis<I>().
size() <<
")";
131 forwardToIndex(I, index);
135 template <
typename GridCellManager,
typename... AxesTypes>
136 template <
typename CellType>
139 auto& axis = m_owner.getOriginalAxis<I>();
140 auto found_axis =
std::find(axis.begin(), axis.end(), value);
141 if (found_axis == axis.end()) {
142 throw Elements::Exception() <<
"Failed to fix axis " << m_owner.getOriginalAxis<I>().name() <<
" (given value not found)";
144 size_t index = found_axis - axis.begin();
145 return fixAxisByIndex<I>(index);
148 template <
typename GridCellManager,
typename... AxesTypes>
149 template <
typename CellType>
152 size_t current_index = m_owner.m_index_helper.axisIndex(axis, current_size);
153 if (fixed_index != current_index) {
154 size_t axis_factor = m_owner.m_index_helper.m_axes_index_factors[axis];
155 size_t distance = (fixed_index > current_index) ? fixed_index - current_index
156 : m_owner.m_index_helper.m_axes_sizes[axis] + fixed_index - current_index;
157 m_data_iter += distance * axis_factor;
161 template <
typename IterFrom,
typename IterTo,
int I>
163 to.template fixAxisByValue<I>(from.template axisValue<I>());
167 template <
typename IterFrom,
typename IterTo>
170 template <
typename GridCellManager,
typename... AxesTypes>
171 template <
typename CellType>
172 template <
typename OtherIter>
cell_manager_iter_type m_data_iter
size_t size() const
Returns the total number of cells of the grid.
std::map< size_t, size_t > m_fixed_indices
A map containing the axes which have been fixed, if this grid is a slice.
Class to iterate through the GridContainer cells.
GridContainer & operator=(GridContainer< GridCellManager, AxesTypes...> &&)=default
static iterator end(GridCellManager &cell_manager)
bool operator!=(const Euclid::SourceCatalog::Source::id_type &a, const Euclid::SourceCatalog::Source::id_type &b)
boost::variant specifies an equality operator (==), but, in older boost versions, not an inequality o...
Representation of a multi-dimensional grid which contains axis information.
GridCellManagerTraits< GridCellManager >::iterator cell_manager_iter_type
static iterator begin(GridCellManager &cell_manager)
GridContainer< GridCellManager, AxesTypes...> fixAxisByIndex(size_t index)
Returns a slice of the grid based on an axis index.
GridContainer< GridCellManager, AxesTypes...> fixAxisByValue(const axis_type< I > &value)
Returns a slice of the grid based on an axis value.
typename std::tuple_element< I, std::tuple< AxesTypes...>>::type axis_type
static void fixSameAxes(IterFrom &from, IterTo &to, const TemplateLoopCounter< I > &)