feat(vtk): I3dSceneRepository 加异步 loadSection(帘面Grid+色阶)+LocalSample样本实现(①.1)
This commit is contained in:
parent
77f1b5543e
commit
744b55c1b6
|
|
@ -6,6 +6,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "model/Anomaly.hpp"
|
#include "model/Anomaly.hpp"
|
||||||
|
#include "model/ColorScale.hpp"
|
||||||
#include "model/Field.hpp"
|
#include "model/Field.hpp"
|
||||||
#include "repo/RepoTypes.hpp"
|
#include "repo/RepoTypes.hpp"
|
||||||
|
|
||||||
|
|
@ -28,6 +29,12 @@ struct TerrainPaths {
|
||||||
std::string demPath, imagePath;
|
std::string demPath, imagePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 切面/剖面着色数据:帘面渲染输入(Grid + 色阶)。spec §6.2 帘面入 3D。
|
||||||
|
struct SectionData {
|
||||||
|
geopro::core::Grid grid{0, 0}; // Grid 无默认构造,给 0×0 占位(加载后填)
|
||||||
|
geopro::core::ColorScale scale;
|
||||||
|
};
|
||||||
|
|
||||||
// 三维场景仓储抽象(异步,spec §6 评审 HIGH)。
|
// 三维场景仓储抽象(异步,spec §6 评审 HIGH)。
|
||||||
// 取数方法走回调 std::function(LocalSample 本地数据同步算好后直接回调;
|
// 取数方法走回调 std::function(LocalSample 本地数据同步算好后直接回调;
|
||||||
// 将来 Api3dRepository 在网络完成时回调,上层不变)。
|
// 将来 Api3dRepository 在网络完成时回调,上层不变)。
|
||||||
|
|
@ -48,6 +55,10 @@ public:
|
||||||
virtual void loadVolume(const std::string& dsId,
|
virtual void loadVolume(const std::string& dsId,
|
||||||
std::function<void(VolumeGrid)> onOk, OnError onErr) = 0;
|
std::function<void(VolumeGrid)> onOk, OnError onErr) = 0;
|
||||||
|
|
||||||
|
// 异步:加载剖面(帘面)着色数据(Grid+色阶)。本地样本同步回调;Api 实现走 ERT 反演端点异步回调。
|
||||||
|
virtual void loadSection(const std::string& dsId,
|
||||||
|
std::function<void(SectionData)> onOk, OnError onErr) = 0;
|
||||||
|
|
||||||
// 异步:加载地形 DEM/影像路径。
|
// 异步:加载地形 DEM/影像路径。
|
||||||
virtual void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) = 0;
|
virtual void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,19 @@ void LocalSample3dRepository::loadVolume(const std::string& /*dsId*/,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalSample3dRepository::loadSection(const std::string& /*dsId*/,
|
||||||
|
std::function<void(SectionData)> onOk, OnError onErr) {
|
||||||
|
// P1 样本:忽略入参 dsId(本地仅一份样本 grid1);真实 Api 实现走 ERT 反演端点按 dsId 取。
|
||||||
|
try {
|
||||||
|
SectionData s;
|
||||||
|
s.grid = base_.loadGrid("grid1"); // 样本 dd_section 网格
|
||||||
|
s.scale = base_.loadColorScale("grid1"); // 对应色阶
|
||||||
|
onOk(std::move(s)); // 本地同步回调
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
onErr(std::string("LocalSample3dRepository::loadSection: ") + e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LocalSample3dRepository::loadTerrainPaths(std::function<void(TerrainPaths)> onOk,
|
void LocalSample3dRepository::loadTerrainPaths(std::function<void(TerrainPaths)> onOk,
|
||||||
OnError onErr) {
|
OnError onErr) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ public:
|
||||||
DsDimension dimensionOf(const DsRow& ds) const override;
|
DsDimension dimensionOf(const DsRow& ds) const override;
|
||||||
void loadVolume(const std::string& dsId, std::function<void(VolumeGrid)> onOk,
|
void loadVolume(const std::string& dsId, std::function<void(VolumeGrid)> onOk,
|
||||||
OnError onErr) override;
|
OnError onErr) override;
|
||||||
|
void loadSection(const std::string& dsId, std::function<void(SectionData)> onOk,
|
||||||
|
OnError onErr) override;
|
||||||
void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) override;
|
void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) override;
|
||||||
|
|
||||||
// 切片 CRUD(spec §6.3 内存态 stub)
|
// 切片 CRUD(spec §6.3 内存态 stub)
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,16 @@ struct FakeSceneRepo : data::I3dSceneRepository {
|
||||||
g.vmin = 0.0; g.vmax = 1.0;
|
g.vmin = 0.0; g.vmax = 1.0;
|
||||||
onOk(std::move(g)); // 同步回调(异步壳)
|
onOk(std::move(g)); // 同步回调(异步壳)
|
||||||
}
|
}
|
||||||
|
void loadSection(const std::string&, std::function<void(data::SectionData)> onOk,
|
||||||
|
OnError) override {
|
||||||
|
data::SectionData s;
|
||||||
|
s.grid = core::Grid(2, 2);
|
||||||
|
s.grid.lat = {22.0, 22.001};
|
||||||
|
s.grid.lon = {114.0, 114.001};
|
||||||
|
s.scale.addStop(0.0, core::Rgba{0, 0, 255, 255});
|
||||||
|
s.scale.addStop(1.0, core::Rgba{255, 0, 0, 255});
|
||||||
|
onOk(std::move(s)); // 同步回调(异步壳)
|
||||||
|
}
|
||||||
void loadTerrainPaths(std::function<void(data::TerrainPaths)> onOk, OnError) override {
|
void loadTerrainPaths(std::function<void(data::TerrainPaths)> onOk, OnError) override {
|
||||||
onOk(data::TerrainPaths{"dem.tif", "image.tif"});
|
onOk(data::TerrainPaths{"dem.tif", "image.tif"});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue