mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-02 05:28:48 -04:00
MaximalRectangles.InRegion finds the largest axis-aligned rectangles that fit wholly inside a Clipper region, such as a cutout shrunk by the part spacing. It grids the region on its vertex coordinates plus even divisions, keeps a cell only when no edge enters it and an even-odd row scan puts it inside, then runs the shared histogram search. Exact for regions with only horizontal and vertical edges; slanted and curved edges are followed as a staircase that never crosses the boundary, short of the true maximum by up to about one cell per side. Tests cover a rectangle, an L shape, a frame with a hole, a round hole (inscribed square), a diamond and a star; disabling the edge-crossing check fails the three slanted-edge tests.