FireSTARR
Loading...
Searching...
No Matches
CellPoints.h
1/* Copyright (c) Jordan Evens, 2005, 2021 */
2/* Copyright (c) Queen's Printer for Ontario, 2020. */
3/* Copyright (c) His Majesty the King in Right of Canada as represented by the Minister of Natural Resources, 2021-2025. */
4
5/* SPDX-License-Identifier: AGPL-3.0-or-later */
6
7#pragma once
8#include "stdafx.h"
9#include "InnerPos.h"
10#include "IntensityMap.h"
11
12namespace fs::sim
13{
15// using sim::CellPoints;
16using topo::Cell;
17using topo::SpreadKey;
18class SpreadData : std::tuple<DurationSize>
19{
20public:
21 using std::tuple<DurationSize>::tuple;
22 DurationSize time() const
23 {
24 return std::get<0>(*this);
25 }
26};
27
28static constexpr size_t FURTHEST_N = 0;
29static constexpr size_t FURTHEST_NNE = 1;
30static constexpr size_t FURTHEST_NE = 2;
31static constexpr size_t FURTHEST_ENE = 3;
32static constexpr size_t FURTHEST_E = 4;
33static constexpr size_t FURTHEST_ESE = 5;
34static constexpr size_t FURTHEST_SE = 6;
35static constexpr size_t FURTHEST_SSE = 7;
36static constexpr size_t FURTHEST_S = 8;
37static constexpr size_t FURTHEST_SSW = 9;
38static constexpr size_t FURTHEST_SW = 10;
39static constexpr size_t FURTHEST_WSW = 11;
40static constexpr size_t FURTHEST_W = 12;
41static constexpr size_t FURTHEST_WNW = 13;
42static constexpr size_t FURTHEST_NW = 14;
43static constexpr size_t FURTHEST_NNW = 15;
44static constexpr size_t NUM_DIRECTIONS = 16;
45
46static constexpr auto MASK_NE = DIRECTION_N & DIRECTION_NE & DIRECTION_E;
47static constexpr auto MASK_SE = DIRECTION_S & DIRECTION_SE & DIRECTION_E;
48static constexpr auto MASK_SW = DIRECTION_S & DIRECTION_SW & DIRECTION_W;
49static constexpr auto MASK_NW = DIRECTION_N & DIRECTION_NW & DIRECTION_W;
50// mask of sides that would need to be burned for direction to not matter
51static constexpr std::array<CellIndex, NUM_DIRECTIONS> DIRECTION_MASKS{
52 DIRECTION_N,
53 MASK_NE,
54 MASK_NE,
55 MASK_NE,
56 DIRECTION_E,
57 MASK_SE,
58 MASK_SE,
59 MASK_SE,
60 DIRECTION_S,
61 MASK_SW,
62 MASK_SW,
63 MASK_SW,
64 DIRECTION_W,
65 MASK_NW,
66 MASK_NW,
67 MASK_NW};
68
69class CellPointsMap;
70// using dist_pt = pair<DistanceSize, InnerPos>;
71// using array_cellpts = std::array<dist_pt, NUM_DIRECTIONS>;
72using array_dists = std::array<DistanceSize, NUM_DIRECTIONS>;
73using array_pts = std::array<InnerPos, NUM_DIRECTIONS>;
74using array_cellpts = std::tuple<array_dists, array_pts>;
75// using array_cellpts = std::array<DistanceSize, NUM_DIRECTIONS>;
77 : public array_cellpts
78{
79public:
80 using array_cellpts::array_cellpts;
81 inline const array_dists& distances() const
82 {
83 return std::get<0>(*this);
84 }
85 inline const array_pts& points() const
86 {
87 return std::get<1>(*this);
88 }
89 inline array_dists& distances()
90 {
91 return std::get<0>(*this);
92 }
93 inline array_pts& points()
94 {
95 return std::get<1>(*this);
96 }
97};
102{
103public:
104 using spreading_points = map<SpreadKey, vector<pair<Location, CellPoints>>>;
105 CellPoints() noexcept;
106 // // HACK: so we can emplace with NULL
107 // CellPoints(size_t) noexcept;
108 // HACK: so we can emplace with nullptr
109 CellPoints(const CellPoints* rhs) noexcept;
110 // CellPoints(const vector<InnerPos>& pts) noexcept;
112 const XYSize x,
113 const XYSize y) noexcept;
114 CellPoints(CellPoints&& rhs) noexcept = default;
115 CellPoints(const CellPoints& rhs) noexcept = default;
116 CellPoints& operator=(CellPoints&& rhs) noexcept = default;
117 CellPoints& operator=(const CellPoints& rhs) noexcept = default;
118 CellPoints& insert(
119 const XYSize x,
120 const XYSize y) noexcept;
121 CellPoints& insert(const InnerPos& p) noexcept;
122 // template <class _ForwardIterator>
123 // CellPoints& insert(_ForwardIterator begin, _ForwardIterator end)
124 // {
125 // // don't do anything if empty
126 // if (end != begin)
127 // {
128 // auto it = begin;
129 // while (end != it)
130 // {
131 // (*it);
132 // ++it;
133 // }
134 // }
135 // return *this;
136 // }
137 CellPoints& merge(const CellPoints& rhs);
138 set<XYPos> unique() const noexcept;
139 bool operator<(const CellPoints& rhs) const noexcept;
140 bool operator==(const CellPoints& rhs) const noexcept;
141 [[nodiscard]] Location location() const noexcept;
142 void clear();
143 // const array_pts points() const;
144 bool empty() const;
145 // DurationSize arrival_time_;
146 // IntensitySize intensity_at_arrival_;
147 // ROSSize ros_at_arrival_;
148 // Direction raz_at_arrival_;
149 // friend CellPointsMap;
150 // FIX: just access directly for now
151public:
152 CellPointArrays pts_;
153 // use Idx instead of Location so it can be negative (invalid)
154 CellPos cell_x_y_;
155private:
156 CellPoints(const Idx cell_x, const Idx cell_y) noexcept;
157 CellPoints(const XYPos& p) noexcept;
158};
159
160using spreading_points = CellPoints::spreading_points;
161class Scenario;
162// map that merges items when try_emplace doesn't insert
164{
165public:
167 // CellPoints& insert(
168 // const DurationSize& arrival_time,
169 // const IntensitySize intensity,
170 // const ROSSize& ros,
171 // const Direction& raz,
172 // const XYSize x,
173 // const XYSize y) noexcept;
174 CellPoints& insert(
175 const XYSize x,
176 const XYSize y) noexcept;
177 CellPointsMap& merge(
178 const BurnedData& unburnable,
179 const CellPointsMap& rhs) noexcept;
180 set<XYPos> unique() const noexcept;
181#ifdef DEBUG_CELLPOINTS
182 size_t size() const noexcept;
183#endif
184 // apply function to each CellPoints within and remove matches
185 void remove_if(std::function<bool(const pair<Location, CellPoints>&)> F) noexcept;
186 // FIX: public for debugging right now
187 // private:
188 map<Location, CellPoints> map_;
189};
190}
Definition CellPoints.h:78
Definition CellPoints.h:164
Definition CellPoints.h:102
The position within the Environment that a spreading point has.
Definition InnerPos.h:81
The position within a Cell that a spreading point has.
Definition InnerPos.h:59
A single Scenario in an Iteration using a specific FireWeather stream.
Definition Scenario.h:31
Definition CellPoints.h:19
The position within the Environment that a spreading point has.
Definition InnerPos.h:67
Definition Location.h:229
Direction with access to degrees or radians.
Definition Weather.h:64