pub mod aabb;
mod angles;
pub mod angular_span;
pub mod arc2;
pub mod arc3;
pub mod bezier2;
pub mod brep;
pub mod circle2;
pub mod circle3;
mod circular3;
pub mod closest;
pub mod cone_surface;
pub mod curvature;
pub mod curve2;
pub mod curve3;
pub mod cylinder_surface;
pub mod datum;
pub mod ellipse2;
pub mod extrude;
pub mod intersect;
pub mod intersect3;
pub mod line2;
pub mod line3;
pub mod mesh;
pub mod nurbs;
pub mod nurbs_curve;
pub mod nurbs_surface;
pub mod offset2;
pub mod plane_surface;
pub mod polyline3;
pub mod revolve;
pub mod sphere_surface;
pub mod surface3;
pub mod sweep;
pub mod sweep_surface;
pub mod torus_surface;

pub use aabb::Aabb2;
pub use angular_span::AngularSpan;
pub use arc2::{Arc2, arc_bounding_box};
pub use arc3::Arc3;
pub use bezier2::Bezier2;
pub use brep::boolean::ssi::{
    AnalyticSurface, InfiniteLine, IntersectionCurve, SsiGap, SurfaceIntersection,
    intersect_surfaces,
};
pub use brep::boolean::{BooleanOp, boolean};
pub use brep::eval::{
    ExtrudeScene, RevolveScene, SweepRails, evaluate_extrude, evaluate_extrude_plan,
    evaluate_revolve, evaluate_sweep, next_face_distance, resolve_revolve, resolve_sweep,
};
pub use brep::localops::{
    AnalyticPatch, BlendGap, BlendRadius, BlendSpine, FillContinuity, NormalSide, OffsetDegeneracy,
    OffsetDistance, OffsetResult, PatchGap, TrimGap, carrier, face_boundary, fill_patch,
    offset_surface, rolling_ball_blend, trim_line_to_face,
};
pub use brep::profile::{ExtrudeProfile, ProfileEdge, ProfileLoop};
pub use brep::{
    BooleanGap, BrepEdge, BrepError, BrepFace, BrepLoop, BrepReattach, BrepShell, BrepSolid,
    BrepVertex, EdgeCurve3, EdgePolyline, EdgePolylines, EdgeReattach, FaceMesh, LabelKind,
    MeshError, ProfileDefect, ProjectedCurve, SolidMesh, TruckGap,
};
pub use circle2::Circle2;
pub use circle3::Circle3;
pub use closest::{ClosestPoint, ClosestPoint2, ClosestPoint3};
pub use cone_surface::ConeSurface;
pub use curvature::Curvature;
pub use curve2::{Curve2, Curve2Kind};
pub use curve3::{Curve3, Curve3Kind};
pub use cylinder_surface::CylinderSurface;
pub use datum::{
    AlongCurvePlacement, AxisRecipe, CsysAxisRef, CsysRecipe, CsysRotation, DatumError,
    DatumFeature, DatumGap, DatumGeometry, PlaneRecipe, PointRecipe, ReferenceGeometry,
};
pub use ellipse2::Ellipse2;
pub use extrude::{
    ContourSelection, Direction2, DirectionPlan, DraftAngle, DraftDirection, DraftMagnitude,
    ExtrudeDirection, ExtrudeEndCondition, ExtrudeFeature, ExtrudeOperation, ExtrudeSense,
    FeatureScope, FromCondition, MergeResult, PlaneRef, ResolvedSweep, ThinPlan, 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 nurbs::{Degree, KnotVector, RationalControlPoint};
pub use nurbs_curve::NurbsCurve3;
pub use nurbs_surface::NurbsSurface3;
pub use plane_surface::PlaneSurface;
pub use polyline3::Polyline3;
pub use revolve::{
    ResolvedRevolve, RevolveAngle, RevolveAxis, RevolveDirection2, RevolveEndCondition,
    RevolveFeature,
};
pub use sphere_surface::SphereSurface;
pub use surface3::Surface3;
pub use sweep::{
    SweepAlignment, SweepDirection, SweepFeature, SweepOrientation, SweepPath, SweepProfileKind,
    SweepTangency, SweepTwist, TwistUnit,
};
pub use sweep_surface::{
    ArcFraction, CompositePath3, Frame, FrameGuide, SampleCount, StationCount, SweepDefect,
    SweepPath3, transport, transport_with,
};
pub use torus_surface::TorusSurface;

#[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("ellipse semi-axis is within tolerance of zero")]
    DegenerateEllipse,
    #[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("cone surface radius, height, half-angle, or sweep is degenerate")]
    DegenerateCone,
    #[error("sphere surface radius, polar span, or azimuth span is degenerate")]
    DegenerateSphere,
    #[error("torus surface radii, major span, or minor span is degenerate")]
    DegenerateTorus,
    #[error("nurbs degree, knot vector, control net, or weight is degenerate")]
    DegenerateNurbs,
    #[error("draft angle must be within [0, 90) degrees: {0} deg")]
    DraftAngleOutOfRange(f64),
    #[error("revolve angle must be within (0, 2π] radians: {0} rad")]
    RevolveAngleOutOfRange(f64),
}

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