mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-13 10:45:51 +00:00
Add information about curves to validation error
This commit is contained in:
parent
3266a01077
commit
f3a77af94b
@ -4,7 +4,7 @@ use fj_math::{Point, Scalar};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{CurveBoundary, SurfaceGeometry},
|
geometry::{CurveBoundary, SurfaceGeometry},
|
||||||
objects::{HalfEdge, Shell, Surface, Vertex},
|
objects::{Curve, HalfEdge, Shell, Surface, Vertex},
|
||||||
queries::{
|
queries::{
|
||||||
AllHalfEdgesWithSurface, BoundingVerticesOfHalfEdge, SiblingOfHalfEdge,
|
AllHalfEdgesWithSurface, BoundingVerticesOfHalfEdge, SiblingOfHalfEdge,
|
||||||
},
|
},
|
||||||
@ -47,11 +47,15 @@ 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\
|
||||||
|
{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 curves of the half-edges
|
||||||
|
curves: Box<CoincidentHalfEdgeCurves>,
|
||||||
|
|
||||||
/// The vertices of the half-edges
|
/// The vertices of the half-edges
|
||||||
vertices: Box<CoincidentHalfEdgeVertices>,
|
vertices: Box<CoincidentHalfEdgeVertices>,
|
||||||
|
|
||||||
@ -235,6 +239,10 @@ impl ShellValidationError {
|
|||||||
)
|
)
|
||||||
.all(|d| d < config.distinct_min_distance)
|
.all(|d| d < config.distinct_min_distance)
|
||||||
{
|
{
|
||||||
|
let curves = Box::new(CoincidentHalfEdgeCurves {
|
||||||
|
curves: [half_edge_a, half_edge_b]
|
||||||
|
.map(|half_edge| half_edge.curve().clone()),
|
||||||
|
});
|
||||||
let vertices = Box::new(CoincidentHalfEdgeVertices {
|
let vertices = Box::new(CoincidentHalfEdgeVertices {
|
||||||
vertices: [half_edge_a, half_edge_b].map(|half_edge| {
|
vertices: [half_edge_a, half_edge_b].map(|half_edge| {
|
||||||
shell
|
shell
|
||||||
@ -247,6 +255,7 @@ impl ShellValidationError {
|
|||||||
|
|
||||||
errors.push(
|
errors.push(
|
||||||
Self::CoincidentHalfEdgesAreNotSiblings {
|
Self::CoincidentHalfEdgesAreNotSiblings {
|
||||||
|
curves,
|
||||||
vertices,
|
vertices,
|
||||||
half_edge_a: half_edge_a.clone(),
|
half_edge_a: half_edge_a.clone(),
|
||||||
half_edge_b: half_edge_b.clone(),
|
half_edge_b: half_edge_b.clone(),
|
||||||
@ -259,6 +268,29 @@ impl ShellValidationError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct CoincidentHalfEdgeCurves {
|
||||||
|
pub curves: [Handle<Curve>; 2],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CoincidentHalfEdgeCurves {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let [a, b] = &self.curves;
|
||||||
|
|
||||||
|
if a.id() != b.id() {
|
||||||
|
writeln!(
|
||||||
|
f,
|
||||||
|
"Curves don't match.\n\
|
||||||
|
\tHalf-edge 1 lies on {a:?}\n\
|
||||||
|
\tHalf-edge 2 lies on {b:?}\n\
|
||||||
|
\t(must be the same)"
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CurveCoordinateSystemMismatch {
|
pub struct CurveCoordinateSystemMismatch {
|
||||||
pub half_edge_a: Handle<HalfEdge>,
|
pub half_edge_a: Handle<HalfEdge>,
|
||||||
|
Loading…
Reference in New Issue
Block a user