FireSTARR
Loading...
Searching...
No Matches
BurnedData.h
1/* SPDX-License-Identifier: AGPL-3.0-or-later */
2#ifndef FS_BURNEDDATA_H
3#define FS_BURNEDDATA_H
4#include "stdafx.h"
5#include "ConstantGrid.h"
6#include "Location.h"
7namespace fs
8{
10{
11public:
12 BurnedData(const CellGrid& cells) noexcept;
13 BurnedData(const FuelGrid& fuel) noexcept;
14 bool at(const XYIdx& h) const noexcept;
15 void set(const XYIdx& h) noexcept;
16 void clear() noexcept;
17 BurnedData() noexcept = default;
18 BurnedData(const BurnedData& rhs) noexcept;
19 BurnedData(BurnedData&& rhs) noexcept;
20 BurnedData& operator=(const BurnedData& rhs) noexcept;
21 BurnedData& operator=(BurnedData&& rhs) noexcept;
22 [[nodiscard]] constexpr Idx height() const noexcept { return height_; }
23 [[nodiscard]] constexpr Idx width() const noexcept { return width_; }
28 [[nodiscard]] MathSize fireSize() const noexcept
29 {
30 // we know that every cell is a key, so we convert that to hectares
31 const MathSize per_width = (cell_size_ / 100.0);
32 // size of fire is number of bits set * cell size
33 return static_cast<MathSize>(data_->count() - unburnable_) * per_width * per_width;
34 }
35
36private:
37 // std::bitset doesn't heap allocate
38 using dtype = std::bitset<static_cast<size_t>(MAX_HEIGHT) * MAX_WIDTH>;
39 uptr<dtype> data_{nullptr};
40 static uptr<dtype> from_grid(auto& grid, auto fct);
41 MathSize cell_size_{-1};
42 size_t unburnable_{0};
43 Idx height_{};
44 Idx width_{};
45};
46}
47#endif
Definition BurnedData.h:10
MathSize fireSize() const noexcept
Calculate area for cells that have a value (ha)
Definition BurnedData.h:28
Definition Location.h:81