feat(v11): CI/CD + regression tests + fuzzing + benchmarks + code quality
CI / Build & Test (push) Failing after 41s
CI / Release Build (push) Failing after 30s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled

v11.1 — Test Infrastructure (14 files):
- .github/workflows/ci.yml: Ubuntu 22.04 + GCC 11, auto ctest on push
- tests/regression/: degenerate geometry, extreme coords, thin wall, large models
- tests/fuzz/: SDF random CSG, random booleans, format round-trip, continuous mode
- tests/benchmark/: boolean perf, MC perf, IO perf benchmarks
- docs/benchmark-report.md: benchmark template

v11.2 — Code Quality + Docs:
- .clang-tidy: 15 check categories, 22 exclusions
- .github/workflows/static-analysis.yml: clang-tidy CI scan
- CODEOWNERS, SECURITY.md
- docs: API overview, testing guide, contributing guide
- README: module capability overview table

Pending: binary formats + curve projection (retrying)
This commit is contained in:
茂之钳
2026-07-27 01:10:58 +08:00
parent 97ee97057b
commit 7b76689ea1
30 changed files with 4318 additions and 577 deletions
+60
View File
@@ -81,4 +81,64 @@ struct TrimmedSurface {
double u0, double u1, double v0, double v1);
};
// ═══════════════════════════════════════════════════════════════
// 曲面偏移
// ═══════════════════════════════════════════════════════════════
/// 自交区域描述
struct SelfIntersectionRegion {
std::pair<double, double> u_range; ///< 自交区域在 u 参数方向的范围
std::pair<double, double> v_range; ///< 自交区域在 v 参数方向的范围
std::string intersection_type; ///< "overlap" 或 "tangent_crossing"
};
/// 曲面偏移结果
struct OffsetResult {
curves::NurbsSurface offset_surface; ///< 偏移后的曲面
bool has_self_intersection = false; ///< 是否检测到自交
std::vector<SelfIntersectionRegion> self_intersection_regions; ///< 自交区域
TrimmedSurface offset_trimmed; ///< 自动裁剪后的偏移曲面
};
/**
* @brief 沿法向偏移曲面
*
* 使用控制点偏移法(Greville 横坐标评估法向)构造偏移曲面。
* 这是工业中 Parasolid/ACIS 的常用近似方法,精确偏移仅对可展曲面成立。
*
* 自动检测自交区域并构建裁剪曲面。
*
* @param surface 原始 NURBS 曲面
* @param distance 偏移距离(正 = 法向正方向,负 = 反向)
* @return OffsetResult 包含偏移曲面 + 自交信息 + 裁剪曲面
*/
[[nodiscard]] OffsetResult offset_surface(
const curves::NurbsSurface& surface, double distance);
/**
* @brief 检测曲面自交区域
*
* 通过网格采样 + 空间哈希检测参数域中不同位置映射到
* 同一 3D 空间的区域。
*
* @param surface 待检测曲面
* @param grid_res 采样网格分辨率(默认 50)
* @return 自交区域列表
*/
[[nodiscard]] std::vector<SelfIntersectionRegion> detect_self_intersections(
const curves::NurbsSurface& surface, int grid_res = 50);
/**
* @brief 从裁剪曲面中移除自交区域
*
* 将检测到的自交区域作为内部孔洞裁剪掉。
*
* @param ts 原始裁剪曲面
* @param regions 自交区域列表
* @return 移除自交区域后的裁剪曲面
*/
[[nodiscard]] TrimmedSurface trim_self_intersections(
const TrimmedSurface& ts,
const std::vector<SelfIntersectionRegion>& regions);
} // namespace vde::brep
@@ -0,0 +1,86 @@
#pragma once
#include "vde/curves/nurbs_curve.h"
#include "vde/curves/nurbs_surface.h"
#include "vde/core/point.h"
#include <utility>
#include <vector>
namespace vde::curves {
/** @defgroup curves_projection 曲线-曲面投影
* @brief 将 3D 点/曲线投影到 NURBS 曲面上
*
* 核心能力:
* - project_point_on_surface: 点到曲面最近点投影,返回 (u,v) 参数
* - project_curve_on_surface: 空间曲线 → 参数空间 p-curve
* - evaluate_pcurve_on_surface: p-curve → 3D 点序列
*
* 这些能力是布尔运算、拓扑修复、面分割等功能的基础依赖。
* @ingroup curves
*/
/**
* @brief 将 3D 点投影到 NURBS 曲面上
*
* 使用多起点 Newton-Raphson 迭代求点面最近点。
* 算法:全局网格搜索 → 局部 Newton 精化 → 多起点验证。
*
* @param point 要投影的 3D 点
* @param surface 目标 NURBS 曲面
* @return (u, v) 参数对 —— 曲面上离 point 最近的点
*
* @note 对复杂曲面(高曲率、多极值),使用 6 个种子点增加鲁棒性
*/
[[nodiscard]] std::pair<double, double> project_point_on_surface(
const core::Point3D& point, const NurbsSurface& surface);
/**
* @brief 将空间曲线投影到曲面上,生成参数空间 p-curve
*
* 均匀采样曲线点 → 逐点投影 → 构建 NURBS p-curve。
* p-curve 的控制点是 (u, v, 0),只有 X/Y 有意义,
* Z 坐标在 p-curve 中被忽略。
*
* @param curve 待投影的空间 NURBS 曲线
* @param surface 目标曲面
* @param samples 采样点数(默认 50
* @return 参数空间中的 NURBS 曲线(p-curve
*/
[[nodiscard]] NurbsCurve project_curve_on_surface(
const NurbsCurve& curve,
const NurbsSurface& surface,
int samples = 50);
/**
* @brief 带弦高容差的自适应曲线投影
*
* 递归细分确保投影误差 ≤ chord_tolerance。
* 仅在曲线曲率大的区域增加采样点。
*
* @param curve 待投影的空间曲线
* @param surface 目标曲面
* @param chord_tolerance 弦高容差
* @return 参数空间 p-curve
*/
[[nodiscard]] NurbsCurve project_curve_on_surface_adaptive(
const NurbsCurve& curve,
const NurbsSurface& surface,
double chord_tolerance = 0.001);
/**
* @brief 沿 p-curve 采样并评估 3D 点
*
* 在 p-curve 上均匀采样,将每个 (u,v) 参数映射回曲面上的 3D 点。
* 用于验证投影精度。
*
* @param pcurve 参数空间 p-curve
* @param surface 曲面
* @param num_samples 采样数
* @return 曲面上沿投影曲线分布的 3D 点序列
*/
[[nodiscard]] std::vector<core::Point3D> evaluate_pcurve_on_surface(
const NurbsCurve& pcurve,
const NurbsSurface& surface,
int num_samples = 50);
} // namespace vde::curves
@@ -116,6 +116,14 @@ enum class ParasolidFormat {
*/
void export_parasolid_xt(const brep::BrepModel& body, const std::string& path);
/**
* @brief 将 B-Rep 模型导出为 Parasolid XT 二进制格式
*
* @param body B-Rep 模型
* @param path 输出 XB 文件路径 (.x_b)
*/
void export_parasolid_xt_binary(const brep::BrepModel& body, const std::string& path);
// ═══════════════════════════════════════════════════════════════
// ACIS SAT
// ═══════════════════════════════════════════════════════════════