# Surface meshes extraction from reference and a deformed version of a volumetric mesh

**URL:** https://discourse.paraview.org/t/surface-meshes-extraction-from-reference-and-a-deformed-version-of-a-volumetric-mesh/12592
**Category:** ParaView Support
**Created:** [July 27, 2023, 3:21pm UTC](https://discourse.paraview.org/t/surface-meshes-extraction-from-reference-and-a-deformed-version-of-a-volumetric-mesh/12592 "2023-07-27T15:21:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chathu](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/b19c9b/32.png) [@chathu](https://discourse.paraview.org/u/chathu)
#### Post date: [July 27, 2023, 3:21pm UTC](https://discourse.paraview.org/t/surface-meshes-extraction-from-reference-and-a-deformed-version-of-a-volumetric-mesh/12592/1 "2023-07-27T15:21:04Z")

</div>

Hi,

I first extract the surface mesh from a reference volumetric mesh (.vtk format) using extract surface filter in Paraview and save to disk (as .stl file).

I then deform this volumetric mesh by applying simple translation using another tool and then attempt to extract the sufrace mesh using the same filter (i.e. using extract surface filter) and save as a .stl file.

However, I encounter different face ids when I checked them with trimesh package.

I just want to extract the surface meshes from the reference and the deformed version and save them for other postprocessing steps.

Am I missed anything or any steps here ? If so can you elaborate the steps with an example please ?

I herewith attached a sample reference mesh and its deformed version for your further reference.

I also make an effort by writing Python shell code. But it also did not function well.

```auto
import os

volumetric_mesh_path = 'F:/deformed_1.vtk'
save_path = 'F:/deformed_1.stl'

meshReader = OpenDataFile(volumetric_mesh_path)
extracted_surface = ExtractSurface(Input=meshReader)

writer = CreateWriter(save_path)
writer.UpdatePipeline()

```

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [July 28, 2023, 4:11am UTC](https://discourse.paraview.org/t/surface-meshes-extraction-from-reference-and-a-deformed-version-of-a-volumetric-mesh/12592/2 "2023-07-28T04:11:02Z")

</div>

The `Extract Surface` filter is multithreaded, so there may be a difference in face ids. You may want to set the number of threads to 1 by `vtkSMPTools::Initialize` function as shown below.

```python
import os
from paraview.simple import *
import vtk

volumetric_mesh_path = 'F:/deformed_1.vtk'
save_path = 'F:/deformed_1.stl'

# Set the number of threads to 1
vtk.vtkSMPTools.Initialize(1);

meshReader = OpenDataFile(volumetric_mesh_path)
extracted_surface = ExtractSurface(Input=meshReader)

writer = CreateWriter(save_path)
writer.UpdatePipeline()

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 6, 2023, 9:34am UTC](https://discourse.paraview.org/t/surface-meshes-extraction-from-reference-and-a-deformed-version-of-a-volumetric-mesh/12592/3 "2023-11-06T09:34:40Z")

</div>

data removed as requested by @chathu
