Skip to content

Commit

Permalink
Merge pull request #707 from hannobraun/validation
Browse files Browse the repository at this point in the history
Rename `validation::Config` to `ValidationConfig`
  • Loading branch information
hannobraun authored Jun 21, 2022
2 parents f3d8c29 + f3cb2b7 commit 4447d2f
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
16 changes: 8 additions & 8 deletions crates/fj-kernel/src/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::{
/// Validate the given [`Shape`]
pub fn validate(
shape: Shape,
config: &Config,
config: &ValidationConfig,
) -> Result<Validated<Shape>, ValidationError> {
for edge in shape.edges() {
coherence::validate_edge(&edge.get(), config.identical_max_distance)?;
Expand All @@ -51,7 +51,7 @@ pub fn validate(

/// Configuration required for the validation process
#[derive(Debug, Clone, Copy)]
pub struct Config {
pub struct ValidationConfig {
/// The minimum distance between distinct objects
///
/// Objects whose distance is less than the value defined in this field, are
Expand All @@ -67,7 +67,7 @@ pub struct Config {
pub identical_max_distance: Scalar,
}

impl Default for Config {
impl Default for ValidationConfig {
fn default() -> Self {
Self {
distinct_min_distance: Scalar::from_f64(5e-7), // 0.5 µm,
Expand Down Expand Up @@ -183,7 +183,7 @@ mod tests {
use crate::{
objects::Edge,
shape::{LocalForm, Shape},
validation::Config,
validation::ValidationConfig,
};

#[test]
Expand Down Expand Up @@ -213,18 +213,18 @@ mod tests {

let result = super::validate(
shape.clone(),
&Config {
&ValidationConfig {
identical_max_distance: deviation * 2.,
..Config::default()
..ValidationConfig::default()
},
);
assert!(result.is_ok());

let result = super::validate(
shape,
&Config {
&ValidationConfig {
identical_max_distance: deviation / 2.,
..Config::default()
..ValidationConfig::default()
},
);
assert!(result.is_err());
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use fj_kernel::{
algorithms::Tolerance,
objects::{Cycle, Edge, Face, Surface},
shape::{LocalForm, Shape},
validation::{self, validate, Validated, ValidationError},
validation::{validate, Validated, ValidationConfig, ValidationError},
};
use fj_math::{Aabb, Point, Scalar};

Expand All @@ -12,7 +12,7 @@ use super::ToShape;
impl ToShape for fj::Circle {
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
_: Tolerance,
_: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/difference_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use fj_kernel::{
algorithms::Tolerance,
objects::{Cycle, Edge, Face},
shape::{LocalForm, Shape},
validation::{self, validate, Validated, ValidationError},
validation::{validate, Validated, ValidationConfig, ValidationError},
};
use fj_math::Aabb;

Expand All @@ -12,7 +12,7 @@ use super::ToShape;
impl ToShape for fj::Difference2d {
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_interop::debug::DebugInfo;
use fj_kernel::{
algorithms::Tolerance,
shape::Shape,
validation::{self, validate, Validated, ValidationError},
validation::{validate, Validated, ValidationConfig, ValidationError},
};
use fj_math::Aabb;

Expand All @@ -11,7 +11,7 @@ use super::ToShape;
impl ToShape for fj::Group {
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError> {
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-operations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use fj_interop::debug::DebugInfo;
use fj_kernel::{
algorithms::Tolerance,
shape::Shape,
validation::{self, Validated, ValidationError},
validation::{Validated, ValidationConfig, ValidationError},
};
use fj_math::Aabb;

Expand All @@ -38,7 +38,7 @@ pub trait ToShape {
/// Compute the boundary representation of the shape
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError>;
Expand Down Expand Up @@ -91,7 +91,7 @@ macro_rules! dispatch {

dispatch! {
to_shape(
config: &validation::Config,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError>;
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/shape_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use fj_interop::{debug::DebugInfo, mesh::Mesh};
use fj_kernel::{
algorithms::{triangulate, InvalidTolerance, Tolerance},
validation::{self, ValidationError},
validation::{ValidationConfig, ValidationError},
};
use fj_math::{Aabb, Point, Scalar};

Expand Down Expand Up @@ -38,7 +38,7 @@ impl ShapeProcessor {
Some(user_defined_tolerance) => user_defined_tolerance,
};

let config = validation::Config::default();
let config = ValidationConfig::default();
let mut debug_info = DebugInfo::new();
let shape = shape.to_shape(&config, tolerance, &mut debug_info)?;
let mesh = triangulate(shape.into_inner(), tolerance, &mut debug_info);
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use fj_kernel::{
algorithms::Tolerance,
objects::{Face, Surface},
shape::Shape,
validation::{self, validate, Validated, ValidationError},
validation::{validate, Validated, ValidationConfig, ValidationError},
};
use fj_math::{Aabb, Point};

Expand All @@ -12,7 +12,7 @@ use super::ToShape;
impl ToShape for fj::Sketch {
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
_: Tolerance,
_: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_interop::debug::DebugInfo;
use fj_kernel::{
algorithms::{sweep_shape, Tolerance},
shape::Shape,
validation::{self, validate, Validated, ValidationError},
validation::{validate, Validated, ValidationConfig, ValidationError},
};
use fj_math::{Aabb, Vector};

Expand All @@ -11,7 +11,7 @@ use super::ToShape;
impl ToShape for fj::Sweep {
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-operations/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_interop::debug::DebugInfo;
use fj_kernel::{
algorithms::{transform_shape, Tolerance},
shape::Shape,
validation::{self, validate, Validated, ValidationError},
validation::{validate, Validated, ValidationConfig, ValidationError},
};
use fj_math::{Aabb, Transform, Vector};

Expand All @@ -11,7 +11,7 @@ use super::ToShape;
impl ToShape for fj::Transform {
fn to_shape(
&self,
config: &validation::Config,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Shape>, ValidationError> {
Expand Down

0 comments on commit 4447d2f

Please sign in to comment.