diff --git a/crates/fj-core/src/core.rs b/crates/fj-core/src/core.rs index d4f273c18..e1e65fc7d 100644 --- a/crates/fj-core/src/core.rs +++ b/crates/fj-core/src/core.rs @@ -2,26 +2,46 @@ //! //! See [`Core`]. -use crate::{layers::Layers, validation::ValidationConfig}; +use crate::{ + algorithms::approx::Tolerance, layers::Layers, validation::ValidationConfig, +}; /// An instance of the Fornjot core /// /// This is the main entry point to `fj-core`'s API. -#[derive(Default)] pub struct Core { /// The layers of data that make up the state of a core instance pub layers: Layers, + + /// Default tolerance used for intermediate geometry representation + pub default_tolerance: Tolerance, } impl Core { - /// Construct an instance of `Instance` + /// Construct an instance of `Core` pub fn new() -> Self { - Self::default() + Self::from_layers(Layers::default()) } - /// Construct an instance of `Instance`, using the provided configuration + /// Construct an instance of `Core`, using the provided configuration pub fn with_validation_config(config: ValidationConfig) -> Self { let layers = Layers::with_validation_config(config); - Self { layers } + Self::from_layers(layers) + } + + fn from_layers(layers: Layers) -> Self { + let default_tolerance = Tolerance::from_scalar(0.001) + .expect("Tolerance provided is larger than zero"); + + Self { + layers, + default_tolerance, + } + } +} + +impl Default for Core { + fn default() -> Self { + Self::new() } }