1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum SmoothError {
7 NonFiniteInput,
9 NegativeInput,
11 DegenerateAxis,
13 InvalidAngle,
15 TooFewPoints,
17 DegenerateFrame,
19 ConcaveFrame,
21 SelfIntersectingFrame,
23}
24
25impl fmt::Display for SmoothError {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match self {
28 SmoothError::NonFiniteInput => write!(f, "输入包含非有限数值"),
29 SmoothError::NegativeInput => write!(f, "长度、半径或限制不能为负数"),
30 SmoothError::DegenerateAxis => write!(f, "角点方向向量退化"),
31 SmoothError::InvalidAngle => write!(f, "角点角度必须满足 0 < phi < PI"),
32 SmoothError::TooFewPoints => write!(f, "闭合 frame 至少需要 3 个点"),
33 SmoothError::DegenerateFrame => write!(f, "frame 包含退化边或面积为零"),
34 SmoothError::ConcaveFrame => write!(f, "当前版本仅支持凸 frame"),
35 SmoothError::SelfIntersectingFrame => write!(f, "当前版本不支持自相交 frame"),
36 }
37 }
38}
39
40impl Error for SmoothError {}