From 5beb8e8a54055847e3f13692817a57f4f2816c1a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Aug 2024 19:15:37 +0200 Subject: [PATCH 1/4] Prepare for follow-on change --- crates/fj-core/src/core.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/core.rs b/crates/fj-core/src/core.rs index d4f273c18..5102c2307 100644 --- a/crates/fj-core/src/core.rs +++ b/crates/fj-core/src/core.rs @@ -7,7 +7,6 @@ use crate::{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, @@ -16,7 +15,9 @@ pub struct Core { impl Core { /// Construct an instance of `Instance` pub fn new() -> Self { - Self::default() + Self { + layers: Layers::default(), + } } /// Construct an instance of `Instance`, using the provided configuration @@ -25,3 +26,9 @@ impl Core { Self { layers } } } + +impl Default for Core { + fn default() -> Self { + Self::new() + } +} From 5a7f10964e7e75b4cb369178daa4ea8dafdbd178 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Aug 2024 19:22:32 +0200 Subject: [PATCH 2/4] Update documentation of `Core` --- crates/fj-core/src/core.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/core.rs b/crates/fj-core/src/core.rs index 5102c2307..d53e7d3a2 100644 --- a/crates/fj-core/src/core.rs +++ b/crates/fj-core/src/core.rs @@ -13,14 +13,14 @@ pub struct Core { } impl Core { - /// Construct an instance of `Instance` + /// Construct an instance of `Core` pub fn new() -> Self { Self { 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 } From cc457a85a2935dff011849831e6e498d45c88c3e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Aug 2024 19:26:17 +0200 Subject: [PATCH 3/4] Prepare for follow-on change --- crates/fj-core/src/core.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/core.rs b/crates/fj-core/src/core.rs index d53e7d3a2..47336abcc 100644 --- a/crates/fj-core/src/core.rs +++ b/crates/fj-core/src/core.rs @@ -15,14 +15,16 @@ pub struct Core { impl Core { /// Construct an instance of `Core` pub fn new() -> Self { - Self { - layers: Layers::default(), - } + Self::from_layers(Layers::default()) } /// 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::from_layers(layers) + } + + fn from_layers(layers: Layers) -> Self { Self { layers } } } From ddd7a392ba3ed7bc13f4a8ca24757102a69773a8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Aug 2024 19:33:53 +0200 Subject: [PATCH 4/4] Add default tolerance to `Core` As per its documentation, this can be used when computing the new uniform intermediate geometry representation. I'm working on that right now, so it's hopefully going to see some use soon. --- crates/fj-core/src/core.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/core.rs b/crates/fj-core/src/core.rs index 47336abcc..e1e65fc7d 100644 --- a/crates/fj-core/src/core.rs +++ b/crates/fj-core/src/core.rs @@ -2,7 +2,9 @@ //! //! See [`Core`]. -use crate::{layers::Layers, validation::ValidationConfig}; +use crate::{ + algorithms::approx::Tolerance, layers::Layers, validation::ValidationConfig, +}; /// An instance of the Fornjot core /// @@ -10,6 +12,9 @@ use crate::{layers::Layers, validation::ValidationConfig}; 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 { @@ -25,7 +30,13 @@ impl Core { } fn from_layers(layers: Layers) -> Self { - Self { layers } + let default_tolerance = Tolerance::from_scalar(0.001) + .expect("Tolerance provided is larger than zero"); + + Self { + layers, + default_tolerance, + } } }