feat/vtk-3d-view #7
|
|
@ -1,6 +1,7 @@
|
||||||
#include "api/Api3dRepository.hpp"
|
#include "api/Api3dRepository.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QJsonDocument>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
@ -106,6 +107,19 @@ std::string Api3dRepository::createVolume(VolumeBuildParams params, const std::s
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Api3dRepository::createVolume(const VoxelGenerateRequest& req) {
|
||||||
|
const std::string id = createVolume(fromRequest(req), req.name); // 复用 mock 存储 + 惰性插值
|
||||||
|
if (auto it = volumes_.find(id); it != volumes_.end()) it->second.request = req;
|
||||||
|
qInfo().noquote() << "[volreq] createVolume 请求体:"
|
||||||
|
<< QJsonDocument(req.toJson()).toJson(QJsonDocument::Compact);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VoxelGenerateRequest* Api3dRepository::lastVoxelRequest(const std::string& dsId) const {
|
||||||
|
const auto it = volumes_.find(dsId);
|
||||||
|
return (it != volumes_.end() && it->second.request) ? &*it->second.request : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<DsRow> Api3dRepository::volumeRows() const {
|
std::vector<DsRow> Api3dRepository::volumeRows() const {
|
||||||
std::vector<DsRow> rows;
|
std::vector<DsRow> rows;
|
||||||
rows.reserve(volumes_.size());
|
rows.reserve(volumes_.size());
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "dto/Vtk3dRequests.hpp"
|
||||||
#include "geo/GeoLocalFrame.hpp"
|
#include "geo/GeoLocalFrame.hpp"
|
||||||
#include "repo/I3dSceneRepository.hpp"
|
#include "repo/I3dSceneRepository.hpp"
|
||||||
#include "repo/VolumeBuildParams.hpp"
|
#include "repo/VolumeBuildParams.hpp"
|
||||||
|
|
@ -39,6 +40,10 @@ public:
|
||||||
// ── 客户端创建三维体(mock 持久化:内存;端点就绪后换实现)──────────────────
|
// ── 客户端创建三维体(mock 持久化:内存;端点就绪后换实现)──────────────────
|
||||||
// 登记新三维体(仅存参数,不立即插值)→ 返回新 dsId("vol-N")。插值在首次 loadVolume 惰性做并缓存。
|
// 登记新三维体(仅存参数,不立即插值)→ 返回新 dsId("vol-N")。插值在首次 loadVolume 惰性做并缓存。
|
||||||
std::string createVolume(VolumeBuildParams params, const std::string& name);
|
std::string createVolume(VolumeBuildParams params, const std::string& name);
|
||||||
|
// 请求体形态创建:组装真实 VoxelGenerateRequest → 派生 params 存储 + 打印请求体 JSON(供后端联调)。
|
||||||
|
std::string createVolume(const VoxelGenerateRequest& req);
|
||||||
|
// 取回某三维体组装的请求体(测试/联调);非本 repo 创建或无 request 时返回 nullptr。
|
||||||
|
const VoxelGenerateRequest* lastVoxelRequest(const std::string& dsId) const;
|
||||||
// 已创建三维体的列表行(ddCode="dd_voxel"),供三维分析栏合并注入(每次 setDatasets 追加)。
|
// 已创建三维体的列表行(ddCode="dd_voxel"),供三维分析栏合并注入(每次 setDatasets 追加)。
|
||||||
std::vector<DsRow> volumeRows() const;
|
std::vector<DsRow> volumeRows() const;
|
||||||
|
|
||||||
|
|
@ -116,6 +121,7 @@ private:
|
||||||
std::optional<VolumeGrid> cachedGrid;
|
std::optional<VolumeGrid> cachedGrid;
|
||||||
core::ColorScale cachedScale; // 与 cachedGrid 同时填(源剖面色阶)
|
core::ColorScale cachedScale; // 与 cachedGrid 同时填(源剖面色阶)
|
||||||
std::optional<std::size_t> pointCount; // 聚合散点数(finalizeVolume 时持久化,详情统计用)
|
std::optional<std::size_t> pointCount; // 聚合散点数(finalizeVolume 时持久化,详情统计用)
|
||||||
|
std::optional<VoxelGenerateRequest> request; // 组装的真实请求体(createVolume(req) 路径填充)
|
||||||
};
|
};
|
||||||
std::map<std::string, StoredVolume> volumes_; // dsId → 体
|
std::map<std::string, StoredVolume> volumes_; // dsId → 体
|
||||||
int volumeCounter_ = 0;
|
int volumeCounter_ = 0;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,19 @@ QJsonObject VoxelGenerateRequest::toJson() const {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VolumeBuildParams fromRequest(const VoxelGenerateRequest& req) {
|
||||||
|
VolumeBuildParams p;
|
||||||
|
p.sourceDatasetIds = req.sourceDatasetIds;
|
||||||
|
p.interpModel = (req.interpModel == "Kriging") ? VolumeBuildParams::Model::Kriging
|
||||||
|
: VolumeBuildParams::Model::Idw;
|
||||||
|
p.cellXY = req.cellXY;
|
||||||
|
p.cellZ = req.cellZ;
|
||||||
|
p.power = req.power;
|
||||||
|
p.maxDist = req.maxDist;
|
||||||
|
p.colorScaleId = req.colorScaleId;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonObject SliceGenerateRequest::toJson() const {
|
QJsonObject SliceGenerateRequest::toJson() const {
|
||||||
QJsonObject o{
|
QJsonObject o{
|
||||||
{"projectId", qs(projectId)},
|
{"projectId", qs(projectId)},
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include "repo/VolumeBuildParams.hpp"
|
||||||
|
|
||||||
namespace geopro::data {
|
namespace geopro::data {
|
||||||
|
|
||||||
|
|
@ -32,4 +33,7 @@ struct SliceGenerateRequest {
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// VoxelGenerateRequest → VolumeBuildParams(客户端插值用;interpModel 字符串→enum)。
|
||||||
|
VolumeBuildParams fromRequest(const VoxelGenerateRequest& req);
|
||||||
|
|
||||||
} // namespace geopro::data
|
} // namespace geopro::data
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,30 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include "dto/Vtk3dRequests.hpp"
|
#include "dto/Vtk3dRequests.hpp"
|
||||||
|
#include "repo/VolumeBuildParams.hpp"
|
||||||
using namespace geopro::data;
|
using namespace geopro::data;
|
||||||
|
|
||||||
|
TEST(Vtk3dRequests, VolumeBuildParamsFromRequest) {
|
||||||
|
VoxelGenerateRequest q;
|
||||||
|
q.sourceDatasetIds = {"d1"};
|
||||||
|
q.cellXY = 2.0;
|
||||||
|
q.power = 3.0;
|
||||||
|
q.colorScaleId = "cs1";
|
||||||
|
q.interpModel = "Kriging";
|
||||||
|
const auto p = fromRequest(q);
|
||||||
|
ASSERT_EQ(p.sourceDatasetIds.size(), 1u);
|
||||||
|
EXPECT_EQ(p.sourceDatasetIds[0], "d1");
|
||||||
|
EXPECT_DOUBLE_EQ(p.cellXY, 2.0);
|
||||||
|
EXPECT_DOUBLE_EQ(p.power, 3.0);
|
||||||
|
EXPECT_EQ(p.colorScaleId, "cs1");
|
||||||
|
EXPECT_EQ(p.interpModel, VolumeBuildParams::Model::Kriging);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Vtk3dRequests, FromRequestDefaultsToIdw) {
|
||||||
|
VoxelGenerateRequest q; // interpModel 默认 "Idw"
|
||||||
|
EXPECT_EQ(fromRequest(q).interpModel, VolumeBuildParams::Model::Idw);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Vtk3dRequests, VoxelToJsonMatchesContract) {
|
TEST(Vtk3dRequests, VoxelToJsonMatchesContract) {
|
||||||
VoxelGenerateRequest q;
|
VoxelGenerateRequest q;
|
||||||
q.projectId = "p1"; q.structParentId = "g1"; q.structParentConfType = 1;
|
q.projectId = "p1"; q.structParentId = "g1"; q.structParentConfType = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue