Rendering truss structures using Tubes, with variable thickness

I want to render a structure of trusses using the Tubes filter. Importantly, each truss has a different (scalar) thickness. My problem is that I cannot select a scalar property for the “Vary Radius” option. (The scalar dropdown menu in Tube properties is empty).

Here’s some sample code that I wrote in Julia, for a structure composed of 2 trusses, with two unique thicknesses

# [x,y] coordinates of nodes
nodes = [
    [0.0  0.0], # node 1
    [1.0  0.0], # node 2
    [0.5  1.0], # node 3
]

# [nodes] to make up elements
elements = [
    [1 2], # element 1
    [2 3], # element 2
]

# toy displacement vector
u = [0.0, 0.0, -0.5, -1.0, 0.0, 0.0]

# thickness of each element
t = [0.1, 0.2]

# 3D coordinates of the nodes
points3D = zeros(3, 3)
for (i,n) in enumerate(nodes)
    points3D[i,1:2] = n
end

# elements make up grouped coordinates
cells = [MeshCell(PolyData.Lines()  , r) for r in eachrow(vcat(elements...))]

# add displacement as a vector to the dofs of each node
uvec = zeros(3,3)
for i in range(1,3)
    uvec[i,1] = u[i*2-1]
    uvec[i,2] = u[i*2]
end

# add displacement vector 
vtk_grid("paraview/testfile", transpose(points3D), cells) do vtk
    vtk["displacement"] = transpose(uvec)
    vtk["thickness"] = t
end

After loading the file in the ParaView UI (and applying Tube filter), the “Scalars” option is empty, as can be seen below.

One thing I tried is to use cells = [MeshCell(VTKCellTypes.VTK_LINE , r) for r in eachrow(vcat(elements...))] , so an “unstructured grid” instead of “poly data” (this requires the Extract Surface filter to be applied before the Tube filter. However, this still does not fix the issue.

Looking forward to hearing your insights and suggestions.

Welcome to the ParaView community, @hendrik!

The problem is that the tube filter cannot use cell-associated data, like your “thickness” array, to adjust the size, counterintuitive though that may be. It can use point-associated data, and it interpolates along the length of the line segment. A couple things you could do:

  • Apply the Cell Data to Point Data filter to interpolate the cell-associated data onto point-associated data arrays. If you do that, the interpolated “thickness” array will be available where you expect it.
  • Duplicate the line segment end points and assign point-associated thickness values to each endpoint that is the tube thickness. You won’t have nice contiguous tubes, however, with this approach.
1 Like

Hi Cory,

Thanks for your reply. I solved the problem by defining using the Cell Data to Point Data filter suggestion.

Here I found that it is important to ensure that the trusses have unique end points—otherwise their thickness values will be merged at the end points (and a linear interpolation between the points for the radius will be used).

To prevent overlapping of points, one should duplicate the points at which trusses meet (so that each truss is solely composed of unique points). This resulted in trusses with constant radii for me, which is what I was looking for.

Thanks again for your helpful suggestion.

1 Like