-
-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathconfig.rs
50 lines (45 loc) · 1.95 KB
/
config.rs
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
use fj_math::Scalar;
/// Configuration required for the validation process
#[derive(Debug, Clone, Copy)]
pub struct ValidationConfig {
/// Panic on first validation error, instead of storing it
///
/// Validation errors are usually stored in the validation layer, and only
/// cause a panic if the validation layer is dropped with unhandled errors.
///
/// This provides flexibility in handling validation errors, but can also be
/// helpful in understanding them, as experience has shown that the first
/// validation error often does not provide a full picture of what's wrong.
///
/// However, it can be helpful to get an immediate panic on a validation
/// error, to get the code that caused it into a stack trace. This is what
/// happens, if this option is set to `true`.
///
/// Defaults to `false`.
pub panic_on_error: bool,
/// The minimum distance between distinct objects
///
/// Objects whose distance is less than the value defined in this field, are
/// considered identical.
pub distinct_min_distance: Scalar,
/// The maximum distance between identical objects
///
/// Objects that are considered identical might still have a distance
/// between them, due to inaccuracies of the numerical representation. If
/// that distance is less than the one defined in this field, can not be
/// considered identical.
pub identical_max_distance: Scalar,
}
impl Default for ValidationConfig {
fn default() -> Self {
Self {
panic_on_error: false,
distinct_min_distance: Scalar::from_f64(5e-7), // 0.5 µm,
// This value was chosen pretty arbitrarily. Seems small enough to
// catch errors. If it turns out it's too small (because it produces
// false positives due to floating-point accuracy issues), we can
// adjust it.
identical_max_distance: Scalar::from_f64(5e-14),
}
}
}