Skip to content

Commit

Permalink
TileSetView
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasaunai committed Nov 9, 2024
1 parent 34f4111 commit b47a9ad
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/core/data/tiles/tile_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,39 @@
#include "core/utilities/types.hpp"
#include "core/def.hpp"
#include "core/data/ndarray/ndarray_vector.hpp"
#include "core/utilities/span.hpp"

#include <array>
#include <utility>
#include <string>

namespace PHARE::core
{
template<typename Tile>
class TileSetView
{
public:
static auto constexpr dimension = Tile::dimension;

TileSetView(Box<int, dimension> const& box, std::array<std::size_t, dimension> const& tile_size,
std::array<int, dimension> const& shape, Tile** tiles, std::size_t tile_nbr,
int** cells, std::size_t nbr_cells)
: box_{box}
, tile_size_{tile_size}
, shape_{shape}
, tiles_{tiles, tile_nbr}
, cells_{cells, nbr_cells}
{
}

private:
Box<int, dimension> const box_;
std::array<std::size_t, dimension> tile_size_;
std::array<int, dimension> shape_;
Span<Tile*> tiles_;
NdArrayView<dimension, Tile*> cells_;
};

template<typename Tile>
class TileSet
{
Expand Down Expand Up @@ -73,6 +99,13 @@ class TileSet
return cells_(indexes...);
}


auto make_view()
{
return TileSetView<Tile>{box_, tile_size_, shape_, tiles_.data(),
tiles_.size(), cells_.data(), cells_.size()};
}

private:
void consistent_tile_size_() const
{
Expand Down Expand Up @@ -156,6 +189,10 @@ class TileSet
std::vector<Tile> tiles_;
NdArrayVector<dimension, Tile*> cells_;
};




} // namespace PHARE::core


Expand Down

0 comments on commit b47a9ad

Please sign in to comment.