vtk

Alternative for the DYLD_LIBRARY_PATH-trick since Mac OS 10.11 El Capitan with System Integrity Protection

◇◆丶佛笑我妖孽 提交于 2019-11-30 17:53:31
问题 Here is what I have: Mac OS 10.11 El Capitan python 2.7.12, installed from python.org under /Library/Frameworks/Python.framework/ PyCharm 2016.2.3 vtk 7.1.0 Here is what I do: Build a python module locally. In my case, this is vtk. For a summary, see the CMake call with which I configure vtk. cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -DVTK_WRAP_PYTHON=ON -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="/opt/dev/versions/vtk/vtk-7.1.0-shared" -DPYTHON

How to set data values on a vtkStructuredGrid

て烟熏妆下的殇ゞ 提交于 2019-11-30 15:17:00
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 of data at each point (not a vector, 3 distinct scalars). grid = vtk.vtkStructuredGrid() numPoints =

Using QVTKWidget and QOpenGLWidget in the same UI?

早过忘川 提交于 2019-11-30 14:02:09
问题 I'm working on a project that uses a custom subclass of QOpenGLWidget to display some renderings. At the end of the paintGL() method it calls the widget's update() method to trigger a repaint event if it's visible. Now I want to add an additional QVTKWidget to my Ui and I do so by using something like this: QVBoxLayout* layout = findChild<QVBoxLayout*>("layout_simulation"); QVTKWidget* widget = new QVTKWidget(); // Setup arrow vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer

Installing VTK for Python

拈花ヽ惹草 提交于 2019-11-30 12:09:21
I'm trying to install VTK module for python, I am however unsuccesful in doing so. I have downloaded a VTK tar-file, but I'm unable to extract it. I'm capable of extracting other tar-files, so there must be something specific with this file I suppose. This is my error: gzip: stdin: invalid compressed data--format violated tar: Child returned status 1 tar: Error is not recoverable: exiting now I hope somebody can help me with this. The answer depends on the operating system you are using. This will be a lot easier if you can find a package or installer for your specific operating system and/or

Reading a .vtk file with python

╄→гoц情女王★ 提交于 2019-11-30 11:05: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... 回答1: Here is the solution that I came up with, the trick was turning on ReadAllVectorsOn(). import numpy from vtk import

Using QVTKWidget and QOpenGLWidget in the same UI?

这一生的挚爱 提交于 2019-11-30 09:12:07
I'm working on a project that uses a custom subclass of QOpenGLWidget to display some renderings. At the end of the paintGL() method it calls the widget's update() method to trigger a repaint event if it's visible. Now I want to add an additional QVTKWidget to my Ui and I do so by using something like this: QVBoxLayout* layout = findChild<QVBoxLayout*>("layout_simulation"); QVTKWidget* widget = new QVTKWidget(); // Setup arrow vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New(); [more VTK stuff...] widget->GetRenderWindow()->AddRenderer(renderer); renderer-

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

泄露秘密 提交于 2019-11-30 07:31:57
问题 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

How to display point cloud in vtk in different colors?

淺唱寂寞╮ 提交于 2019-11-30 05:39:25
问题 I have a point cloud which I want to visualize in vtk. I want to see them in different colors depending on some conditions. I am using python. Any suggestions on how to do that? Thanks a lot 回答1: Here is an example that sets the point color based on z-axis value. import vtk from numpy import random class VtkPointCloud: def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6): self.maxNumPoints = maxNumPoints self.vtkPolyData = vtk.vtkPolyData() self.clearPoints() mapper = vtk

VTK to Matplotlib using Numpy

a 夏天 提交于 2019-11-30 00:45:29
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 # load input data reader = vtk.vtkXMLUnstructuredGridReader() reader.SetFileName("my_input_data.vtk") reader

installing Mayavi with pip - no module named vtk

萝らか妹 提交于 2019-11-29 23:52:43
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 occurs: Downloading/unpacking mayavi Running setup.py egg_info for package mayavi build_src building