29 namespace GridContainer {
31 template<
typename GridCellManager,
typename... AxesTypes>
35 template<
typename GridCellManager,
typename... AxesTypes>
39 template<
typename... AxesTypes>
46 template<
typename GridCellManager,
typename... AxesTypes>
49 size_t axis,
size_t index)
50 : m_axes{other.
m_axes}, m_axes_fixed{
fixAxis(other.m_axes_fixed, axis, index)},
51 m_fixed_indices{other.m_fixed_indices}, 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>
124 size_t total_index = m_index_helper.totalIndex(indices...);
126 for (
auto& pair : m_fixed_indices) {
127 total_index += pair.second * m_index_helper.m_axes_index_factors[pair.first];
129 return (*m_cell_manager)[total_index];
132 template<
typename GridCellManager,
typename... AxesTypes>
137 template<
typename GridCellManager,
typename... AxesTypes>
140 m_index_helper.checkAllFixedAreZero(m_fixed_indices, indices...);
141 size_t total_index = m_index_helper.totalIndexChecked(indices...);
143 for (
auto& pair : m_fixed_indices) {
144 total_index += pair.second * m_index_helper.m_axes_index_factors[pair.first];
146 return (*m_cell_manager)[total_index];
149 template<
typename GridCellManager,
typename... AxesTypes>
154 template<
typename GridCellManager,
typename... AxesTypes>
157 if (index >= getOriginalAxis<I>().size()) {
159 << getOriginalAxis<I>().name() <<
" size ("
160 << getOriginalAxis<I>().size() <<
")";
162 return GridContainer<GridCellManager, AxesTypes...>(*
this, I, index);
165 template<
typename GridCellManager,
typename... AxesTypes>
168 return const_cast<GridContainer<GridCellManager, AxesTypes...
>*>(
this)->fixAxisByIndex<I>(index);
171 template<
typename GridCellManager,
typename... AxesTypes>
174 auto& axis = getOriginalAxis<I>();
176 if (iter == axis.end()) {
178 <<
" (given value not found)";
180 return GridContainer<GridCellManager, AxesTypes...>(*
this, I, iter-axis.begin());
183 template<
typename GridCellManager,
typename... AxesTypes>
186 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)