ViewDesignEngine  3.1.0
高性能 CAD 计算几何引擎
vde::foundation::Tolerance类 参考

分层容差管理类 更多...

#include <tolerance.h>

Public 成员函数

 Tolerance (double absolute=1e-6, double relative=1e-8, double angular=1e-8, double snapping=1e-4)
 构造容差对象 更多...
 
bool points_equal (const Eigen::MatrixXd &a, const Eigen::MatrixXd &b) const
 判断两点是否相等(基于绝对容差) 更多...
 
template<typename T >
bool is_zero (T value) const
 判断值是否接近零 更多...
 
template<typename T >
bool equals (T a, T b) const
 混合容差相等判断 更多...
 
double absolute () const
 获取绝对容差 更多...
 
double relative () const
 获取相对容差 更多...
 
double angular () const
 获取角度容差 更多...
 
double snapping () const
 获取吸附容差 更多...
 
Tolerance tighten (double factor=0.1) const
 收紧容差 更多...
 
Tolerance relax (double factor=10.0) const
 放宽容差 更多...
 

静态 Public 成员函数

static Tolerance min (const Tolerance &a, const Tolerance &b)
 合并两个容差,取更严格的(更小的) 更多...
 
static Toleranceglobal ()
 获取全局容差实例 更多...
 
static void set_global (const Tolerance &tol)
 设置全局容差 更多...
 
static constexpr double Modeling ()
 建模级精度 (1e-6):通用几何建模 更多...
 
static constexpr double Fitting ()
 拟合级精度 (1e-3):曲面拟合、近似计算 更多...
 
static constexpr double Intersection ()
 求交级精度 (1e-8):精确求交、布尔运算 更多...
 
static constexpr double Snapping ()
 吸附级精度 (1e-4):点合并、顶点焊接 更多...
 

详细描述

分层容差管理类

提供四级容差(绝对、相对、角度、吸附),支持全局实例和局部作用域覆盖。 用于数值比较、几何判定和点合并时的精度控制。

四级容差含义:

  • 绝对容差 (absolute): 对接近零的值使用,直接比较差值的绝对值
  • 相对容差 (relative): 对大值使用,比较差值 / max(|a|, |b|)
  • 角度容差 (angular): 角度/方向比较时的阈值(弧度)
  • 吸附容差 (snapping): 点合并/对齐时的容差,通常比判定容差宽松

预设精度等级:

在文件 tolerance.h29 行定义.

构造及析构函数说明

◆ Tolerance()

vde::foundation::Tolerance::Tolerance ( double  absolute = 1e-6,
double  relative = 1e-8,
double  angular = 1e-8,
double  snapping = 1e-4 
)
inline

构造容差对象

参数
absolute绝对容差,默认 1e-6
relative相对容差,默认 1e-8
angular角度容差(弧度),默认 1e-8
snapping吸附容差,默认 1e-4

在文件 tolerance.h39 行定义.

被这些函数引用 min(), relax() , 以及 tighten().

成员函数说明

◆ absolute()

double vde::foundation::Tolerance::absolute ( ) const
inline

获取绝对容差

在文件 tolerance.h93 行定义.

◆ angular()

double vde::foundation::Tolerance::angular ( ) const
inline

获取角度容差

在文件 tolerance.h97 行定义.

◆ equals()

template<typename T >
bool vde::foundation::Tolerance::equals ( a,
b 
) const
inline

混合容差相等判断

综合使用绝对和相对容差: |a - b| < absolute + relative * max(|a|, |b|)

模板参数
T数值类型
参数
a第一个值
b第二个值
返回
true 若两值在容差范围内相等
Tolerance tol(1e-6, 1e-8);
tol.equals(1.0000001, 1.0); // true
tol.equals(1000.0001, 1000.0); // true (相对项起作用)
Tolerance(double absolute=1e-6, double relative=1e-8, double angular=1e-8, double snapping=1e-4)
构造容差对象
Definition: tolerance.h:39

在文件 tolerance.h88 行定义.

◆ Fitting()

static constexpr double vde::foundation::Tolerance::Fitting ( )
inlinestaticconstexpr

拟合级精度 (1e-3):曲面拟合、近似计算

在文件 tolerance.h171 行定义.

◆ global()

static Tolerance& vde::foundation::Tolerance::global ( )
inlinestatic

获取全局容差实例

线程局部存储,默认值为建模精度 (1e-6)。

返回
全局容差的引用

在文件 tolerance.h155 行定义.

◆ Intersection()

static constexpr double vde::foundation::Tolerance::Intersection ( )
inlinestaticconstexpr

求交级精度 (1e-8):精确求交、布尔运算

在文件 tolerance.h173 行定义.

◆ is_zero()

template<typename T >
bool vde::foundation::Tolerance::is_zero ( value) const
inline

判断值是否接近零

参数
value测试值
返回
true 若 |value| < absolute_

在文件 tolerance.h66 行定义.

◆ min()

static Tolerance vde::foundation::Tolerance::min ( const Tolerance a,
const Tolerance b 
)
inlinestatic

合并两个容差,取更严格的(更小的)

参数
a第一个容差
b第二个容差
返回
每项取 min 的新容差

在文件 tolerance.h139 行定义.

引用了 Tolerance().

◆ Modeling()

static constexpr double vde::foundation::Tolerance::Modeling ( )
inlinestaticconstexpr

建模级精度 (1e-6):通用几何建模

在文件 tolerance.h169 行定义.

◆ points_equal()

bool vde::foundation::Tolerance::points_equal ( const Eigen::MatrixXd &  a,
const Eigen::MatrixXd &  b 
) const
inline

判断两点是否相等(基于绝对容差)

使用欧氏距离与绝对容差比较。

参数
a第一个点(Eigen 矩阵)
b第二个点(Eigen 矩阵)
返回
true 若两点的欧氏距离 < absolute_

在文件 tolerance.h55 行定义.

◆ relative()

double vde::foundation::Tolerance::relative ( ) const
inline

获取相对容差

在文件 tolerance.h95 行定义.

◆ relax()

Tolerance vde::foundation::Tolerance::relax ( double  factor = 10.0) const
inline

放宽容差

所有容差乘以 factor(> 1),用于在上层操作中降低精度要求。

参数
factor放宽因子(默认 10.0)
返回
放宽后的新容差对象

在文件 tolerance.h128 行定义.

引用了 Tolerance().

◆ set_global()

static void vde::foundation::Tolerance::set_global ( const Tolerance tol)
inlinestatic

设置全局容差

参数
tol新的全局容差
注解
推荐使用 ToleranceScope 进行临时修改,确保自动恢复

在文件 tolerance.h164 行定义.

被这些函数引用 vde::foundation::ToleranceScope::ToleranceScope() , 以及 vde::foundation::ToleranceScope::~ToleranceScope().

◆ Snapping()

static constexpr double vde::foundation::Tolerance::Snapping ( )
inlinestaticconstexpr

吸附级精度 (1e-4):点合并、顶点焊接

在文件 tolerance.h175 行定义.

◆ snapping()

double vde::foundation::Tolerance::snapping ( ) const
inline

获取吸附容差

在文件 tolerance.h99 行定义.

◆ tighten()

Tolerance vde::foundation::Tolerance::tighten ( double  factor = 0.1) const
inline

收紧容差

所有容差乘以 factor(< 1),用于在子操作中提高精度要求。

参数
factor收紧因子(默认 0.1)
返回
收紧后的新容差对象
auto rough = Tolerance(Tolerance::Fitting());
auto precise = rough.tighten(0.01); // 拟合 → 建模级
static constexpr double Fitting()
拟合级精度 (1e-3):曲面拟合、近似计算
Definition: tolerance.h:171

在文件 tolerance.h116 行定义.

引用了 Tolerance().


该类的文档由以下文件生成: