65 using LossFn = std::function<double(
const std::function<
double(
const Point3D&)>&)>;
101 const std::vector<Point3D>& target_points,
102 double learning_rate = 0.01,
103 int max_iterations = 100);
121 const std::vector<Point3D>& surface_points,
122 double learning_rate = 0.01,
123 int max_iterations = 100);
149 const std::function<
double(
const Point3D&)>& target_sdf,
151 int grid_resolution = 16,
152 double learning_rate = 0.01,
153 int max_iterations = 100);
179 double step_size = 0.1,
180 int max_iterations = 50);
225 int hemisphere_samples = 64);
269 double plane_offset = 0.0,
324 int samples = 10000);
344 int samples = 10000);
406 const std::vector<ParamRef>& params,
407 const std::function<
double()>& loss_fn,
448 double step(std::vector<double>& params,
449 const std::function<
double(
const std::vector<double>&,
450 std::vector<double>&)>& grad_fn);
459 [[nodiscard]]
int iteration()
const {
return iteration_; }
int iteration() const
获取当前迭代次数
GradientDescent(double lr)
构造优化器
void set_learning_rate(double lr)
设置学习率
double learning_rate() const
获取学习率
double step(std::vector< double > ¶ms, const std::function< double(const std::vector< double > &, std::vector< double > &)> &grad_fn)
执行单步梯度下降
foundation::Vector3D Vector3D
双精度三维向量(重新导出)
foundation::Point3D Point3D
双精度三维点(重新导出)
SymmetryResult find_symmetry_plane(const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, int samples=1000)
自动找到形状的最佳反射对称平面
Point3D find_accessible_point(const SdfNodePtr &shape, const Vector3D &approach_dir, const Point3D &bmin, const Point3D &bmax, int grid_res=32)
找到给定接近方向下具有最大可及性的表面点
double accessibility(const SdfNodePtr &shape, const Point3D &p, const Vector3D &direction, int hemisphere_samples=64)
计算形状表面上点的可及性分数
OptimizeResult fit_surface_to_points(const SdfNodePtr &initial, const std::vector< Point3D > &surface_points, double learning_rate=0.01, int max_iterations=100)
将形状表面移动到目标采样点
Point3D center_of_mass(const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, int samples=10000)
通过蒙地卡罗法估算形状的质心
std::function< double(const std::function< double(const Point3D &)> &)> LossFn
损失函数类型
OptimizeResult fit_to_point_cloud(const SdfNodePtr &initial, const std::vector< Point3D > &target_points, double learning_rate=0.01, int max_iterations=100)
将参数化形状拟合到目标点云
OptimizeResult fit_to_sdf(const SdfNodePtr &source, const std::function< double(const Point3D &)> &target_sdf, const Point3D &bmin, const Point3D &bmax, int grid_resolution=16, double learning_rate=0.01, int max_iterations=100)
拟合一个 SDF 形状以匹配另一个目标 SDF
bool resolve_collision(SdfNodePtr &shape_a, SdfNodePtr &shape_b, double step_size=0.1, int max_iterations=50)
通过平移解决两个形状之间的穿透
double symmetry_score(const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, const Vector3D &plane_normal, double plane_offset=0.0, int samples=1000)
检测形状在给定方向上的反射对称性
double penetration_depth(const SdfNodePtr &shape_a, const SdfNodePtr &shape_b, const Point3D &bmin, const Point3D &bmax, int samples=1000)
估算两个形状之间的最小穿透距离
std::shared_ptr< SdfNode > SdfNodePtr
double estimate_volume(const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, int samples=10000)
通过蒙地卡罗法估算隐式形状的体积
std::vector< ParamRef > collect_params(SdfNodePtr &root)
从叶节点收集所有可变数值参数
std::vector< double > numerical_gradient(const std::vector< ParamRef > ¶ms, const std::function< double()> &loss_fn, double eps=1e-6)
计算标量损失对收集到的参数的数值梯度
SdfNodePtr optimized_shape
优化后的 SDF 树(参数已更新)
std::vector< double > loss_history
每次迭代的损失记录
std::string name
参数名称(调试用)
Vector3D normal
最佳对称平面的法向量