mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 05:57:08 +01:00
94958b5b45
Traced on the photo the points are clicked sparsely, every 100-300 m, the ground rising and falling between them: laid through the points, from one height clicked to the next, the track went into the ground between them (193 m of the line of the shots over Warszawa Zachodnia). In the shape from the photo the heights are fitted to the ground within the norms (Fitted, "Łagodnie po terenie") till the user chooses them in this run; then as chosen, the bends keep the setting as before. - click_heights::heights_for: the rule. lay_heights_now() gives the heights of the lay tool, its free end dragged too: the panel shows them, the line, its preview, its summary and the grade line fitted to the terrain model follow them. Choosing them in the panel, or layheights of a self-test, is the user's choice. Tests: U: from the photo fitted unless chosen, the bends the setting. E: tr_1 expects the heights fitted; expect layheights.
84 lines
1.9 KiB
C++
84 lines
1.9 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "editor/editorClickHeights.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
|
|
namespace click_heights
|
|
{
|
|
|
|
std::size_t settle(std::vector<glm::dvec3> &Points, std::vector<source> &Sources, std::function<double(std::size_t)> const &Ground)
|
|
{
|
|
std::size_t changed{0};
|
|
auto const count{std::min(Points.size(), Sources.size())};
|
|
for (std::size_t i = 0; i < count; ++i)
|
|
{
|
|
auto &point{Points[i]};
|
|
switch (Sources[i])
|
|
{
|
|
case source::none:
|
|
{
|
|
auto const height{Ground(i)};
|
|
if (false == std::isfinite(height))
|
|
break;
|
|
if (point.y != height)
|
|
{
|
|
point.y = height;
|
|
++changed;
|
|
}
|
|
Sources[i] = source::ground;
|
|
break;
|
|
}
|
|
case source::level:
|
|
if (i > 0 && point.y != Points[i - 1].y)
|
|
{
|
|
point.y = Points[i - 1].y;
|
|
++changed;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return changed;
|
|
}
|
|
|
|
bool guessed(std::vector<source> const &Sources)
|
|
{
|
|
return std::find(Sources.begin(), Sources.end(), source::none) != Sources.end();
|
|
}
|
|
|
|
std::size_t guessed_count(std::vector<source> const &Sources)
|
|
{
|
|
return static_cast<std::size_t>(std::count(Sources.begin(), Sources.end(), source::none));
|
|
}
|
|
|
|
bool waiting(std::vector<source> const &Sources, std::function<bool(std::size_t)> const &Coming)
|
|
{
|
|
for (std::size_t i = 0; i < Sources.size(); ++i)
|
|
if (Sources[i] == source::none && Coming(i))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool wait_on(std::vector<source> const &Sources, std::function<bool(std::size_t)> const &Coming, double const Waited)
|
|
{
|
|
return Waited < wait_longest && waiting(Sources, Coming);
|
|
}
|
|
|
|
editorSettings::lay_heights heights_for(editorSettings::lay_heights const Setting, bool const Traced, bool const Chosen)
|
|
{
|
|
return Traced && false == Chosen ? editorSettings::lay_heights::fitted : Setting;
|
|
}
|
|
|
|
} // namespace click_heights
|