Skip to content

Commit

Permalink
Merge pull request #2440 from hannobraun/tolerance
Browse files Browse the repository at this point in the history
Add default tolerance to `Core`
  • Loading branch information
hannobraun authored Aug 6, 2024
2 parents 4de577f + ddd7a39 commit b41344f
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions crates/fj-core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit b41344f

Please sign in to comment.