micycle1 / PGS

Processing Geometry Suite
https://micycle1.github.io/PGS/
167 stars 13 forks source link

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

Closed jawordesign closed 1 year ago

jawordesign commented 2 years ago

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.

micycle1 commented 2 years ago

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

jawordesign commented 2 years ago

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!

micycle1 commented 2 years ago

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).

jawordesign commented 2 years ago

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.

micycle1 commented 2 years ago

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.

jawordesign commented 2 years ago

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.

micycle1 commented 1 year ago

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