Files
KCP Wave7 W43 fec4cda4db test(coverage): W43 core-plus profile + 19 critical-path tests
- add core-plus coverage profile (59 targets: core 41 + 18 IO/serialization + 3 new)
- measured line coverage 54.09% (67146/124129, gate 40%), func 61.14%, branch 33.94%
- foundation module 0.00% -> 73.49% via IO/serializer targets already linked in vde
- new tests: foundation BinarySerializer roundtrip (7), brep boolean+heal (8), curves SSI (4)
- update baseline.json core-plus entry via --update-baseline (measured only)
- nightly.yml: core-plus report-only archive + opt-in baseline hard gate
- pr-quality.yml: core-plus --dry-run profile plan
- exclude test_curved_boolean_baseline from core-plus (3 instrumentation-sensitive
  wall-clock CBRA chain-budget cases; W31 precedent, documented in cov-notes)
- notes: docs/planning/wave7/cov-notes.md
2026-11-20 12:13:47 +08:00

102 lines
4.0 KiB
C++
Raw Permalink 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.
// KCP-1.0 Wave 7 / W43 (task-117):core-plus 覆盖率补齐
// 目标:curves 曲面求交(SSI)主路径 —— 平面/圆柱截交、平面-平面交线、
// 无交快路径;不改变产品代码。
#include <gtest/gtest.h>
#include "vde/core/plane.h"
#include "vde/curves/nurbs_surface.h"
#include "vde/curves/surface_intersection.h"
#include <cmath>
using namespace vde::curves;
using vde::core::Point3D;
using vde::core::Vector3D;
namespace {
/// 单位正方形平面(z=0,[0,1]x[0,1])。
NurbsSurface make_plane_xy() {
return NurbsSurface({{Point3D(0, 0, 0), Point3D(0, 1, 0)},
{Point3D(1, 0, 0), Point3D(1, 1, 0)}},
{0, 0, 1, 1}, {0, 0, 1, 1}, {}, 1, 1);
}
/// X 轴倾斜平面(绕 X 轴旋转 angle_rad 的 [0,1]x[0,1] 平面)。
NurbsSurface make_tilted_plane(double angle_rad) {
const double c = std::cos(angle_rad);
const double s = std::sin(angle_rad);
return NurbsSurface({{Point3D(0, 0, 0), Point3D(0, c, s)},
{Point3D(1, 0, 0), Point3D(1, c, s)}},
{0, 0, 1, 1}, {0, 0, 1, 1}, {}, 1, 1);
}
/// 半径 1、高 2、沿 Z 轴居中的 NURBS 圆柱面(u 方向 degree 2,v 方向 degree 1)。
NurbsSurface make_cylinder(double radius = 1.0, double height = 2.0) {
const double hh = height * 0.5;
const double r = radius;
const double w = std::sqrt(2.0) / 2.0;
const std::vector<Point3D> circle_bottom = {
{r, 0, -hh}, {r, r, -hh}, {0, r, -hh}, {-r, r, -hh}, {-r, 0, -hh},
{-r, -r, -hh}, {0, -r, -hh}, {r, -r, -hh}, {r, 0, -hh}};
const std::vector<Point3D> circle_top = {
{r, 0, hh}, {r, r, hh}, {0, r, hh}, {-r, r, hh}, {-r, 0, hh},
{-r, -r, hh}, {0, -r, hh}, {r, -r, hh}, {r, 0, hh}};
const std::vector<double> u_weights = {1, w, 1, w, 1, w, 1, w, 1};
std::vector<std::vector<Point3D>> grid;
std::vector<std::vector<double>> weights;
for (int i = 0; i < 9; ++i) {
grid.push_back({circle_bottom[i], circle_top[i]});
weights.push_back({u_weights[i], u_weights[i]});
}
return NurbsSurface(grid,
{0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1},
{0, 0, 1, 1}, weights, 2, 1);
}
} // namespace
// 水平中截面 z=0 与圆柱求交:应得到至少一条闭合截交线,且点都在 z=0 平面。
TEST(CovCurvesSsi, PlaneCylinderMidSection) {
auto cyl = make_cylinder(1.0, 2.0);
auto curves = intersect_plane_surface(cyl, Point3D(0, 0, 0), Vector3D(0, 0, 1), 32);
ASSERT_GE(curves.size(), 1u);
ASSERT_GE(curves[0].points.size(), 8u);
for (const auto& p : curves[0].points) {
EXPECT_NEAR(p.z(), 0.0, 1e-6);
}
}
// z=0.5 偏置截面与圆柱求交:仍有截交线,且所有点 z=0.5。
TEST(CovCurvesSsi, PlaneCylinderOffsetSection) {
auto cyl = make_cylinder(1.0, 2.0);
auto curves = intersect_plane_surface(cyl, Point3D(0, 0, 0.5), Vector3D(0, 0, 1), 32);
ASSERT_GE(curves.size(), 1u);
ASSERT_GE(curves[0].points.size(), 8u);
for (const auto& p : curves[0].points) {
EXPECT_NEAR(p.z(), 0.5, 1e-6);
}
}
// z=3 平面完全在圆柱之上:无交。
TEST(CovCurvesSsi, PlaneAboveCylinderNoIntersection) {
auto cyl = make_cylinder(1.0, 2.0);
auto curves = intersect_plane_surface(cyl, Point3D(0, 0, 3.0), Vector3D(0, 0, 1), 16);
EXPECT_TRUE(curves.empty());
}
// 平面-倾斜平面求交:应至少得到一条交线(交线落在 z=0 平面的 y 轴方向约束内)。
TEST(CovCurvesSsi, TwoPlanesIntersectNonEmpty) {
auto p1 = make_plane_xy();
auto p2 = make_tilted_plane(0.5);
auto curves = intersect_surfaces(p1, p2, 8, 1e-4);
ASSERT_GE(curves.size(), 1u);
EXPECT_GE(curves[0].points.size(), 2u);
for (const auto& p : curves[0].points) {
// 交线同时位于 z=0 平面(p1):y*sin+0 关系下 p1 上点 z 必为 0,
// 且 p2 上点必须满足 z = y*tan(0.5) 的比例关系(用容差放宽采样误差)。
EXPECT_NEAR(p.z(), p.y() * std::tan(0.5), 1e-2);
}
}