vtk

How to visualize 2d array of doubles in vtk?

限于喜欢 提交于 2021-01-29 06:43:24
问题 I have 2d array (of size 20x30) of doubles: double a[20*30]; How to visualize it using VTK? It is extremely difficult to find proper documentation. The closest example which I found is this, however it uses as input 3 unsigned chars which represents color. As I understand I should use vtkScalarsToColors class to somehow map scalars to colors, but I can't figure out how to put everything into single piece of code. 回答1: What you probably want to do is to assign scalars to points or cells of a

Rendering an actor created within a vtkCommand (callback)

老子叫甜甜 提交于 2021-01-29 06:25:42
问题 I am attempting to write a program that displays and cycles through images of different file formats when the arrow keys are pressed. I have found that setting up my reader->mapper->actor pipeline and then starting my RenderWindowInteractor allows the actor to be rendered, but moving this code to a callback for the RenderWindowInteractor's KeyPressEvent does not allow the actor to be rendered. Are there additional steps required to set up a new actor once the event loop has started, or have I

Write vtk file in binary format

假如想象 提交于 2021-01-29 03:54:19
问题 I am trying to write a vtk file from my C++ code. I have two versions, one ASCII and the other binary. The ASCII version works well. I want to do something similar to this post : Error writing binary VTK files Here is my code : std::ofstream file; if(is_binary) file.open("test.vtk", std::ios::out | std::ios::binary); else file.open("test.vtk"); file << "# vtk DataFile Version 2.0" << std::endl << "Comment if needed" << std::endl; if(is_binary) file << "BINARY"<< std::endl << std::endl; else

Single line with multiple radii with Mayavi

a 夏天 提交于 2021-01-29 02:33:05
问题 I am trying to plot a single line (or tube) in Mayavi that has a non-constant width or radius. This seems like a simple task though I may not be understanding what is happening behind the scenes well enough to make this happen. The following code creates the line I want, and I am able to scale by color; however, I would also like to scale by width. import mayavi.mlab as mlab import numpy as np x = range(100) y = range(100) z = range(100) s = np.random.uniform(0, 1, 100) mlab.plot3d(x, y, z, s

Save an array of data from a VTK in Python

若如初见. 提交于 2021-01-28 08:00:18
问题 Question : How do I extract a dataset array from a VTK in Python and save it in a new file? e.g. for a VTK with data sets for magnitudes force , displacement and current extract only displacement and save it in a smaller file. Problem : I have hundreds of 4GB VTK files in a remote server and I want to extract one of the several data sets that are generated for different magnitudes. In these data sets I have Scalars and Vectors. I wrote the following VTK Python code where I read the

convert vti files to open it with python

让人想犯罪 __ 提交于 2021-01-28 03:04:32
问题 I have several .vti files . How can I convert .vti files into a standard format of 2D images? I've tried ParaView, but didn't find any option to convert in one of above mentioned formats like JPEG or PNG. 回答1: In ParaView: load your vti file, then in the File menu click "Save Data..." and chose the image file format you prefer (I tested with PNG, it works). In Python, this script reads test.vti and saves test.jpg: import vtk reader = vtk.vtkXMLImageDataReader() reader.SetFileName("test.vti")

VTK: The data array in the element may be too short

谁说胖子不能爱 提交于 2021-01-27 18:41:01
问题 I'm trying to visualize some data in vtr format. For this purposes I've created a couple npy files by this library, then I've converted this files by PyEVTK into the vtr format (like in the lowlevel.py example). But when I'm trying to visualize this data by ParaView, an error appears: ERROR: In /var/tmp/portage/sci-visualization/paraview-4.0.1-r1/work/ParaView-v4.0.1-source/VTK/IO/XML/vtkXMLDataReader.cxx, line 510 vtkXMLRectilinearGridReader (0x36bb080): Cannot read point data array

Basic 3D voxel grid in Mayavi

点点圈 提交于 2021-01-27 10:19:55
问题 I'm trying to visualize a 3D array through Mayavi in Python. I simply want to create a structured 3D voxel grid in which I can show some pre-specified voxel-space-filling points. I do not think that I want The only example that I can find that I think is relatively relevant is this MRI example. I can use the following code to get a somewhat workable example: import numpy as np from mayavi import mlab data = (100, 100, 100) data = np.zeros(data) data[0:50, 50:70, 0:50] = 1 data[0:50, 0:20, 0

VTK 图像滤波

孤者浪人 提交于 2021-01-24 07:48:39
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QFileDialog> #include <QDebug> #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRenderingOpenGL2) VTK_MODULE_INIT(vtkInteractionStyle) #include <vtkSmartPointer.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> #include <vtkRenderWindowInteractor.h> #include <vtkJPEGReader.h> #include <vtkImageData.h> #include <vtkImageLuminance.h> #include <vtkImageActor.h> #include <vtkImageThreshold.h> #include <vtkInteractorStyleImage.h> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public:

VTK vtkLight

最后都变了- 提交于 2021-01-17 14:53:21
示例vtkLight的简单用法 #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRenderingOpenGL2) VTK_MODULE_INIT(vtkInteractionStyle) #include <vtkSmartPointer.h> #include <vtkRenderer.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> #include <vtkInteractorStyleTrackball.h> #include <vtkInteractorStyle.h> #include <vtkCylinderSource.h> #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkTexture.h> #include <vtkProperty.h> #include <vtkLight.h> namespace Ui { class MainWindow; } class MainWindow : public