13#include <unordered_map>
31 explicit grid(
unsigned int rows = 1u,
unsigned int columns = 1u,
unsigned int levels = 1u);
35 explicit grid(
const std::tuple<unsigned int, unsigned int, unsigned int>& dimens);
68 std::tuple<
unsigned int,
unsigned int,
unsigned int>
get_dimensions() const noexcept override;
97 std::shared_ptr<
cell> const& neighbor) noexcept override;
100 std::shared_ptr<
cell> get_north(const std::shared_ptr<
cell>& c) const noexcept override;
101 std::shared_ptr<
cell> get_south(const std::shared_ptr<
cell>& c) const noexcept override;
102 std::shared_ptr<
cell> get_east(const std::shared_ptr<
cell>& c) const noexcept override;
103 std::shared_ptr<
cell> get_west(const std::shared_ptr<
cell>& c) const noexcept override;
108 std::shared_ptr<
cell>
search(
int index) const noexcept override;
119 void set_str(std::
string const& str) noexcept override;
122 std::
string get_str() const noexcept override;
124 void set_file(std::
string const& f) noexcept override;
130 std::vector<std::tuple<
int,
int,
int,
int>>
get_vertices() const noexcept override;
134 void set_vertices(const std::vector<std::tuple<
int,
int,
int,
int>>& vertices) noexcept override;
138 std::vector<std::vector<std::uint32_t>>
get_faces() const noexcept override;
142 void set_faces(const std::vector<std::vector<std::uint32_t>>& faces) noexcept override;
146 std::vector<std::uint8_t>
get_pixels() const noexcept override;
150 void set_pixels(const std::vector<std::uint8_t>& pixels) noexcept override;
153 void resize(
unsigned int rows,
unsigned int cols,
unsigned int levels) noexcept override;
156 std::unordered_map<
int, std::shared_ptr<
cell>> m_cells;
158 std::tuple<
unsigned int,
unsigned int,
unsigned int> m_dimensions;
162 mutable std::mutex m_topology_mutex;
163 std::unordered_map<
int, std::unordered_map<
direction,
int>> m_topology;
170 std::vector<std::tuple<
int,
int,
int,
int>> m_vertices;
171 std::vector<std::vector<std::uint32_t>> m_faces;
174 std::vector<std::uint8_t> m_pixels;
direction
Directional neighbors for grid topology.
Definition barriers.h:24
Cell class with links to other cells.
Definition cell.h:19
Interface for the grid class.
Definition grid_interface.h:20
Interface for grid navigation and manipulation operations.
Definition grid_operations.h:19
General purpose grid class for 2D maze generation.
Definition grid.h:25
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 std::tuple< unsigned int, unsigned int, unsigned int > &dimens)
Construct a grid using a tuple of unsigned integers.
grid(const grid &other)
Copy constructor.
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.
void set_str(std::string const &str) noexcept override
Set a string value.
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 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 > get_neighbor(std::shared_ptr< cell > const &c, direction dir) const noexcept override
Get neighbor by the cell's respective location.
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.
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_file(std::string const &f) noexcept override
Set the file name.
std::vector< std::shared_ptr< cell > > get_neighbors(std::shared_ptr< cell > const &c) const noexcept override
Get all the neighbors by the cell.
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.
void clear_cells() noexcept override
Cleanup cells by cleaning up links within cells.
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.
std::string get_str() const noexcept override
Get a string value.
int num_cells() const noexcept override
Get the count of cells in the grid.
~grid() override
Destructor.
std::string get_file() const noexcept override
Get the file name.