# Visualizing Unstructured Grids

**URL:** https://discourse.vtk.org/t/visualizing-unstructured-grids/9203
**Category:** Support
**Created:** [August 24, 2022, 12:34am UTC](https://discourse.vtk.org/t/visualizing-unstructured-grids/9203 "2022-08-24T00:34:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [August 24, 2022, 12:34am UTC](https://discourse.vtk.org/t/visualizing-unstructured-grids/9203/1 "2022-08-24T00:34:31Z")

</div>

I just started working with the vtkUnstructuredGrid class and have built a simple sphere using VTK\_HEXAHEDRON elements.

When the sphere is rendered, only the exterior surfaces are displayed. This is evident when I press the _w_ key to view the wire frame.

I’m not sure what to expect with this class. I’ve looked at the class description as well as the Vtk user’s guide and text book and the online unstructured grid examples for answers.

Is there at least a way to render the entire wire frame for the unstructured grid and not just for the exterior surface of the object?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [August 24, 2022, 10:51am UTC](https://discourse.vtk.org/t/visualizing-unstructured-grids/9203/2 "2022-08-24T10:51:54Z")

</div>

I suspect that you are using a vtkDataSetMapper to render the ugrid - this internally uses vtkDataSetSurfaceFilter to extract the surface/boundary faces and produces the result you see.

If you want to see a gigantic pile of wireframe spaghetti 🙂 you’ll need to extract edges. Try vtkExtractEdges.

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [December 19, 2022, 8:59pm UTC](https://discourse.vtk.org/t/visualizing-unstructured-grids/9203/3 "2022-12-19T20:59:41Z")

</div>

Sorry for taking so long in getting back to this.

I’m stumped on how to implement this. The online examples for vtkExtractEdges use a vtkUnstructuredGridReader to feed the edge object. For example:

```auto
vtkNew<vtkUnstructuredGridReader> reader;
  reader->SetFileName(filename.c_str());
  reader->Update();
vtkNew<vtkExtractEdges> extractEdges;
  extractEdges->SetInputConnection(reader->GetOutputPort());

```

I’m not using the vtkUnstructuredGridReader. I have vtkUnstructuredGrid objects that I create in other ways. I’ve looked at the vtkUnstructuredGrid class documentation, but I can’t see how to extract directly from that class to the vtkExtractEdges class object.

Any ideas?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [December 19, 2022, 9:26pm UTC](https://discourse.vtk.org/t/visualizing-unstructured-grids/9203/4 "2022-12-19T21:26:59Z")

</div>

If you have the vtkUnstructuredGrid instance myUGrid, use SetInputData(), something like the following. You use ports / connections when linking filters in a pipeline.

```auto
vtkNew<vtkExtractEdges> extractEdges;
  extractEdges->SetInputData(myUGrid);

```

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [December 21, 2022, 7:21pm UTC](https://discourse.vtk.org/t/visualizing-unstructured-grids/9203/5 "2022-12-21T19:21:13Z")

</div>

I was able to get this to work as you described.  
Thanks.  
BK
