TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
79 / 79
100.0%
Branches:
56 / 61
91.8%
Functions:
17 / 17, 1 excl
100.0%

raster/cell_loops.h
Line Branch Exec Source
1 /// @file
2 /// @brief Parallel loops over a raster's cells: every cell, or the windows around features.
3 #pragma once
4
5 #include "terraingen/raster/grid.h"
6 #include "terraingen/raster/raster.h"
7 #include "terraingen/util/geometry.h"
8 #include "terraingen/util/parallel.h"
9 #include "terraingen/util/surface.h"
10
11 #include <algorithm>
12 #include <cstddef>
13 #include <vector>
14
15 namespace terraingen {
16
17 /// A block of a raster's cells: columns [`colBegin`, `colEnd`) and rows [`rowBegin`,
18 /// `rowEnd`).
19 struct PixelWindow {
20 2 std::size_t colBegin = 0; ///< First column.
21 2 std::size_t colEnd = 0; ///< One past the last column.
22 2 std::size_t rowBegin = 0; ///< First row.
23 2 std::size_t rowEnd = 0; ///< One past the last row.
24
25 /// Whether the window holds no cell, either range being empty.
26 171005 bool Empty() const {
27
4/4
✓ Branch 0 taken 146844 times.
✓ Branch 1 taken 24161 times.
✓ Branch 2 taken 10812 times.
✓ Branch 3 taken 136032 times.
171005 return colBegin >= colEnd || rowBegin >= rowEnd;
28 }
29
30
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 bool operator==(const PixelWindow&) const = default;
31 };
32
33 /// The possibly empty window of a grid's pixels whose extent meets a world-coordinate box,
34 /// clamped to the grid.
35 /// @throws std::domain_error if the grid's transform is not invertible.
36 PixelWindow PixelWindowIn(const RasterGrid& grid, const Bounds2d& box);
37
38 /// `PixelWindowIn` the raster's grid.
39 PixelWindow PixelWindowIn(const Raster<float>& raster, const Bounds2d& box);
40
41 /// The non-empty windows of a grid (in `surface`'s coordinates) covering a box: one on a plane,
42 /// up to three on a sphere, none off the grid.
43 /// @param box The box: on a sphere a longitude-latitude box, which is also taken a turn either way
44 /// so a grid running past the antimeridian is covered on both sides.
45 /// @throws std::domain_error if the grid's transform is not invertible.
46 std::vector<PixelWindow> PixelWindowsIn(const RasterGrid& grid, const Bounds2d& box,
47 const Surface& surface);
48
49 /// `PixelWindowsIn` the raster's grid.
50 std::vector<PixelWindow> PixelWindowsIn(const Raster<float>& raster, const Bounds2d& box,
51 const Surface& surface);
52
53 /// Rows per band of `ForEachFeatureCell`, the unit of work handed to a thread.
54 inline constexpr std::size_t kBandRows = 32;
55
56 /// One cell `ForEachFeatureCell` visits.
57 struct FeatureCell {
58 std::size_t feature = 0; ///< Index of the feature.
59 std::size_t window = 0; ///< Index of the window among the feature's.
60 std::size_t col = 0; ///< Column of the cell.
61 std::size_t row = 0; ///< Row of the cell.
62 Vec2d centre{}; ///< World coordinates of the cell's centre.
63 };
64
65 /// Visits the cells of each feature's windows, feature by feature, on several threads.
66 ///
67 /// Each band of `kBandRows` rows is one task and visits the features in order, so every cell sees
68 /// them in the same order whatever `threads` is. No-data cells are skipped.
69 /// @param threads Threads to split the bands over; 0 for every hardware thread.
70 /// @param windowsOf `windowsOf(n)` gives the windows of feature n, as a `std::vector<PixelWindow>`
71 /// (`PixelWindowsIn`); windows of one feature must not overlap.
72 /// @param visit `visit(cell, at)` with `cell` the value to read and update and `at` its
73 /// `FeatureCell`.
74 template <typename T, typename WindowsOf, typename Visit>
75 175 void ForEachFeatureCell(Raster<T>& raster, unsigned threads, std::size_t featureCount,
76 const WindowsOf& windowsOf, const Visit& visit) {
77 175 const std::size_t bands = (raster.Height() + kBandRows - 1) / kBandRows;
78
14/14
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
void terraingen::ForEachFeatureCell<double, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(unsigned long)#1}, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(double&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<double>&, unsigned int, unsigned long, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(unsigned long)#1} const&, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(double&, terraingen::FeatureCell const&)#1} const&):
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
void terraingen::ForEachFeatureCell<double, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(unsigned long)#2}, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(double&, terraingen::FeatureCell const&)#2}>(terraingen::Raster<double>&, unsigned int, unsigned long, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(unsigned long)#2} const&, terraingen::BoulderLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(double&, terraingen::FeatureCell const&)#2} const&):
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
void terraingen::ForEachFeatureCell<double, terraingen::SandShadowLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(unsigned long)#1}, terraingen::SandShadowLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(double&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<double>&, unsigned int, unsigned long, terraingen::SandShadowLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(unsigned long)#1} const&, terraingen::SandShadowLayer::MaterialCoverOver(terraingen::RasterGrid const&, double, terraingen::Ground const*, unsigned int) const::{lambda(double&, terraingen::FeatureCell const&)#1} const&):
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
void terraingen::ForEachFeatureCell<float, terraingen::BoulderLayer::DrawRelief(terraingen::SampleBlock&, std::vector<terraingen::BoulderLayer::Relief, std::allocator<terraingen::BoulderLayer::Relief> > const&, unsigned int) const::{lambda(unsigned long)#1}, terraingen::BoulderLayer::DrawRelief(terraingen::SampleBlock&, std::vector<terraingen::BoulderLayer::Relief, std::allocator<terraingen::BoulderLayer::Relief> > const&, unsigned int) const::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::BoulderLayer::DrawRelief(terraingen::SampleBlock&, std::vector<terraingen::BoulderLayer::Relief, std::allocator<terraingen::BoulderLayer::Relief> > const&, unsigned int) const::{lambda(unsigned long)#1} const&, terraingen::BoulderLayer::DrawRelief(terraingen::SampleBlock&, std::vector<terraingen::BoulderLayer::Relief, std::allocator<terraingen::BoulderLayer::Relief> > const&, unsigned int) const::{lambda(float&, terraingen::FeatureCell const&)#1} const&):
✓ Branch 1 taken 81 times.
✓ Branch 4 taken 81 times.
void terraingen::ForEachFeatureCell<float, terraingen::SandShadowLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(unsigned long)#1}, terraingen::SandShadowLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::SandShadowLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(unsigned long)#1} const&, terraingen::SandShadowLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float&, terraingen::FeatureCell const&)#1} const&):
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
385 ParallelFor(bands, threads, [&](std::size_t band) {
79 210 const std::size_t bandBegin = band * kBandRows;
80 210 const std::size_t bandEnd = std::min(raster.Height(), bandBegin + kBandRows);
81
4/4
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 204 times.
10566 for (std::size_t n = 0; n < featureCount; ++n) {
82 10356 const std::vector<PixelWindow>& windows = windowsOf(n);
83
4/4
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 12 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 10344 times.
✓ Branch 2 taken 10344 times.
20718 for (std::size_t w = 0; w < windows.size(); ++w) {
84 10362 const PixelWindow& window = windows[w];
85 10362 const std::size_t rowEnd = std::min(bandEnd, window.rowEnd);
86
4/4
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 164 times.
✓ Branch 2 taken 18 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 23609 times.
✓ Branch 2 taken 10344 times.
34135 for (std::size_t row = std::max(bandBegin, window.rowBegin); row < rowEnd; ++row) {
87
4/4
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 164 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 0 taken 734295 times.
✓ Branch 1 taken 23609 times.
759676 for (std::size_t col = window.colBegin; col < window.colEnd; ++col) {
88 735903 T& cell = raster(col, row);
89
3/4
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 1606 times.
✓ Branch 2 taken 2 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 734295 times.
✗ Branch 2 not taken.
735903 if (!raster.IsNoData(cell)) {
90
2/2
terraingen::ForEachFeatureCell<float, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1}, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(unsigned long)#1} const&, ForEachFeatureCell_VisitsEachFeaturesCellsInOrderOnAnyNumberOfThreads_Test::TestBody()::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 2 taken 1606 times.
terraingen::ForEachFeatureCell<float, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1}, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1}>(terraingen::Raster<float>&, unsigned int, unsigned long, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(unsigned long)#1} const&, terraingen::ApplyCraters(terraingen::Raster<float>&, terraingen::CraterList const&, terraingen::CraterShapeModels const&, terraingen::CraterApplyOptions const&, terraingen::CraterSampling const&)::{lambda(float&, terraingen::FeatureCell const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 2 taken 734295 times.
735901 visit(cell, FeatureCell{n, w, col, row, raster.CellCenter(col, row)});
91 }
92 }
93 }
94 }
95 }
96 });
97 175 }
98
99 /// Sets each cell of a raster holding data to a function of its height and centre, rows
100 /// over several threads.
101 /// @param threads Threads to split the rows over; 0 for every hardware thread.
102 /// @param map `map(height, centre)` returning the cell's new height as a `float`.
103 1047 template <typename Map> void MapCells(Raster<float>& heights, unsigned threads, const Map& map) {
104
4/4
terraingen::MapCells<MapCells_MapsEveryCellHoldingData_Test::TestBody()::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, MapCells_MapsEveryCellHoldingData_Test::TestBody()::{lambda(float, terraingen::Vec2d const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 3 taken 1 time.
terraingen::MapCells<terraingen::FormulaLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, terraingen::FormulaLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 3 taken 70 times.
void terraingen::MapCells<terraingen::ApplyKernel<terraingen::NoiseReliefKernel>(terraingen::SampleBlock&, terraingen::LayerContext const&, terraingen::NoiseReliefKernel const&, terraingen::Vec2d const&)::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, terraingen::ApplyKernel<terraingen::NoiseReliefKernel>(terraingen::SampleBlock&, terraingen::LayerContext const&, terraingen::NoiseReliefKernel const&, terraingen::Vec2d const&)::{lambda(float, terraingen::Vec2d const&)#1} const&):
✓ Branch 3 taken 870 times.
void terraingen::MapCells<terraingen::NoiseRelief::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, terraingen::NoiseRelief::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1} const&):
✓ Branch 3 taken 106 times.
16698 ParallelFor(heights.Height(), threads, [&](std::size_t row) {
105
4/4
terraingen::MapCells<MapCells_MapsEveryCellHoldingData_Test::TestBody()::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, MapCells_MapsEveryCellHoldingData_Test::TestBody()::{lambda(float, terraingen::Vec2d const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 4 times.
terraingen::MapCells<terraingen::FormulaLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, terraingen::FormulaLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 10411337 times.
✓ Branch 2 taken 15651 times.
10427012 for (std::size_t col = 0; col < heights.Width(); ++col) {
106 10411357 float& cell = heights(col, row);
107
4/4
terraingen::MapCells<MapCells_MapsEveryCellHoldingData_Test::TestBody()::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, MapCells_MapsEveryCellHoldingData_Test::TestBody()::{lambda(float, terraingen::Vec2d const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 1 time.
terraingen::MapCells<terraingen::FormulaLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1}>(terraingen::Raster<float>&, unsigned int, terraingen::FormulaLayer::ApplySamples(terraingen::SampleBlock&, terraingen::LayerContext const&) const::{lambda(float, terraingen::Vec2d const&)#1} const&)::{lambda(unsigned long)#1}::operator()(unsigned long) const:
✓ Branch 1 taken 10411332 times.
✓ Branch 2 taken 5 times.
10411357 if (!heights.IsNoData(cell)) {
108
1/1
✓ Branch 2 taken 10411332 times.
10411351 cell = map(cell, heights.CellCenter(col, row));
109 }
110 }
111 });
112 1047 }
113
114 } // namespace terraingen
115