Skip to content

Commit

Permalink
Merge pull request #2095 from hannobraun/validate
Browse files Browse the repository at this point in the history
Allow valid `Cycle`s to be empty; validate `Face` boundary instead
  • Loading branch information
hannobraun authored Nov 15, 2023
2 parents 0989937 + 7a501d4 commit 18d768c
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 224 deletions.
2 changes: 0 additions & 2 deletions crates/fj-core/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ mod tests {
let expected =
CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]);
assert_eq!(CurveFaceIntersection::compute(&path, &face), expected);

services.only_validate(face);
}

#[test]
Expand Down
4 changes: 0 additions & 4 deletions crates/fj-core/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ mod tests {

let intersection = FaceFaceIntersection::compute([&a, &b]);
assert!(intersection.is_none());

services.only_validate([a, b]);
}

#[test]
Expand Down Expand Up @@ -147,7 +145,5 @@ mod tests {
intersection_intervals: expected_intervals
})
);

services.only_validate([a, b]);
}
}
16 changes: 0 additions & 16 deletions crates/fj-core/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ mod tests {

let intersection = (&face, &point).intersect();
assert_eq!(intersection, None);

services.only_validate(face);
}

#[test]
Expand All @@ -193,8 +191,6 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsInsideFace)
);

services.only_validate(face);
}

#[test]
Expand All @@ -221,8 +217,6 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsInsideFace)
);

services.only_validate(face);
}

#[test]
Expand All @@ -249,8 +243,6 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsInsideFace)
);

services.only_validate(face);
}

#[test]
Expand All @@ -277,8 +269,6 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsInsideFace)
);

services.only_validate(face);
}

#[test]
Expand Down Expand Up @@ -311,8 +301,6 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsInsideFace)
);

services.only_validate(face);
}

#[test]
Expand Down Expand Up @@ -347,8 +335,6 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsOnEdge(edge.clone()))
);

services.only_validate(face);
}

#[test]
Expand Down Expand Up @@ -384,7 +370,5 @@ mod tests {
intersection,
Some(FacePointIntersection::PointIsOnVertex(vertex))
);

services.only_validate(face);
}
}
14 changes: 0 additions & 14 deletions crates/fj-core/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ mod tests {
let face = face.translate([-1., 0., 0.], &mut services);

assert_eq!((&ray, &face).intersect(), None);

services.only_validate(face);
}

#[test]
Expand Down Expand Up @@ -212,8 +210,6 @@ mod tests {
(&ray, &face).intersect(),
Some(RayFaceIntersection::RayHitsFace)
);

services.only_validate(face);
}

#[test]
Expand All @@ -238,8 +234,6 @@ mod tests {
let face = face.translate([0., 0., 2.], &mut services);

assert_eq!((&ray, &face).intersect(), None);

services.only_validate(face);
}

#[test]
Expand Down Expand Up @@ -274,8 +268,6 @@ mod tests {
(&ray, &face).intersect(),
Some(RayFaceIntersection::RayHitsEdge(edge.clone()))
);

services.only_validate(face);
}

#[test]
Expand Down Expand Up @@ -311,8 +303,6 @@ mod tests {
(&ray, &face).intersect(),
Some(RayFaceIntersection::RayHitsVertex(vertex))
);

services.only_validate(face);
}

#[test]
Expand All @@ -339,8 +329,6 @@ mod tests {
(&ray, &face).intersect(),
Some(RayFaceIntersection::RayHitsFaceAndAreParallel)
);

services.only_validate(face);
}

#[test]
Expand All @@ -365,7 +353,5 @@ mod tests {
let face = face.translate([0., 0., 1.], &mut services);

assert_eq!((&ray, &face).intersect(), None);

services.only_validate(face);
}
}
3 changes: 0 additions & 3 deletions crates/fj-core/src/algorithms/triangulate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ mod tests {
})
.insert(&mut services)
});
services.only_validate(&face);

let a = Point::from(a).to_xyz();
let b = Point::from(b).to_xyz();
Expand Down Expand Up @@ -157,7 +156,6 @@ mod tests {
.insert(&mut services)
},
);
services.only_validate(&face);

let triangles = triangulate(face)?;

Expand Down Expand Up @@ -222,7 +220,6 @@ mod tests {
.insert(&mut services)
},
);
services.only_validate(&face);

let triangles = triangulate(face)?;

Expand Down
2 changes: 0 additions & 2 deletions crates/fj-core/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
mod handles;
mod kinds;
mod object;
mod set;
mod stores;

pub use self::{
Expand All @@ -60,6 +59,5 @@ pub use self::{
vertex::Vertex,
},
object::{Bare, BehindHandle, Form, Object, WithHandle},
set::ObjectSet,
stores::{Objects, Surfaces},
};
108 changes: 0 additions & 108 deletions crates/fj-core/src/objects/set.rs

This file was deleted.

5 changes: 5 additions & 0 deletions crates/fj-core/src/operations/insert/insert_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pub trait Insert: Sized {
type Inserted;

/// Insert the object into its respective store
///
/// Inserted objects will automatically be validated in the background. You
/// should not insert an invalid object into the stores, unless you have a
/// specific reason to do so, and you are handling validation errors in a
/// non-standard way.
#[must_use]
fn insert(self, services: &mut Services) -> Self::Inserted;
}
Expand Down
11 changes: 1 addition & 10 deletions crates/fj-core/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod service;
mod validation;

use crate::{
objects::{Object, ObjectSet, Objects, WithHandle},
objects::{Object, Objects, WithHandle},
validate::ValidationErrors,
};

Expand Down Expand Up @@ -56,15 +56,6 @@ impl Services {
}
}

/// Validate the provided objects and forget all other validation errors
pub fn only_validate(&mut self, objects: impl Into<ObjectSet>) {
let objects = objects.into();

let mut events = Vec::new();
self.validation
.execute(ValidationCommand::OnlyValidate { objects }, &mut events);
}

/// Drop `Services`; return any unhandled validation error
pub fn drop_and_validate(self) -> Result<(), ValidationErrors> {
let errors = ValidationErrors(
Expand Down
Loading

0 comments on commit 18d768c

Please sign in to comment.