geopro/tests/render/test_curtain.cpp

41 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <gtest/gtest.h>
#include <vtkDataSet.h>
#include <vtkDataSetMapper.h>
#include <vtkMapper.h>
#include "actors/CurtainActor.hpp"
#include "geo/GeoLocalFrame.hpp"
#include "model/ColorScale.hpp"
#include "model/Field.hpp"
using namespace geopro::core;
// buildCurtain: 小 Grid(3,2) + lat/lon/y/values -> 非空 actormapper 输入点数=6。
TEST(Curtain, BuildsStructuredGridFromSmallGrid) {
Grid g(3, 2); // nx=3 (lat/lon 列), ny=2 (深度行)
g.lat = {22.50, 22.50, 22.50};
g.lon = {114.16, 114.17, 114.18};
g.y = {0.0, -10.0}; // 两层深度
double n = 0.0;
for (int j = 0; j < 2; ++j)
for (int i = 0; i < 3; ++i) g.valueAt(i, j) = n++;
g.vmin = 0.0;
g.vmax = 5.0;
ColorScale cs;
cs.addStop(0.0, Rgba{0, 0, 255, 255});
cs.addStop(5.0, Rgba{255, 0, 0, 255});
GeoLocalFrame frame(22.50, 114.16);
auto actor = geopro::render::buildCurtain(g, cs, frame);
ASSERT_NE(actor.GetPointer(), nullptr);
auto* mapper = vtkDataSetMapper::SafeDownCast(actor->GetMapper());
ASSERT_NE(mapper, nullptr);
auto* input = mapper->GetInput();
ASSERT_NE(input, nullptr);
EXPECT_EQ(input->GetNumberOfPoints(), 6);
}