Draw Cylinder & Curved Shapes in VTKUnStructuredGrid

Q1: I’m trying to generate VTK data. I have some Data that have cylindrical shapes like pipes and bends. I would like to convert them to VTK format. To achieve this, I am using VtkUnstructuredGrid.I searched thoroughly online for information on using CylinderSource in VtkUnstructuredGrid, but I could not find any helpful resources. I utilized VTK_POLYHEDRON to transform the problem into a cylindrical shape, but the results were not up to par with my expectations. The shape requires further enhancement to attain a more accurate cylindrical appearance. How to do it?

Please check the attached Image below:

For this, I only had 2 Points as Starting and Ending. I generated 12 Points in a Circular manner with a specified radius for both starting and ending points and Joined them, forming a 14-faced PolyHedron shape.

Q2: How to Draw Bend / Curved Edge/ Curve Cylinder in VtkUnstructuredGrid?

Q3: Why does it display a 2D flat shape instead of the Polyhedron shape above when I maintain the same Z-axis for both the starting and ending points? Let me know if I missed any important principles or if you have any recommendations on how to handle this

Kindly provide me with your suggestions or information regarding this matter.


Do you need 3D cell, or surface cells could be enough?

Hi Sebastien,
Thank you for your quick response. I am primarily interested in 3D cells, but I would also like to understand the case with Surface cells.

My question was more regarding if it was just for rendering or do you have data within those cells that needs to be cut. Based on which cell type you pick that will affect how the point data would be interpolate along the volume (3d cells) or surface (2d cells).

No, it is not just rendering. We have data within those cells like displacement, Forces etc.

Then I will go with PolyData (or keep using unstructured grid) but just define triangles/triangle-strip. Very much how the cylinder source is doing. Maybe you can either use the tube filter or create your own if that make sense.

Perfect. Thanks for the suggestion. Actually, I am looking for solutions to two problems. I’ll list them one by one.

  1. How to smooth the surface of the following shape like VTKCylinderSource? I used VtkUnStructuredGrid and VTK_POLYHEDRON cell type with 12 Points & 8 Faces.

One possible solution is that Increase the Number of points & Faces, but still, the shape does not attain a more accurate cylindrical appearance( Smooth Surface). Attached is the image below with 100 Points & 52 faces.

  1. Using any cell type, How to create Curved Shapes / Bends/ Torus in VtkUnStructuredGrid? Can you provide an example related to this?


To smooth things up a little bit, you can add normals which will make them appear smoother.

1 Like

Perfect, Thank you for your response. How to smooth surface using VTK in Python or C++? Could you provide any examples for reference? Do we have to calculate Normals manually or VTK provides any utility to directly calculate Normals and smoothen the surface?

There is a filter for that https://vtk.org/doc/nightly/html/classvtkPolyDataNormals.html