I’m trying to visualize a highly dense mesh. I have the coordinates and the connectivity of said coordinates.
I have already succeeded in showing the mesh, however, after my initial testing, I received a substantially larger mesh, containing roughly 350,000 elements. It looks great and all that, however, when trying to interact with the scene, rotation, panning, and stuff, everything is lagging and it is near impossible to work with.
This is the code I have right now, where I have simply included some dummy coordinates and connectivity for allowing the code to run
import vtk surfaces = [[[0, 0, 0], [2, 0, 0], [1, 2, 0]], [[2, 0, 0], [3, 0, 0], [3, 2, 0], [1, 2, 0]]] append_data = vtk.vtkAppendPolyData() for vertices in surfaces: # Draw one surface at the time. points = vtk.vtkPoints() cell = vtk.vtkCellArray() surface = vtk.vtkPolygon() surface.GetPointIds().SetNumberOfIds(len(vertices)) for index, vertex in enumerate(vertices): points.InsertNextPoint(vertex) surface.GetPointIds().SetId(index, index) cell.InsertNextCell(surface) polydata = vtk.vtkPolyData() polydata.SetPoints(points) polydata.SetPolys(cell) polydata.Modified() append_data.AddInputData(polydata) # Update and clean the polydata. append_data.Update() clean_filter = vtk.vtkCleanPolyData() clean_filter.SetInputConnection(append_data.GetOutputPort()) clean_filter.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(clean_filter.GetOutputPort()) actor = vtk.vtkActor() actor.SetMapper(mapper) renderer = vtk.vtkRenderer() render_window = vtk.vtkRenderWindow() render_window.AddRenderer(renderer) interactor = vtk.vtkRenderWindowInteractor() interactor.SetRenderWindow(render_window) renderer.AddActor(actor) render_window.Render() interactor.Start()`:
This is good and all, but as I said, come hundreds of thousands of elements, this is not efficient anymore.
I was thinking about forming this as an UnstructedGrid, and working on it right now (It requires some input changes). However, I don’t know if that will help me, performance-wise.
I’m no shark at Vtk just yet, so I am wondering if any of you could have any ideas of how I could speed things up?