Function libreda_db::layout::algorithms::decompose_rectangles[−][src]

pub fn decompose_rectangles<T: CoordinateType + PrimInt>(
    rpoly: &SimpleRPolygon<T>
) -> Vec<Rect<T>>
Expand description

Decompose a manhattanized polygon into non-overlapping horizontal rectangles. A point is considered inside the polygon when the polygon wraps around it a non-zero number of times.

Example

    use libreda_db::prelude::*;
    use libreda_db::layout::algorithms::decompose_rectangles;
    // Use a polygon like the following.
    //    +--+
    //    |  |
    // +--+  |
    // |     |
    // +-----+
    let poly = SimpleRPolygon::try_new(vec![
        (0, 0), (2, 0), (2, 2), (1, 2), (1, 1), (0, 1)
    ].iter().map(|t| Point::from(t)).collect()).unwrap();

    // Decompose the polygon into non-overlapping horizontal rectangles.
    let rects = decompose_rectangles(&poly);
    assert_eq!(rects, vec![Rect::new((0, 0), (2, 1)), Rect::new((1, 1), (2, 2))]);