geopro/src/data/repo/I3dSceneRepository.hpp

53 lines
2.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.

#pragma once
#include <array>
#include <functional>
#include <string>
#include "model/Field.hpp"
#include "repo/RepoTypes.hpp"
namespace geopro::data {
// ds 维度属性(由 ds 类型/ddCode 决定spec §6.1)。三栏列表筛选用。
enum class DsDimension { Dim2D, Dim3D, Analysis3D, Other };
// 三维体模型数据:规则标量体 + 世界系原点/间距 + 值域(去裸 double[],用 std::arrayspec §6.2)。
struct VolumeGrid {
geopro::core::ScalarVolume vol{0, 0, 0};
std::array<double, 3> origin{{0.0, 0.0, 0.0}}; // ox, oy, oz世界米
std::array<double, 3> spacing{{0.0, 0.0, 0.0}}; // dx, dy, dz
double vmin = 0.0, vmax = 0.0;
bool valid() const { return vol.nx() > 0 && vol.ny() > 0 && vol.nz() > 0 && vmax > vmin; }
};
// DEM/影像 GeoTIFF 绝对路径(供 render::buildTerrain 经 GDAL 读spec §6.2)。
struct TerrainPaths {
std::string demPath, imagePath;
};
// 三维场景仓储抽象异步spec §6 评审 HIGH
// 取数方法走回调 std::functionLocalSample 本地数据同步算好后直接回调;
// 将来 Api3dRepository 在网络完成时回调,上层不变)。
// **契约onOk/onErr 必须在主(GUI)线程调用**——上层(VtkSceneController)回调内直接操作
// 场景/发 Qt 信号依赖主线程亲和Api 实现若在工作线程完成须 post 回主线程再回调。
// dimensionOf 是同步纯函数(无 I/O只做类型→维度映射
// 切片/异常/任务等签名本期不在接口内(留 P3/P4
class I3dSceneRepository {
public:
using OnError = std::function<void(const std::string& message)>;
virtual ~I3dSceneRepository() = default;
// 同步纯函数ds 类型 → 维度spec §6.1 映射表)。
virtual DsDimension dimensionOf(const DsRow& ds) const = 0;
// 异步:加载三维体模型(成功回调 VolumeGrid失败回调消息
virtual void loadVolume(const std::string& dsId,
std::function<void(VolumeGrid)> onOk, OnError onErr) = 0;
// 异步:加载地形 DEM/影像路径。
virtual void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) = 0;
};
} // namespace geopro::data