Add ValidationConfig::from_tolerance

This commit is contained in:
Hanno Braun 2024-08-12 21:40:53 +02:00
parent 710ee5ead0
commit 7515515a99

View File

@ -39,12 +39,14 @@ pub struct ValidationConfig {
pub identical_max_distance: Scalar,
}
impl Default for ValidationConfig {
fn default() -> Self {
impl ValidationConfig {
/// Compute validation config from a tolerance value
pub fn from_tolerance(tolerance: impl Into<Tolerance>) -> Self {
let tolerance = tolerance.into();
Self {
panic_on_error: false,
tolerance: Tolerance::from_scalar(0.001)
.expect("Tolerance provided is larger than zero"),
tolerance,
distinct_min_distance: Scalar::from_f64(5e-7), // 0.5 µm,
// This value was chosen pretty arbitrarily. Seems small enough to
@ -55,3 +57,9 @@ impl Default for ValidationConfig {
}
}
}
impl Default for ValidationConfig {
fn default() -> Self {
Self::from_tolerance(0.001)
}
}