Skip to main content

cartan_remesh/
error.rs

1// ~/cartan/cartan-remesh/src/error.rs
2
3//! Error types for remeshing operations.
4
5/// Errors that can occur during remeshing.
6#[derive(Debug, Clone, thiserror::Error)]
7pub enum RemeshError {
8    /// Edge collapse would cause a triangle foldover (normal inversion).
9    #[error(
10        "foldover detected at face {face}: normal rotation {angle_rad:.4} rad exceeds threshold {threshold:.4} rad"
11    )]
12    Foldover {
13        face: usize,
14        angle_rad: f64,
15        threshold: f64,
16    },
17
18    /// The edge is a boundary edge and cannot be flipped.
19    #[error("edge {edge} is a boundary edge (only one adjacent face)")]
20    BoundaryEdge { edge: usize },
21
22    /// The edge flip would not improve the Delaunay criterion.
23    #[error(
24        "edge {edge} already satisfies Delaunay criterion (opposite angle sum = {angle_sum:.4} rad)"
25    )]
26    AlreadyDelaunay { edge: usize, angle_sum: f64 },
27
28    /// A vertex or edge index is out of bounds.
29    #[error("index out of bounds: {index} >= {len}")]
30    IndexOutOfBounds { index: usize, len: usize },
31
32    /// The edge has fewer than 2 adjacent faces (boundary or degenerate).
33    #[error("edge {edge} has {count} adjacent faces, need exactly 2")]
34    NotInteriorEdge { edge: usize, count: usize },
35
36    /// A manifold geodesic operation (log/exp) failed.
37    #[error("geodesic computation failed: {reason}")]
38    GeodesicFailed { reason: String },
39
40    /// Caller-supplied input is malformed.
41    #[error("invalid input: {0}")]
42    InvalidInput(String),
43}