-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the convex-hull calculation itself failible.
- Loading branch information
Showing
5 changed files
with
69 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#[derive(Debug, PartialEq)] | ||
/// Errors generated by the convex-hull calculation. | ||
pub enum ConvexHullError { | ||
/// Reached an impossible configuration in the convex-hull calculation, | ||
/// likely because of a bug. | ||
InternalError(&'static str), | ||
/// The convex hull calculation was unable to find a support point. | ||
/// This generally happens if the input point set contains invalid points (with NaN coordinates) | ||
/// or if they are almost coplanar. | ||
MissingSupportPoint, | ||
/// Reached a piece of code we shouldn’t (internal error). | ||
Unreachable, | ||
} | ||
|
||
impl std::fmt::Display for ConvexHullError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
ConvexHullError::InternalError(reason) => write!(f, "InternalError({})", reason), | ||
ConvexHullError::MissingSupportPoint => write!(f, "MissingSupportPoint"), | ||
ConvexHullError::Unreachable => write!(f, "Unreachable"), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for ConvexHullError {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
pub(self) use self::initial_mesh::{get_initial_mesh, InitialMesh}; | ||
pub use self::error::ConvexHullError; | ||
pub(self) use self::initial_mesh::{try_get_initial_mesh, InitialMesh}; | ||
pub(self) use self::triangle_facet::TriangleFacet; | ||
pub(self) use self::validation::check_facet_links; | ||
pub use convex_hull::convex_hull; | ||
pub use convex_hull::{convex_hull, try_convex_hull}; | ||
pub use validation::check_convex_hull; | ||
|
||
mod convex_hull; | ||
pub mod initial_mesh; | ||
mod error; | ||
mod initial_mesh; | ||
mod triangle_facet; | ||
mod validation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters