Simplifying outlines

2024-12-10

Or how to speed up the building of sheets 😊

One of the issues with using “No Fit Polygon”, is that the execution time is directly affected by the number of points and edges in the shapes.

Illustration of NFP placements at each point of the shape

JTS has a handy DouglasPeuckerLineSimplifier that does a good job of removing a lot of the non-necessary points, but there is one - and with relation to logos - rather big limitation: If the logo is cicular/round, the simplifier will still leave a lot of points.

A round logo resulting in a lot of points in the outline

To overcome this, I’m using the thinness ratio: 4 * π * (A / P2), where A is the area of the logo (polygon) and P it’s perimiter.

The closer to 1 this ratio is, the “rounder” the logo is. When this is the case, I just increase the tolerance of the simplifier quite a bit:

The same round logo, but this time with a lot fewer points

Written by: Jesper Halvorsen