1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
mod curve;
mod cycle;
mod edge;
mod face;
mod shell;
mod sketch;
mod solid;
mod surface;
mod vertex;
pub use self::{
cycle::CycleValidationError,
edge::HalfEdgeValidationError,
face::FaceValidationError,
vertex::{SurfaceVertexValidationError, VertexValidationError},
};
use std::convert::Infallible;
use fj_math::Scalar;
pub trait Validate: Sized {
type Error: Into<ValidationError>;
fn validate(&self) -> Result<(), Self::Error> {
self.validate_with_config(&ValidationConfig::default())
}
fn validate_with_config(
&self,
config: &ValidationConfig,
) -> Result<(), Self::Error>;
}
#[derive(Debug, Clone, Copy)]
pub struct ValidationConfig {
pub distinct_min_distance: Scalar,
pub identical_max_distance: Scalar,
}
impl Default for ValidationConfig {
fn default() -> Self {
Self {
distinct_min_distance: Scalar::from_f64(5e-7), identical_max_distance: Scalar::from_f64(5e-14),
}
}
}
#[derive(Clone, Debug, thiserror::Error)]
pub enum ValidationError {
#[error(transparent)]
Cycle(#[from] CycleValidationError),
#[error(transparent)]
Face(#[from] FaceValidationError),
#[error(transparent)]
HalfEdge(#[from] HalfEdgeValidationError),
#[error(transparent)]
SurfaceVertex(#[from] SurfaceVertexValidationError),
#[error(transparent)]
Vertex(#[from] VertexValidationError),
}
impl From<Infallible> for ValidationError {
fn from(infallible: Infallible) -> Self {
match infallible {}
}
}