30 namespace GridContainer {
32 template<
typename GridCellManager,
typename... AxesTypes>
33 template<
typename CellType>
37 : m_owner(owner), m_data_iter {data_iter} { }
39 template<
typename GridCellManager,
typename... AxesTypes>
40 template<
typename CellType>
47 template<
typename GridCellManager,
typename... AxesTypes>
48 template<
typename CellType>
53 size_t axis = fixed_index_pair.first;
54 size_t fixed_index = fixed_index_pair.second;
55 forwardToIndex(axis, fixed_index);
60 if (m_data_iter > end_iter) {
61 m_data_iter = end_iter;
67 template<
typename GridCellManager,
typename... AxesTypes>
68 template<
typename CellType>
73 template<
typename GridCellManager,
typename... AxesTypes>
74 template<
typename CellType>
79 template<
typename GridCellManager,
typename... AxesTypes>
80 template<
typename CellType>
82 return &(*m_data_iter);
85 template<
typename GridCellManager,
typename... AxesTypes>
86 template<
typename CellType>
88 return &(*m_data_iter);
91 template<
typename GridCellManager,
typename... AxesTypes>
92 template<
typename CellType>
97 template<
typename GridCellManager,
typename... AxesTypes>
98 template<
typename CellType>
103 template<
typename GridCellManager,
typename... AxesTypes>
104 template<
typename CellType>
108 return m_owner.m_index_helper.axisIndex(I, index);
111 template<
typename GridCellManager,
typename... AxesTypes>
112 template<
typename CellType>
115 size_t index = axisIndex<I>();
116 return std::get<I>(m_owner.m_axes)[index];
119 template<
typename GridCellManager,
typename... AxesTypes>
120 template<
typename CellType>
126 <<
" is already fixed";
128 if (index >= m_owner.getOriginalAxis<I>().size()) {
130 << m_owner.getOriginalAxis<I>().name() <<
" size ("
131 << m_owner.getOriginalAxis<I>().
size() <<
")";
134 forwardToIndex(I, index);
138 template<
typename GridCellManager,
typename... AxesTypes>
139 template<
typename CellType>
142 auto& axis = m_owner.getOriginalAxis<I>();
144 if (iter == axis.end()) {
145 throw Elements::Exception() <<
"Failed to fix axis " << m_owner.getOriginalAxis<I>().name()
146 <<
" (given value not found)";
148 size_t index = iter - axis.begin();
149 return fixAxisByIndex<I>(index);
152 template<
typename GridCellManager,
typename... AxesTypes>
153 template<
typename CellType>
156 size_t current_index = m_owner.m_index_helper.axisIndex(axis, current_size);
157 if (fixed_index != current_index) {
158 size_t axis_factor = m_owner.m_index_helper.m_axes_index_factors[axis];
159 size_t distance = (fixed_index > current_index)
160 ? fixed_index - current_index
161 : m_owner.m_index_helper.m_axes_sizes[axis] + fixed_index - current_index;
162 m_data_iter += distance * axis_factor;
166 template<
typename IterFrom,
typename IterTo,
int I>
168 to.template fixAxisByValue<I>(from.template axisValue<I>());
172 template<
typename IterFrom,
typename IterTo>
176 template<
typename GridCellManager,
typename... AxesTypes>
177 template<
typename CellType>
178 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 > &)