Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to sort polylines for most optimal total path? #19

Open
stephanschulz opened this issue Dec 15, 2021 · 3 comments
Open

How to sort polylines for most optimal total path? #19

stephanschulz opened this issue Dec 15, 2021 · 3 comments

Comments

@stephanschulz
Copy link

stephanschulz commented Dec 15, 2021

Hey
I was wondering if you can suggest a good way to sort the resulting polyline vector from polylines = ofxTraceSkeleton::trace(im); in such a way that a xy plotter could draw the most efficient path through all of the polylines?
Currently the order is all jumbled.

Dec-15-2021 18-38-42
Here is a small test I did in OpenFrameworks.

I am sure you have already done something like this for https://github.com/CreativeInquiry/PEmbroider

Thanks a bunch.

@msurguy
Copy link

msurguy commented Dec 17, 2021

@stephanschulz I'd suggest you use something like Vpype which has sorting, simplification and other features that make your SVG output CNC machine friendly: https://vpype.readthedocs.io/en/stable/reference.html#linesort

@stephanschulz
Copy link
Author

Thank you, I will check it out.
I have a feeling axidraw uses something similar in their reordering call: https://axidraw.com/doc/py_api/#reordering
I was hoping to do the reordering inside OpenFrameworks to avoid using external libraries.
In any case your advice @msurguy will be very helpful.

@msurguy
Copy link

msurguy commented Dec 17, 2021

@stephanschulz I think you can call CLI command after SVG generation, call vpype to optimize and wait for the result. You'll save yourself a lot of headache. https://openframeworks.cc/learning/08_other/system/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants