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

A grid that restricts cell availability based on a boolean mask. More...

#include <masked_grid.h>

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

Public Member Functions

 masked_grid (const masked_grid &)=delete
 
masked_gridoperator= (const masked_grid &)=delete
 
 masked_grid (masked_grid &&) noexcept=default
 
masked_gridoperator= (masked_grid &&) noexcept=default
 
 masked_grid (mask m)
 Construct a masked grid from a mask object.
 
std::shared_ptr< cellsearch (int index) const noexcept override
 Search for a cell by index, respecting the mask.
 
int num_cells () const noexcept override
 Return the number of available (unmasked) cells.
 
const maskget_mask () const noexcept
 Access the mask used by this grid.
 
std::shared_ptr< cellrandom_cell (randomizer &rng) const noexcept
 Return a random available cell based on the mask.
 
- Public Member Functions inherited from mazes::grid
 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
 
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

A grid that restricts cell availability based on a boolean mask.

Cells at positions where the mask returns false are treated as non-existent. Inherits from grid and overrides search() so that algorithms naturally skip blocked positions. Use binary_tree or sidewinder algorithms with masked grids.

Constructor & Destructor Documentation

◆ masked_grid()

mazes::masked_grid::masked_grid ( mask m)
explicit

Construct a masked grid from a mask object.

Parameters
mThe mask controlling which cells are available

Member Function Documentation

◆ get_mask()

const mask & mazes::masked_grid::get_mask ( ) const
noexcept

Access the mask used by this grid.

Returns
Const reference to the mask

◆ num_cells()

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

Return the number of available (unmasked) cells.

Returns
Count of available cells as reported by the mask

Reimplemented from mazes::grid.

◆ random_cell()

std::shared_ptr< cell > mazes::masked_grid::random_cell ( randomizer & rng) const
noexcept

Return a random available cell based on the mask.

Parameters
rngRandomizer to use
Returns
A shared pointer to a random available cell

◆ search()

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

Search for a cell by index, respecting the mask.

Parameters
indexCell index (row * columns + col)
Returns
The cell if the position is available, nullptr if blocked or out of range

Reimplemented from mazes::grid.


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