pub mod aabb;
mod angles;
pub mod arc2;
pub mod arc3;
pub mod brep;
pub mod circle2;
pub mod circle3;
mod circular3;
pub mod closest;
pub mod curvature;
pub mod curve2;
pub mod curve3;
pub mod cylinder_surface;
pub mod extrude;
pub mod intersect;
pub mod intersect3;
pub mod line2;
pub mod line3;
pub mod mesh;
pub mod plane_surface;
pub mod polyline3;
pub mod surface3;

pub use aabb::Aabb2;
pub use arc2::{Arc2, arc_bounding_box};
pub use arc3::Arc3;
pub use brep::eval::evaluate_extrude;
pub use brep::profile::{ExtrudeProfile, ProfileEdge, ProfileLoop};
pub use brep::{
    BrepEdge, BrepError, BrepFace, BrepLoop, BrepShell, BrepSolid, BrepVertex, EdgeCurve3,
    EdgePolyline, EdgePolylines, FaceMesh, LabelKind, MeshError, ProfileDefect, SolidMesh,
    TruckGap,
};
pub use circle2::Circle2;
pub use circle3::Circle3;
pub use closest::{ClosestPoint, ClosestPoint2, ClosestPoint3};
pub use curvature::Curvature;
pub use curve2::{Curve2, Curve2Kind};
pub use curve3::{Curve3, Curve3Kind};
pub use cylinder_surface::CylinderSurface;
pub use extrude::{
    DraftAngle, DraftDirection, DraftMagnitude, ExtrudeDirection, ExtrudeEndCondition,
    ExtrudeFeature, ExtrudeSense, MergeResult, PlaneRef, ThinWall, ThinWallDirection,
};
pub use intersect::{IntersectionSet, IntersectionSet2, intersect_curves};
pub use intersect3::{IntersectionSet3, intersect_curves_3};
pub use line2::Line2;
pub use line3::Line3;
pub use mesh::{MeshVertex, TriMesh};
pub use plane_surface::PlaneSurface;
pub use polyline3::Polyline3;
pub use surface3::Surface3;

#[derive(Debug, thiserror::Error)]
pub enum KernelError {
    #[error("line endpoints coincide within tolerance")]
    DegenerateLine,
    #[error("arc sweep is within tolerance of zero or exceeds 2π")]
    DegenerateArc,
    #[error("circle radius is within tolerance of zero")]
    DegenerateCircle,
    #[error("polyline needs at least two vertices and no zero-length segment")]
    DegeneratePolyline,
    #[error("plane surface extent is within tolerance of zero")]
    DegeneratePlane,
    #[error("cylinder surface radius, height, or sweep is degenerate")]
    DegenerateCylinder,
    #[error("draft angle must be within [0, 90) degrees: {0} deg")]
    DraftAngleOutOfRange(f64),
}

pub type Result<T, E = KernelError> = core::result::Result<T, E>;
