Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
potentialcontours2d_tests.cpp
Go to the documentation of this file.
1/**
2 * @file potentialcontours2d_tests.cpp
3 * @brief Implements regression and invariant tests for potentialcontours2d tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/potentialcontours2d_tests.cpp. This file is part of Quantum Phenomena Explorer (QPE),
7 * maintained by Officina Turini. See LICENSE_IT.txt / LICENSE.txt for the
8 * QPE freeware source-available terms and THIRD_PARTY_NOTICES.txt for
9 * third-party components.
10 */
11
15#include <cmath>
16
17namespace qpe { namespace tests {
18
19/**
20 * @brief Runs potential contours2 d tests.
21 * @param error Output diagnostic text on failure.
22 */
23bool runPotentialContours2DTests(std::string &error)
24{
25 error.clear();
26 PotentialField2D binary(32, 32, 0.1f, 0.1f);
27 binary.clear();
28 binary.addRectangle(0.0f, 0.0f, 1.0f, 0.8f, 8.0f);
30 if (!c1.binaryField || c1.levels.size() != 1u || c1.segments.empty()) { error = "Binary contour extraction failed"; return false; }
31 if (std::fabs(c1.levels[0] - 4.0f) > 1.0e-5f) { error = "Binary midpoint level is wrong"; return false; }
32
33 PotentialField2D ramp(8, 8, 0.25f, 0.25f);
34 for (std::size_t y = 0; y < ramp.height(); ++y) {
35 for (std::size_t x = 0; x < ramp.width(); ++x) {
36 ramp.set(x, y, static_cast<float>(x));
37 }
38 }
40 if (c2.binaryField || c2.levels.size() != 3u || c2.segments.empty()) { error = "Continuous contour extraction failed"; return false; }
41 return true;
42}
43
44} }
static PotentialContours2DResult compute(const PotentialField2D &potential, std::size_t requestedLevels)
Performs compute.
Implements the Potential Field2D component.
std::size_t height() const noexcept
Returns height.
void clear() noexcept
Performs clear.
void addRectangle(float centerX, float centerY, float width, float height, Value value)
Adds rectangle.
std::size_t width() const noexcept
Returns width.
void set(std::size_t x, std::size_t y, Value value) noexcept
Performs set.
bool runPotentialContours2DTests(std::string &error)
Runs potential contours2 d tests.
Declares the potentialcontours2d physics/numerical component used by QPE experiments.
Declares regression and invariant tests for potentialcontours2d tests.
Declares the potentialfield2d physics/numerical component used by QPE experiments.
Data record containing Potential Contours2D Result.
std::vector< PotentialContourSegment2D > segments