|
FhSim
3.1.0
Marine systems simulation
|
#include <HashGrid.h>
Public Member Functions | |
| HashGrid ()=default | |
| An empty grid; every query reports nothing. | |
| HashGrid (std::span< const Box > boxes, double cellSize) | |
| double | CellSize () const |
| The cell edge in use [m]. | |
| std::size_t | CellCount () const |
| The number of cells. | |
| template<class Visitor > | |
| void | ForEachCandidate (const Box &query, Visitor &&visit) const |
| void | Candidates (const Box &query, std::vector< std::uint32_t > &out) const |
Appends the ids of the boxes that overlap the query box to out (cleared first). | |
Static Public Attributes | |
| static constexpr std::size_t | kMaxCells = 4'000'000 |
| The largest number of cells; a larger domain gets larger cells. | |
Index of boxes by horizontal cell, for fast "which boxes touch this query box" lookups.
The grid has square cells. Each box is listed in every cell its horizontal extent touches, together with its own bounds, so a query tests the vertical range and the exact box before it reports a box. A box is reported once per query, however many cells both share.
The grid is immutable after construction, so concurrent queries are safe.
| environment::field::aggregation::HashGrid::HashGrid | ( | std::span< const Box > | boxes, |
| double | cellSize | ||
| ) |
Builds the grid.
| [in] | boxes | One box per item; the item id is the index. Bounds must be finite. |
| [in] | cellSize | Cell edge [m]. A value of zero or less takes the median of the longer horizontal box side. It is enlarged when the cell count would pass kMaxCells. |
|
inline |
Calls visit(id) once for each box that overlaps the query box.
The order is unspecified.