mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-13 10:45:51 +00:00
Add info about boundaries to validation error
This commit is contained in:
parent
f3a77af94b
commit
a8ec30565f
@ -47,12 +47,16 @@ pub enum ShellValidationError {
|
|||||||
#[error(
|
#[error(
|
||||||
"`Shell` contains `HalfEdge`s that are coincident but are not \
|
"`Shell` contains `HalfEdge`s that are coincident but are not \
|
||||||
siblings\n\
|
siblings\n\
|
||||||
|
{boundaries}\
|
||||||
{curves}\
|
{curves}\
|
||||||
{vertices}\
|
{vertices}\
|
||||||
Half-edge 1: {half_edge_a:#?}\n\
|
Half-edge 1: {half_edge_a:#?}\n\
|
||||||
Half-edge 2: {half_edge_b:#?}"
|
Half-edge 2: {half_edge_b:#?}"
|
||||||
)]
|
)]
|
||||||
CoincidentHalfEdgesAreNotSiblings {
|
CoincidentHalfEdgesAreNotSiblings {
|
||||||
|
/// The boundaries of the half-edges
|
||||||
|
boundaries: Box<CoincidentHalfEdgeBoundaries>,
|
||||||
|
|
||||||
/// The curves of the half-edges
|
/// The curves of the half-edges
|
||||||
curves: Box<CoincidentHalfEdgeCurves>,
|
curves: Box<CoincidentHalfEdgeCurves>,
|
||||||
|
|
||||||
@ -239,6 +243,10 @@ impl ShellValidationError {
|
|||||||
)
|
)
|
||||||
.all(|d| d < config.distinct_min_distance)
|
.all(|d| d < config.distinct_min_distance)
|
||||||
{
|
{
|
||||||
|
let boundaries = Box::new(CoincidentHalfEdgeBoundaries {
|
||||||
|
boundaries: [half_edge_a, half_edge_b]
|
||||||
|
.map(|half_edge| half_edge.boundary()),
|
||||||
|
});
|
||||||
let curves = Box::new(CoincidentHalfEdgeCurves {
|
let curves = Box::new(CoincidentHalfEdgeCurves {
|
||||||
curves: [half_edge_a, half_edge_b]
|
curves: [half_edge_a, half_edge_b]
|
||||||
.map(|half_edge| half_edge.curve().clone()),
|
.map(|half_edge| half_edge.curve().clone()),
|
||||||
@ -255,6 +263,7 @@ impl ShellValidationError {
|
|||||||
|
|
||||||
errors.push(
|
errors.push(
|
||||||
Self::CoincidentHalfEdgesAreNotSiblings {
|
Self::CoincidentHalfEdgesAreNotSiblings {
|
||||||
|
boundaries,
|
||||||
curves,
|
curves,
|
||||||
vertices,
|
vertices,
|
||||||
half_edge_a: half_edge_a.clone(),
|
half_edge_a: half_edge_a.clone(),
|
||||||
@ -268,6 +277,29 @@ impl ShellValidationError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct CoincidentHalfEdgeBoundaries {
|
||||||
|
pub boundaries: [CurveBoundary<Point<1>>; 2],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CoincidentHalfEdgeBoundaries {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let [a, b] = &self.boundaries;
|
||||||
|
|
||||||
|
if a != &b.reverse() {
|
||||||
|
writeln!(
|
||||||
|
f,
|
||||||
|
"Boundaries don't match.\n\
|
||||||
|
\tHalf-edge 1 has boundary `{a:?}`\n\
|
||||||
|
\tHalf-edge 2 has boundary `{b:?}`\n\
|
||||||
|
\t(expecting same boundary, but reversed)"
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CoincidentHalfEdgeCurves {
|
pub struct CoincidentHalfEdgeCurves {
|
||||||
pub curves: [Handle<Curve>; 2],
|
pub curves: [Handle<Curve>; 2],
|
||||||
|
Loading…
Reference in New Issue
Block a user