30 lines
1.2 KiB
C++
30 lines
1.2 KiB
C++
|
|
#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
|