pyvista / pyvista Goto Github PK
View Code? Open in Web Editor NEW3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)
Home Page: https://docs.pyvista.org
License: MIT License
3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)
Home Page: https://docs.pyvista.org
License: MIT License
Is it possible to exaggerate an axis in a VTK rendering window? If so, could we implement a method to do so?
I ask because this is very common (almost necessary) for many geoscientific applications. Often we're dealing with 10s-100s of square kilometers in the lateral (XY-plane) while looking only in the 10s-100s of meters in the Z-direction. These proportions make visualization rather difficult and exaggeration would help significantly
When closing a plotter, you currently must press the q
button. If you press the exit button in the window, the plotter does not properly closed. For example:
import vtki
from vtki import examples
data = examples.load_uniform()
p = vtki.Plotter(notebook=False)
p.add_mesh(data)
p.show(screenshot='foo.png') # USE EXIT BUTTON NOT Q KEY
which produces a blank image because I guess the renderer is destroyed before the screenshot code is executed:
We need streamlined kwargs
for controlling all aspects of the plotter. Feedback on additional items to control would be appreciated!
Also, how these kwargs
are used/passed around needs to be updated to be a bit easier/more intuitive to users familiar with matplotlib
.
Axes Labels Plotter.add_bounds_axes
font_family
font_size
bold
, italic
color
ticks
fmt
Scalar Bar Plotter.add_scalar_bar
or p.add_mesh
-> scalar_bar_args={}
title
or stitle
n_labels
font_family
title_font_size
, label_font_size
bold
, italic
color
interactive
Control window parameters:
window_size
on instantiationGeneral feature requests:
Something happened between v0.13.1 and v0.14.0 that broke the in_background
plotting:
Here is a simple example with an input prompt to not exit the task:
import vtki
from vtki import examples
dataset = examples.load_uniform()
p = vtki.Plotter(notebook=False)
p.add_mesh(dataset)
p.plot(in_background=True)
input('Let me know when you're done:')
Works as expected on v0.13.1 but is broken on v0.14.0 with the following output to the console:
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
2019-01-08 18:12:24.332 python[2136:35526] Warning: CGSSetSurfaceProperty had error 268435459 during sync of extended DR for {NSSurface 0x7fd76a1075d0: _view=0x7fd764ecf210, _window=0x7fd767ca1f00, _frame={{0, 0}, {150, 150}}, res=2.0, _surfaceID=4137, _backingStore=0, _graphicsContext=0x0, _focused=0}
2019-01-08 18:12:24.333 python[2136:35526] CGSGetSurfaceBounds failed - error 268435459 (window:1028, surface:4137
2019-01-08 18:12:24.333 python[2136:35526] CGSSetSurfaceShape failed - error 268435459 (window:1028, surface:4137, bounds:{{0, 0}, {150, 150}}
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
2019-01-08 18:12:24.335 python[2136:35526] Warning: CGSSetSurfaceProperty had error 268435459 during sync of extended DR for {NSSurface 0x7fd76a1075d0: _view=0x7fd764ecf210, _window=0x7fd767ca1f00, _frame={{0, 0}, {150, 150}}, res=2.0, _surfaceID=4137, _backingStore=0, _graphicsContext=0x0, _focused=0}
2019-01-08 18:12:24.335 python[2136:35526] CGSGetSurfaceBounds failed - error 268435459 (window:1028, surface:4137
2019-01-08 18:12:24.336 python[2136:35526] CGSSetSurfaceShape failed - error 268435459 (window:1028, surface:4137, bounds:{{0, 0}, {512, 384}}
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
python(2136,0x10c1595c0) malloc: *** can't vm_purgable_control(..., VM_PURGABLE_SET_STATE) for large freed block at 0x11667a000
python(2136,0x10c1595c0) malloc: can't allocate region
*** mach_vm_map(size=18446576513437405184) failed (error code=4)
python(2136,0x10c1595c0) malloc: *** set a breakpoint in malloc_error_break to debug
python(2136,0x10c1595c0) malloc: can't allocate region
*** mach_vm_map(size=18446576513437405184) failed (error code=4)
python(2136,0x10c1595c0) malloc: *** set a breakpoint in malloc_error_break to debug
python(2136,0x10c1595c0) malloc: can't allocate region
*** mach_vm_map(size=18446576513437405184) failed (error code=4)
python(2136,0x10c1595c0) malloc: *** set a breakpoint in malloc_error_break to debug
python(2136,0x10c1595c0) malloc: can't allocate region
*** mach_vm_map(size=18446576513437405184) failed (error code=4)
python(2136,0x10c1595c0) malloc: *** set a breakpoint in malloc_error_break to debug
python(2136,0x10c1595c0) malloc: can't allocate region
*** mach_vm_map(size=18446576513437405184) failed (error code=4)
python(2136,0x10c1595c0) malloc: *** set a breakpoint in malloc_error_break to debug
python(2136,0x10c1595c0) malloc: can't allocate region
*** mach_vm_map(size=18446576513437405184) failed (error code=4)
python(2136,0x10c1595c0) malloc: *** set a breakpoint in malloc_error_break to debug
This is necessary for #33
def UpdateCoordinates(self, points, mesh=None, render=True):
""" updates points of object (point only for now)
assumes last inputted mesh if mesh left empty
"""'
if mesh is None:
mesh = self.mesh
self.mesh.SetNumpyPoints(points)
if render:
self.Render()
self.mesh.SetNumpyPoints(points)
probable should be mesh.SetNumpyPoints(points)
Something isn't right with the Qt renderer mouse locations. When interacting with the axes widget, it detects that the user is hovering over it at the wrong locations... see video below.
Perhaps this is why we can't move the interactive scalar bar widget in #79
Can we change the default behavior of what is returned on the Plotter.screenshot
call when a filename is passed? Perhaps add an argument return_image=None
that can be used to get the NumPy array of the image if a user wants it after saving the image?
It makes notebooks a bit messy in its current implementation:
Thank you very much for the vtkInterface, it is the best interface I have seen so far.
However, when running the following code, I observe error
import vtkInterface as vtki
import numpy as np
# Make data
x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
x, y = np.meshgrid(x, y)
r = np.sqrt(x**2 + y**2)
z = np.sin(r)
# create and plot structured grid
grid = vtki.StructuredGrid(x, y, z)
grid.Plot() # basic plot
# Plot mean curvature
grid.PlotCurvature()
as
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-9afe5b8e784d> in <module>()
14
15 # Plot mean curvature
---> 16 grid.PlotCurvature()
/usr/local/lib/python2.7/dist-packages/vtkInterface/grid.pyc in PlotCurvature(self, curvtype, rng)
68 """
69 # extract surface and plot its curvature
---> 70 self.ExtractExteriorTri()[0].PlotCurvature(curvtype, rng)
71
72 @property
TypeError: PlotCurvature() takes at most 2 arguments (3 given)
In [3]: examples.BeamExample()
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-3-f6334ffa27c4> in <module>()
----> 1 examples.BeamExample()
~\AppData\Roaming\Python\Python36\site-packages\vtkInterface\examples\examples.py in BeamExample()
117 plobj.AddMesh(grid, scalars=d[:, 1], stitle='Y Displacement',
118 rng=[-d.max(), d.max()], colormap=colormap)
--> 119 plobj.AddAxes()
120 plobj.SetCameraPosition(cpos)
121 plobj.AddText('Static Beam Example')
~\AppData\Roaming\Python\Python36\site-packages\vtkInterface\plotting.py in AddAxes(self)
1286 def AddAxes(self):
1287 """ Add axes actor at origin """
-> 1288 raise Exception('Disabled')
1289 pass # causes segfault
1290 # axes = vtk.vtkAxesActor()
Exception: Disabled
Windows users are reporting crashes/segfaults on Windows with PyQt5
version 5.12
.
Immediate solution of downgrading PyQt5
to version 5.11.3
works for now but we need a patch for this.
Edit: Travis is also reporting failures on Linux
See discussion in #74
There are a few examples of plotting time-varying data using vtki
:
These examples are all a bit convoluted and difficult for new users to experiment with. I propose a new feature in the plotting code that will handle all the background threading nuances so that new users (and power users like myself) do not have to make sure old threads are cleaned up and everything will simply work.
Perhaps we could create a new function on the plotters called run_update_thread(func, **kwargs)
that will take a user-defined function and it's keyword arguments. Then vtki
will handle setting up the background threads and managing them when they are no longer in use.
I'm thinking this is necessary because I have seen a few users try to use the background threads and then try to make a change and end up with numerous background threads that are still updating old plotters and eating up memory/resources (I also do this all the time and end up to restarting my kernel).
This type of feature would make sure any threads associated with a plotter are killed when the plotter is closed.
Below is what I'm thinking this might look like. I'm also brainstorming ideas of how we could have a user define a loop statement and then tell vtki
to run that loop making sure to use a defined time step between each iteration if desired.
import vtki
import numpy as np
x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
x, y = np.meshgrid(x, y)
r = np.sqrt(x**2 + y**2)
z = np.sin(r)
# Create and structured surface
grid = vtki.StructuredGrid(x, y, z)
grid.point_array['foo'] = z.ravel()
# Creat a plotter object and set the scalars to the Z height
p = vtki.BackgroundPlotter()
p.add_mesh(grid)
def my_func():
"""My user defined function that will update the plotter"""
nframe = 25
for phase in np.linspace(0, 2*np.pi, nframe + 1)[:nframe]:
grid.points[:,-1] = np.sin(r + phase)
grid.point_array['foo'] = z.ravel()
return None
# Now repeatedly run that function!
p.run_update_thread(my_func, tstep=0.01)
I'm simply brainstorming what users might want/need and I'm hoping to solicit feedback.
For those of you who I know are interested in time-varying visualizations, what would you like to see?: @tomtomatron and @sgkang
I can get tests.ShowWave()
to work, but none of the other examples run because LoadMesh isn't working.
vtkInterface 0.4.0 from pip
MacOS 10.13
Homebrew Python 3.6.2
Homebrew VTK 8.1.0
I'd like to implement a new orthographic slicer where I use a 2 by 2 multi-window plotter.
Features needed:
import vtki
from vtki import examples
data = examples.load_uniform()
data.set_active_scalar('Spatial Cell Data')
slices = data.slice_orthogonal()
# Orthographic Slicer
p = vtki.Plotter(shape=(2,2), notebook=False)
p.subplot(1,1)
p.add_mesh(slices, clim=data.get_data_range())
p.subplot(0,0)
p.add_mesh(slices['XY'])
p.view_xy()
p.disable()
p.subplot(0,1)
p.add_mesh(slices['XZ'])
p.view_xz(negative=True)
p.disable()
p.subplot(1,0)
p.add_mesh(slices['YZ'])
p.view_yz()
p.disable()
p.show()
I want this to behave similarly to ParaView's orthographic slicer:
When initializing PolyData, it seems like there's some sampling on the original stl file. I wonder if there's a way to turn off the sampling, and get a very fine mesh of the original stl file as a numpy array
At the moment it's not possible to pass the output of the PolyDataNormals filter to PolyData.Overwrite as with other functions in the PolyData class, as this doesn't preserve the PointData object.
Can we implement the vtk.vtkEDLShading
class to get eye dome lighting? Check out this blog post on how ParaView implements it.
I've been working with a lot of point clouds lately and ParaView's EDL view makes seeing the clouds so much easier. Note the comparison below. It would be really nice to have the option to apply this shader to only specific datasets in a scene but that might not be possible.
Note: https://discourse.vtk.org/t/eye-dome-lighting-vtkedlshading-example-request/508
Hello, I am using the vtki for texture mapping and I also want to use the vtk.camera object with vtki. I have some questions:
Here is my code for texture mapping and the change of the camera position:
texture = vtki.load_texture(img_path)
obj = vtki.read(stl_path)
obj.texture_map_to_plane(inplace=True)
Mapper = vtk.vtkPolyDataMapper()
Mapper.SetInputData(obj)
Actor = vtk.vtkActor()
Actor.SetMapper(Mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(Actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
// The camera position code
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
renWin.Render()
iren.Start()
Hello,
Is there any methods to clear the plotted mesh?
Once I call "add_mesh" method, I can't clear the mesh plotting.
I tried to call add_mesh method with dummy grid object but didn't help.
When updating a scalar array, the scalar bar is not updated if the data range is updated. For example:
This example is from #75
from threading import Thread
import time
import numpy as np
import vtk
import vtki
sphere = vtki.Sphere()
sphere.point_arrays['scalars'] = sphere.points[:, 2]
# points = vtki_ndarray(sphere.points, sphere)
cpos = [(-1.3410801252605407, -2.735564325598376, 1.3608119983788354),
(0.0, 0.0, 0.0),
(0.16724779351273428, 0.37216861144284896, 0.9129724531560762)]
plotter = vtki.BackgroundPlotter()
plotter.add_mesh(sphere, lighting=False, show_edges=True, scalars='scalars')
plotter.camera_position = cpos
# shrink sphere in the background
def shrink():
for i in range(10):
sphere.points *= 0.9
# Update sclars
sphere.point_arrays['scalars'] += np.random.rand(sphere.n_points)
time.sleep(0.5)
thread = Thread(target=shrink)
thread.start()
We should add a way that the scalar bars can be updated automatically if their corresponding meshes' data ranges change.
We will likely need a way to disable this if the user wants to explicitly define the scalar range
To implement this, we'll need some sort of callback or observer that will fetch the data ranges for each array linked to a scalar bar. This could turn into quite a bit of overhead if we do this on every render call.... perhaps there is a way to link the VTK scalar bar to the Cell/Point data to listen for a Modified()
call?
I was checking and the LookUpTable (colormap) is hardcoded in vtkInterface. Is there any chance that we can change it?
Colormaps serve different purposes in different datasets and it would be nice to change. Furthermore, the rainbow colormap is considered to be suboptimal, see for example:
Borland, David, and Russell M. Taylor II. "Rainbow color map (still) considered harmful." IEEE computer graphics and applications 27.2 (2007): 14-17.
When running the demo for advanced numpy plotting from the docs http://vtkinterface.readthedocs.io/en/latest/index.html
I get the following error:
File "C:\Users\aniranjan\AppData\Local\Continuum\anaconda3\envs\py35\lib\site-packages\vtkInterface\plotting.py", line 1090, in AddArrows
pdata = vtkInterface.CreateVectorPolyData(cent, direction * mag)
File "C:\Users\aniranjan\AppData\Local\Continuum\anaconda3\envs\py35\lib\site-packages\vtkInterface\utilities.py", line 138, in CreateVectorPolyData
vcells.SetCells(npts, numpy_to_vtkIdTypeArray(cells, deep=True))
File "C:\Users\aniranjan\AppData\Local\Continuum\anaconda3\envs\py35\lib\site-packages\vtk\util\numpy_support.py", line 192, in numpy_to_vtkIdTypeArray
'Expecting a numpy.int32 array, got %s instead.' % (str(dtype)))
ValueError: Expecting a numpy.int32 array, got int64 instead.
The issue appears to be in numpy_to_vtkIdTypeArray(), or at least how it's called in AddArrows()->CreateVectorPolyData()->vtk.vtkCellArray().SetCells()
I know it is somehow possible to use math-tex / LaTeX math formatting for labels in VTK, but how can we enable it in vtki
? For example:
plotter.add_bounds_axes(xlabel='$F^2$')
plotter.add_mesh(data, stitle='$stuff^2$')
Hello i tried installing your package via pip (i'm running python 3.6.3 on anaconda) and got this error:
`runfile('C:/Users/Tomas/Desktop/teste.py', wdir='C:/Users/Tomas/Desktop')
Traceback (most recent call last):
File "", line 1, in
runfile('C:/Users/Tomas/Desktop/teste.py', wdir='C:/Users/Tomas/Desktop')
File "C:\Users\Tomas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "C:\Users\Tomas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Tomas/Desktop/teste.py", line 1, in
import vtkInterface
File "C:\Users\Tomas\Anaconda3\lib\site-packages\vtkInterface_init_.py", line 10, in
from vtkInterface.plotting import *
File "C:\Users\Tomas\Anaconda3\lib\site-packages\vtkInterface\plotting.py", line 12, in
from PIL import Image
File "C:\Users\Tomas\Anaconda3\lib\site-packages\PIL\Image.py", line 56, in
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.`
Can't figure out why i'm getting this error, as i've vtk installed (vtk 8.1.0).
Can you help me out?
OS: Windows 10
I am using conda 4.3.25 on Windows, and I have created an environment for python 2.7 in order to be able to install vtk.
Then I have installed pyansys and vtkInterface using pip.
When trying to import pyansys i get
Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:17:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import pyansys
C:\Users\myusername\AppData\Local\Continuum\Anaconda3\envs\py27\lib\site-packages\pyansys\archive_reader.py:32: UserWarning: Unable to load vtk dependent modules
warnings.warn('Unable to load vtk dependent modules')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\myusername\AppData\Local\Continuum\Anaconda3\envs\py27\lib\site-packages\pyansys\__init__.py", line 4, in <module>
from pyansys.binary_reader import *
File "C:\Users\myusername\AppData\Local\Continuum\Anaconda3\envs\py27\lib\site-packages\pyansys\binary_reader.py", line 7, in <module>
import vtkInterface
File "C:\Users\myusername\AppData\Local\Continuum\Anaconda3\envs\py27\lib\site-packages\vtkInterface\__init__.py", line 7, in <module>
from vtkInterface.polydata import PolyData
File "C:\Users\myusername\AppData\Local\Continuum\Anaconda3\envs\py27\lib\site-packages\vtkInterface\polydata.py", line 22, in <module>
class PolyData(vtkPolyData, vtkInterface.Common):
ValueError: multiple inheritance is not allowed with VTK classes
Any clue on how to solve this ?
Can we isolate click events to each renderer in the multi-plotting view? For example, if on click on one renderer to rotate the camera, as soon as you cross the boundary into the other renderer, it starts rotating the other window.
import vtki
from vtki import examples
p = vtki.Plotter(shape=(1,2), notebook=False)
p.subplot(0,0)
p.add_mesh(examples.load_airplane())
p.subplot(0,1)
p.add_mesh(examples.load_globe())
p.show()
The docs are looking pretty OK at the moment. To make the docs more friendly to new users as well as useful for power users, I propose the following restructure:
Contents:
vtki
wraps and why users might want to choose different mesh types for different problems. These notes will point to the respective vtki class docs)plotting
module offershi all:
This project is very interesting for visualization based on VTK.
I want to use vtkInterface
with jupyter notebook
then i can view the result in notebook.
Maybe, it can integrate with pythreejs.
Current, the result show in another window as following:
@akaszynski do you have a plan for rendering on jupyter ?
We should remove the wiki page/examples (or move them to the docs).
The wiki cannot be tested via a CI and will be difficult to maintain.
There are some PolyData functions that I think would benefit from having an option to edit the input object in place. I would suggest adding this functionality as a function argument in the style of e.g.
def Decimate(self, target_reduction, ..., inplace=False):
<...>
if inplace:
self.Overwrite(decimate.GetOutput())
else:
return PolyData(decimate.GetOutput())
Candidate functions for this feature include (but aren't limited to)
Similarly, for the functions that exclusively do in-place operations, it might be good to add the flexibility to be able to return the object (such as for PolyData.Clean etc.).
Not having inplace arguments breaks code style consistency. Example:
mesh.ClipPlane([0, 0, 0], [0,0,1])
mesh.ExtractLargest()
mesh.FillHoles(100.0)
mesh.FlipNormals()
normals = mesh.Normals()
mesh.SetNormals(*normals)
mesh.Clean()
mesh = mesh.Decimate(0.9)
The 2D Delaunay filter on the vtki.PolyData
class is misspelt as .delauney_2d
which is inconsist with the spelling in VTK and the 3D Delaunay filter under vtki.DataSetFilters
.
This is leading to confusion among new users.
Iโm afraid this might not be a simple fix by refactoring since .delauney_2D
filter has been around for a long time and other dependencies might call it.
When I attempt to use PolyData with vertices and faces I either get a segfault style crash or for some simple demos I get an empty VTK render window.
For example, the code on this page: https://vtkinterface.readthedocs.io/en/latest/polydata.html:
import numpy as np
import vtkInterface
# mesh points
vertices = np.array([[0, 0, 0],
[1, 0, 0],
[1, 1, 0],
[0, 1, 0]])
# mesh faces
faces = np.hstack([[4, 0, 1, 2, 3], # square
[3, 0, 1, 4], # triangle
[3, 1, 2, 4]]) # triangle
surf = vtkInterface.PolyData(vertices, faces)
# plot each face with a different color
surf.Plot(scalars=np.arange(3))
Just gives me an empty render window.
The following example segfaults:
import vtkInterface
import numpy as np
from vtkInterface import PolyData
verts = np.array([[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[1, 0, 1]], dtype=np.float64)
faces = np.array([[0, 1, 2],
[1, 2, 3]], dtype=np.int64)
pd = PolyData(verts, faces)
pd.Plot()
When I follow the debugger it's the PolyData.SetPolys() line that causes the crash.
Just to be clear... if I instead build the triangles one at time using pure vtk it works fine.
import numpy as np
import vtk
verts = np.array([[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[1, 0, 1]], dtype=np.float64)
faces = np.array([[0, 1, 2],
[1, 2, 3]], dtype=np.int64)
points = vtk.vtkPoints()
triangles = vtk.vtkCellArray()
for i, tri in enumerate(faces):
p1 = verts[tri[0]]
p2 = verts[tri[1]]
p3 = verts[tri[2]]
points.InsertNextPoint(*p1)
points.InsertNextPoint(*p2)
points.InsertNextPoint(*p3)
triangle = vtk.vtkTriangle()
triangle.GetPointIds().SetId(0, 3 * i + 0)
triangle.GetPointIds().SetId(1, 3 * i + 1)
triangle.GetPointIds().SetId(2, 3 * i + 2)
triangles.InsertNextCell(triangle)
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
polydata.SetPolys(triangles)
mapper = vtk.vtkDataSetMapper()
mapper.SetInputData(polydata)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.SetRenderWindow(renWin)
renderer.AddActor(actor)
renWin.SetSize(640, 480)
renWin.Render()
renWin.Render()
iren.Start()
Any ideas?
I see the Travis script uses pytest-cov
, does this test runner report code coverage?
Do you, @akaszynski, by chance have the coverage reported to a service like codecov?
This would be a major help for me to figure out what still needs testing as I've added quite a bit of untested code in the last 24 hours
These requests stemmed from conversations with @prisae and @craigmillernz
Can we implement a way for a user to make custom colormaps using matplotlib
and send that map as the cmap
argument? This should be as simple as adding in a type check and skipping over the colormap lookup code.
Update: implemented in #126
We also need a way to have categorical colormaps
Update: this is possible by using a custom built colormap from
matplotlib
norm
optionAlso, could we add a new norm
keyword argument similar to matplotlib
? See this page. This would help users apply a standard matplotlib
norm or center a color mapping around a value without changing the range. E.g "My data scale goes from -0.6
to 0.3
and I'd like the red/blue color map to be centered so that white is at 0
."
@craigmillernz provided a super useful function for implementing this type of norm:
#Class to normalize colors to center around a value
from matplotlib.colors import Normalize
class MidpointNormalize(Normalize):
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y))
Could we maybe make a tool to create custom colormaps? This honestly might make the most sense to create a totally separate module under @OpenGeoVis. I'm thinking some sort of ipywidget
or PyQt5
type interface where a user can harness to create a custom colormap. If we can get this going, then provide a way for it to like with vtki
and update the mappers so a user can interactively update the rendering scene while changing the colormap.
Here is an example from @prisae in MatLab:
Dear Alex,
it is possible to get the area for each cell of a cutting plane, or volume for each cell of a mesh? In particular, I want to get the average for a value over surface or volume.
Thank you for your time.
Regards,
Christian
We should add topics and a link to the docs (http://docs.vtki.org/) in the repository header information. Currently, the header looks like:
We should add topics to help people discover vtki
. Possible tags include:
Check out https://github.com/topics for more info
For example, PVGeo has topics and a link:
UpdateScalars do not add the scalar points to mesh , i.e., it doesn't call AddCellScalars or AddPointCellScalars. Due to this the scalar remains in the same initial state without being updated.
I see sphere.ply
in version control but not sphere.vtk
?
It seems that the method AddPointScalars
allows to add vector data. But this is not clear from the docs. I just tested it with the following snippet
import numpy as np
import vtkInterface
x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
z = 0
x, y, z = np.meshgrid(x, y, z)
data = np.column_stack((x.flatten(), y.flatten(), x.flatten()))
grid = vtkInterface.StructuredGrid(x, y, z)
grid.AddPointScalars(data, "data")
grid.Write("test.vts")
I think that this can be useful info to add to the docs.
@akaszynski, could we implement an easy way to specify the resolution of the screenshots using a DPI or similar type of metric?
This is needed for making publication ready figures
@akaszynski, can you remove the old PyPI deployment to avoid confusion from new users
Note, the only project on PyPI that appears to have a dependency to the old vtkInterface
is tetgen
I propose we get a conda build recipe up for vtki
because of the headaches that Windows installations bring:
I've been running into trouble making vtki
a dependency of my project PVGeo. When I run the Windows CI testing (AppVeyor) for the environment:
Environment: PYTHON_VERSION=3.6, CONDA=C:\Miniconda36; Platform: x86
The setup.py
script for vtki
tries to add VTK to the dependencies but it is unavailable for that build from pip, only from conda.
Collecting vtk (from vtki>=0.13.0->-r requirements.txt (line 9))
Could not find a version that satisfies the requirement vtk (from vtki>=0.13.0->-r requirements.txt (line 9)) (from versions: )
No matching distribution found for vtk (from vtki>=0.13.0->-r requirements.txt (line 9))
Perhaps we should change the setup.py script to always warn on windows? Or better yet, do you (@akaszynski) know how to setup conda build recipes?
I haven't been able to figure this out for myself but I beginning to see that conda recipes will be a necessity for projects depending on VTK.
In the qt plotter example in the docs, a menubar and menu item to add datasets to the render window is created. Could we do this for the Background plotter and implement a few methods that make calls to the Plotter?
I'm thinking it would be useful to have at least:
File
menu:
View
menu:
I'm mulling over whether or not to implement a vtkTable
wrapper in vtki
and I'm curious about other's thoughts.
The vtkTable
is a very common dataset I use and I have some functions in PVGeo that will convert them back and forth to Pandas DataFrame
objects (basically just tables with an awesome interface).
My hesitations are:
vtkTable
s are subclasses of vtkDataObject
s not vtkDataSet
s unlike everything else in vtki
. This means we'd have to set up a new/separate module for DataObject wrappers.DataFrame
with callbacks to the VTK data object?vtki
(as in it will be quite time consuming to get right)A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.