2026-07-23 05:27:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
#include "vde/core/point.h"
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <array>
|
2026-07-23 12:36:39 +00:00
|
|
|
#include <functional>
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
|
|
|
namespace vde::curves {
|
2026-07-23 08:19:24 +00:00
|
|
|
using core::Point3D;
|
|
|
|
|
using core::Vector3D;
|
2026-07-23 05:27:51 +00:00
|
|
|
|
2026-07-23 12:36:39 +00:00
|
|
|
/// Tessellate a parametric surface into a uniform triangle mesh
|
2026-07-23 05:27:51 +00:00
|
|
|
/// @param eval Function(u,v) -> Point3D
|
|
|
|
|
/// @param res_u, res_v Number of samples in u/v directions
|
|
|
|
|
/// @return Pairs of (vertices, triangle indices)
|
|
|
|
|
std::pair<std::vector<Point3D>, std::vector<std::array<int, 3>>>
|
|
|
|
|
tessellate(const std::function<Point3D(double,double)>& eval,
|
|
|
|
|
int res_u, int res_v);
|
|
|
|
|
|
2026-07-23 12:36:39 +00:00
|
|
|
/// Adaptive tessellation based on normal-angle deviation
|
|
|
|
|
/// Recursively subdivides the parameter domain when the angular deviation
|
|
|
|
|
/// between corner normals exceeds the threshold.
|
|
|
|
|
/// @param eval Function(u,v) -> Point3D
|
|
|
|
|
/// @param normal_fn Function(u,v) -> Vector3D (unit normal)
|
|
|
|
|
/// @param min_res Minimum subdivisions per direction (1 = single quad)
|
|
|
|
|
/// @param max_depth Maximum recursion depth (limits total subdivisions)
|
|
|
|
|
/// @param angle_threshold_deg Maximum normal-angle deviation in degrees
|
|
|
|
|
/// @return Pairs of (vertices, triangle indices)
|
|
|
|
|
std::pair<std::vector<Point3D>, std::vector<std::array<int, 3>>>
|
|
|
|
|
adaptive_tessellate(
|
|
|
|
|
const std::function<Point3D(double,double)>& eval,
|
|
|
|
|
const std::function<Vector3D(double,double)>& normal_fn,
|
|
|
|
|
int min_res = 2, int max_depth = 6,
|
|
|
|
|
double angle_threshold_deg = 5.0);
|
|
|
|
|
|
2026-07-23 05:27:51 +00:00
|
|
|
} // namespace vde::curves
|