23 lines
837 B
C++
23 lines
837 B
C++
#include <gtest/gtest.h>
|
|
#include "ContourBands.hpp"
|
|
using namespace geopro::core;
|
|
using namespace geopro::render;
|
|
|
|
// 2x2 平滑梯度网格 + 2 段色阶 → 至少 1 个色带多边形,多边形顶点 >=3。
|
|
TEST(ContourBands, ProducesNonEmptyBands) {
|
|
Grid g(3, 3);
|
|
g.x = {0, 1, 2}; g.y = {0, 1, 2};
|
|
for (int j = 0; j < 3; ++j)
|
|
for (int i = 0; i < 3; ++i) g.valueAt(i, j) = static_cast<double>(i + j); // 0..4
|
|
g.vmin = 0; g.vmax = 4;
|
|
ColorScale cs;
|
|
cs.addStop(0.0, Rgba{0, 0, 255, 255});
|
|
cs.addStop(2.0, Rgba{0, 255, 0, 255});
|
|
cs.addStop(4.0, Rgba{255, 0, 0, 255});
|
|
|
|
ContourOptions opt; opt.upsample = 1; opt.smooth = 0; opt.simplifyTol = 0;
|
|
auto r = buildContourBands(g, cs, opt);
|
|
ASSERT_FALSE(r.bands.empty());
|
|
for (const auto& b : r.bands) EXPECT_GE(b.ring.size(), 3u);
|
|
}
|