Files
hm 0d9108cd2a
Build & Test / build-and-test (push) Canceled after 0s
VDE Build & Test / build-and-test (push) Canceled after 0s
Build & Test / python-bindings (push) Canceled after 0s
feat: bridge TU 迁移 + cam/cae/ui/pdm 模块包 + 容器沙箱 + largeMesh 修复 + scaffold/远程索引(1.0.74)
### 宿主复测闭环
- VDE-1249/VDE-1250 标记 Fixed(宿主 1.0.68 复测记录:0 error、13,030/0 ctest、n42 82s、n49/n50/n60、save-load match=1);
- VDE-1251(dense pattern,1.0.72 修复)待宿主复测;

### P3-15c ui/pdm bridge TU 迁移
- geometric_snap/snap_ext→vde_ui、structural_profiles→vde_pdm;规范头 + 旧 brep 兼容转发头(不进 kernel SDK);
- check_kernel_boundary allowlist 清零;默认 build 0 error、定向 170/170、kernel-only 971 步 0 undefined;

### P3-15d/e 模块包
- 新增 vde-cam/vde-cae/vde-ui/vde-pdm 包(共 8 个模块包);独立 consumer:
  CAM_CONSUMER_PASS segments=1006 gcode=1011、CAE_CONSUMER_PASS tet=384 patches=6、
  UI_CONSUMER_PASS layouts=4 picked=1、PDM_CONSUMER_PASS materials=21 profiles=32 bom=1;
- 默认构建/聚合不变;docs module-packaging-split §7.1/§7.2;剩余 assembly/PMI/钣金;

### P3-14c 外部服务容器运行时抽象
- sandbox.container{runtime auto|docker|podman,image,network,read_only};argv 构造 docker/podman run(仅挂载 workdir、
  --network none、--read-only/tmpfs、env 白名单、超时/失败清理);无 runtime 默认 unsupported_sandbox,allow_unsandboxed 降级;
- fake runtime 测试 5/5;docs §7.3/§12.9;真实 docker e2e 需环境;

### P3-16c largeMesh O(F²) 修复
- display_conforming_patch 每体一次统计 sphere 面数;8192 面球 >600s→~2s(261k tris、deg/open/zeroArea=0);
- degenerate_triangles 语义澄清 + 回退场景用 B-Rep wireframe 的宿主指引;test_vde1250_large_mesh 3/3;

### P3-17 插件 SDK scaffold + 远程索引
- tool scaffold 四类模板(独立 build/--check/--list PASS)+ --fetch-index(本地/http WinHTTP,签名/路径/ABI/哈希校验);

### 工程
- 版本 1.0.74;全量构建 0 error(375 targets);全量 ctest 7540 注册、7445/7445 PASS(0 failed,25 skipped,224.07s)。
2026-10-29 08:20:26 +08:00

158 lines
6.5 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.
#pragma once
/**
* @file snap_ext.h
* @brief VDE-333 补齐:批量吸附(batch_snap)与网格吸附(grid_snap)
*
* 既有 `snap_to_geometry`(geometric_snap.h)对单个实体求最近吸附点;
* 本头文件补上提案要求的 `batch_snap`(多实体全局最近)与 `grid_snap`
* (吸附到规则网格)。
*
* @ingroup brep
*/
#include "vde/brep/brep.h"
#include "vde_ui/geometric_snap.h"
#include "vde/core/point.h"
#include <functional>
#include <vector>
namespace vde::brep {
// ═══════════════════════════════════════════════
// VDE-333 §1: 实时光标捕捉(Live Cursor Snap)
// ═══════════════════════════════════════════════
/**
* @brief 实时捕捉配置
*
* 供交互拖动/草图过程中每帧调用 `live_snap` 使用。
*/
struct LiveSnapConfig {
SnapType types = SnapType::All; ///< 生效的捕捉类型
double tolerance = 15.0; ///< 捕捉容差(世界单位)
double aperture_size = 10.0; ///< 捕捉孔径(世界单位;≤0 时退回 tolerance)
bool show_indicator = true; ///< 是否显示捕捉指示线(UI 提示,不参与几何)
bool show_tooltip = true; ///< 是否显示捕捉类型提示(UI 提示,不参与几何)
bool sticky_snap = true; ///< 粘滞捕捉:优先保持上一帧目标,避免抖动
double sticky_radius = 5.0; ///< 粘滞半径(世界单位)
};
/**
* @brief 连续捕捉查询(实时)
*
* 与 `snap_to_geometry`(单次静态查询)不同,本函数针对 60+ fps 高频调用:
* - 粘滞:若 `last_snap` 有效且仍落在 `sticky_radius` 内,直接复用上一帧目标,
* 避免在两个相邻候选之间来回跳变(sticky snap)。
* - 否则按 `config.aperture_size`(孔径向)在单体内枚举候选并返回最近者。
*
* @param body B-Rep 模型
* @param cursor_position_3d 光标世界坐标
* @param view_dir 视图方向(世界空间内核暂不使用,预留给屏幕空间可见性剔除)
* @param config 实时捕捉配置
* @param last_snap 上一帧捕捉结果(用于粘滞)
* @return 最近捕捉目标;孔径向无候选时 `snap_type == SnapType::None`
*/
[[nodiscard]] SnapResult live_snap(
const BrepModel& body,
const core::Point3D& cursor_position_3d,
const core::Vector3D& view_dir,
const LiveSnapConfig& config,
const SnapResult& last_snap);
// ═══════════════════════════════════════════════
// VDE-333 §2: 批量捕捉(多候选)
// ═══════════════════════════════════════════════
/**
* @brief 批量捕捉:返回容差内的所有候选,按距离升序
*
* 当光标同时靠近多个几何特征(如一条边的中点与另一条边的端点)时,
* 返回全部候选供 UI 列表展示。
*
* @param body B-Rep 模型
* @param near_point 查询点
* @param types 捕捉类型掩码
* @param tolerance 捕捉容差
* @param max_candidates 最大候选数(默认 8,0 表示不限制)
* @return 候选列表(距离最近者在前)
*/
[[nodiscard]] std::vector<SnapResult> batch_snap(
const BrepModel& body,
const core::Point3D& near_point,
SnapType types,
double tolerance = 1.0,
size_t max_candidates = 8);
/**
* @brief 批量吸附:在多个实体中取全局最近吸附点
*
* 对每个实体调用 `snap_to_geometry`,返回容差内距离最小的那个候选。
* 若无任何候选在容差内,返回 `SnapResult{snap_type=None}`。
*
* @param bodies 实体列表
* @param near_point 查询点
* @param snap_types 吸附类型掩码(按位 OR)
* @param tolerance 吸附容差
* @return 最优吸附结果(含所属实体的 face/edge/vertex 索引)
*/
[[nodiscard]] SnapResult batch_snap(
const std::vector<std::reference_wrapper<const BrepModel>>& bodies,
const core::Point3D& near_point, SnapType snap_types, double tolerance = 1.0);
// ═══════════════════════════════════════════════
// VDE-333 §3: 网格捕捉(Grid Snapping)
// ═══════════════════════════════════════════════
/**
* @brief 网格捕捉配置
*
* 网格位于由 `origin` / `u_axis` / `v_axis` 定义的平面上;垂直于该平面的
* 分量不参与吸附(原样保留),从而支持在任意草图平面工作。
*/
struct GridConfig {
bool enabled = false; ///< 是否启用网格吸附
double spacing = 10.0; ///< 网格间距(mm)
double major_line_every = 5; ///< 每 N 条次网格线一条主网格线
core::Point3D origin{0, 0, 0}; ///< 网格原点
core::Vector3D u_axis{1, 0, 0}; ///< 网格 U 轴
core::Vector3D v_axis{0, 1, 0}; ///< 网格 V 轴
bool adaptive = true; ///< 缩放自适应间距(UI 提示,不参与几何)
};
/**
* @brief 把点吸附到网格最近节点(VDE-333)
*
* 将点投影到网格平面 (origin, u_axis, v_axis),对 U/V 分量分别取最近节点,
* 垂直分量原样保留。`enabled == false` 或 `spacing <= 0` 时原样返回。
*
* @param point 查询点
* @param grid 网格配置
* @return 吸附后的点
*/
[[nodiscard]] core::Point3D grid_snap(const core::Point3D& point, const GridConfig& grid);
/**
* @brief 网格吸附:把点吸附到规则网格最近节点(各轴等间距)
*
* 节点为 `origin + (i,j,k)·spacing`(i,j,k 为整数)。间距 ≤ 0 时原样返回。
*
* @param p 查询点
* @param origin 网格原点
* @param spacing 间距(mm)
* @return 最近网格节点
*/
[[nodiscard]] core::Point3D grid_snap(const core::Point3D& p, const core::Point3D& origin,
double spacing);
/**
* @brief 网格吸附:各轴独立间距
*
* @param p 查询点
* @param origin 网格原点
* @param spacing 三轴间距(任一轴 ≤ 0 时该轴保留原值)
* @return 最近网格节点
*/
[[nodiscard]] core::Point3D grid_snap(const core::Point3D& p, const core::Point3D& origin,
const core::Vector3D& spacing);
} // namespace vde::brep