VTK data type (vtkPointSet) is not currently supported by pyvista.
See original GitHub issueDescribe the bug, what’s wrong, and what you expected.
Hi!
When I create a vtkPointSet object I am unable to plot it using the pyvista.Plotter() even though PointSets are now ufficially supported. In fact when creating a pyvista.PointSet() instance and doing a ShallowCopy of the vtkPointSet everything runs as intended. Is this normal? I’d rather not use the ShallowCopy route since in my case the vtk objects are modified and I’d prefer to use one instance of the data without copying It every time I need to plot the results.
Have a nice weekend!
Steps to reproduce the bug.
import pyvista as pv
import vtk
plotter = pv.Plotter()
pc = some_VTK_FLOAT_data
points = vtk.vtkPoints()
points.SetData(pc)
vtk_ps = vtk.vtkPointSet()
vtk_ps.SetPoints(points)
vtk_ps.Modified()
plotter.add_points(vtk_ps)
returns
WARNING:root:VTK data type (vtkPointSet) is not currently supported by pyvista.
but when doing:
pv_ps = pv.PointSet()
pv_ps.ShallowCopy(vtk_ps)
plotter.add_points(pv_ps)
Everything runs fine
System Information
--------------------------------------------------------------------------------
Date: Fri Sep 09 18:10:06 2022 CEST
OS : Linux
CPU(s) : 8
Machine : x86_64
Architecture : 64bit
RAM : 15.5 GiB
Environment : Python
File system : ext4
GPU Vendor : NVIDIA Corporation
GPU Renderer : NVIDIA GeForce GTX 1050/PCIe/SSE2
GPU Version : 4.5.0 NVIDIA 515.48.07
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:56:21)
[GCC 10.3.0]
pyvista : 0.34.0
vtk : 9.1.0
numpy : 1.22.3
imageio : 2.9.0
appdirs : 1.4.4
scooby : 0.5.12
matplotlib : 3.5.2
pyvistaqt : 0.9.0
PyQt5 : 5.12.3
IPython : 8.1.1
colorcet : 3.0.0
cmocean : 2.0
scipy : 1.8.1
tqdm : 4.64.0
--------------------------------------------------------------------------------
Screenshots
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Source code for pyvista.core.pointset
vtkPointSet, Sequence, optional Flexible input type. ... force_float : bool, optional Casts the datatype to ``float32`` if points datatype is non-float.
Read more >pyvista.PointSet — PyVista 0.37.0 documentation
This class is useful for improving the performance of filters on point clouds, but not plotting. For further details see VTK: vtkPointSet Details....
Read more >Core API — PyVista 0.37.0 documentation
PointSet class is an extension of vtk.vtkPointSet. pyvista.PolyData consists of any 1D or 2D geometries to construct vertices, lines, polygons, and triangles.
Read more >PyVista Data Model
PyVista uses the same data types as VTK, but structures them in a more pythonic manner ... VTK already has APIs to directly...
Read more >Point Sets — PyVista 0.37.0 documentation
PyVista point sets are modeled after the same data model as VTK's point sets while being designed to ... UnstructuredGrid , you do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
These are very informative reports @gbene.
pyvista.PointSet
also currently doesn’t support being directly initialized with avtkPointSet
object. It only currently supports a numpy ndarray like object, which isn’t consistent with the rest of the API here. I think that after this is added, it should work.https://github.com/pyvista/pyvista/blob/7d65054dff4717338519e73d287c7709caef1b20/pyvista/core/pointset.py#L406-L410
I applied locally the fix by adding to the wrappers.py file the line:
When running the code to plot vtkPointSet the following error occurs: