30 explicit grid(
unsigned int rows = 1u,
unsigned int columns = 1u,
unsigned int levels = 1u);
34 explicit grid(
const std::tuple<unsigned int, unsigned int, unsigned int>& dimensions);
67 std::tuple<
unsigned int,
unsigned int,
unsigned int>
get_dimensions() const noexcept override;
88 std::span<const std::shared_ptr<
cell>>
cells() const noexcept override;
96 std::shared_ptr<
cell> const& neighbor) noexcept override;
99 std::shared_ptr<
cell> get_north(const std::shared_ptr<
cell>& c) const noexcept override;
100 std::shared_ptr<
cell> get_south(const std::shared_ptr<
cell>& c) const noexcept override;
101 std::shared_ptr<
cell> get_east(const std::shared_ptr<
cell>& c) const noexcept override;
102 std::shared_ptr<
cell> get_west(const std::shared_ptr<
cell>& c) const noexcept override;
107 std::shared_ptr<
cell>
search(
int index) const noexcept override;
118 std::vector<std::tuple<
int,
int,
int,
int>>
get_vertices() const noexcept override;
122 void set_vertices(const std::vector<std::tuple<
int,
int,
int,
int>>& vertices) noexcept override;
126 std::vector<std::vector<std::uint32_t>>
get_faces() const noexcept override;
130 void set_faces(const std::vector<std::vector<std::uint32_t>>& faces) noexcept override;
134 std::vector<std::uint8_t>
get_pixels() const noexcept override;
138 void set_pixels(const std::vector<std::uint8_t>& pixels) noexcept override;
141 void resize(
unsigned int rows,
unsigned int cols,
unsigned int levels) noexcept override;
144 std::vector<std::shared_ptr<
cell>> m_cells;
146 std::tuple<
unsigned int,
unsigned int,
unsigned int> m_dimensions;
150 mutable std::mutex m_topology_mutex;
151 std::unordered_map<
int, std::unordered_map<
Direction,
int>> m_topology;
158 std::vector<std::tuple<
int,
int,
int,
int>> m_vertices;
159 std::vector<std::vector<std::uint32_t>> m_faces;
162 std::vector<std::uint8_t> m_pixels;
Direction
Directional neighbors for grid topology.
Definition barriers.h:30
Cell class with links to other cells.
Definition cell.h:18
Interface for the grid class.
Definition grid_interface.h:20
Interface for grid navigation and manipulation operations.
Definition grid_operations.h:22
static constexpr std::size_t MAX_NEIGHBORS
Maximum number of neighbors a cell can have.
Definition grid_operations.h:48
std::string contents_of(std::shared_ptr< cell > const &c) const noexcept override
Get detailed information of a cell in the grid.
grid_operations & operations() noexcept override
grid(const grid &other)
Copy constructor.
std::span< const std::shared_ptr< cell > > cells() const noexcept override
Zero-copy view of all cells, in index order (level-major, then row, then column).
std::shared_ptr< cell > get_neighbor(std::shared_ptr< cell > const &c, Direction dir) const noexcept override
Get neighbor by the cell's respective location.
void resize(unsigned int rows, unsigned int cols, unsigned int levels) noexcept override
Resize: clear all cells/topology and reset dimensions.
void set_faces(const std::vector< std::vector< std::uint32_t > > &faces) noexcept override
Set the faces.
std::size_t num_cells() const noexcept override
Get the count of cells in the grid.
void set_vertices(const std::vector< std::tuple< int, int, int, int > > &vertices) noexcept override
Set the vertices.
grid & operator=(const grid &other)
Assignment operator.
void clear_cells() noexcept
Cleanup cells by cleaning up links within cells.
void set_pixels(const std::vector< std::uint8_t > &pixels) noexcept override
Set the pixel data for image generation.
grid & operator=(grid &&other) noexcept
Move assignment operator.
std::tuple< unsigned int, unsigned int, unsigned int > get_dimensions() const noexcept override
Get the dimensions of the grid.
std::shared_ptr< cell > search(int index) const noexcept override
Search for a cell by index.
std::vector< std::vector< std::uint32_t > > get_faces() const noexcept override
Get the faces.
void set_neighbor(const std::shared_ptr< cell > &c, Direction dir, std::shared_ptr< cell > const &neighbor) noexcept override
Set neighbor for a cell in a given direction.
grid(const std::tuple< unsigned int, unsigned int, unsigned int > &dimensions)
Construct a grid using a tuple of unsigned integers.
grid(grid &&other) noexcept
Move constructor.
std::uint32_t background_color_for(std::shared_ptr< cell > const &c) const noexcept override
Get the background color for a cell in the grid.
std::size_t collect_neighbors(std::shared_ptr< cell > const &c, std::span< std::shared_ptr< cell >, MAX_NEIGHBORS > out) const noexcept override
Fill a caller-provided buffer with the neighbors of a cell, avoiding allocation.
grid(unsigned int rows=1u, unsigned int columns=1u, unsigned int levels=1u)
Construct a grid using unsigned integers.
std::vector< std::uint8_t > get_pixels() const noexcept override
Get the pixel data for image generation.
std::vector< std::tuple< int, int, int, int > > get_vertices() const noexcept override
Get the vertices.
~grid() override
Destructor.