vtk

Resampling and ploting multiple slices from a vtkPolydata

Resampling and ploting multiple slices from a vtkPolydata Question: I have a vtkPolydata with 3D coordinates of the vertex of the grid as points and Temperature at each point stored as point field data. I want to plot the Temperature distribution at different elevations. I am using Python for the operation. I have created a …

Total answers: 2

How to extract edges from polydata as connected features?

How to extract edges from polydata as connected features? Question: I have a polydata structure and its extracted edges but computed with extract_feature_edges function as unconnected cells (separated lines). Is it possible to connect those cells (lines) from their common points and then get the different features (lands, islands such as what you can see …

Total answers: 2

Holes in PolyData while using vtkLinearExtrusionFilter in Python

Holes in PolyData while using vtkLinearExtrusionFilter in Python Question: I wanna create a 3D object from a surface.I used vtkAdaptiveSubdivisionFilter to remesh a polydata. When I GetOutput from vtkAdaptiveSubdivisionFilter and use vtkLinearExtusionFilter to extrude I see some holes on extrude output and some bad edges. see the pic below. here is my code: normals = …

Total answers: 1

SaveData in Paraview python is not saving the file

SaveData in Paraview python is not saving the file Question: I used one stl file to split the stl using Paraview. I traced the method using python trace in paraview. Now, I used the code in python to run it. It runs perfectly, but it does not save the splitted mesh as needed. The code …

Total answers: 1

Convert STL object to VTK geometry in python

Convert STL object to VTK geometry in python Question: I am wanting to do Boolean operations on STL files with geometric primitives from the VTK library. My problem is converting the STL geometry to something that the VTK Boolean objects will except. I tried the following… import vtk filename = ‘gyroid.stl’ reader = vtk.vtkSTLReader() reader.SetFileName(filename) …

Total answers: 2

Displaying vpl.mesh_plot in PyQT5

Displaying vpl.mesh_plot in PyQT5 Question: I need to render an .stl image on an user interface. I created the UI with PyQt5, and I have managed to render the .stl image with vplotlib. However, I am having problems with displaying this vpl.mesh_plot on the Qframe that I have on UI (name: self.ui.MyQframe; the window does …

Total answers: 1

Setting up VTK, with python3.8 and Ubuntu 20.04

Setting up VTK, with python3.8 and Ubuntu 20.04 Question: I recently updated my system to Ubunutu 20.04, and my python is now 3.8. Since then all my import vtk lines don’t work, ModuleNotFoundError: No module named ‘vtk’ I have tried apt-get python-vtk, pip3 install vtk and pretty much all the standard terminal install commands. Without …

Total answers: 3

How do I create a colormap in VTK?

How do I create a colormap in VTK? Question: I created a simple unstructured square in VTK: x = [0,10,0,10] y = [0, 0, 10, 10] z = [0,0,0,0] data = np.asarray([x,y,z]).T for i in range(0, len(x)): points.InsertPoint(i, data[i]) quad = [2,3,1,0] ugrid.InsertNextCell(vtk.VTK_QUAD, 4, quad) ugrid.SetPoints(points) Say I wanted to create a colormap of the …

Total answers: 2

Load and resize multiple STL files in python

Load and resize multiple STL files in python Question: I found the code to read an STL file but I don’t know how to read multiple STL files in one window and resize them. import vtk filename = "Stl file" reader = vtk.vtkSTLReader() reader.SetFileName(filename) mapper = vtk.vtkPolyDataMapper() if vtk.VTK_MAJOR_VERSION <= 5: mapper.SetInput(reader.GetOutput()) else: mapper.SetInputConnection(reader.GetOutputPort()) actor …

Total answers: 1

vtk render with distancewidget inside a PyQT application

vtk render with distancewidget inside a PyQT application Question: the following simple code does not work and I just want to use QVTKRenderWindowInteractor with vtkDistanceWidget to measure sphere length with mouse. but vtkDistanceWidget does not work import sys import vtk from PyQt5 import QtCore, QtWidgets from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor class MainWindow(QtWidgets.QMainWindow): def __init__(self, parent = …

Total answers: 1