# VTK file visualization and surface/volume mesh extraction

**URL:** https://discourse.slicer.org/t/vtk-file-visualization-and-surface-volume-mesh-extraction/20573
**Category:** Support
**Tags:** vtk, stl
**Created:** [November 10, 2021, 9:37pm UTC](https://discourse.slicer.org/t/vtk-file-visualization-and-surface-volume-mesh-extraction/20573 "2021-11-10T21:37:40Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [November 11, 2021, 2:47am UTC](https://discourse.slicer.org/t/vtk-file-visualization-and-surface-volume-mesh-extraction/20573/2 "2021-11-11T02:47:22Z")

</div>

> [@EMIL\_fluidM](#):
>
> issues i am having is loading the file in slicer shows strands of surface instead of a clean/connected surface

Most likely your mesh contains incorrectly oriented triangles. Older Slicer versions by default did not show backface of triangles. You can enable display of both sides in Models module / Display / 3D Display / Visible Sides → All. Current Slicer versions show both sides by default and contain many other fixes, so most likely they will show the full mesh by default.

> [@EMIL\_fluidM](#):
>
> Can we create a mesh file (obj/stl) from vtk file in slicer. I tried using the save module but the only option available to me are vtk and vtu. I visualized the vtk file through the “models” module

A .vtk file can contain an image, surface mesh, or volumetric mesh. If Slicer only offers to save a model in .vtk and .vtu (unstructured grid) format then it means that the model contains a volumetric mesh, which cannot be saved as a surface mesh (.stl, .obj, .ply, … formats).

You can convert your volumetric mesh to a surface mesh by copy-pasting this code snippet into the Python console (replace `Model` by the name of your model node):

> [@Mesh multiple objects](https://discourse.slicer.org/t/mesh-multiple-objects/10384/4):
>
> You can copy-paste this code to the Python console to extract the surface and put it into a new mode node. volMesh=getNode('Model').GetMesh() extractSurface=vtk.vtkGeometryFilter() extractSurface.SetInputData(volMesh) extractSurface.Update() slicer.modules.models.logic().AddModel(extractSurface.GetOutput()) You can extract a specific material by adding vtkThreshold filter before vtkGeometryFilter.

---

_[View the full topic](https://discourse.slicer.org/t/vtk-file-visualization-and-surface-volume-mesh-extraction/20573)._
