Comments (6)
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
array([[1.666226, 3.261832, 0.646217],
[1.658398, 3.293886, 0.599486],
[1.615146, 3.251326, 0.649149],
...,
[0.11784 , 5.763801, 0.25697 ],
[0.126947, 5.757092, 0.256631],
[0.121833, 5.77197 , 0.242532]], dtype=float32)
from pyvista-support.
I assume the variable clipped
is a vtkPolyData
so you can wrap it with:
clipped = pv.PolyData(clipped)
By default, I think it's only a shallow copy but more details can be found in the pyvista.core.PolyData
class.
And then you have access to clipped.faces
which is a one-dimensional array of cells following VTK convention [cell0_nverts, cell0_v0, cell0_v1, cell0_v2, cell1_nverts, ...]
. You can obtain the number of faces by using the clipped.n_faces
attribute.
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 (points
for points and faces
for cells).
from pyvista-support.
Thank you for responding. If I understand correctly then I think this is very helpful and has answered my question.
Just to check, are the cell0_v0, cell0_v1 and cell0_v2 etc, indices to the points in the points array given by clipped.points?
from pyvista-support.
Just to check, are the cell0_v0, cell0_v1 and cell0_v2 etc, indices to the points in the points array given by clipped.points?
Exactly!
from pyvista-support.
Great! Thank you again @GuillaumeFavelier . I shall close this issue
from pyvista-support.
This is great. Thank you @banesullivan, it is much more concise than what I had done.
from pyvista-support.
Related Issues (20)
- create uniform mesh HOT 3
- Change the orientation of a scalar bar's title
- Applying textures on models from .obj files HOT 6
- How to create an Unstructured grid from points and faces HOT 2
- Type of data, plotting with glyphs HOT 3
- Controlling the thickness and orientation of a slice in Pyvista HOT 3
- Controlling the image position in window, without any click
- Mask/Remove Voxels in Air (small intersection with surface) HOT 3
- custom slider parameters
- running pyvista on headless machine with Centos OS HOT 1
- Seismic Horizon with Pyvista HOT 8
- Algorithm in sample function?
- Automatically updates HOT 3
- Slow interaction HOT 1
- read from text HOT 4
- Uniform Grid thresholding question HOT 8
- Take data by an input x,y,x coordinate (csv file) from vtk data file HOT 4
- Program broke when creating a mesh using pv.PolyData() HOT 4
- ATTENTION: Please move questions to PyVista's Discussions HOT 1
- plotter.enable_terrain_style not working for me HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvista-support.