PGS icon indicating copy to clipboard operation
PGS copied to clipboard

please expose `PGS_Contour.offsetCurves(...)` method

Open jawordesign opened this issue 3 years ago • 5 comments

when working with offsets for CNC paths generation, I feel greatly limited with two existing methods: PGS_Contour.offsetCurvesInwards and PGS_Contour.offsetCurvesOutwards. First one generates uncontrollable number of offsets, and it's impossible to know if any subsequent offset consists of multiple children or not (I just get outlines for subsequent steps, together with their children in one set, unable to differentiate them). The other method provides control on number of curves to offset, so I can potentially generate them one by one, but works only outside :-) no way to cheat it, since it only accepts positive offset distances. The only way to control it fully would be to use underlying (invisible) method PGS_Contour.offsetCurves(...) but it is currently private - please either expose it, or add another method that gives more control.

jawordesign avatar Aug 28 '22 11:08 jawordesign

Would a offsetCurvesInward() method that has a curves parameter suffice?

micycle1 avatar Aug 30 '22 13:08 micycle1

certainly! :-) In the meantime I used PGS_Morphology.buffer() but that also lacks some control, and outputs deeply nested objects. So, I'd be glad to see an update to .offsetCurvesInward(...) method, thanks!

jawordesign avatar Aug 30 '22 14:08 jawordesign

What additional control should buffer() have?

I don't believe the outputs should be deeply nested; rather it would have a child shape for each shape/element in the input (in the same level).

micycle1 avatar Aug 30 '22 14:08 micycle1

the only thing buffer() lacks is the style of the offset (BEVEL, MITER, ROUND), besides it's fine. It's funny how you could actually replace all these 3 functions (buffer, offsetCurvesOutwards, offsetCurvesInwards) with one offsetCurves(..) containing enough parameters (number of curves, offset - positive or negative, and style). But I understand if usability and user experience is your primary concern, it makes sense to keep them. Regarding nesting - I got a deeply nested result when subtracting buffer-generated shapes one by one, but this might have been my mistake (a child of a child of a child... etc). I have to double check this.

jawordesign avatar Aug 30 '22 19:08 jawordesign

I've pushed related changes to the dev branch.

Added the additional method signatures, and where multiple curves are created at the same step, they are formed as a GROUP shape having multiple children.

micycle1 avatar Sep 03 '22 10:09 micycle1

Great! Thanks. It would help a lot to provide me with instructions how to build this to a .jar file, or to push it to the repo / dev branch too, I didn't find it anywhere.

jawordesign avatar Sep 10 '22 10:09 jawordesign

It has been pushed to the dev branch. The current latest .jar build of dev branch is here: https://github.com/micycle1/PGS/suites/8324649972/artifacts/365843541

micycle1 avatar Sep 16 '22 11:09 micycle1