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

optimization by --linemerge #34

Closed
ithinkido opened this issue May 10, 2020 · 5 comments
Closed

optimization by --linemerge #34

ithinkido opened this issue May 10, 2020 · 5 comments

Comments

@ithinkido
Copy link
Contributor

When using --linemerge to connect multiple line segments to one single line, the output still contains the old line nodes, and the result is one line, but with multiple nodes. when plotting a line like this the plotter slows down and speed up for each node and the result is a kind of 'ghost' line in the plot. Is it possible to output a mergerd line as a single line between a start and end node, creating the longest possibe single straight line?
image
image
linetest.zip

@abey79
Copy link
Owner

abey79 commented May 10, 2020

linemerge doesn't attempt to simplify lines. When two lines' endings are close together, they are concatenated and their endings replaced by the mean point, so two collinear 1-segment lines are converted to a single, 3-point line. You want to use linesimplify after linemerge to remove those spurious points.

(Note: the Axidraw isn't at all affected by spurious points -- I'm surprised it's the case for other plotters.)

@ithinkido
Copy link
Contributor Author

Have I understood this correctly, linemerge will produce a 3- point line (start , mean, end), and linesimplify will remove the mean point and produce a 2-point line ( start and end)?
Just tried with:
vpype read 1.svg linemerge --tolerance 0.1mm linesimplify linesort write --layer-label Pen%d --page-format 191x272mm 1_opt.svg
and I still have what looks like the mean point. Is there a way to output only start and end point lines?

@abey79 abey79 closed this as completed in 2086cf5 May 10, 2020
@abey79
Copy link
Owner

abey79 commented May 10, 2020

On second look, I'm seeing issues with linemerge on your file, apparently an issue in Shapely. I've pushed a quick fix that seems to address the situation.

This is what happens now:

vpype read 1.svg linemerge show -dac -u mm

image

vpype read 1.svg linemerge linesimplify show -dac -u mm

image

Side note: while looking into that, I got confused with what happens inside the windows, until I realised that there are overlapping lines there. Is that on purpose?

@ithinkido
Copy link
Contributor Author

yes the double lines are wanted. I just tried out the new version and it is perfect. Thanks, this is going to be very helpfull

@abey79
Copy link
Owner

abey79 commented May 10, 2020

shapely/shapely#911

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