#include <grid.hxx>
Classes | |
class | Cell |
class | Edge |
Edge struct is a convenient struct use to store two cell pointers connected by a link/edge. More... | |
struct | Point |
Point struct is a convenient struct use to represent a 2D point for a grid (index position). More... | |
Public Member Functions | |
Grid (uint32_t width, uint32_t height, bool isConnected=false) | |
void | Connect (const std::shared_ptr< Cell > first, const std::shared_ptr< Cell > second) |
void | Connect (const std::shared_ptr< Cell > root, const std::vector< std::shared_ptr< Cell >> &neighbours) |
void | Disconnect (const std::shared_ptr< Cell > first, const std::shared_ptr< Cell > second) |
void | DisconnectCol (const Point &origin, const uint32_t idx, const uint32_t height, const uint32_t pathIdx) |
void | DisconnectRow (const Point &origin, const uint32_t idx, const uint32_t width, const uint32_t pathIdx) |
uint32_t | Width () const |
uint32_t | Height () const |
std::vector< std::shared_ptr< Cell > > & | operator[] (size_t n) |
const std::vector< std::shared_ptr< Cell > > & | operator[] (size_t n) const |
Private Member Functions | |
Grid | operator= (Grid &) |
void | Init (uint32_t width, uint32_t height, bool isConneccted) |
Private Attributes | |
std::vector< std::vector< std::shared_ptr< Cell > > > | data |
Detailed Description
template<typename CellInfo = CellInfoBase>
class huc::Grid< CellInfo >
Grid - Conveniently wraps a double std::vector<Grid::Cell> and add cell connection managment. The grid class may be used to generate all kind of networks/graphs/mazes with uniform and othonormal cell positionning.
- Template Parameters
-
CellInfo a struct used to store extra information associated with each Grid::Cell
Constructor & Destructor Documentation
|
inlineexplicit |
Grid constructor.
- Parameters
-
width the desired width for the Grid. height the desired height for the Grid. isConnected whether or not the cells of the grid are connected at the initialization.
Definition at line 52 of file grid.hxx.
Member Function Documentation
|
inline |
Connect with a bidirectionnal link first and second.
- Parameters
-
first the cell to be connected to the second cell. second the cell to be connected to the first cell.
- Returns
- void.
|
inline |
Connect with bidirectionnal links the root with the neighbours.
- Parameters
-
root the root to be connected to the neighbours. neighbours list of cells to be connected to the root.
- Returns
- void.
|
inline |
Disconnect the bidirectionnal link between first and second.
- Parameters
-
first the cell to be disconnected to the second cell. second the cell to be disconnected to the first cell.
- Returns
- void.
|
inline |
Disconnect a column of cells - Build a wall between connected cells. Each cell of this column is disconnected to its right (East) neighboor except the one at the pathIdx. If the cells does not have a east neighboor connected : nothing append.
- Parameters
-
origin the origin point on the grid setting the current relative position. idx the relative index of the column of cells to be disconnected. height the size of wall constructed. If it exceeds the size of the Grid: wall will be construted until the border. pathIdx the relative index of the path (door) within the wall. No path is created if pathIdx >= height.
- Returns
- void.
Definition at line 150 of file grid.hxx.
|
inline |
Disconnect a row of cells - Build a wall between connected cells. Each cell of this row is disconnected to its right (East) neighboor except the one at the pathIdx. If the cells does not have a east neighboor connected : nothing append.
- Parameters
-
origin the origin point on the grid setting the current relative position. idx the relative index of the row of cells to be disconnected. width the size of wall constructed. If it exceeds the size of the Grid: wall will be construted until the border. pathIdx the relative index of the path (door) within the wall. No path is created if pathIdx >= width.
- Returns
- void.
Definition at line 177 of file grid.hxx.
|
inline |
|
inlineprivate |
Definition at line 203 of file grid.hxx.
|
private |
|
inline |
|
inline |
|
inline |
Member Data Documentation
The documentation for this class was generated from the following file: