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
How to access point data for a cell? #26
Comments
I assume the variable And then you have access to Is it helpful @S0Phon? btw, I see in the doc it's written that faces returns a pointer to the points as a numpy object, we will correct this ( |
Thank you for responding. If I understand correctly then I think this is very helpful and has answered my question. |
Exactly! |
Great! Thank you again @GuillaumeFavelier . I shall close this issue |
FYI, a true PyVista version of this would be: import pyvista as pv
from pyvista import examples
import numpy as np
poly_data = examples.download_doorman()
clipped = poly_data.clip(normal=[1,0,0],
origin=poly_data.center,
invert=False)
clipped.plot() Then, you could grab the cell nodes like so (if I understand this correctly... if not, @S0Phon, would you please post your solution): cell_indices = clipped.faces
# make sure all triangles
assert not cell_indices.size % 4 and np.all(cell_indices.reshape(-1, 4)[:,0] == 3)
# Grab ids for all cell nodes
cell_node_ids = cell_indices.reshape(-1, 4)[:,1:4].ravel()
cell_nodes = clipped.points[cell_node_ids]
cell_nodes
|
This is great. Thank you @banesullivan, it is much more concise than what I had done. |
I would like to know how to extract point data for polydata on a per cell basis. Ideally this would be in a format of a nx3x3 numpy array, where n is the number of triangles in a trianglular mesh and the x,y,z coordinates of each vertex are given in each row of the 3x3 matrix. However just being able to get an array of the points for each cell would be enough as I could combine and reshape this afterwards.
My reason for doing this is to input these points into another program (which requires this format) after using pyvista to manipulate the original STL import.
I feel like this is probably quite an easy thing to do but so far have been unable to figure out how. I appologise if this has been covered somewhere before but I have searched for some time and cannot find examples of getting the triangle point data, only the mesh point data by using mesh.points.
To create a similar situation using pyvista example files, I have found an example @banesullivan posted on a discourse question.
I would then need to extract the point data for each triangle in clipped as described at the start of the issue.
The text was updated successfully, but these errors were encountered: