Files
ViewDesignEngine/docs/reference/api-reference-mesh.md
T
hm 3b4973b9e2 feat(cae): adaptive tetra size, periodic-body closure fixes and washer regressions
Auto size (A15):
- TetMeshParams::auto_size / auto_size_wall_ratio / auto_size_min / auto_size_max
  (additive; explicit max_size>0 path bit-identical). Estimate wall proxy t=2V/S from a
  coarse tagged tessellation, size=clamp(0.5t, span*0.5%, span*5%), raised when the
  Delaunay point budget demands it; FEAMesh::max_size_used reports the derived value.
- Prism fast path: closed circular edges are sampled from polyline arc length instead of
  endpoint chord, which was always zero for full circles (fixed 8 segments, cap area
  error -9.88%) -- this alone explains the constant PlainWasher volume error.

Periodic-body closure (A16):
- brep_validate Euler count no longer skips closed self-loop edges blindly; degenerate
  detection samples the curve arc length, so washers report chi=0/valid instead of odd
  Euler (5) and watertightness 1.
- cae/fea_mesh.cpp brep_boundary_is_closed counts total edge uses: seam edges used twice
  inside one face loop are closed, only uses<2 are open; closed periodic bodies now take
  the solid-angle fallback instead of a bogus boundary fill.

Tests:
- test_fea_mesh 82 (80 pass + 2 env skip): AutoSize 6 cases (thin plate, determinism,
  additive, clamps, PlainWasher M42, HEAD_FRONT), washer diagnostics case renamed.
- test_step_import 106: StepImportWasherFamily (52 ChamferedWasher closed B-Rep,
  edge-use histogram, chi=0, volume vs revolved analytic <=2%; PlainWasher sampling).
- test_brep_validate 49, test_brep 96, test_measure 162 all pass.

250-file CAE KPI: fixed max_size=5 tet_ok 23 -> 34 (washer fix), auto size 34 -> 102
(44.0%); HEAD_FRONT volume error 12.65% -> 3.33%; ChamferedWasher auto mode 13 files
regress to volume/scale_guard (documented limitation).

Verification: full Release build exit 0; 23 suites 869 passed / 0 failed; PR gate
987/987 (79.69 s).
2026-11-20 15:56:22 +08:00

23 KiB
Raw Blame History

Mesh 模块 API 参考

网格模块 — 半边网格、网格→曲线转换、点云(E57/LAS)、网格曲面混合

模块概述

mesh 模块提供三角网格处理、网格与 NURBS 之间的桥接、点云数据处理能力。核心数据结构为 HalfedgeMesh(半边网格),支持简化、平滑、布尔、参数化、修复等操作。


头文件列表

头文件 说明
halfedge_mesh.h 半边网格核心数据结构
mesh_to_curve.h 网格→NURBS 曲线桥接(VDE-021)
point_cloud.h 点云(E57/LAS/PLY/PTX 加载,降采样,法线估计)
mesh_simplify.h 网格简化
mesh_smooth.h 网格平滑
mesh_repair.h 网格修复
mesh_boolean.h 网格布尔运算
mesh_curvature.h 网格曲率分析
mesh_parameterize.h 网格参数化
mesh_quality.h 网格质量评估
mesh_lod.h 网格 LOD
flattening.h 曲面展开/展平(VDE-152,复合材料铺层、排料等)
voxelize.h 体素化与批量 SDF 采样(VoxelGrid)
slicer.h 增材制造切片(VDE-565)
shape_descriptor.h 形状描述符与相似零件检索
marching_cubes.h Marching Cubes 等值面提取(含 VoxelGrid/体素化桥接)
delaunay_2d.h 二维 Delaunay 三角剖分
delaunay_3d.h 三维 Delaunay 四面体剖分
cdt_2d.h 约束 Delaunay 三角剖分
alpha_shapes.h Alpha Shapes
geodesic.h 测地线距离
reverse_engineering.h 逆向工程(点云→B-Rep)
fea_mesh.h FEA 有限元网格
vde/cae/node_pairing.h 周期/对称节点 1:1 配对(VDE-1619,库 vde_cae)
vde/cae/beam_mesh.h 梁/线单元网格:中心线 + Line2/Line3 + 截面/局部轴(VDE-1621,库 vde_cae)
vde/cae/edge_element_mesh.h Nedelec0 边单元网格交接:全局唯一边表/方向符号/PEC 面边集(VDE-1620,库 vde_cae)
visualization_quality.h 可视化质量
parallel_mc.h 并行 Marching Cubes

详细 API

halfedge_mesh.h — 半边网格核心

namespace vde::mesh {

class HalfedgeMesh {   // 数据成员私有,通过访问器查询拓扑
public:
    HalfedgeMesh() = default;

    // ── 构造 ─────────────────────────────────────────────
    void clear();
    int  add_vertex(const Point3D& p);                      // 返回新顶点索引(0-based)
    int  add_face(const std::vector<int>& vertex_indices);  // 逆时针顶点环,失败返回 -1
    void build_from_triangles(const std::vector<Point3D>& verts,
                              const std::vector<std::array<int, 3>>& tris);
    [[nodiscard]] MCMesh to_mcm() const;                    // 导出为 MCMesh(顶点+三角形索引)

    // ── 访问器 ───────────────────────────────────────────
    [[nodiscard]] size_t num_vertices() const;
    [[nodiscard]] size_t num_faces() const;
    [[nodiscard]] size_t num_edges() const;                 // = 半边数 / 2
    [[nodiscard]] const Point3D& vertex(size_t idx) const;
    [[nodiscard]] const Face& face(size_t idx) const;       // Face{halfedge_index, valence}
    [[nodiscard]] const Halfedge& halfedge(size_t idx) const; // Halfedge{vertex_index, face_index, next/prev/opposite_index}
    void set_vertex(size_t idx, const Point3D& p);          // 置脏法向缓存

    // ── 拓扑查询 ─────────────────────────────────────────
    [[nodiscard]] std::vector<int> face_vertices(int fi) const; // 面的顶点环(按环绕顺序)
    [[nodiscard]] std::vector<int> vertex_faces(int vi) const;  // 顶点的邻面索引环
    [[nodiscard]] bool is_boundary_edge(int hei) const;     // 对侧半边无所属面
    [[nodiscard]] bool is_boundary_vertex(int vi) const;

    // ── 法向 / 包围盒 ────────────────────────────────────
    [[nodiscard]] Vector3D face_normal(int fi) const;
    [[nodiscard]] Vector3D vertex_normal(int vi) const;
    void update_normals();
    [[nodiscard]] AABB3D bounds() const;

    // ── 迭代器(支持 range-based for)────────────────────
    [[nodiscard]] FaceRange faces_range() const;            // 遍历所有面
    [[nodiscard]] VertexOneRing vertex_one_ring(int vi) const; // 顶点 1-ring 邻域
};

} // namespace vde::mesh

mesh_to_curve.h — 网格→曲线桥接(VDE-021)

namespace vde::mesh {

[[nodiscard]] curves::NurbsCurve mesh_boundary_to_curve(const HalfedgeMesh& mesh);    // 边界环→NURBS
[[nodiscard]] curves::NurbsCurve extract_boundary_curves(const HalfedgeMesh& mesh);   // 等效别名

[[nodiscard]] std::vector<curves::NurbsCurve> extract_profiles_from_mesh(
    const HalfedgeMesh& mesh, const core::Vector3D& projection_axis);                 // 多轮廓提取

[[nodiscard]] std::vector<curves::NurbsCurve> mesh_to_directed_curve(
    const HalfedgeMesh& mesh, const core::Vector3D& axis);                            // 有向轮廓(别名)

[[nodiscard]] std::vector<curves::NurbsCurve> mesh_contour_to_curves(
    const HalfedgeMesh& mesh, double z_height);                                       // Z 层截面轮廓

} // namespace vde::mesh

point_cloud.h — 点云

namespace vde::mesh {

class PointCloud {
public:
    std::vector<Point3D> vertices;
    std::vector<Vector3D> normals;
    std::vector<std::array<uint8_t, 3>> colors;
    std::vector<double> intensities;

    PointCloud();
    explicit PointCloud(std::vector<Point3D> pts);

    [[nodiscard]] size_t size() const;
    [[nodiscard]] bool has_normals() const;
    [[nodiscard]] bool has_colors() const;
    [[nodiscard]] bool has_intensity() const;
    [[nodiscard]] AABB3D bounds() const;

    // I/O
    static PointCloud load_ply(const std::string& path);           // PLY 加载
    static PointCloud load_e57(const std::string& path);           // E57 加载(ASTM E2807)
    static PointCloud load_las(const std::string& path);           // LAS/LAZ 加载(1.2/1.3/1.4)
    static PointCloud load_ptx(const std::string& path);           // PTX 加载(Leica)
    bool save_ply(const std::string& path) const;                  // PLY 保存

    // 滤波/降采样
    [[nodiscard]] PointCloud voxel_downsample(double voxel_size) const;              // 体素降采样
    [[nodiscard]] PointCloud statistical_outlier_removal(int k=6, double std_ratio=1.0) const; // SOR 离群点剔除
    [[nodiscard]] std::vector<size_t> curvature_aware_sampling(size_t target_count) const;      // 曲率感知采样
    [[nodiscard]] PointCloud smoothing_filter(double sigma_c=0.0, double sigma_n=0.3, int iterations=3) const; // 双边滤波

    // 法线估计
    [[nodiscard]] PointCloud normal_estimation(int k = 10) const;    // kNN 法线估计

    // 双边法向感知平滑(每迭代先重估法线,适合高噪声扫描数据)
    [[nodiscard]] PointCloud normal_aware_smoothing(
        int k_normal = 10, double sigma_c = 0.0, double sigma_n = 0.3,
        int iterations = 3) const;
};

} // namespace vde::mesh

其余网格模块摘要

namespace vde::mesh {

// mesh_simplify.h
[[nodiscard]] HalfedgeMesh simplify_mesh(const HalfedgeMesh& mesh,
    const SimplifyOptions& opts = {});                     // QEM 简化(target_ratio 默认 0.5)

// mesh_smooth.h
[[nodiscard]] HalfedgeMesh smooth_mesh(const HalfedgeMesh& mesh, const SmoothOptions& opts = {}); // 按 method 分派
[[nodiscard]] HalfedgeMesh smooth_laplacian(const HalfedgeMesh& mesh, int iterations, double lambda);
[[nodiscard]] HalfedgeMesh smooth_taubin(const HalfedgeMesh& mesh, int iterations, double lambda, double mu);
[[nodiscard]] HalfedgeMesh smooth_hc_laplacian(const HalfedgeMesh& mesh, const SmoothOptions& opts = {});
[[nodiscard]] HalfedgeMesh smooth_bilateral(const HalfedgeMesh& mesh, const SmoothOptions& opts = {});

// mesh_repair.h
[[nodiscard]] HalfedgeMesh repair_mesh(const HalfedgeMesh& mesh, const RepairOptions& opts = {});
[[nodiscard]] HalfedgeMesh automatic_hole_filling(const HalfedgeMesh& mesh);  // 补洞
[[nodiscard]] HalfedgeMesh non_manifold_repair(const HalfedgeMesh& mesh);    // 非流形边修复
[[nodiscard]] MeshHealingReport mesh_healing_report(const HalfedgeMesh& mesh); // 修复诊断报告

// mesh_boolean.h(通用入口;便捷包装 mesh_union/mesh_intersection/mesh_difference 见 vde::boolean/boolean_mesh.h)
[[nodiscard]] HalfedgeMesh mesh_boolean(const HalfedgeMesh& a, const HalfedgeMesh& b, BooleanOp op);

// marching_cubes.h(返回 MCMesh:顶点 + 三角形索引,而非 HalfedgeMesh)
[[nodiscard]] MCMesh marching_cubes(
    const std::function<double(double,double,double)>& f,
    double iso_level, const Point3D& bmin, const Point3D& bmax, int resolution);
[[nodiscard]] MCMesh marching_cubes(const VoxelGrid& grid, double isoValue = 0.5);
[[nodiscard]] MCMesh tessellate(const brep::BrepModel& model,
                                double deflection = 0.1, double angleDeg = 20.0); // B-Rep → 扁平三角网格

// delaunay_2d.h
DelaunayResult delaunay_2d(const std::vector<Point2D>& points);

// cdt_2d.h
DelaunayResult constrained_delaunay_2d(
    const std::vector<Point2D>& points,
    const std::vector<std::pair<int, int>>& constraints);   // 约束边强制出现在三角化中

// delaunay_3d.h
TetrahedronMesh delaunay_3d(const std::vector<Point3D>& points);   // 无预算,语义/输出逐位不变
TetrahedronMesh delaunay_3d(const std::vector<Point3D>& points,
                            const Delaunay3dBudget& budget,
                            Delaunay3dStats* stats = nullptr);     // 确定性工作量预算(additive)

// Delaunay3dBudget:全 0 = 不限制 = 旧行为;判定按「计数」而非墙钟,
// 同输入同预算必在同一插入步中止(可复现、可用于回归)
struct Delaunay3dBudget {
    std::size_t max_containment_tests = 0;  // 外接球包含测试总次数上限
    std::size_t max_live_tets = 0;          // 存活四面体峰值上限
    std::size_t max_created_tets = 0;       // 累计新建四面体绝对上限
    std::size_t max_cavity_tets = 0;        // 单次插入 cavity 重建数上限
    std::size_t created_per_point = 0;      // 主护栏:created > per_point*(n+1)+base 即中止
    std::size_t created_base = 0;           // 主护栏基数(起步阶段留量)
};
struct Delaunay3dStats {
    std::size_t points, containment_tests, live_peak, created_tets, cavity_peak;
    bool aborted; const char* abort_reason; // 中止原因静态字符串;未中止为空
};

// alpha_shapes.h
TetrahedronMesh alpha_shapes(const std::vector<Point3D>& points, double alpha);
std::pair<std::vector<Point3D>, std::vector<std::array<int,3>>> alpha_shapes_surface(
    const TetrahedronMesh& tet_mesh);                       // 提取重建表面三角形

// geodesic.h
std::vector<double> geodesic_distance(const HalfedgeMesh& mesh,
                                      const std::vector<int>& sources,
                                      double t = -1.0);     // 热方法,支持多源点

// reverse_engineering.h
HalfedgeMesh point_cloud_to_mesh(const PointCloud& cloud,
                                 const PointCloudToMeshParams& params = {}); // Poisson 曲面重建
NurbsSurface mesh_to_nurbs_surface(const HalfedgeMesh& mesh,
                                   const MeshToNURBSParams& params = {});
[[nodiscard]] brep::BrepModel mesh_to_brep_advanced(
    const HalfedgeMesh& mesh, BRepFeatureFlag features = BRepFeatureFlag::All);
[[nodiscard]] NurbsSurface point_cloud_to_surface(const std::vector<Point3D>& points,
                                                  double tolerance = 0.01);

// fea_mesh.h
FEAMesh tetrahedral_mesh(const brep::BrepModel& body,
                         const TetMeshParams& params = {}); // Delaunay 3D + 质量优化

// 自动尺寸(additive,2026-11-20):仅 max_size<=0 且 auto_size=true 时生效;
// 显式 max_size>0 或关闭 auto 时行为逐位不变(仍 bbox 最大跨度 * 5%)。
struct TetMeshParams {
    // ... 既有字段(max_size / max_edge / ...)
    bool   auto_size = false;
    double auto_size_wall_ratio = 0.5;  // 壁厚代理 t=2V/S 的倍数(<=0→0.5,>4→4)
    double auto_size_min = 0.0;         // >0 时作下界,否则 span*0.005
    double auto_size_max = 0.0;         // >0 时作上界,否则 span*0.05
};
// 推导:粗三角化估 V/S → t=2V/S → size=clamp(ratio*t, lo, hi),
// 预算不足时按 Delaunay 点上限(4000 表面点 / 9000 Delaunay 点)上调;
// 推导失败回退 bbox*5%。确定性(无随机/墙钟输入),同几何必同尺寸。
// FEAMesh::max_size_used 仅在自动模式推导成功时回填实际使用的 max_size(不序列化)。

// mesh_curvature.h
CurvatureResult compute_curvature(const HalfedgeMesh& mesh);
[[nodiscard]] PrincipalCurvatureResult principal_curvature_directions(
    const HalfedgeMesh& mesh, int vertex_id);

// mesh_parameterize.h
[[nodiscard]] std::vector<Point2D> tutte_parameterization(const HalfedgeMesh& mesh);
[[nodiscard]] std::vector<Point2D> lscm_parameterization(const HalfedgeMesh& mesh);
[[nodiscard]] std::vector<Point2D> arap_parameterization(const HalfedgeMesh& mesh, int max_iter = 50);

// mesh_quality.h
MeshQuality evaluate_mesh_quality(const HalfedgeMesh& mesh);
QualityReport mesh_quality_report(const HalfedgeMesh& mesh);

// mesh_lod.h
[[nodiscard]] LODMesh generate_lod(const HalfedgeMesh& mesh,
    int num_levels = 3, double reduction_ratio = 0.5);
[[nodiscard]] LODMesh generate_brep_lod(const brep::BrepModel& body, int num_levels = 3);

// visualization_quality.h
AOResult ambient_occlusion(const HalfedgeMesh& mesh, int samples = 128);
EdgeHighlightResult edge_highlighting(const HalfedgeMesh& mesh, double angle_threshold = 0.785398163);

// parallel_mc.h
[[nodiscard]] HalfedgeMesh parallel_marching_cubes(
    const std::function<double(double,double,double)>& sdf,
    const core::AABB3D& bounds, const ParallelMCConfig& config = {});

// flattening.h(VDE-152 曲面展开)
[[nodiscard]] FlattenResult flattenMesh(const HalfedgeMesh& mesh, const FlattenOptions& options = {});
[[nodiscard]] FlattenResult flattenSurface(const curves::NurbsSurface& surface,
    int sampleU = 50, int sampleV = 50, const FlattenOptions& options = {});

// voxelize.h(批量 SDF 采样 → VoxelGrid,可喂给 marching_cubes(grid, iso))
[[nodiscard]] VoxelGrid sample_sdf(
    const std::function<double(double,double,double)>& sdf,
    const core::AABB3D& bounds, const VoxelizeParams& params = {});
[[nodiscard]] VoxelGrid sample_sdf_batch(const BatchSdfFn& batch_sdf,
    const core::AABB3D& bounds, const VoxelizeParams& params = {});

// slicer.h(VDE-565 增材制造切片)
[[nodiscard]] SliceResult slice_mesh(const HalfedgeMesh& mesh, const SliceConfig& config = {});

// shape_descriptor.h(VDE-580)
[[nodiscard]] ShapeDescriptor compute_shape_descriptor(const HalfedgeMesh& mesh, int d2_samples = 100000);
[[nodiscard]] std::vector<SimilarityMatch> find_similar_parts(
    const ShapeDescriptor& query,
    const std::vector<ShapeDescriptor>& library, int k = 5);

} // namespace vde::mesh

代码示例

示例 1: 网格→B-Rep 建模流水线

#include <vde/mesh/mesh_to_curve.h>
#include <vde/brep/modeling.h>

using namespace vde;

// 加载 STL 网格(假设已有)
mesh::HalfedgeMesh mesh = /* ... */;

// 提取边界轮廓 → NURBS 曲线
auto profile = mesh::mesh_boundary_to_curve(mesh);

// 挤出为 B-Rep 实体
auto brep_body = brep::extrude(profile, core::Vector3D(0, 0, 10.0));

// 倒角
auto result = brep::fillet(brep_body, 0, 2.0);

示例 2: 点云处理

#include <vde/mesh/point_cloud.h>

using namespace vde::mesh;

// 加载 E57 点云(激光扫描仪数据)
auto cloud = PointCloud::load_e57("scan_001.e57");

std::cout << "原始点数: " << cloud.size() << "\n";

// 体素降采样
auto downsampled = cloud.voxel_downsample(0.01);  // 1cm 体素

// 离群点剔除
auto filtered = downsampled.statistical_outlier_removal(6, 1.0);

// 法线估计
auto with_normals = filtered.normal_estimation(10);

// 保存为 PLY
with_normals.save_ply("processed.ply");

cae/node_pairing.h — 周期/对称节点映射(VDE-1619)

namespace vde::mesh {

enum class NodePairKind {
    TranslationalPeriodic,  // p' = p + vector
    RotationalPeriodic,     // p' = origin + R(axis, angle_rad) * (p - origin)
    Mirror,                 // p' = p - 2 * ((p - origin) . n) * n
};

struct NodePairingParams {
    NodePairKind kind = NodePairKind::TranslationalPeriodic;
    int master_face_tag = -1;   // boundary_face_tags 口径
    int slave_face_tag = -1;
    core::Vector3D vector{0, 0, 0};
    core::Vector3D axis{0, 0, 1};
    core::Point3D origin{0, 0, 0};
    double angle_rad = 0.0;
    double tolerance = 1e-4;    // 0 = 1e-6 * 网格包围盒对角线
};

struct NodePair  { int master_node = -1; int slave_node = -1; };
struct NodePairMap {
    bool valid = false;
    std::string message;
    int master_face_tag = -1;
    int slave_face_tag = -1;
    std::vector<NodePair> pairs;
    std::vector<int> unmatched_master;
    std::vector<int> unmatched_slave;
};

[[nodiscard]] NodePairMap pair_periodic_nodes(const FEAMesh& mesh,
                                              const NodePairingParams& params);

}  // namespace vde::mesh
  • 面节点 = mesh.boundary_faces 中对应 boundary_face_tags 命中的多边形顶点并集(去重升序);
  • master 面节点按索引升序做 1:1 贪心最近点绑定,每个 slave 至多用一次;容差内第二候选距离与最近距离差 < 0.1 * tolerance 且候选 ≥ 2 时整单失败(不任选其一,pairs/unmatched_* 清空);
  • valid == true 仅当 pairs.size() 等于 master 面节点数且两侧 unmatched_* 为空;覆盖不足时保留已绑定配对供应用层提示重网格;
  • 只输出配对数据,不生成约束方程、不消去自由度;参数非法/结构非法一律 valid=false + message,不抛异常;只读、确定性、可并发。

测试:tests/cae/test_vde1619_node_pairing.cpp(8 例 VDE1619NodePairing.*:平移/旋转/镜像、细化从面不匹配、歧义、12 种非法参数、确定性、真实四面体网格冒烟)。

cae/beam_mesh.h — 梁/线单元网格(VDE-1621)

namespace vde::mesh {

enum class BeamElementType { Line2, Line3 };

struct BeamSectionSpec {
    int section_id = 0;
    std::string name;
    enum class Shape { Circle, Rectangle, Annulus, UserDefined };
    Shape shape = Shape::Circle;
    double d = 0, b = 0, t = 0;          // 直径/宽/厚(按 Shape 解释)
    double area = 0, inertiaY = 0, inertiaZ = 0, torsionConstant = 0;
    double shearAreaY = 0, shearAreaZ = 0;
};

struct BeamMeshParams {
    double target_length = 0.0;   // 0 = 总长/20,限制在 [1, 50] 段
    BeamElementType element_type = BeamElementType::Line2;
    double min_length = 1e-3;
    bool split_at_section_change = true;
    double junction_tolerance = 1e-3;
};

struct BeamElement {
    int nodes[3] = {-1, -1, -1};  // Line2 只用 [0][1],nodes[2] = -1
    int node_count = 2;
    int section_id = 0;
    core::Vector3D local_x, local_y, local_z;
    double offset_y = 0, offset_z = 0;
    int source_edge_tag = -1;
    int source_face_tag = -1;
};

struct BeamMesh {
    bool valid = false;
    std::string message;
    BeamElementType element_type = BeamElementType::Line2;
    std::vector<core::Point3D> vertices;
    std::vector<BeamElement> elements;
    std::vector<BeamSectionSpec> sections;
    std::vector<int> end_node_ids;
    std::vector<int> junction_node_ids;
};

[[nodiscard]] BeamMesh beam_mesh(const brep::BrepModel& body,
                                 const std::vector<BeamSectionSpec>& sections,
                                 const BeamMeshParams& params = {});

}  // namespace vde::mesh
  • 中心线来源优先级:解析圆柱面轴线(extract_cylindrical_centerlines,跳过内孔/流道面)→ 圆周棱柱轴线推断(faceted 圆柱)→ B-Rep 直线边回退(杆系/盒体骨架);全部为空 → valid=false;
  • 端点按 junction_tolerance 合并为共享顶点,度 ≥ 3 进 junction_node_ids、度 1 进 end_node_ids;Line3 中点是新增内部节点、不参与合并;
  • 局部轴:local_x = 单元轴向,local_y = 参考 up 方向正交化(+Z,近平行时退 +X),local_z = local_x × local_y;
  • 多截面时圆柱段按半径匹配 Shape::Circle(容差 max(1e-6, 1e-3*r)),直线边段无法归属 → 失败;只做「几何 → 网格数据」交接,不生成刚度矩阵、不求解。

测试:tests/cae/test_vde1621_beam_mesh.cpp(9 例 VDE1621BeamMesh.*:圆柱中心线/Line3 中点/目标长度分段/阶梯轴截面/交汇节点/局部轴/退化与非法/确定性)。

cae/edge_element_mesh.h — 边单元网格交接(VDE-1620)

namespace vde::mesh {

enum class EdgeElementType { Nedelec0, Nedelec1 };

struct EdgeElementMesh {
    bool valid = false;
    std::string message;
    std::vector<core::Point3D> vertices;
    std::vector<std::array<int, 2>> edges;              // 全局唯一边,恒 u < v
    std::vector<int> edge_tags;                          // B-Rep edge 索引;面内剖分边 -1
    EdgeElementType element_type = EdgeElementType::Nedelec0;
    std::vector<std::array<int, 6>> tetra_edges;        // 局部边顺序 (01)(02)(03)(12)(13)(23)
    std::vector<std::array<int, 6>> tetra_edge_sign;    // +1 与全局方向同向,-1 反向
    std::vector<int> material_ids;
    std::vector<std::vector<int>> boundary_faces;
    std::vector<int> boundary_face_tags;
    std::vector<std::vector<int>> boundary_face_edges;  // 与 boundary_faces 同序
};

[[nodiscard]] EdgeElementMesh edge_element_mesh(const brep::BrepModel& body,
                                                const TetMeshParams& params = {});
// 增量重载:显式请求单元类型(Nedelec1 尚未实现,会被明确拒绝,不静默降级)
[[nodiscard]] EdgeElementMesh edge_element_mesh(const brep::BrepModel& body,
                                                const TetMeshParams& params,
                                                EdgeElementType element_type);

}  // namespace vde::mesh
  • 方向契约:edges[e] = {u, v} 恒 u < v;单元内第 k 条局部边顶点对 (a, b) 满足 tetra_edges[t][k] = e 且 tetra_edge_sign[t][k] = +1 当且仅当 a < b,即 v - u == sign * (b - a),相邻单元对同一全局边方向自洽;
  • edge_tags >= 0 仅来自 FEAMesh.boundary_edges + boundary_edge_tags 映射(未登记的内部边为 -1);boundary_face_edges 按边界面多边形闭合遍历映射;
  • 仅支持线性 Tet4:Tet10/Hex8/Wedge6、空网格、退化单元、边表不一致均 valid=false + message,不输出部分结果;只读、确定性、可并发。

测试:tests/cae/test_vde1620_edge_element_mesh.cpp(8 例 VDE1620EdgeElementMesh.*:全局边表/方向符号/边 tag/边界面边覆盖/Nedelec1 拒绝/二次单元拒绝/确定性/空模型)。