pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
60 stars 4 forks source link

visualize x y z with colormap #238

Open andrea-bistacchi opened 4 years ago

andrea-bistacchi commented 4 years ago

Hello, I need to visualize x y and z with a color map, and possibly to contour them etc.

Based on previous issue #217 I understand I can create a z scalar property with my_polydata.elevation().

I have two questions:

1- Is there a "sort of" elevation() filter to add also x and y values?

2- I have the suspect that elevation() might duplicate the z values, and that this could cause memory and/or performance problems for large objects. Is this correct? Or maybe the z values are obtained from elevation() just by reference, so no duplication is done?

Thanks!

andrea-bistacchi commented 4 years ago

Update: mesh.points should provide a numpy array with x, y, z, correct? This will do the trick since the I can use e.g. the x column as scalar field.

But is this a shallow or deep copy? Data in the numpy array are duplicated and independent from the original point coordinates of the vtk object, or if I edit some data in the numpy array this is automatically reflected in the vtk object and viceversa?

Thanks!!!

banesullivan commented 4 years ago

mesh.points should provide a numpy array with x, y, z, correct?

Yep, those arrays are what you are looking for

But is this a shallow or deep copy? Data in the numpy array are duplicated and independent from the original point coordinates of the vtk object, or if I edit some data in the numpy array this is automatically reflected in the vtk object and viceversa?

This is a deep copy, editing either the .points or the array added to the point arrays will not reflect in the other array

andrea-bistacchi commented 4 years ago

Thanks very much! Is there a way to make it a shallow copy, so that editing the numpy array you can also easily edit the vtk?

Besides, I also like to edit cells. Is this possible for different types of vtk objects, just for some, or for none?

Thanks again!

banesullivan commented 4 years ago

Maybe I wasn't clear. The numpy array that you have access to is indeed a direct view of the VTK arrays. However, I thought you were originally asking if a scalar array on the mesh could be a shallow copy of the points and that is something we cannot support in PyVista.

Is this possible for different types of vtk objects, just for some, or for none?

This is all the same for all mesh types supported by PyVista