Skip to main content

geometry_overlay/
lib.rs

1//! Boolean-overlay engine — the segment-intersection kernel and the
2//! machinery built on top of it.
3//!
4//! Mirrors `boost/geometry/algorithms/detail/overlay/`. Overlay is the
5//! engine behind `intersection`, `union`, `difference`,
6//! `sym_difference`, and (indirectly) `buffer`, `is_valid`, `relate`,
7//! `crosses`, `overlaps`, `touches`, `point_on_surface`, and
8//! `merge_elements`. Boost concentrates all of it under one `detail`
9//! directory; the port gives it its own crate because the algorithmic
10//! surface is too dense to share a crate with anything else.
11//!
12//! The build order is strict:
13//!
14//! * [`predicate`] — OVL1: the robust predicate layer every overlay
15//!   operation eventually calls (orientation, in-circle,
16//!   segment-segment intersection, coordinate-range gate).
17//! * [`operation`] — OVL5: a split-edge arrangement handles crossings,
18//!   colocations, shared edges, traversal, and output assembly for the four
19//!   Cartesian polygon Boolean operations.
20//! * [`mod@relate`] / [`validity`] / [`mod@buffer`] — the public topology consumers
21//!   layered on those predicates and operations.
22//!
23//! # Robustness
24//!
25//! The Cartesian kernel uses **adaptive expansion predicates with no
26//! rescale**. [`predicate::range_guard`] refuses inputs outside the supported
27//! arithmetic range rather than silently returning a wrong sign.
28
29#![cfg_attr(not(feature = "std"), no_std)]
30#![forbid(unsafe_code)]
31
32extern crate alloc;
33
34pub mod assemble;
35pub mod buffer;
36pub mod line_intersection;
37pub mod merge;
38pub mod operation;
39mod piece_collection;
40pub mod predicate;
41pub mod relate;
42pub mod surface_point;
43pub mod traverse;
44pub mod turn;
45pub mod validity;
46
47// feature-group: Boolean operations
48// feature-desc: Overlay and offset of areal geometries
49pub use buffer::{
50    JoinStrategy, PointStrategy, buffer, buffer_convex_polygon, buffer_point, buffer_with,
51    buffer_with_strategy,
52};
53// feature-group: Boolean operations
54pub use line_intersection::{LineIntersection, line_intersection};
55// feature-group: Mutation & assembly
56pub use merge::{merge_elements, merge_multipolygon, merge_polygons, stitch_triangles};
57// feature-group: Boolean operations
58pub use operation::{
59    OverlayError, difference, difference_multi, intersection, intersection_multi, sym_difference,
60    sym_difference_multi, r#union, union_multi, union_poly,
61};
62// feature-group: Spatial predicates
63pub use relate::{
64    De9im, Dimension, RelateError, contains_properly, crosses, overlaps, relate as relate_matrix,
65    relate as relation, relate_mask as relate, touches,
66};
67// feature-group: Boolean operations
68pub use surface_point::point_on_surface;
69// feature-group: Inspection
70pub use validity::{
71    ValidityFailure, ValidityOptions, is_valid, is_valid_polygon, is_valid_polygon_with,
72    is_valid_ring, is_valid_ring_with, is_valid_with, validity_reason, validity_reason_with,
73};