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

Add ".xyz" extension to PointSet.save #2571

Merged
merged 10 commits into from
May 10, 2022
Merged

Add ".xyz" extension to PointSet.save #2571

merged 10 commits into from
May 10, 2022

Conversation

tkoyama010
Copy link
Member

@tkoyama010 tkoyama010 commented May 7, 2022

Overview

PointSet.save cannot be written because _WRITER does not exist, and an error always occurs. Therefore, in this PR, I have clarified which extension to specify by defining _WRITER. IMO, the only Writer object that can be used with PointSet is vtkSimplePointsWriter, which creates xyz file. (If there are other Writers that can be added, please point them out.)

resolves #2556

Details

import numpy as np
import pyvista

rng = np.random.default_rng()
points = rng.random((10, 3))
pset = pyvista.PointSet(points)
pset.save("pset.xyz")

@github-actions github-actions bot added the enhancement Changes that enhance the library label May 7, 2022
@tkoyama010 tkoyama010 marked this pull request as draft May 7, 2022 01:10
tests/test_pointset.py Outdated Show resolved Hide resolved
@tkoyama010 tkoyama010 marked this pull request as ready for review May 7, 2022 02:10
tests/test_pointset.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 7, 2022

Codecov Report

Merging #2571 (6da1a7f) into main (c49a6ab) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2571   +/-   ##
=======================================
  Coverage   93.69%   93.69%           
=======================================
  Files          75       75           
  Lines       16159    16160    +1     
=======================================
+ Hits        15140    15141    +1     
  Misses       1019     1019           

@MatthewFlamm
Copy link
Contributor

MatthewFlamm commented May 7, 2022

This is a good idea. What about this writer? vtkSimplePointsWriter. Edit: I somehow completely misread this.

It would also be nice to have a reader for xyz files and we could test the roundtrip. vtkSimplePointsReader

@MatthewFlamm
Copy link
Contributor

One problem I see with this format is that I don't think that any point_data will get saved. Maybe the best we can do is writing it to vtp or the xml version?

@tkoyama010
Copy link
Member Author

tkoyama010 commented May 7, 2022

Thanks for the comment. As you say we can casting PointSet to PolyData.
I will improve this PR.
Edit: I noticed that we can output to vtk by using the following expression. I considered doing this internally in PoinSet class but concluded that "as is" is the best way to avoid confusing the user.

pset.cast_to_polydata().save("pset.vtk")

@tkoyama010 tkoyama010 marked this pull request as draft May 7, 2022 11:59
@tkoyama010 tkoyama010 marked this pull request as ready for review May 7, 2022 12:24
tests/test_pointset.py Outdated Show resolved Hide resolved
@tkoyama010
Copy link
Member Author

Anyway, it would be useful to add xyz file output.

@banesullivan banesullivan self-requested a review May 9, 2022 20:32
Copy link
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

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

This is good to merge as-is. We can add a specialized reader as a next step.

@akaszynski akaszynski merged commit d9d1dd7 into main May 10, 2022
@akaszynski akaszynski deleted the feat/poinset-xyz-save branch May 10, 2022 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to save PointSet to file
3 participants