Skip to content

Commit

Permalink
Merge pull request #618 from hannobraun/shape
Browse files Browse the repository at this point in the history
Make "min distance" nomenclature in `Shape` more specific
  • Loading branch information
hannobraun authored May 23, 2022
2 parents 0f3199d + dd5a5c8 commit 727d329
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions crates/fj-kernel/src/shape/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
/// The boundary representation of a shape
#[derive(Clone, Debug)]
pub struct Shape {
min_distance: Scalar,
distinct_min_distance: Scalar,
stores: Stores,
}

Expand All @@ -24,7 +24,7 @@ impl Shape {
// This should really come from `Self::DEFAULT_MIN_DISTANCE`, or a
// similarly named constant. Unfortunately `Scalar::from_f64` can't
// be `const` yet.
min_distance: Scalar::from_f64(5e-7), // 0.5 µm
distinct_min_distance: Scalar::from_f64(5e-7), // 0.5 µm

stores: Stores {
points: Store::new(),
Expand All @@ -39,7 +39,7 @@ impl Shape {
}
}

/// Override the minimum distance for this shape
/// Override the minimum distance of distinct objects
///
/// Used for vertex validation, to determine whether vertices are unique.
///
Expand All @@ -48,11 +48,11 @@ impl Shape {
/// This functionality should be exposed to models, eventually. For now it's
/// just used in unit tests.
#[cfg(test)]
pub fn with_min_distance(
pub fn with_distinct_min_distance(
mut self,
min_distance: impl Into<Scalar>,
distinct_min_distance: impl Into<Scalar>,
) -> Self {
self.min_distance = min_distance.into();
self.distinct_min_distance = distinct_min_distance.into();
self
}

Expand All @@ -61,7 +61,7 @@ impl Shape {
/// Validates the object, and returns an error if it is not valid. See the
/// documentation of each object for validation requirements.
pub fn insert<T: Object>(&mut self, object: T) -> ValidationResult<T> {
object.validate(None, self.min_distance, &self.stores)?;
object.validate(None, self.distinct_min_distance, &self.stores)?;
let handle = self.stores.get::<T>().insert(object);
Ok(handle)
}
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Shape {
/// Returns [`Update`], and API that can be used to update objects in the
/// shape.
pub fn update(&mut self) -> Update {
Update::new(self.min_distance, &mut self.stores)
Update::new(self.distinct_min_distance, &mut self.stores)
}

/// Clone the shape
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {

#[test]
fn add_vertex() -> anyhow::Result<()> {
let mut shape = Shape::new().with_min_distance(MIN_DISTANCE);
let mut shape = Shape::new().with_distinct_min_distance(MIN_DISTANCE);
let mut other = Shape::new();

let point = shape.insert(Point::from([0., 0., 0.]))?;
Expand Down

0 comments on commit 727d329

Please sign in to comment.