46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#pragma once
|
|
#include "vde/mesh/halfedge_mesh.h"
|
|
|
|
namespace vde::mesh {
|
|
using core::Point2D;
|
|
using core::Point3D;
|
|
using core::Vector3D;
|
|
|
|
/**
|
|
* @brief 网格修复选项
|
|
* @ingroup mesh
|
|
*/
|
|
struct RepairOptions {
|
|
bool fill_holes = true; ///< 是否填充孔洞(补面)
|
|
bool remove_duplicates = true; ///< 是否合并重合顶点(距离 < ε)
|
|
bool fix_orientation = true; ///< 是否统一面法向(外翻)
|
|
bool remove_degenerate = true; ///< 是否删除退化面(面积为 0 的三角形)
|
|
};
|
|
|
|
/**
|
|
* @brief 自动网格修复
|
|
*
|
|
* 对输入网格执行一系列修复操作,输出水密的流形网格:
|
|
* - fill_holes: 检测边界环并用 fan 三角化填充
|
|
* - remove_duplicates: 空间哈希合并间距 < 1e-8 的重复顶点
|
|
* - fix_orientation: 从最大连通分量开始遍历传播一致的半边朝向
|
|
* - remove_degenerate: 剔除面积 < ε 的退化三角形
|
|
*
|
|
* @param mesh 输入网格(可能有缺陷)
|
|
* @param opts 修复选项(默认全部启用)
|
|
* @return 修复后的网格
|
|
*
|
|
* @note 修复为启发式算法,不保证 100% 成功;孔洞过大或非流形边可能仍有残留问题
|
|
* @code{.cpp}
|
|
* auto fixed = repair_mesh(broken_mesh); // 默认全修复
|
|
*
|
|
* RepairOptions opts;
|
|
* opts.fill_holes = false; // 仅做去重 + 定向
|
|
* auto cleaned = repair_mesh(mesh, opts);
|
|
* @endcode
|
|
* @ingroup mesh
|
|
*/
|
|
HalfedgeMesh repair_mesh(const HalfedgeMesh& mesh, const RepairOptions& opts = {});
|
|
|
|
} // namespace vde::mesh
|