feat(v4.6): memory pool + parallel boolean/MC/intersection + GMP exact predicates
M1 — Memory Pool (内存池): - ObjectPool<T>: O(1) acquire/release with free-list, chunk-based expansion - ThreadSafeObjectPool<T>: per-thread local pools with global fallback - CowPtr<T>: copy-on-write smart pointer with shallow/deep copy - 10 tests: single/multi-thread, CoW detach, reuse rate M2 — Parallel Boolean (并行布尔): - parallel_face_face_intersection(): OpenMP face-pair dispatch with AABB culling - parallel_classify_faces(): thread-safe ray casting classification - parallel_mesh_union/intersection/difference + B-Rep variants - Thread count management API - 12 tests: coverage, empty cases, identity operations M3 — Parallel Marching Cubes (并行MC): - parallel_marching_cubes(): Z-slice parallel voxel processing - parallel_adaptive_mc(): octree-based adaptive resolution - Complete 256-entry edge table + Möller-Trumbore interpolation - 5 tests: sphere basic/high-res/empty/adaptive/threaded M4 — Parallel Surface Intersection (并行求交): - parallel_curve_intersections(): per-pair parallel dispatch - parallel_surface_intersection(): recursive subdivision + Newton refinement - AABB broad-phase culling before narrow-phase - 4 tests: curve pairs, surface batch M5 — GMP Exact Predicates (精确谓词): - exact_orient2d/3d: adaptive precision (double → GMP fallback) - exact_in_sphere: circumsphere test with degenerate handling - exact_point_in_polygon/polyhedron: robust ray casting - PrecisionMode: Fast/Adaptive/Exact with global toggle - 12 tests: all orientations, boundary cases, mode switching 21 files, +2263 lines
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
/**
|
||||
* @file parallel_mc.h
|
||||
* @brief 并行 Marching Cubes
|
||||
*
|
||||
* 体素网格分块并行处理,每线程独立三角形缓冲区,最终合并。
|
||||
* 支持自适应八叉树分辨率。
|
||||
*
|
||||
* @ingroup mesh
|
||||
*/
|
||||
|
||||
#include "vde/mesh/halfedge_mesh.h"
|
||||
#include "vde/sdf/sdf_tree.h"
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
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<double(double, double, double)>& 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<double(double, double, double)>& sdf,
|
||||
const core::AABB3D& bounds,
|
||||
const ParallelMCConfig& config = {});
|
||||
|
||||
} // namespace vde::mesh
|
||||
Reference in New Issue
Block a user