u_nesting/lib.rs
1//! # U-Nesting
2//!
3//! Domain-agnostic 2D/3D spatial optimization engine.
4//!
5//! This crate provides algorithms for:
6//! - **2D Nesting**: Polygon placement optimization (cutting, packing)
7//! - **3D Bin Packing**: Box placement in containers
8//!
9//! ## Quick Start
10//!
11//! ```rust
12//! use u_nesting::d2::{Boundary2D, Geometry2D, Nester2D};
13//! use u_nesting::{Config, Solver, Strategy};
14//!
15//! let geometries = vec![Geometry2D::rectangle("plate", 100.0, 50.0).with_quantity(4)];
16//! let boundary = Boundary2D::rectangle(1000.0, 500.0);
17//!
18//! let config = Config::new().with_strategy(Strategy::NfpGuided);
19//! let result = Nester2D::new(config).solve(&geometries, &boundary)?;
20//! assert_eq!(result.placements.len(), 4);
21//! # Ok::<(), u_nesting::core::Error>(())
22//! ```
23//!
24//! ## Feature Flags
25//!
26//! - `d2` (default): 2D nesting algorithms
27//! - `d3` (default): 3D bin packing algorithms
28//! - `cutting`: cutting path optimization for a 2D layout
29//! - `serde`: Serialization support
30//! - `parallel`: evaluates a search's population (GA, BRKGA) and computes
31//! no-fit polygons on rayon's thread pool. Without it every solve runs on
32//! the calling thread. The solve uses the pool it is called from, so
33//! `rayon::ThreadPool::install` (or `RAYON_NUM_THREADS`) sets how many
34//! threads it uses.
35
36/// Core traits and abstractions.
37pub use u_nesting_core as core;
38
39/// 2D nesting algorithms.
40#[cfg(feature = "d2")]
41pub use u_nesting_d2 as d2;
42
43/// 3D bin packing algorithms.
44#[cfg(feature = "d3")]
45pub use u_nesting_d3 as d3;
46
47/// Cutting path optimization.
48#[cfg(feature = "cutting")]
49pub use u_nesting_cutting as cutting;
50
51// Re-export commonly used types at root level
52pub use u_nesting_core::{Config, Placement, SolveResult, Solver, StopReason, Strategy};
53
54// The README's Rust examples are the first code most users copy, so they are
55// compiled and run with the doc-tests. Without this they were checked by
56// nothing.
57#[cfg(doctest)]
58#[doc = include_str!("../../../README.md")]
59pub struct ReadmeDoctests;