Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation error message #1518

Merged
merged 3 commits into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions crates/fj-kernel/src/validate/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,15 @@ pub enum VertexValidationError {
#[error(
"`Vertex` position doesn't match position of its surface form\n\
- `Vertex`: {vertex:#?}\n\
- `SurfaceVertex`: {surface_vertex:#?}\n\
- `Vertex` position as surface: {curve_position_as_surface:?}\n\
- `Vertex` position on surface: {curve_position_on_surface:?}\n\
- Distance between the positions: {distance}"
)]
PositionMismatch {
/// The vertex
vertex: Vertex,

/// The mismatched surface vertex
surface_vertex: SurfaceVertex,

/// The curve position converted into a surface position
curve_position_as_surface: Point<2>,
curve_position_on_surface: Point<2>,

/// The distance between the positions
distance: Scalar,
Expand Down Expand Up @@ -101,20 +97,19 @@ impl VertexValidationError {
config: &ValidationConfig,
errors: &mut Vec<ValidationError>,
) {
let curve_position_as_surface = vertex
let curve_position_on_surface = vertex
.curve()
.path()
.point_from_path_coords(vertex.position());
let surface_position = vertex.surface_form().position();

let distance = curve_position_as_surface.distance_to(&surface_position);
let distance = curve_position_on_surface.distance_to(&surface_position);

if distance > config.identical_max_distance {
errors.push(
Box::new(Self::PositionMismatch {
vertex: vertex.clone(),
surface_vertex: vertex.surface_form().clone_object(),
curve_position_as_surface,
curve_position_on_surface,
distance,
})
.into(),
Expand Down