Maze Builder Docs 8.2.1
Loading...
Searching...
No Matches
mazes::grid Class Reference

General purpose grid class for 2D maze generation. More...

#include <grid.h>

Inheritance diagram for mazes::grid:
[legend]
Collaboration diagram for mazes::grid:
[legend]

Public Member Functions

 grid (unsigned int rows=1u, unsigned int columns=1u, unsigned int levels=1u)
 Construct a grid using unsigned integers.
 
 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.
 
gridoperator= (const grid &other)
 Assignment operator.
 
 grid (grid &&other) noexcept
 Move constructor.
 
gridoperator= (grid &&other) noexcept
 Move assignment operator.
 
 ~grid () override
 Destructor.
 
grid_operationsoperations () noexcept override
 
const grid_operationsoperations () const noexcept override
 
std::tuple< unsigned int, unsigned int, unsigned int > get_dimensions () const noexcept override
 Get the dimensions of the grid.
 
std::string contents_of (std::shared_ptr< cell > const &c) const noexcept override
 Get detailed information of a cell in the grid.
 
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::shared_ptr< cellget_neighbor (std::shared_ptr< cell > const &c, direction dir) const noexcept override
 Get neighbor by the cell's respective location.
 
std::vector< std::shared_ptr< cell > > get_neighbors (std::shared_ptr< cell > const &c) const noexcept override
 Get all the neighbors by the cell.
 
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< cellget_north (const std::shared_ptr< cell > &c) const noexcept override
 
std::shared_ptr< cellget_south (const std::shared_ptr< cell > &c) const noexcept override
 
std::shared_ptr< cellget_east (const std::shared_ptr< cell > &c) const noexcept override
 
std::shared_ptr< cellget_west (const std::shared_ptr< cell > &c) const noexcept override
 
std::shared_ptr< cellsearch (int index) const noexcept override
 Search for a cell by index.
 
int num_cells () const noexcept override
 Get the count of cells in the grid.
 
void clear_cells () noexcept override
 Cleanup cells by cleaning up links within cells.
 
void set_str (std::string const &str) noexcept override
 Set a string value.
 
std::string get_str () const noexcept override
 Get a string value.
 
void set_file (std::string const &f) noexcept override
 Set the file name.
 
std::string get_file () const noexcept override
 Get the file name.
 
std::vector< std::tuple< int, int, int, int > > get_vertices () const noexcept override
 Get the vertices.
 
void set_vertices (const std::vector< std::tuple< int, int, int, int > > &vertices) noexcept override
 Set the vertices.
 
std::vector< std::vector< std::uint32_t > > get_faces () const noexcept override
 Get the faces.
 
void set_faces (const std::vector< std::vector< std::uint32_t > > &faces) noexcept override
 Set the faces.
 
std::vector< std::uint8_t > get_pixels () const noexcept override
 Get the pixel data for image generation.
 
void set_pixels (const std::vector< std::uint8_t > &pixels) noexcept override
 Set the pixel data for image generation.
 
void resize (unsigned int rows, unsigned int cols, unsigned int levels) noexcept override
 Resize: clear all cells/topology and reset dimensions.
 
- Public Member Functions inherited from mazes::grid_interface
virtual ~grid_interface ()=default
 Virtual destructor for the grid_interface class.
 
- Public Member Functions inherited from mazes::grid_operations
virtual ~grid_operations ()=default
 Destroys the grid_operations object and releases any associated resources.
 
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 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from mazes::grid_operations
static bool is_valid_ops (const grid_operations *ops) noexcept
 Checks for nullity.
 

Detailed Description

General purpose grid class for 2D maze generation.

Constructor & Destructor Documentation

◆ grid() [1/4]

mazes::grid::grid ( unsigned int rows = 1u,
unsigned int columns = 1u,
unsigned int levels = 1u )
explicit

Construct a grid using unsigned integers.

Parameters
rows
columns
levels

◆ grid() [2/4]

mazes::grid::grid ( const std::tuple< unsigned int, unsigned int, unsigned int > & dimens)
explicit

Construct a grid using a tuple of unsigned integers.

Parameters
dimens

◆ grid() [3/4]

mazes::grid::grid ( const grid & other)

Copy constructor.

Parameters
other

◆ grid() [4/4]

mazes::grid::grid ( grid && other)
noexcept

Move constructor.

Parameters
other

Member Function Documentation

◆ background_color_for()

std::uint32_t mazes::grid::background_color_for ( std::shared_ptr< cell > const & c) const
overridevirtualnoexcept

Get the background color for a cell in the grid.

Parameters
c
Returns

Implements mazes::grid_interface.

◆ clear_cells()

void mazes::grid::clear_cells ( )
overridevirtualnoexcept

Cleanup cells by cleaning up links within cells.

Implements mazes::grid_operations.

◆ contents_of()

std::string mazes::grid::contents_of ( std::shared_ptr< cell > const & c) const
overridevirtualnoexcept

Get detailed information of a cell in the grid.

Parameters
c
Returns

Implements mazes::grid_interface.

◆ get_dimensions()

std::tuple< unsigned int, unsigned int, unsigned int > mazes::grid::get_dimensions ( ) const
overridevirtualnoexcept

Get the dimensions of the grid.

Returns
A tuple containing the number of rows, columns, and levels

Implements mazes::grid_operations.

◆ get_east()

std::shared_ptr< cell > mazes::grid::get_east ( const std::shared_ptr< cell > & c) const
overridevirtualnoexcept

◆ get_faces()

std::vector< std::vector< std::uint32_t > > mazes::grid::get_faces ( ) const
overridevirtualnoexcept

Get the faces.

Returns
A vector of faces, where each face is a vector of vertex indices

Implements mazes::grid_operations.

◆ get_file()

std::string mazes::grid::get_file ( ) const
overridevirtualnoexcept

Get the file name.

Returns

Implements mazes::grid_operations.

◆ get_neighbor()

std::shared_ptr< cell > mazes::grid::get_neighbor ( std::shared_ptr< cell > const & c,
direction dir ) const
overridevirtualnoexcept

Get neighbor by the cell's respective location.

Parameters
c
dir
Returns

Implements mazes::grid_operations.

◆ get_neighbors()

std::vector< std::shared_ptr< cell > > mazes::grid::get_neighbors ( std::shared_ptr< cell > const & c) const
overridevirtualnoexcept

Get all the neighbors by the cell.

Parameters
c
Returns

Implements mazes::grid_operations.

◆ get_north()

std::shared_ptr< cell > mazes::grid::get_north ( const std::shared_ptr< cell > & c) const
overridevirtualnoexcept

◆ get_pixels()

std::vector< std::uint8_t > mazes::grid::get_pixels ( ) const
overridevirtualnoexcept

Get the pixel data for image generation.

Returns
A vector of RGBA pixel data

Implements mazes::grid_operations.

◆ get_south()

std::shared_ptr< cell > mazes::grid::get_south ( const std::shared_ptr< cell > & c) const
overridevirtualnoexcept

◆ get_str()

std::string mazes::grid::get_str ( ) const
overridevirtualnoexcept

Get a string value.

Implements mazes::grid_operations.

◆ get_vertices()

std::vector< std::tuple< int, int, int, int > > mazes::grid::get_vertices ( ) const
overridevirtualnoexcept

Get the vertices.

Returns
A vector of vertices as tuples (x, y, z, w)

Implements mazes::grid_operations.

◆ get_west()

std::shared_ptr< cell > mazes::grid::get_west ( const std::shared_ptr< cell > & c) const
overridevirtualnoexcept

◆ num_cells()

int mazes::grid::num_cells ( ) const
overridevirtualnoexcept

Get the count of cells in the grid.

Returns
The number of cells in the grid

Implements mazes::grid_operations.

Reimplemented in mazes::masked_grid.

◆ operations() [1/2]

const grid_operations & mazes::grid::operations ( ) const
overridevirtualnoexcept
Returns

Implements mazes::grid_interface.

◆ operations() [2/2]

grid_operations & mazes::grid::operations ( )
overridevirtualnoexcept
Returns

Implements mazes::grid_interface.

◆ operator=() [1/2]

grid & mazes::grid::operator= ( const grid & other)

Assignment operator.

Parameters
other
Returns

◆ operator=() [2/2]

grid & mazes::grid::operator= ( grid && other)
noexcept

Move assignment operator.

Parameters
other
Returns

◆ search()

std::shared_ptr< cell > mazes::grid::search ( int index) const
overridevirtualnoexcept

Search for a cell by index.

Parameters
index
Returns

Implements mazes::grid_operations.

Reimplemented in mazes::masked_grid.

◆ set_faces()

void mazes::grid::set_faces ( const std::vector< std::vector< std::uint32_t > > & faces)
overridevirtualnoexcept

Set the faces.

Parameters
facesA vector of faces, where each face is a vector of vertex indices

Implements mazes::grid_operations.

◆ set_file()

void mazes::grid::set_file ( std::string const & f)
overridevirtualnoexcept

Set the file name.

Parameters
f

Implements mazes::grid_operations.

◆ set_neighbor()

void mazes::grid::set_neighbor ( const std::shared_ptr< cell > & c,
direction dir,
std::shared_ptr< cell > const & neighbor )
overridevirtualnoexcept

Set neighbor for a cell in a given direction.

Parameters
c
dir
neighbor
Returns

Implements mazes::grid_operations.

◆ set_pixels()

void mazes::grid::set_pixels ( const std::vector< std::uint8_t > & pixels)
overridevirtualnoexcept

Set the pixel data for image generation.

Parameters
pixelsA vector of RGBA pixel data

Implements mazes::grid_operations.

◆ set_str()

void mazes::grid::set_str ( std::string const & str)
overridevirtualnoexcept

Set a string value.

Parameters
str

Implements mazes::grid_operations.

◆ set_vertices()

void mazes::grid::set_vertices ( const std::vector< std::tuple< int, int, int, int > > & vertices)
overridenoexcept

Set the vertices.

Parameters
verticesA vector of vertices as tuples (x, y, z, w)

The documentation for this class was generated from the following file: