OpenTTD Source 20261112-master-gbcbec5e63f
SpiralTileSequence Class Reference

Generate TileIndices around a center tile or tile area, with increasing distance. More...

#include <tilearea_spiral.h>

Public Types

using iterator = SpiralTileIterator
 The tile iterator type for this tile area type.

Public Member Functions

 SpiralTileSequence (TileIndex center, uint diameter)
 Generate TileIndices for a square area around a center tile.
 SpiralTileSequence (TileIndex start_north, uint radius, uint w, uint h)
 Generate TileIndices for a rectangular area with an optional rectangular hole in the center.
SpiralTileIterator begin () const
 Returns an iterator to the start of the tile area.
std::default_sentinel_t end () const
 Returns an iterator to the end of the tile area.

Private Attributes

SpiralTileIterator start
 The starting iterator for thi spiral sequence.

Detailed Description

Generate TileIndices around a center tile or tile area, with increasing distance.

Definition at line 99 of file tilearea_spiral.h.

Member Typedef Documentation

◆ iterator

The tile iterator type for this tile area type.

Definition at line 101 of file tilearea_spiral.h.

Constructor & Destructor Documentation

◆ SpiralTileSequence() [1/2]

SpiralTileSequence::SpiralTileSequence ( TileIndex center,
uint diameter )
inline

Generate TileIndices for a square area around a center tile.

The size of the square is given by the length of the edge. If the size is even, the south extent will be larger than the north extent.

Example for diameter=4, [ ] is the "center": 1 1 1 1 [0] 1 1 0 0 1 1 0 1 1 1 1 The sequence starts with the "0" tiles, and continues with the shells around it.

Parameters
centerCenter of the square area.
diameterEdge length of the square.
Precondition
diameter > 0
Note
This constructor uses a "diameter", unlike the other constructor using a "radius".

Definition at line 124 of file tilearea_spiral.h.

References start.

◆ SpiralTileSequence() [2/2]

SpiralTileSequence::SpiralTileSequence ( TileIndex start_north,
uint radius,
uint w,
uint h )
inline

Generate TileIndices for a rectangular area with an optional rectangular hole in the center.

The TileIndices will be sorted by increasing distance from the center (hole).

Example for radius=2, w=2, h=1, [ ] is "start_north": 1 1 1 1 [0] 1 1 0 0 1 1 0 H 0 1 1 0 H 0 1 1 0 0 1 1 0 1 1 1 1 The sequence starts with the "0" tiles, and continues with the shells around it.

Parameters
start_northTile directly north from the center hole.
radiusRadial distance between outer rectangle and center hole.
wWidth of the inner rectangular hole.
hHeight of the inner rectangular hole.
Precondition
radius > 0
Note
This constructor uses a "radius", unlike the other constructor using a "diameter".

Definition at line 150 of file tilearea_spiral.h.

References start.

Member Function Documentation

◆ begin()

SpiralTileIterator SpiralTileSequence::begin ( ) const
inline

Returns an iterator to the start of the tile area.

Returns
The SpiralTileIterator.

Definition at line 156 of file tilearea_spiral.h.

References start.

◆ end()

std::default_sentinel_t SpiralTileSequence::end ( ) const
inline

Returns an iterator to the end of the tile area.

Returns
The iterator.

Definition at line 165 of file tilearea_spiral.h.

Field Documentation

◆ start

SpiralTileIterator SpiralTileSequence::start
private

The starting iterator for thi spiral sequence.

Definition at line 171 of file tilearea_spiral.h.

Referenced by begin(), SpiralTileSequence(), and SpiralTileSequence().


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