ViewDesignEngine  3.1.0
高性能 CAD 计算几何引擎
sdf_optimize.h 文件参考

基于梯度的 SDF 形状优化 更多...

#include "vde/sdf/sdf_tree.h"
#include "vde/core/point.h"
#include <vector>
#include <functional>
sdf_optimize.h 的引用(Include)关系图:

浏览源代码.

struct  vde::sdf::OptimizeResult
 优化结果 更多...
 
struct  vde::sdf::SymmetryResult
 对称检测结果 更多...
 
struct  vde::sdf::ParamRef
 SDF 树中可变参数的引用 更多...
 
class  vde::sdf::GradientDescent
 固定学习率的简单梯度下降优化器 更多...
 

命名空间

 vde
 
 vde::sdf
 

类型定义

using vde::sdf::LossFn = std::function< double(const std::function< double(const Point3D &)> &)>
 损失函数类型 更多...
 

函数

OptimizeResult vde::sdf::fit_to_point_cloud (const SdfNodePtr &initial, const std::vector< Point3D > &target_points, double learning_rate=0.01, int max_iterations=100)
 将参数化形状拟合到目标点云 更多...
 
OptimizeResult vde::sdf::fit_surface_to_points (const SdfNodePtr &initial, const std::vector< Point3D > &surface_points, double learning_rate=0.01, int max_iterations=100)
 将形状表面移动到目标采样点 更多...
 
OptimizeResult vde::sdf::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 vde::sdf::resolve_collision (SdfNodePtr &shape_a, SdfNodePtr &shape_b, double step_size=0.1, int max_iterations=50)
 通过平移解决两个形状之间的穿透 更多...
 
double vde::sdf::penetration_depth (const SdfNodePtr &shape_a, const SdfNodePtr &shape_b, const Point3D &bmin, const Point3D &bmax, int samples=1000)
 估算两个形状之间的最小穿透距离 更多...
 
double vde::sdf::accessibility (const SdfNodePtr &shape, const Point3D &p, const Vector3D &direction, int hemisphere_samples=64)
 计算形状表面上点的可及性分数 更多...
 
Point3D vde::sdf::find_accessible_point (const SdfNodePtr &shape, const Vector3D &approach_dir, const Point3D &bmin, const Point3D &bmax, int grid_res=32)
 找到给定接近方向下具有最大可及性的表面点 更多...
 
double vde::sdf::symmetry_score (const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, const Vector3D &plane_normal, double plane_offset=0.0, int samples=1000)
 检测形状在给定方向上的反射对称性 更多...
 
SymmetryResult vde::sdf::find_symmetry_plane (const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, int samples=1000)
 自动找到形状的最佳反射对称平面 更多...
 
double vde::sdf::estimate_volume (const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, int samples=10000)
 通过蒙地卡罗法估算隐式形状的体积 更多...
 
Point3D vde::sdf::center_of_mass (const SdfNodePtr &shape, const Point3D &bmin, const Point3D &bmax, int samples=10000)
 通过蒙地卡罗法估算形状的质心 更多...
 
std::vector< ParamRef > vde::sdf::collect_params (SdfNodePtr &root)
 从叶节点收集所有可变数值参数 更多...
 
std::vector< double > vde::sdf::numerical_gradient (const std::vector< ParamRef > &params, const std::function< double()> &loss_fn, double eps=1e-6)
 计算标量损失对收集到的参数的数值梯度 更多...
 

详细描述

基于梯度的 SDF 形状优化

提供 SDF 形状的拟合、碰撞解析、可及性分析和对称性检测等功能。

主要功能

功能 说明
Shape Fitting 将参数化形状拟合到点云或目标 SDF
Collision Avoidance 平移形状以解决穿透
Accessibility 采样半球以评估表面上点的可及性
Symmetry Detection 检测反射对称性并找到最佳对称平面
Volume & Mass 通过蒙地卡罗法估计体积和质心
Parameter Optimization 收集所有可优化的参数并计算数值梯度

使用模式

auto shape = SdfNode::sphere(0.5);
auto result = fit_to_point_cloud(shape, points, 0.01, 200);
if (result.converged) {
// result.optimized_shape 包含优化后的参数
}
OptimizeResult fit_to_point_cloud(const SdfNodePtr &initial, const std::vector< Point3D > &target_points, double learning_rate=0.01, int max_iterations=100)
将参数化形状拟合到目标点云
double sphere(const Point3D &p, double radius)
球体的 SDF

在文件 sdf_optimize.h 中定义.