### P1.x 内核对齐(P1 遗留收口)
- 原生 .vde 序列化(serializer/vde_format/vde_text)迁入内核 vde_brep;C API 序列化回迁 vde_kernel_capi;
PMI/MBD 拆为内核数据模型(vde_brep)+ 3D-PDF 导出(vde_io/pmi_export.cpp),消除 kernel→io 反向依赖;
- make_geometry_host_services() 迁入内核 vde_brep,kernel-only 下 PluginManager+宿主服务可用;
- kernel-only 约 40 个测试 target + 4 个 examples 门控;六业务 OFF 的 2 个测试 target 门控;
- vde_version() 返回 0.5.0 既有缺陷修复;kernel SDK consumer 实测 1.0.47;
### P2-1 vde_cae 官方模块
- include/vde/cae/*、src/cae/*、tests/cae/*;旧路径转发头兼容;VDE_BUILD_CAE 开关;
- vde_io 移除 fea_mesh/fluid_domain;ctest 用例数保持(95 项 CAE 测试);CAE=OFF 构建 937/937;
### P2-2 插件 ABI 1.2:CAE solver / CAM strategy 扩展点
- VdeCaeSolverPlugin/VdeCamStrategyPlugin + Registration 尾部扩展(旧插件兼容);
- PluginManager cae_solvers()/cam_strategies()/solve_cae()/invoke_cam(),加载校验/失败隔离;
- plugins/sample_cae、sample_cam_post、abi11_compat、external/{runner,sample_stl_converter};
- docs/design/vde-service-protocol.md 进程外服务协议草案;test_plugin_extensions 9/9;
### VDE-1249 三阻塞修复
- fix1 共享边采样性能悬崖:sagitta 自适应段数 + 自由曲面证据触发 + fast planar loop 256 + IncrementalMesher 复用 mesh_face_diag;
box+16 孔 legacy 3.3-3.6s→69.5ms、rebuild 4095→103ms;box+25 孔 5.1s→190.9ms;n42 链 ≤222ms;open=0/面积体积正确;
- fix2 fillet/blend 破损体护栏(fillet_edges_checked:watertight/dangling 护栏 + heal 重试 + 显式失败/诊断;
静默 no-op success → 显式失败)+ delete_face_with_heal/fill_hole 边环重排(26 面盒 0/26→6/6,box 2/6→6/6);
- fix3 wireframe tight payload:WireframeOptions.include_segment_info + C API VdeWireframeOptions 尾扩展 +
vde_body_to_wireframe_opt2(旧 ABI 安全);tight≈49-61% full(与 1.0.12 旧风格差 4B/段);
### 工程
- 修复 .gitignore `*.txt` 误伤:`!CMakeLists.txt`,把 plugins/**、tools/、tests/plugin、tests/cae 等漏入库的
CMakeLists.txt 纳入版本库(保证干净 checkout 可构建);
- 版本 1.0.47(CMake/version.h/test_version/README/docs index/module-manual 同步);
验证:全量构建 0 error(334 targets);全量 ctest 7395 注册、7300/7300 PASS(0 failed,24 skipped,194.39s);
kernel-only(-DVDE_BUILD_IO=OFF + BUILD_TESTS=ON)全量构建 0 failed、plugin 30/12 + capi_split 7 全绿;
六业务 OFF 全量测试构建 0 failed;CAE 95/95;插件 ctest 61/61;VDE-1249 repro 前后数字见 CHANGELOG。
215 lines
8.5 KiB
C++
215 lines
8.5 KiB
C++
/**
|
||
* @file test_vde1249_wireframe_payload.cpp
|
||
* @brief VDE-1249-fix3:wireframe tight payload(逐段分类/元数据可关)回归与度量
|
||
*
|
||
* 覆盖:
|
||
* - 默认(full)与 include_segment_info=false(tight)两档段几何完全一致;
|
||
* - tight 档 segment_info 为空、classified=false,payload 字节按预期减少;
|
||
* - box / box+hole / box+16holes / 圆角(fillet) 体 的 tight/full 段数与字节度量。
|
||
*/
|
||
#include <gtest/gtest.h>
|
||
|
||
#include "vde/brep/brep.h"
|
||
#include "vde/brep/modeling.h"
|
||
#include "vde/mesh/display_mesh.h"
|
||
|
||
#include <cstdio>
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
namespace {
|
||
|
||
using vde::brep::BrepModel;
|
||
using vde::brep::HoleSpec;
|
||
using vde::brep::Point3D;
|
||
using vde::brep::Vector3D;
|
||
using vde::mesh::build_wireframe;
|
||
using vde::mesh::Wireframe;
|
||
using vde::mesh::WireframeEdgeClass;
|
||
using vde::mesh::WireframeOptions;
|
||
using vde::mesh::wireframe_payload_bytes;
|
||
|
||
BrepModel make_box() { return vde::brep::make_box(60.0, 60.0, 20.0); }
|
||
|
||
BrepModel make_box_with_hole() {
|
||
HoleSpec spec;
|
||
spec.diameter = 10.0;
|
||
spec.depth = 0.0; // 通孔
|
||
return vde::brep::make_hole(make_box(), Point3D(0.0, 0.0, 10.0),
|
||
Vector3D(0.0, 0.0, -1.0), spec);
|
||
}
|
||
|
||
BrepModel make_box_with_16_holes() {
|
||
HoleSpec spec;
|
||
spec.diameter = 4.0;
|
||
spec.depth = 0.0;
|
||
BrepModel body = make_box();
|
||
for (int iy = 0; iy < 4; ++iy) {
|
||
for (int ix = 0; ix < 4; ++ix) {
|
||
const double x = -22.5 + ix * 15.0;
|
||
const double y = -22.5 + iy * 15.0;
|
||
body = vde::brep::make_hole(body, Point3D(x, y, 10.0),
|
||
Vector3D(0.0, 0.0, -1.0), spec);
|
||
}
|
||
}
|
||
return body;
|
||
}
|
||
|
||
BrepModel make_rounded_box() {
|
||
BrepModel box = make_box();
|
||
const std::vector<int> sharp = box.sharp_edges(30.0);
|
||
return vde::brep::fillet_edges(box, sharp,
|
||
std::vector<double>(sharp.size(), 2.0));
|
||
}
|
||
|
||
/// payload 字节统计(与 GPU 上传裸数组口径一致)
|
||
struct PayloadStats {
|
||
size_t points = 0;
|
||
size_t segments = 0;
|
||
size_t geometric_bytes = 0; // positions + segments
|
||
size_t old_style_bytes = 0; // + segment_edge_id(1.0.12 VdeWireframe 风格)
|
||
size_t tight_bytes = 0; // 仅几何(VDE-1249-fix3 tight)
|
||
size_t full_bytes = 0; // + segment_info(VDE-1235 #4/1239 §4 全量)
|
||
};
|
||
|
||
PayloadStats stats_of(const Wireframe& full, const Wireframe& tight) {
|
||
PayloadStats s;
|
||
s.points = full.positions.size();
|
||
s.segments = full.segments.size();
|
||
s.geometric_bytes = s.points * 3 * sizeof(double) +
|
||
s.segments * 2 * sizeof(std::uint32_t);
|
||
s.tight_bytes = wireframe_payload_bytes(tight, /*include_metadata=*/false);
|
||
s.old_style_bytes = s.geometric_bytes +
|
||
full.segment_edge_id.size() * sizeof(std::int32_t);
|
||
s.full_bytes = wireframe_payload_bytes(full, /*include_metadata=*/true);
|
||
return s;
|
||
}
|
||
|
||
void print_stats(const char* name, const PayloadStats& s) {
|
||
const double ratio =
|
||
s.full_bytes ? 100.0 * static_cast<double>(s.tight_bytes) /
|
||
static_cast<double>(s.full_bytes)
|
||
: 0.0;
|
||
std::printf(
|
||
"[VDE-1249-fix3] %-18s points=%zu segments=%zu geo=%zuB old=%zuB "
|
||
"full=%zuB tight=%zuB tight/full=%.1f%%\n",
|
||
name, s.points, s.segments, s.geometric_bytes, s.old_style_bytes,
|
||
s.full_bytes, s.tight_bytes, ratio);
|
||
}
|
||
|
||
void expect_same_geometry(const Wireframe& a, const Wireframe& b) {
|
||
ASSERT_EQ(a.positions.size(), b.positions.size());
|
||
ASSERT_EQ(a.segments.size(), b.segments.size());
|
||
ASSERT_EQ(a.segment_edge_id.size(), b.segment_edge_id.size());
|
||
for (size_t i = 0; i < a.positions.size(); ++i) {
|
||
EXPECT_DOUBLE_EQ(a.positions[i].x(), b.positions[i].x());
|
||
EXPECT_DOUBLE_EQ(a.positions[i].y(), b.positions[i].y());
|
||
EXPECT_DOUBLE_EQ(a.positions[i].z(), b.positions[i].z());
|
||
}
|
||
for (size_t i = 0; i < a.segments.size(); ++i) {
|
||
EXPECT_EQ(a.segments[i][0], b.segments[i][0]);
|
||
EXPECT_EQ(a.segments[i][1], b.segments[i][1]);
|
||
EXPECT_EQ(a.segment_edge_id[i], b.segment_edge_id[i]);
|
||
}
|
||
EXPECT_EQ(a.num_input_segments, b.num_input_segments);
|
||
EXPECT_EQ(a.num_duplicate_removed, b.num_duplicate_removed);
|
||
EXPECT_EQ(a.num_short_filtered, b.num_short_filtered);
|
||
}
|
||
|
||
} // namespace
|
||
|
||
TEST(VDE1249WireframePayload, TightAndFullGeometryIdentical) {
|
||
const std::vector<std::pair<const char*, BrepModel>> fixtures{
|
||
{"box", make_box()},
|
||
{"box+hole", make_box_with_hole()},
|
||
{"box+16holes", make_box_with_16_holes()},
|
||
{"rounded_box", make_rounded_box()},
|
||
};
|
||
for (const auto& [name, body] : fixtures) {
|
||
SCOPED_TRACE(name);
|
||
WireframeOptions full_opt;
|
||
const Wireframe full = build_wireframe(body, full_opt);
|
||
WireframeOptions tight_opt;
|
||
tight_opt.include_segment_info = false;
|
||
const Wireframe tight = build_wireframe(body, tight_opt);
|
||
|
||
ASSERT_FALSE(full.segments.empty());
|
||
expect_same_geometry(full, tight);
|
||
|
||
// full:逐段分类字段齐全
|
||
EXPECT_TRUE(full.classified);
|
||
EXPECT_EQ(full.segment_info.size(), full.segments.size());
|
||
EXPECT_GT(full.num_segments_of_class(WireframeEdgeClass::Crease) +
|
||
full.num_segments_of_class(WireframeEdgeClass::Tangent) +
|
||
full.num_segments_of_class(WireframeEdgeClass::Boundary) +
|
||
full.num_segments_of_class(WireframeEdgeClass::Unknown),
|
||
0u);
|
||
// tight:无逐段元数据
|
||
EXPECT_FALSE(tight.classified);
|
||
EXPECT_TRUE(tight.segment_info.empty());
|
||
EXPECT_EQ(tight.num_segments_of_class(WireframeEdgeClass::Crease), 0u);
|
||
EXPECT_FALSE(tight.all_crease());
|
||
}
|
||
}
|
||
|
||
TEST(VDE1249WireframePayload, ByteReductionAndMeasurement) {
|
||
const std::vector<std::pair<const char*, BrepModel>> fixtures{
|
||
{"box", make_box()},
|
||
{"box+hole", make_box_with_hole()},
|
||
{"box+16holes", make_box_with_16_holes()},
|
||
{"rounded_box", make_rounded_box()},
|
||
};
|
||
for (const auto& [name, body] : fixtures) {
|
||
SCOPED_TRACE(name);
|
||
const Wireframe full = build_wireframe(body, WireframeOptions{});
|
||
WireframeOptions tight_opt;
|
||
tight_opt.include_segment_info = false;
|
||
const Wireframe tight = build_wireframe(body, tight_opt);
|
||
const PayloadStats s = stats_of(full, tight);
|
||
print_stats(name, s);
|
||
|
||
ASSERT_GT(s.segments, 0u);
|
||
// tight(仅几何)严格小于 full(几何+ids+info)
|
||
EXPECT_LT(s.tight_bytes, s.full_bytes);
|
||
EXPECT_LT(s.tight_bytes, s.old_style_bytes);
|
||
// tight 字节 = 几何字节(helper 口径一致性)
|
||
EXPECT_EQ(s.tight_bytes, s.geometric_bytes);
|
||
// full = 几何 + ids + segment_info
|
||
EXPECT_EQ(s.full_bytes,
|
||
s.geometric_bytes + s.segments * sizeof(std::int32_t) +
|
||
s.segments * sizeof(vde::mesh::WireframeSegmentInfo));
|
||
// 关闭分类后至少省下 segment_info 的 24B/段:相对 full 减少 ≥20%
|
||
EXPECT_LE(s.tight_bytes, s.full_bytes * 4 / 5);
|
||
// tight 相对 1.0.12 风格(几何+edge ids)仅少 ids(4B/段)
|
||
EXPECT_EQ(s.tight_bytes + s.segments * sizeof(std::int32_t),
|
||
s.old_style_bytes);
|
||
}
|
||
}
|
||
|
||
TEST(VDE1249WireframePayload, PayloadHelperMatchesFields) {
|
||
const BrepModel body = make_box_with_hole();
|
||
const Wireframe wf = build_wireframe(body, WireframeOptions{});
|
||
const size_t geo = wf.positions.size() * 3 * sizeof(double) +
|
||
wf.segments.size() * 2 * sizeof(std::uint32_t);
|
||
EXPECT_EQ(wireframe_payload_bytes(wf, true),
|
||
geo + wf.segment_edge_id.size() * sizeof(std::int32_t) +
|
||
wf.segment_info.size() * sizeof(vde::mesh::WireframeSegmentInfo));
|
||
EXPECT_EQ(wireframe_payload_bytes(wf, false), geo);
|
||
}
|
||
|
||
TEST(VDE1249WireframePayload, BoxClassificationSemanticsUnchanged) {
|
||
// 默认 full 档 box 全部为锐边(旧行为不变);tight 档不输出分类
|
||
const BrepModel box = make_box();
|
||
const Wireframe full = build_wireframe(box, WireframeOptions{});
|
||
EXPECT_TRUE(full.classified);
|
||
EXPECT_TRUE(full.all_crease());
|
||
EXPECT_EQ(full.num_segments_of_class(WireframeEdgeClass::Crease),
|
||
full.segments.size());
|
||
|
||
WireframeOptions tight_opt;
|
||
tight_opt.include_segment_info = false;
|
||
const Wireframe tight = build_wireframe(box, tight_opt);
|
||
EXPECT_FALSE(tight.classified);
|
||
EXPECT_FALSE(tight.all_crease());
|
||
}
|