feat(sdf): S11 — SDF 隐式建模完整模块
CI / Build & Test (push) Failing after 29s
CI / Release Build (push) Failing after 35s

S11-A: SDF 图元库
- 14 种基础形状(inline header)
- sphere/box/round_box/torus/capsule/cylinder/cone/plane/ellipsoid
- triangular_prism/hex_prism/link/wedge
- 2D 挤出(extrusion/extrusion_bounded/revolution)

S11-B: SDF 操作 + 域变形
- 锐利布尔: union/intersection/difference
- 平滑布尔: smooth_union/smooth_intersection/smooth_difference
- 修饰器: round/onion
- 域变形: repeat/mirror/rotate/translate/scale/twist/bend/elongate/displace/cheap_bend
- 24 项测试

S11-C: CSG 表达式树 + 网格转换 + Python 绑定
- SdfNode 树结构 — 工厂构造函数,递归求值
- sdf_to_mesh — 基于 marching_cubes 的 SDF→网格
- bind_sdf — pybind11 Python 绑定

文件: 14 文件,2,545 行(测试 1,296 行)
This commit is contained in:
茂之钳
2026-07-24 07:04:55 +00:00
parent 6d3f8fc8b3
commit b7419a7881
17 changed files with 1997 additions and 115 deletions
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include "vde/sdf/sdf_tree.h"
#include "vde/mesh/marching_cubes.h"
#include <functional>
namespace vde::sdf {
/// Convert an SDF expression tree to a triangle mesh using marching cubes
/// @param root SDF expression tree root node
/// @param resolution Grid resolution per axis (e.g. 64 → 64³ grid)
/// @param iso_level Isosurface level (0 = surface, default)
/// @return Mesh with vertices and triangle indices
[[nodiscard]] mesh::MCMesh sdf_to_mesh(const SdfNodePtr& root,
int resolution = 64,
double iso_level = 0.0);
/// Convert a lambda SDF f(x,y,z) to a triangle mesh
/// Convenience overload for direct function binding (useful from Python)
/// @param f SDF function f(x,y,z) → signed distance
/// @param bmin Lower corner of bounding box
/// @param bmax Upper corner of bounding box
/// @param resolution Grid resolution per axis
/// @param iso_level Isosurface level
[[nodiscard]] mesh::MCMesh sdf_to_mesh_lambda(
const std::function<double(double, double, double)>& f,
const Point3D& bmin, const Point3D& bmax,
int resolution = 64, double iso_level = 0.0);
} // namespace vde::sdf