29 namespace GridContainer {
31 template <
typename GridCellManager,
typename... AxesTypes>
34 template <
typename GridCellManager,
typename... AxesTypes>
38 template <
typename... AxesTypes>
45 template <
typename GridCellManager,
typename... AxesTypes>
49 , m_axes_fixed{
fixAxis(other.m_axes, axis, index)}
50 , m_fixed_indices{other.m_fixed_indices}
51 , m_cell_manager{other.m_cell_manager} {
53 if (m_fixed_indices.find(axis) != m_fixed_indices.end()) {
56 m_fixed_indices[axis] = index;
59 template <
typename GridCellManager,
typename... AxesTypes>
62 return std::get<I>(m_axes);
65 template <
typename GridCellManager,
typename... AxesTypes>
67 return std::tuple_size<decltype(m_axes_fixed)>::value;
70 template <
typename GridCellManager,
typename... AxesTypes>
73 return std::get<I>(m_axes_fixed);
76 template <
typename GridCellManager,
typename... AxesTypes>
81 template <
typename GridCellManager,
typename... AxesTypes>
88 template <
typename GridCellManager,
typename... AxesTypes>
95 template <
typename GridCellManager,
typename... AxesTypes>
102 template <
typename GridCellManager,
typename... AxesTypes>
107 template <
typename GridCellManager,
typename... AxesTypes>
112 template <
typename GridCellManager,
typename... AxesTypes>
117 template <
typename GridCellManager,
typename... AxesTypes>
119 return m_index_helper_fixed.m_axes_index_factors.back();
122 template <
typename GridCellManager,
typename... AxesTypes>
125 size_t total_index = m_index_helper.totalIndex(indices...);
127 for (
auto& pair : m_fixed_indices) {
128 total_index += pair.second * m_index_helper.m_axes_index_factors[pair.first];
130 return (*m_cell_manager)[total_index];
133 template <
typename GridCellManager,
typename... AxesTypes>
139 template <
typename GridCellManager,
typename... AxesTypes>
143 m_index_helper.checkAllFixedAreZero(m_fixed_indices, indices...);
144 size_t total_index = m_index_helper.totalIndexChecked(indices...);
146 for (
auto& pair : m_fixed_indices) {
147 total_index += pair.second * m_index_helper.m_axes_index_factors[pair.first];
149 return (*m_cell_manager)[total_index];
152 template <
typename GridCellManager,
typename... AxesTypes>
158 template <
typename GridCellManager,
typename... AxesTypes>
161 if (index >= getOriginalAxis<I>().size()) {
162 throw Elements::Exception() <<
"Index (" << index <<
") out of axis " << getOriginalAxis<I>().name() <<
" size ("
163 << getOriginalAxis<I>().size() <<
")";
165 return GridContainer<GridCellManager, AxesTypes...>(*
this, I, index);
168 template <
typename GridCellManager,
typename... AxesTypes>
172 return const_cast<GridContainer<GridCellManager, AxesTypes...
>*>(
this)->fixAxisByIndex<I>(index);
175 template <
typename GridCellManager,
typename... AxesTypes>
179 auto& axis = getOriginalAxis<I>();
180 auto found_axis =
std::find(axis.begin(), axis.end(), value);
181 if (found_axis == axis.end()) {
182 throw Elements::Exception() <<
"Failed to fix axis " << getOriginalAxis<I>().name() <<
" (given value not found)";
184 return GridContainer<GridCellManager, AxesTypes...>(*
this, I, found_axis - axis.begin());
187 template <
typename GridCellManager,
typename... AxesTypes>
191 return const_cast<GridContainer<GridCellManager, AxesTypes...
>*>(
this)->fixAxisByValue<I>(value);
std::tuple< GridAxis< AxesTypes >...> m_axes
A tuple containing the axes of the grid.
Class to iterate through the GridContainer cells.
Class used by the GridContainer to access the different CellManagers.
Representation of a multi-dimensional grid which contains axis information.
const cell_type & at(decltype(std::declval< GridAxis< AxesTypes >>().size())...indices) const
Provides information related with an axis of a GridContainer.
GridContainer construction helper class.
typename std::tuple_element< I, std::tuple< AxesTypes...>>::type axis_type
GridCellManagerTraits< GridCellManager >::data_type cell_type
The type of the values stored in the grid cells.
std::tuple< GridAxis< AxesTypes >...> fixAxis(const std::tuple< GridAxis< AxesTypes >...> &original, size_t axis, size_t index)