# Draw Cylinder & Curved Shapes in VTKUnStructuredGrid

**URL:** https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541
**Category:** ParaView Support
**Tags:** opengl, exodus, releases, vtk, python
**Created:** [July 19, 2023, 5:21am UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541 "2023-07-19T05:21:05Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![anshakeel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anshakeel/32/10709_2.png) [@anshakeel](https://discourse.paraview.org/u/anshakeel)
#### Post date: [July 19, 2023, 5:21am UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/1 "2023-07-19T05:21:05Z")

</div>

**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:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/8/8c4d4e9c4a91400976c8e9da5a932d5972d49532.png)

> Note  
> 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_  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/0/0d5ba54b11dd7f8b0b7be60a47a170119e69fb7d.png)

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

Regards,  
Ans

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [July 19, 2023, 3:25pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/2 "2023-07-19T15:25:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![anshakeel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anshakeel/32/10709_2.png) [@anshakeel](https://discourse.paraview.org/u/anshakeel)
#### Post date: [July 19, 2023, 6:20pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/3 "2023-07-19T18:20:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [July 19, 2023, 6:50pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/4 "2023-07-19T18:50:54Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![anshakeel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anshakeel/32/10709_2.png) [@anshakeel](https://discourse.paraview.org/u/anshakeel)
#### Post date: [July 19, 2023, 7:01pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/5 "2023-07-19T19:01:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [July 19, 2023, 7:34pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/6 "2023-07-19T19:34:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![anshakeel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anshakeel/32/10709_2.png) [@anshakeel](https://discourse.paraview.org/u/anshakeel)
#### Post date: [July 19, 2023, 8:06pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/7 "2023-07-19T20:06:53Z")

</div>

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.

> [@anshakeel](#):
>
> ![image](https://discourse.paraview.org/uploads/default/original/2X/8/8c4d4e9c4a91400976c8e9da5a932d5972d49532.png)

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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/d/df85a3d146bf18202647121fc3b16b3a64a31ce9.png)

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

Regards,  
Ans

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [July 19, 2023, 8:35pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/8 "2023-07-19T20:35:14Z")

</div>

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

 ![Screen Shot 2023-07-19 at 2.34.55 PM](https://discourse.paraview.org/uploads/default/original/2X/6/6b91320aa84fed919715c434b7b3806e85552d9e.jpeg)

---

<div class="post-metadata">

### Author: ![anshakeel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anshakeel/32/10709_2.png) [@anshakeel](https://discourse.paraview.org/u/anshakeel)
#### Post date: [July 19, 2023, 9:04pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/9 "2023-07-19T21:04:06Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [July 19, 2023, 9:24pm UTC](https://discourse.paraview.org/t/draw-cylinder-curved-shapes-in-vtkunstructuredgrid/12541/10 "2023-07-19T21:24:15Z")

</div>

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