pub fn decompose_rectangles<T, I>(redges: I) -> Vec<Rect<T>>Expand description
Decompose a set of manhattanized polygons into non-overlapping horizontal rectangles. The polygons in form of an iterator over all the edges. A point is considered inside the polygon when the polygon wraps around it a non-zero number of times.
ยงExample
use iron_shapes::prelude::*;
use iron_shapes_algorithms::rectangle_decomposition::decompose_rectangles;
// Use a polygon like the following.
// +--+
// | |
// +--+ |
// | |
// +-----+
let poly = SimpleRPolygon::try_new([
(0, 0), (2, 0), (2, 2), (1, 2), (1, 1), (0, 1)
]).unwrap();
// Decompose the polygon into non-overlapping horizontal rectangles.
let rects = decompose_rectangles(poly.edges());
assert_eq!(rects, vec![Rect::new((0, 0), (2, 1)), Rect::new((1, 1), (2, 2))]);