#pragma once /** * @file parallel_mc.h * @brief 并行 Marching Cubes * * 体素网格分块并行处理,每线程独立三角形缓冲区,最终合并。 * 支持自适应八叉树分辨率。 * * @ingroup mesh */ #include "vde/mesh/halfedge_mesh.h" #include "vde/sdf/sdf_tree.h" #include #include namespace vde::mesh { // ═══════════════════════════════════════════════════════════ // Parallel Marching Cubes // ═══════════════════════════════════════════════════════════ /// 并行 MC 配置 struct ParallelMCConfig { int resolution = 64; ///< 基础分辨率(每轴体素数) int num_threads = 0; ///< 线程数(0 = 自动) bool adaptive = false; ///< 是否启用自适应分辨率 double min_voxel_size = 0.01; ///< 自适应最小体素 int max_depth = 4; ///< 自适应最大细分深度 }; /** * @brief 并行 Marching Cubes * * 将体素网格沿 Z 轴分块,每线程处理一块。 * SDF 求值需要线程安全(只读操作)。 * * @param sdf SDF 求值函数 f(x,y,z) → signed distance * @param bounds 体素空间包围盒 * @param config 配置参数 * @return 生成的三角网格 */ [[nodiscard]] HalfedgeMesh parallel_marching_cubes( const std::function& sdf, const core::AABB3D& bounds, const ParallelMCConfig& config = {}); /** * @brief 并行自适应 Marching Cubes * * 平坦区域用大格子,曲面附近细分。 * * @param sdf SDF 求值函数 * @param bounds 包围盒 * @param config 配置参数 * @return 生成的三角网格 */ [[nodiscard]] HalfedgeMesh parallel_adaptive_mc( const std::function& sdf, const core::AABB3D& bounds, const ParallelMCConfig& config = {}); } // namespace vde::mesh