mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-07 19:38:29 +00:00
Merge pull request #2447 from hannobraun/validate
Add more information to validation error
This commit is contained in:
commit
a19143c87b
@ -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>
|
||||
///
|
||||
|
@ -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>,
|
||||
}
|
||||
@ -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(())
|
||||
@ -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)
|
||||
@ -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.
|
||||
@ -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,
|
||||
})
|
||||
}
|
||||
@ -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>,
|
||||
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user