Maze Builder Docs 8.2.1
Loading...
Searching...
No Matches
grid_operations.h
Go to the documentation of this file.
1#ifndef GRID_OPERATIONS_H
2#define GRID_OPERATIONS_H
3
5#include <MazeBuilder/cell.h>
6
7#include <cstdint>
8#include <memory>
9#include <tuple>
10#include <vector>
11
14namespace mazes
15{
19 {
20 public:
24 [[nodiscard]]
25 static bool is_valid_ops(const grid_operations* ops) noexcept
26 {
27 return ops != nullptr;
28 }
29
31 virtual ~grid_operations() = default;
32
35 [[nodiscard]] virtual std::tuple<std::uint32_t, std::uint32_t, std::uint32_t> get_dimensions() const noexcept =
36 0;
37
42 [[nodiscard]] virtual std::shared_ptr<cell> get_neighbor(std::shared_ptr<cell> const& c,
43 direction dir) const noexcept = 0;
44
48 [[nodiscard]] virtual std::vector<std::shared_ptr<cell>> get_neighbors(
49 std::shared_ptr<cell> const& c) const noexcept = 0;
50
56 virtual void set_neighbor(const std::shared_ptr<cell>& c, direction dir,
57 std::shared_ptr<cell> const& neighbor) noexcept = 0;
58
59 // Convenience methods for accessing neighbors
60 [[nodiscard]] virtual std::shared_ptr<cell> get_north(const std::shared_ptr<cell>& c) const noexcept = 0;
61 [[nodiscard]] virtual std::shared_ptr<cell> get_south(const std::shared_ptr<cell>& c) const noexcept = 0;
62 [[nodiscard]] virtual std::shared_ptr<cell> get_east(const std::shared_ptr<cell>& c) const noexcept = 0;
63 [[nodiscard]] virtual std::shared_ptr<cell> get_west(const std::shared_ptr<cell>& c) const noexcept = 0;
64
68 [[nodiscard]] virtual std::shared_ptr<cell> search(int index) const noexcept = 0;
69
72 [[nodiscard]] virtual int num_cells() const noexcept = 0;
73
75 virtual void clear_cells() noexcept = 0;
76
79 virtual void set_str(std::string const& str) noexcept = 0;
80
83 [[nodiscard]] virtual std::string get_str() const noexcept = 0;
84
87 virtual void set_file(std::string const& f) noexcept = 0;
88
91 [[nodiscard]] virtual std::string get_file() const noexcept = 0;
92
95 [[nodiscard]] virtual std::vector<std::tuple<std::int32_t, std::int32_t, std::int32_t, std::int32_t>>
96 get_vertices() const noexcept = 0;
97
100 virtual void set_vertices(
101 const std::vector<std::tuple<std::int32_t, std::int32_t, std::int32_t, std::int32_t>>& vertices) noexcept =
102 0;
103
106 [[nodiscard]] virtual std::vector<std::vector<std::uint32_t>> get_faces() const noexcept = 0;
107
110 virtual void set_faces(const std::vector<std::vector<std::uint32_t>>& faces) noexcept = 0;
111
114 [[nodiscard]] virtual std::vector<std::uint8_t> get_pixels() const noexcept = 0;
115
118 virtual void set_pixels(const std::vector<std::uint8_t>& pixels) noexcept = 0;
119
122 virtual void resize(std::uint32_t rows, std::uint32_t cols, std::uint32_t levels) noexcept = 0;
123 };
124} // namespace mazes
125
126#endif // GRID_OPERATIONS_H
direction
Directional neighbors for grid topology.
Definition barriers.h:24
Cell class with links to other cells.
Definition cell.h:19
Interface for grid navigation and manipulation operations.
Definition grid_operations.h:19
static bool is_valid_ops(const grid_operations *ops) noexcept
Checks for nullity.
Definition grid_operations.h:25
virtual void set_neighbor(const std::shared_ptr< cell > &c, direction dir, std::shared_ptr< cell > const &neighbor) noexcept=0
Set neighbor for a cell in a given direction.
virtual std::vector< std::uint8_t > get_pixels() const noexcept=0
Get the pixel data for image generation.
virtual void set_pixels(const std::vector< std::uint8_t > &pixels) noexcept=0
Set the pixel data for image generation.
virtual int num_cells() const noexcept=0
Get the count of cells in the grid.
virtual void resize(std::uint32_t rows, std::uint32_t cols, std::uint32_t levels) noexcept=0
Resize the grid to new dimensions, clearing all existing cells and topology.
virtual void set_vertices(const std::vector< std::tuple< std::int32_t, std::int32_t, std::int32_t, std::int32_t > > &vertices) noexcept=0
Set the vertices.
virtual void set_file(std::string const &f) noexcept=0
Set the file name.
virtual std::vector< std::shared_ptr< cell > > get_neighbors(std::shared_ptr< cell > const &c) const noexcept=0
Get all the neighbors by the cell.
virtual std::tuple< std::uint32_t, std::uint32_t, std::uint32_t > get_dimensions() const noexcept=0
Retrieves the dimensions as a tuple of three unsigned integers.
virtual std::vector< std::vector< std::uint32_t > > get_faces() const noexcept=0
Get the faces.
virtual void clear_cells() noexcept=0
Cleanup cells by cleaning up links within cells.
virtual std::string get_str() const noexcept=0
Get a string value.
virtual void set_str(std::string const &str) noexcept=0
Set a string value.
virtual std::vector< std::tuple< std::int32_t, std::int32_t, std::int32_t, std::int32_t > > get_vertices() const noexcept=0
Get the vertices.
virtual std::shared_ptr< cell > get_neighbor(std::shared_ptr< cell > const &c, direction dir) const noexcept=0
Get neighbor by the cell's respective location.
virtual ~grid_operations()=default
Destroys the grid_operations object and releases any associated resources.
virtual std::shared_ptr< cell > search(int index) const noexcept=0
Search for a cell by index.
virtual std::string get_file() const noexcept=0
Get the file name.
virtual void set_faces(const std::vector< std::vector< std::uint32_t > > &faces) noexcept=0
Set the faces.