parry3d/transformation/mesh_intersection/
mesh_intersection_error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use core::fmt;

#[cfg(doc)]
use crate::shape::{TriMesh, TriMeshFlags};

/// Error indicating that a query is not supported between certain shapes
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum MeshIntersectionError {
    MissingTopology,
    MissingPseudoNormals,
    TriTriError,
    DuplicateVertices,
    TriangulationError,
}

impl fmt::Display for MeshIntersectionError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::MissingTopology => {
                f.pad("at least one of the meshes is missing its topology information. Call `mesh.compute_topology` on the mesh")
            }
            Self::MissingPseudoNormals => {
                f.pad("at least one of the meshes is missing its pseudo-normals. Call `mesh.compute_pseudo_normals` on the mesh")
            }
            Self::TriTriError => f.pad("internal failure while intersecting two triangles"),
            Self::DuplicateVertices => f.pad("internal failure while merging faces resulting from intersections"),
            Self::TriangulationError => f.pad("internal failure while triangulating an intersection face"),
        }
    }
}

#[cfg(feature = "std")]
impl std::error::Error for MeshIntersectionError {}