15#include <fhsim_environment/AggregationField.h>
20namespace environment::field
31 std::array<double, 3>
origin {0.0, 0.0, 0.0};
32 std::vector<float> x, y, z, a, b, c, cosPhi, sinPhi, amp;
33 std::vector<aggregation::Box> boxes;
38 double totalMass = 0.0;
43 std::vector<AggregationId>
ids;
44 std::vector<std::uint8_t>
live;
45 std::size_t liveCount = 0;
49 [[nodiscard]] std::size_t
Size()
const {
return keyed ? liveCount : x.size(); }
52 [[nodiscard]] std::size_t
SlotCount()
const {
return x.size(); }
55 [[nodiscard]]
bool IsLive(std::size_t slot)
const {
return !keyed ||
live[slot] != 0; }
58 [[nodiscard]] AggregationId
NextId()
const {
return keyed ?
nextId :
static_cast<AggregationId
>(x.size()); }
62 return {x[i], y[i], z[i], a[i], b[i], c[i], cosPhi[i], sinPhi[i], amp[i]};
66 template<
class Visitor>
87 [[nodiscard]] std::vector<double>
SlotMassInBox(
const OrientedBox& box)
const;
93 void WriteSlot(std::size_t slot,
const Aggregation& aggregation);
99 [[nodiscard]] std::optional<std::size_t>
SlotOf(AggregationId
id)
const;
102 [[nodiscard]] AggregationId
IdOf(std::size_t slot)
const {
return keyed ?
ids[slot] :
static_cast<AggregationId
>(slot); }
105 [[nodiscard]] std::vector<aggregation::TiledGrid::Item>
AllItems()
const;
111 [[nodiscard]] std::shared_ptr<State>
CopyWithRoom(std::size_t extra)
const;
118[[nodiscard]]
const char* AggregationProblem(
const Aggregation& aggregation);
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).
void ForEachCandidate(const Box &query, Visitor &&visit) const
Definition HashGrid.h:86
Definition TiledGrid.h:36
void ForEachCandidate(const Box &query, Visitor &&visit) const
Definition TiledGrid.h:114
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).
Definition FieldState.h:30
std::shared_ptr< State > Compacted() const
A keyed state without holes, with the same origin and grid geometry.
AggregationId NextId() const
The id the next add gets.
Definition FieldState.h:58
void ForEachCandidate(const aggregation::Box &query, Visitor &&visit) const
Calls visit(slot) once for each aggregation whose support box overlaps the query box.
Definition FieldState.h:67
double LiveMass() const
The sum of the masses of the live slots, in slot order.
aggregation::TiledGrid FirstGrid(const std::optional< AggregationGridBounds > &bounds) const
The empty grid of a first change: over the bounds, or over the support boxes; none when neither exist...
AggregationId IdOf(std::size_t slot) const
The id of a slot.
Definition FieldState.h:102
void WriteSlot(std::size_t slot, const Aggregation &aggregation)
bool IsLive(std::size_t slot) const
True when the slot holds an aggregation.
Definition FieldState.h:55
std::array< double, 3 > origin
Positions below are relative to this point.
Definition FieldState.h:31
void Candidates(const aggregation::Box &query, std::vector< std::uint32_t > &out) const
The slots of ForEachCandidate in out (cleared first).
Definition FieldState.h:77
aggregation::TiledGrid tiled
The index of a keyed state; no extent until a change leaves a box or gives bounds.
Definition FieldState.h:42
std::size_t Size() const
The number of aggregations.
Definition FieldState.h:49
std::vector< AggregationId > ids
Per slot, rising.
Definition FieldState.h:43
std::optional< std::size_t > SlotOf(AggregationId id) const
The slot of a live id, or none.
std::vector< std::size_t > patchIndices
Per aggregation; empty when patchCentres is.
Definition FieldState.h:36
std::shared_ptr< State > CopyWithRoom(std::size_t extra) const
A copy with room for extra more slots, so appending them does not copy the arrays again....
std::vector< std::array< double, 2 > > patchCentres
Thomas process patch centres of the last Initialise; may be empty.
Definition FieldState.h:35
std::vector< Aggregation > shapes
The aggregations as given, in double precision.
Definition FieldState.h:34
std::vector< aggregation::TiledGrid::Item > AllItems() const
The grid items of every live slot.
AggregationId nextId
The id of the next add.
Definition FieldState.h:46
std::vector< std::uint8_t > live
Per slot; 0 for a hole.
Definition FieldState.h:44
std::size_t SlotCount() const
The number of slots (aggregations and holes).
Definition FieldState.h:52
std::vector< double > SlotMassInBox(const OrientedBox &box) const
The mass [kg] of each slot inside an oriented box (0 for a hole); see MassPerAggregationInBox.
An axis-aligned box, NED [m]. Closed: a box that only touches another one overlaps it.
Definition HashGrid.h:21
One bump with its precomputed constants, in double.
Definition Bump.h:38