Comments (13)
@banesullivan You could make a plugin to PyVista using PyQt to show these tables and allow selections to callback to the extract filters. Making the GUI would be the hard part... all the extraction and PyVista stuff is already implemented".
@laserman781 Do you have any ideas on how I could do this? Also, how do I get the mesh data (point data and or cell data) in a table for this?
On the lastest version of PyVista, the Table
class was introduced - a wrapped implementation of vtkTable
which can also go back and forth to a Pandas DataFrame. I'd start by making tables of the mesh's point/cell data by passing those dictionaries to the Table
constructor:
import pyvista as pv
from pyvista import examples
# Any mesh
mesh = examples.download_st_helens().warp_by_scalar()
# Make a table
point_table = pv.Table(mesh.point_arrays)
Also, now you have a Table
which can be converted to a Pandas DataFrame
:
df = point_table.to_pandas()
I'd recommend starting there and then taking a look at the Qt Table Widget and this SO post about making Qt Tables from data frames. Then you'd want to display that widget in an app (maybe link it to PyVista's BackgroundPlotter
) and enable row selection in the qt widget which would call back to function that extracts the cell/point indices (row indices from the table) using either extract_cells
or extract_points
from pyvista-support.
Cell selection is currently possible - check out the .enable_cell_picking
method on the plotter: https://docs.pyvista.org/plotting/plotting.html#pyvista.BasePlotter.enable_cell_picking
You could pass a custom callback
function to save out the mesh or grab the saved mesh after closing the plotter from the .picked_cells
attribute
Otherwise, I'm not sure what you mean by selecting elements/holes...
from pyvista-support.
What kind of function would I need to create to do this? I simply want to be able to select a mesh from the plot and export it as it's own vtk file using the save function.
from pyvista-support.
Or more specifically selecting a vtk cell
from pyvista-support.
The goal is to try and get something similar to extract selection from ParaView.
from pyvista-support.
After making a selection with the plotter's .enable_cell_picking
(which recently had some enhancements that aren't released yet), you can grab the mesh from the .picked_cells
attribute on that plotter - then you could save that mesh if desired.
Here's an example
import pyvista as pv
from pyvista import examples
mesh = examples.download_dragon()
p = pv.Plotter(notebook=False)
p.add_mesh(mesh)
p.enable_cell_picking(mesh)
p.show()
selection = p.picked_cells
selection.plot(color='white')
# Save it
selection.save('my_selection.vtk')
from pyvista-support.
This works great! I am getting the option "Press P to pick a single cell under the mouse"
Is this coming in the next release?
from pyvista-support.
Yes, a few new features with cell selection are coming in the next release! Along with many other point selection tools and widgets.
from pyvista-support.
Awesome! Final question... I mentioned above being able to select from a table. In ParaView there is the option to have a spreadsheet view side by side with the plot and be able to select the cells by their rows (see screenshot in email). from there I can apply the extract cellls filter. Is something like this possible in PyVista as well?
from pyvista-support.
In short, not really as PyVista isn't designed to be GUI application like ParaView.
But if you know the cell IDs (the rows in the spreadsheet view) then you can use PyVista's .extract_cells
filter to extract cells by their IDs which is exactly what ParaView's extract selection filter is doing.
Coming in the next release of PyVista is support for vtkTable
objects in a new Table
class which can go back and forth with Pandas DataFrame
objects. Perhaps there are good tools for interactively making selections from Pandas data frames that would be well suited for this? I image we could make a tool that would display the cell data (or point data) as a pandas DataFrame and perhaps leverage some sort of interactive DataFrame tool to make selections and extract cells in a similar fashion.
Unfortunately it is out of scope for us to deisgn any sort of interactive selection tool based on a table representation.
from pyvista-support.
Or if you are feeling really adventurous, you could make a plugin to PyVista using PyQt to show these tables and allow selections to callback to the extract filters. Making the GUI would be the hard part... all the extraction and PyVista stuff is already implemented
from pyvista-support.
Okay, I will give this a try. Thank you!
from pyvista-support.
FYI... there are some custom Qt widgets implemented in VTK for tables but I'm not sure if they are available on the Python distribution: https://vtk.org/doc/nightly/html/classvtkQtTableView.html
It might require a custom build of VTK
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.