跳到内容
CADCAMFUN
文档

文档

公差和镶嵌

一种弦高公差如何决定 CAD 内核中的段数、显示小数和曲线镶嵌。

从英文自动翻译。 查看英文原文

一种公差,每条曲线

A tolerance is the largest distance the model may be from the true shape, in millimetres. For a circle drawn as a polygon that distance is the chord's sagitta r(1 − cos(π/n)), so the number of segments follows from the tolerance. packages/core/src/cad/tolerance.ts (39 行) 遵守该规则;编辑器的渲染器、助手的元素目录、实体镶嵌器和测试都使用它。

Ø20 圆,三个公差 拖动进行轨道旋转·滚动进行缩放·右键拖动进行平移
The same radius-10 circle as segmentsFor gives it: 10 segments at 0.5 mm (chord error 0.489), 23 at 0.1 mm (0.093) and 71 at the 0.01 mm default (0.0098). Each polygon is extruded 2 mm.

常数

姓名价值意义
TOLERANCE_PRESETS0.1, 0.05, 0.01, 0.005, 0.002, 0.001, 0.0005uI 提供什么,从粗到细
DEFAULT_TOLERANCE0.01编辑器和曲面细分默认值
MIN_TOLERANCE0.0001下面这个 isTolerance 为 false
MAX_TOLERANCE10上面这个 isTolerance 为 false
MIN_CURVE_SEGMENTS8圆的最少线段
MAX_CURVE_SEGMENTS2048段的默认上限For
MAX_SEGMENTS(tessellate.ts)65 536实体镶嵌器中每个实体的硬上限
MIN_TOLERANCE(tessellate.ts)1e-6下限,因此零容差不能产生无限计数
tolerance.ts
export const isTolerance: (value: unknown) => value is number      // finite, in [0.0001, 10]
/** Smallest n ≥ 8 with r(1 − cos(π/n)) ≤ tolerance, capped. */
export const segmentsFor: (radius: number, tolerance: number, cap?: number /* 2048 */) => number
export const chordError: (radius: number, segments: number) => number   // r(1 − cos(π/n))
/** 0.001 → 3, 0.05 → 2, 0.5 → 1; at most 6. */
export const decimalsForTolerance: (tolerance: number) => number

预设数字

真实的 segmentsFor, chordError 和 decimalsForTolerance 每个预设的输出:

公差,毫米段 r 10和弦错误 r 10小数段 r 50
0.1239.314e-2150
0.05324.815e-2271
0.01(默认)719.788e-32158
0.0051004.934e-33223
0.0021581.977e-33352
0.0012239.923e-43497
0.00053154.973e-44703

边缘情况,也是真实的: segmentsFor(1000, 0.0001) = 2048(上限), segmentsFor(2, 5) = 8(公差≥半径), isTolerance(0.00005) =假, isTolerance(10) = 真实, decimalsForTolerance(0.0001) = 4.

细分绘图实体

tessellate(entity, tolerance) 中 tessellate.ts 将任何绘图实体转换为弦公差范围内的折线。该折线是 CAM 层偏移的内容以及视口渲染的内容。闭合形状返回一个环,其第一个点和最后一个点不同;结束部分是隐式的。
实体规则
线它的两个端点
圆、弧根据半径、扫掠和公差计算圆弧段数,上限为 65 536
椭圆均匀参数步长h = √(8·tol / a),a较大半径,至少8段
样条线样条折线的解析界
折线凸出的弧段
长方形四个角
文字、尺寸无大纲:空列表

对于半径为 20 和 10 的椭圆, ellipseSegmentCount 给出 100.0 mm 处的 01 段和 32.0 mm 处的 1 段。

公差满足的地方

核心公差参数默认
草图轮廓sketchProfiles(草图,公差)0.01 mm
网格图元meshOf(实体,公差)0.1 mm
南玻巧合CsgOptions.tolerance1e-7 × 范围
B-rep 镶嵌TessellateOptions.chordTol对角线 / 2000,在 [0.001,0.05]
B-rep 布尔巧合BooleanOptions.tol1e-8 × 大小,≥ 1e-7
螺旋和弦stepsPerTurn0.01 mm

显示公差不是加工公差

绘图公差控制曲线的近似方式。 CAM验证和G代码圆弧拟合有自己的公差;请参阅 CAM 内核。

故障排除

症状原因使固定
圆圈看起来是多边形的大半径上的公差 0.1选择更精细的预设;细分市场随着 √r 增长
大型绘图上的视口速度缓慢许多曲线上的公差非常精细0.01足以显示;保留更精细的出口值
长度显示太多小数小数遵循公差decimalsForTolerance(0.01) = 2
某个值被视为容差而被拒绝在 [0.0001, 10] 之外使用预设