Skip to content

Commit

Permalink
Merge pull request #2447 from hannobraun/validate
Browse files Browse the repository at this point in the history
Add more information to validation error
  • Loading branch information
hannobraun authored Aug 12, 2024
2 parents cf97375 + 2f7fcaa commit a19143c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/fj-core/src/operations/build/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub trait BuildCycle {
/// ## Implementation Note
///
/// The cycle can't be built out of a single half-edge. That would be
/// invalid although there's not validation check to document and enforce
/// invalid although there's no validation check to document and enforce
/// that yet. Please refer to the following issue for more information:
/// <https://github.com/hannobraun/fornjot/issues/2374>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub struct CoincidentHalfEdgesAreNotSiblings {
/// The second half-edge
pub half_edge_b: Handle<HalfEdge>,

/// The points on the half-edges that were checked
pub points: Vec<[Point<3>; 2]>,

/// The distances between the points on the half-edges that were checked
pub distances: Vec<Scalar>,
}
Expand Down Expand Up @@ -76,8 +79,9 @@ impl fmt::Display for CoincidentHalfEdgesAreNotSiblings {
f,
"Half-edge 1: {:#?}\n\
Half-edge 2: {:#?}\n\
Points: {:#?}\n\
Distances: {:#?}",
self.half_edge_a, self.half_edge_b, self.distances
self.half_edge_a, self.half_edge_b, self.points, self.distances
)?;

Ok(())
Expand Down Expand Up @@ -112,7 +116,7 @@ impl ValidationCheck<Shell> for CoincidentHalfEdgesAreNotSiblings {
continue;
}

let Some(distances) = distances(
let Some(points_and_distances) = distances(
half_edge_a.clone(),
object
.find_cycle_of_half_edge(half_edge_a)
Expand All @@ -137,7 +141,9 @@ impl ValidationCheck<Shell> for CoincidentHalfEdgesAreNotSiblings {
// hence these half-edges can't be coincident.
continue;
};
let distances = distances.collect::<Vec<_>>();

let (points, distances): (Vec<_>, Vec<_>) =
points_and_distances.into_iter().unzip();

// If all points on distinct curves are within
// `distinct_min_distance`, that's a problem.
Expand All @@ -158,6 +164,7 @@ impl ValidationCheck<Shell> for CoincidentHalfEdgesAreNotSiblings {
vertices,
half_edge_a: half_edge_a.clone(),
half_edge_b: half_edge_b.clone(),
points,
distances,
})
}
Expand All @@ -179,7 +186,7 @@ fn distances(
end_vertex_b: &Handle<Vertex>,
surface_b: &Handle<Surface>,
geometry: &Geometry,
) -> Option<impl Iterator<Item = Scalar>> {
) -> Option<Vec<([Point<3>; 2], Scalar)>> {
fn sample(
percent: f64,
half_edge: &Handle<HalfEdge>,
Expand Down Expand Up @@ -232,9 +239,9 @@ fn distances(
surface_b,
geometry,
)?;
distances.push(sample1.distance_to(&sample2))
distances.push(([sample1, sample2], sample1.distance_to(&sample2)))
}
Some(distances.into_iter())
Some(distances)
}

#[cfg(test)]
Expand Down

0 comments on commit a19143c

Please sign in to comment.