46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
#include <gtest/gtest.h>
|
||
|
||
#include <vtkPolyData.h>
|
||
#include <vtkPolyDataMapper.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 -> 非空 actor,经 banded contour 管线
|
||
// (vtkDataSetSurfaceFilter→vtkBandedPolyDataContourFilter→vtkPolyDataMapper) 产出非空 polydata。
|
||
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 = vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
|
||
ASSERT_NE(mapper, nullptr);
|
||
ASSERT_NE(mapper->GetLookupTable(), nullptr);
|
||
|
||
// 运行管线,断言 banded contour 产出非空 polydata(色带面)。
|
||
mapper->Update();
|
||
auto* out = mapper->GetInput();
|
||
ASSERT_NE(out, nullptr);
|
||
EXPECT_GT(out->GetNumberOfPoints(), 0);
|
||
EXPECT_GT(out->GetNumberOfCells(), 0);
|
||
}
|