vtk

Reading a .vtk file with python

耗尽温柔 提交于 2019-11-29 23:13:26
I've been given a legacy format vtk file (I think its an unstructured grid) and I'd like to read it in with python and output a .npy file instead, since I know how to deal with that. The file is a dump from ATHENA and so has density, velocity, magnetic field along with the coordinates. I'm very much a procedural programmer, so all these objects are confusing... Ben Jackel Here is the solution that I came up with, the trick was turning on ReadAllVectorsOn(). import numpy from vtk import vtkStructuredPointsReader from vtk.util import numpy_support as VN reader = vtkStructuredPointsReader()

How to set data values on a vtkStructuredGrid

こ雲淡風輕ζ 提交于 2019-11-29 21:34:35
问题 I'm trying to fill in a structured grid with an analytical field, but despite reading the vtk docs, I haven't found out how to actually set scalar values at the grid points or the set the spacing/origin info of the grid. Starting from the code below, how do I associate spatial information with the grid (ie cell 0,0,0 is at coordinates 0,0,0, the spacing is dx in every direction) associate scalar values with each grid point. To start, I just need one, but eventually I'd like to store 3 pieces

Exporting a 3D numpy to a VTK file for viewing in Paraview/Mayavi

人盡茶涼 提交于 2019-11-29 04:36:34
For those that want to export a simple 3D numpy array (along with axes) to a .vtk (or .vtr) file for post-processing and display in Paraview or Mayavi there's a little module called PyEVTK that does exactly that. The module supports structured and unstructured data etc.. Unfortunately, even though the code works fine in unix-based systems I couldn't make it work (keeps crashing) on any windows installation which simply makes things complicated. Ive contacted the developer but his suggestions did not work Therefore my question is: How can one use the from vtk.util import numpy_support function

VTK to Matplotlib using Numpy

徘徊边缘 提交于 2019-11-28 21:37:45
问题 I want to extract some data (e.g. scalars) from a VTK file along with their coordinates on the grid then process it in Matplotlib . The problem is I dont know how to grab the point/cell data from the VTK file (by giving the name of the scalar, for instance) and load them into a numpy array using vtk_to_numpy My code should look like: import matplotlib.pyplot as plt from scipy.interpolate import griddata import numpy as np from vtk import * from vtk.util.numpy_support import vtk_to_numpy #

installing Mayavi with pip - no module named vtk

梦想与她 提交于 2019-11-28 21:00:53
问题 I want to use Mayavi. Situation I use a MacBook Air, with OSX 10.7.3. I use Python 2.7.2 I have virtualenv installed. But I have not used it for this installation. I've manually installed all it's dependencies, including VTK . For VTK , I followed its installation guide and installed the python wrapper. Now if I open a new terminal window and open python, I can import vtk without any error. Problem I try to install Mayavi with the following command: pip install mayavi But the following error

Combining Qt 5.4.1 with vtk 6.2.0 (using CMake GUI 3.2.1) on windows

你说的曾经没有我的故事 提交于 2019-11-28 13:08:35
I know almost nothing about CMake. What I'm trying to do is to use VTK with Qt. Unfortunately, I'm stuck at the CMake part. For some reason, when I press "configure", I get the following error: CMake Error at GUISupport/Qt/CMakeLists.txt:58 (find_package): By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Widgets", but CMake did not find one. Could not find a package configuration file provided by "Qt5Widgets" with any of the following names: Qt5WidgetsConfig.cmake qt5widgets-config.cmake Add the

VTK failed after update Lights 16 OpenGL errors detected 错误

纵然是瞬间 提交于 2019-11-28 08:24:25
在读取.VTK文件的时候出现如标题错误,代码如下 1 #include<vtkSmartPointer.h> 2 #include<vtkRenderWindow.h> 3 #include<vtkRenderer.h> 4 #include<vtkRenderWindowInteractor.h> 5 #include<vtkInteractorStyleTrackballCamera.h> 6 #include<vtkCylinderSource.h> 7 #include<vtkPolyDataMapper.h> 8 #include<vtkActor.h> 9 #include<vtkLight.h> 10 #include<vtkCamera.h> 11 #include<vtkJPEGReader.h> 12 #include<vtkTexture.h> 13 #include<vtkPlaneSource.h> 14 #include<vtkStructuredPointsReader.h> 15 #include<vtkMarchingCubes.h> 16 #include "vtkOpenGLRenderWindow.h" 17 18 void showMarchingCubes() 19 { 20 vtkSmartPointer

VTK Demo(一) 显示圆柱体

余生长醉 提交于 2019-11-28 07:59:44
() 1 #include<vtkSmartPointer.h> 2 #include<vtkRenderWindow.h> 3 #include<vtkRenderer.h> 4 #include<vtkRenderWindowInteractor.h> 5 #include<vtkInteractorStyleTrackballCamera.h> 6 #include<vtkCylinderSource.h> 7 #include<vtkPolyDataMapper.h> 8 #include<vtkActor.h> 9 10 #include "vtkAutoInit.h" 11 12 VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2 13 VTK_MODULE_INIT(vtkInteractionStyle); 14 //https://blog.csdn.net/thecentry/article/details/79111295 15 int main() 16 { 17 vtkSmartPointer<vtkCylinderSource>cylinder = vtkSmartPointer<vtkCylinderSource>::New(); 18

How to install VTK 6.1 for OSX 10.8 with Cocoa/XCode support?

风流意气都作罢 提交于 2019-11-28 07:03:26
The extremely helpful guidelines posted at http://www.vtk.org/Wiki/Cocoa_VTK and via the readme file by Sean McBride and Mike Jackson inside the VTK repo were slightly out of date for VTK 6.1. So in case this helps anybody, I'm posting instructions for installing VTK 6.1 on OSX 10.8 with support for the SimpleCocoaVTK Xcode project. Angus Forbes * Installing VTK 6.1 for OSX 10.8 with Cocoa support * These instructions slightly modify Ryan Glover's instructions at http://www.vtk.org/Wiki/Cocoa_VTK and the README.rtf in the VTK/Examples/GUI/Cocoa/Documentation folder by Sean McBride and Mike

Animating a mayavi points3d plot

依然范特西╮ 提交于 2019-11-27 22:59:35
I'm trying to make a video of the trajectories of particles. However, somehow my scene never updates. Here's a very simple example: from __future__ import absolute_import, division, print_function from mayavi import mlab import numpy as np import math alpha = np.linspace(0, 2*math.pi, 100) xs = np.cos(alpha) ys = np.sin(alpha) zs = np.zeros_like(xs) mlab.points3d(0,0,0) plt = mlab.points3d(xs[:1], ys[:1], zs[:1]) @mlab.animate(delay=100) def anim(): f = mlab.gcf() while True: for (x, y, z) in zip(xs, ys, zs): print('Updating scene...') plt.mlab_source.x[0] = x plt.mlab_source.y[0] = y plt.mlab