bsp_tree/
lib.rs

1//! BSP (Binary Space Partitioning) tree implementation.
2//!
3//! This crate provides a BSP tree for 3D polygon management, enabling efficient
4//! spatial partitioning, ordered traversal, and polygon cutting operations.
5//!
6//! # Core Types
7//!
8//! - [`Polygon`], [`Triangle`], [`Rectangle`]: Geometric primitives
9//! - [`Plane3D`]: 3D plane representation with classification operations
10//! - [`Cuttable`]: Trait for splitting geometry by planes
11//! - [`BspTree`]: The BSP tree container
12//! - [`BspNode`]: Tree nodes holding splitting planes and coplanar polygons
13//!
14//! # Example
15//!
16//! ```
17//! use bsp_tree::{BspTree, Polygon};
18//! use nalgebra::Point3;
19//!
20//! // Create some polygons
21//! let poly1 = Polygon::new(vec![
22//!     Point3::new(0.0, 0.0, 0.0),
23//!     Point3::new(1.0, 0.0, 0.0),
24//!     Point3::new(0.0, 1.0, 0.0),
25//! ]);
26//!
27//! // Build the tree
28//! let tree = BspTree::from_polygons(vec![poly1]);
29//!
30//! assert_eq!(tree.polygon_count(), 1);
31//! ```
32
33pub mod bsp;
34mod cuttable;
35mod plane;
36mod polygon;
37mod rectangle;
38mod triangle;
39
40// Re-export BSP tree types at crate root for convenience
41pub use bsp::{BspNode, BspTree, BspVisitor, FirstPolygon, PlaneSelector};
42
43pub use cuttable::Cuttable;
44pub use plane::{Classification, Plane3D, PlaneSide, PLANE_EPSILON};
45pub use polygon::Polygon;
46pub use rectangle::Rectangle;
47pub use triangle::Triangle;