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

Render G2/G3 arcs in 3D view by interpolating them as line segments #1092

Merged
merged 2 commits into from
Aug 20, 2020

Conversation

IgorYeremin
Copy link
Contributor

No description provided.

@kliment
Copy link
Owner

kliment commented Aug 11, 2020

@IgorYeremin thank you for your contributions!

@volconst could I have your thoughts on this and Igor's other two active PRs? They look good to me but I would like your opinion before I merge them.

@volconst
Copy link
Collaborator

@kliment , Sorry for the delay, I have missed it's referencing me.
@IgorYeremin , can you upload/link a test file.

@IgorYeremin
Copy link
Contributor Author

Sure! I'm testing Marlin on a plasma machine, so here are gcode files generating using Fusion360.
One file uses M3 to turn cutter on (would render as travel without my other patches), the other one uses E moves, so it should work as is.

test-fusion-plasma-arcs.zip

@volconst
Copy link
Collaborator

@IgorYeremin do you have uncommitted changes in your work dir, I am getting exception:

Loading file: /home/.../test-fusion-plasma-arcs/test-fusion-plasma-m3.gcode
Loaded /home/.../test-fusion-plasma-arcs/test-fusion-plasma-m3.gcode, 657 lines
0.00mm of filament used in this print
...
Traceback (most recent call last):
File "/home/.../Printrun/printrun/pronterface.py", line 1605, in loadviz
generator_output = next(generator)
File "/home/.../Printrun/printrun/gcview.py", line 333, in addfile_perlayer
generator_output = next(generator)
File "/home/.../Printrun/printrun/gl/libtatlin/actors.py", line 472, in load_data
for gline_idx, gline in interpolate_arcs(layer):
File "/home/.../Printrun/printrun/gl/libtatlin/actors.py", line 349, in interpolate_arcs
mid = copy.copy(gline)
File "/usr/lib/python3.7/copy.py", line 96, in copy
rv = reductor(4)
TypeError: 'NoneType' object is not callable

@IgorYeremin
Copy link
Contributor Author

I do not have uncommitted changes in my work dir.
Did you run python setup.py build_ext --inplace to recompile the modified gcoder_line.pyx?

@volconst
Copy link
Collaborator

No, maybe the python class needs changes

@volconst
Copy link
Collaborator

I am not using gcoder_line.
WARNING:root:Memory-efficient GCoder implementation unavailable: cannot import name 'gcoder_line' from 'printrun' (/home/.../Printrun/printrun/init.py)

@IgorYeremin
Copy link
Contributor Author

Ah ok, didn't realize you can run without Cython, here's the copy function for PyLine

mid = copy.copy(gline)
mid.current_x = cx + math.cos(a) * r
mid.current_y = cy + math.sin(a) * r
yield (gline_idx, mid)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying and translating G2 Arc commands and pretending they are lines is neither semantically, nor performance-wise desirable. Would make sense only if we have to fool some foreign interface we do not control. Fortunately the site of consumption of interpolate_arcs is in the same file.
Here it's seen that the only value/information that we add is tuple(current_x, current_y), which a better candidate for return value
I think the clean way is to add a separate inner iteration loop which eventually expands glines to points, so we have both access to the original gline and the interpolated points, without copying.
The indisputable advantage of the current setup is that it exists and works :)

@volconst
Copy link
Collaborator

@kliment Let's merge #1092, #1093, #1094 .
@IgorYeremin thanks for these contributions

@kliment
Copy link
Owner

kliment commented Aug 20, 2020

@volconst okay, I'll merge them, thank you for reviewing

@kliment kliment merged commit b48ad60 into kliment:master Aug 20, 2020
@IgorYeremin IgorYeremin deleted the render-arcs-3d branch August 20, 2020 15:21
@IgorYeremin IgorYeremin restored the render-arcs-3d branch August 20, 2020 15:32
@IgorYeremin IgorYeremin deleted the render-arcs-3d branch August 20, 2020 15:32
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

Successfully merging this pull request may close these issues.

3 participants