OpenTTD Source 20250506-master-geca826b0a4
SpiralTileSequence Class Reference

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

#include <tilearea_type.h>

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
 
std::default_sentinel_t end () const
 

Private Attributes

SpiralTileIterator start
 

Detailed Description

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

Definition at line 316 of file tilearea_type.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 339 of file tilearea_type.h.

◆ 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 365 of file tilearea_type.h.

Member Function Documentation

◆ begin()

SpiralTileIterator SpiralTileSequence::begin ( ) const
inline

Definition at line 367 of file tilearea_type.h.

◆ end()

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

Definition at line 368 of file tilearea_type.h.

Field Documentation

◆ start

SpiralTileIterator SpiralTileSequence::start
private

Definition at line 371 of file tilearea_type.h.


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