CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
442 stars 28 forks source link

Errors with shape culling #20

Closed golanlevin closed 4 years ago

golanlevin commented 4 years ago

Shape culling needs some attention, please, as demonstrated by the example, PEmbroider_shape_culling.

Currently, small turds from culled shapes are sporadically left in the scene. As small as these isolated stitches are, they can cause major headaches later when the TSP is run. Below you can see screenshots of PEmbroider_shape_culling, with and without the TSP visualization.

Screen Shot 2020-06-14 at 3 47 34 AM Screen Shot 2020-06-14 at 3 48 44 AM

A close look also shows that some stitches are culled prematurely, instead of being culled precisely; see magnification below. Perhaps its a related issue. Is culling currently using raster internals?

Untitled

LingDong- commented 4 years ago

Hi @golanlevin

Currently cull works by rasterizing the polylines with certain stroke weight and checking occlusion.

It doesn't have info about what type of shape was drawn at the time, what was the spacing and all the other settings you were using when it was drawn. So when the spacing is quite high like in the screenshot, there're seams in the rendering causing small strokes to squeeze in.

The magic stroke weight was hard coded to be 5 and you're using 6 for all the spacings ;)

I now expose the option for setting the spacing: 23ae79946c6fd858792ab5ae4bd783b3225c2972

E.CULL_SPACING = 7
Screen Shot 2020-06-14 at 4 12 23 AM

I also halved the raster interval to give higher accuracy

golanlevin commented 4 years ago

OK, that works. Thanks!