Reputation: 69
I want to create line segments in Paraview. The format of my input data for each line segment is as: x0,y0,z0,x1,y1,z1,width I have tried using "Line" command and using https://stackoverflow.com/a/64140580/14367898 @Nico Vuaille's https://stackoverflow.com/users/10219194/nico-vuaille answer I managed to do it. However, since the the number of my line segments gets really high, I need a method that runs faster. I searched and found this method https://discourse.paraview.org/t/rendering-a-few-lines-takes-an-unreasonable-amount-of-memory/667/2:
import vtk
from random import uniform
points = vtk.vtkPoints()
lines = vtk.vtkCellArray()
for i in xrange(600):
pt1 = points.InsertNextPoint(uniform(0, 100), uniform(0, 100), 0)
pt2 = points.InsertNextPoint(uniform(0, 100), uniform(0, 100), 0)
lines.InsertNextCell(2, [pt1, pt2])
output.SetPoints(points)
output.SetLines(lines)
It's runs perfectly fast but the line segments doesn't have width. I want to know how can I use the above (or any other appropriate) method, for drawing lines with specific width for each segment. Your help will be much appreciated, Regards, Hamid Rajabi.
Upvotes: 0
Views: 880
Reputation: 2488
you can add the width as a data array:
import vtk
from random import uniform
points = vtk.vtkPoints()
lines = vtk.vtkCellArray()
widths = vtk.vtkDoubleArray()
widths.SetName("width")
for i in range(60):
pt1 = points.InsertNextPoint(uniform(0, 100), uniform(0, 100), 0)
pt2 = points.InsertNextPoint(uniform(0, 100), uniform(0, 100), 0)
w = uniform(0,3)
widths.InsertNextValue(w)
widths.InsertNextValue(w)
lines.InsertNextCell(2, [pt1, pt2])
output.SetPoints(points)
output.GetPointData().AddArray(widths)
output.SetLines(lines)
Then add a Tube
filter, choose Vary Radius / By Absolute Scalar
(and maybe change the factor)
Upvotes: 1