Maze Builder Docs 8.8.13
Loading...
Searching...
No Matches
mazes::grid_operations Class Referenceabstract

Interface for grid navigation and manipulation operations. More...

#include <grid_operations.h>

Inheritance diagram for mazes::grid_operations:
[legend]

Public Types

using neighbor_buffer = std::array<std::shared_ptr<cell>, MAX_NEIGHBORS>
 Reusable neighbor buffer type for collect_neighbors.

Public Member Functions

virtual ~grid_operations ()=default
 Destroys the grid_operations object and releases any associated resources.
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::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 std::size_t collect_neighbors (std::shared_ptr< cell > const &c, std::span< std::shared_ptr< cell >, MAX_NEIGHBORS > out) const noexcept=0
 Fill a caller-provided buffer with the neighbors of a cell, avoiding allocation.
std::vector< std::shared_ptr< cell > > collect_neighbors (std::shared_ptr< cell > const &c) const noexcept
 Get all the neighbors by the cell.
virtual std::span< const std::shared_ptr< cell > > cells () const noexcept=0
 Zero-copy view of all cells, in index order (level-major, then row, then column).
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::shared_ptr< cell > get_north (const std::shared_ptr< cell > &c) const noexcept=0
virtual std::shared_ptr< cell > get_south (const std::shared_ptr< cell > &c) const noexcept=0
virtual std::shared_ptr< cell > get_east (const std::shared_ptr< cell > &c) const noexcept=0
virtual std::shared_ptr< cell > get_west (const std::shared_ptr< cell > &c) const noexcept=0
virtual std::shared_ptr< cell > search (int index) const noexcept=0
 Search for a cell by index.
virtual std::size_t num_cells () const noexcept=0
 Get the count of cells in the grid.
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 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 std::vector< std::vector< std::uint32_t > > get_faces () const noexcept=0
 Get the faces.
virtual void set_faces (const std::vector< std::vector< std::uint32_t > > &faces) noexcept=0
 Set the faces.
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 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.

Static Public Member Functions

static bool is_valid_ops (const grid_operations *ops) noexcept
 Checks for nullity.

Static Public Attributes

static constexpr std::size_t MAX_NEIGHBORS = 4
 Maximum number of neighbors a cell can have.

Detailed Description

Interface for grid navigation and manipulation operations.

Member Function Documentation

◆ cells()

virtual std::span< const std::shared_ptr< cell > > mazes::grid_operations::cells ( ) const
nodiscardpure virtualnoexcept

Zero-copy view of all cells, in index order (level-major, then row, then column).

Note
The span is invalidated by resize()

Implemented in mazes::grid.

◆ collect_neighbors() [1/2]

std::vector< std::shared_ptr< cell > > mazes::grid_operations::collect_neighbors ( std::shared_ptr< cell > const & c) const
inlinenodiscardnoexcept

Get all the neighbors by the cell.

Deprecated
Allocates on every call; use the buffer overload instead

◆ collect_neighbors() [2/2]

virtual std::size_t mazes::grid_operations::collect_neighbors ( std::shared_ptr< cell > const & c,
std::span< std::shared_ptr< cell >, MAX_NEIGHBORS > out ) const
nodiscardpure virtualnoexcept

Fill a caller-provided buffer with the neighbors of a cell, avoiding allocation.

Parameters
c
outBuffer to fill (reusable across calls)
Returns
The number of neighbors written to out

Implemented in mazes::grid.

◆ get_dimensions()

virtual std::tuple< std::uint32_t, std::uint32_t, std::uint32_t > mazes::grid_operations::get_dimensions ( ) const
nodiscardpure virtualnoexcept

Retrieves the dimensions as a tuple of three unsigned integers.

Returns
A tuple containing three unsigned integers representing the dimensions.

Implemented in mazes::grid.

◆ get_faces()

virtual std::vector< std::vector< std::uint32_t > > mazes::grid_operations::get_faces ( ) const
nodiscardpure virtualnoexcept

Get the faces.

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

Implemented in mazes::grid.

◆ get_neighbor()

virtual std::shared_ptr< cell > mazes::grid_operations::get_neighbor ( std::shared_ptr< cell > const & c,
Direction dir ) const
nodiscardpure virtualnoexcept

Get neighbor by the cell's respective location.

Parameters
c
dir
Returns

Implemented in mazes::grid.

◆ get_pixels()

virtual std::vector< std::uint8_t > mazes::grid_operations::get_pixels ( ) const
nodiscardpure virtualnoexcept

Get the pixel data for image generation.

Returns
A vector of RGBA pixel data

Implemented in mazes::grid.

◆ get_vertices()

virtual std::vector< std::tuple< std::int32_t, std::int32_t, std::int32_t, std::int32_t > > mazes::grid_operations::get_vertices ( ) const
nodiscardpure virtualnoexcept

Get the vertices.

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

Implemented in mazes::grid.

◆ is_valid_ops()

bool mazes::grid_operations::is_valid_ops ( const grid_operations * ops)
inlinestaticnodiscardnoexcept

Checks for nullity.

Parameters
ops
Returns

◆ num_cells()

virtual std::size_t mazes::grid_operations::num_cells ( ) const
nodiscardpure virtualnoexcept

Get the count of cells in the grid.

Returns
The number of cells in the grid

Implemented in mazes::grid, and mazes::masked_grid.

◆ resize()

virtual void mazes::grid_operations::resize ( std::uint32_t rows,
std::uint32_t cols,
std::uint32_t levels )
pure virtualnoexcept

Resize the grid to new dimensions, clearing all existing cells and topology.

Parameters
rowsNew row count
colsNew column count
levelsNew level count

◆ search()

virtual std::shared_ptr< cell > mazes::grid_operations::search ( int index) const
nodiscardpure virtualnoexcept

Search for a cell by index.

Parameters
index
Returns

Implemented in mazes::grid, and mazes::masked_grid.

◆ set_faces()

virtual void mazes::grid_operations::set_faces ( const std::vector< std::vector< std::uint32_t > > & faces)
pure virtualnoexcept

Set the faces.

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

Implemented in mazes::grid.

◆ set_neighbor()

virtual void mazes::grid_operations::set_neighbor ( const std::shared_ptr< cell > & c,
Direction dir,
std::shared_ptr< cell > const & neighbor )
pure virtualnoexcept

Set neighbor for a cell in a given direction.

Parameters
c
dir
neighbor
Returns

Implemented in mazes::grid.

◆ set_pixels()

virtual void mazes::grid_operations::set_pixels ( const std::vector< std::uint8_t > & pixels)
pure virtualnoexcept

Set the pixel data for image generation.

Parameters
pixelsA vector of RGBA pixel data

Implemented in mazes::grid.

◆ set_vertices()

virtual void mazes::grid_operations::set_vertices ( const std::vector< std::tuple< std::int32_t, std::int32_t, std::int32_t, std::int32_t > > & vertices)
pure virtualnoexcept

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: