# The web version of STLReader getNumberOfPoints results are different from the python version

**URL:** https://discourse.vtk.org/t/the-web-version-of-stlreader-getnumberofpoints-results-are-different-from-the-python-version/11415
**Category:** Web
**Created:** [May 9, 2023, 12:20pm UTC](https://discourse.vtk.org/t/the-web-version-of-stlreader-getnumberofpoints-results-are-different-from-the-python-version/11415 "2023-05-09T12:20:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![qq769747518](https://discourse.vtk.org/user_avatar/discourse.vtk.org/qq769747518/32/4509_2.png) [@qq769747518](https://discourse.vtk.org/u/qq769747518)
#### Post date: [May 9, 2023, 12:20pm UTC](https://discourse.vtk.org/t/the-web-version-of-stlreader-getnumberofpoints-results-are-different-from-the-python-version/11415/1 "2023-05-09T12:20:02Z")

</div>

The same stl file.  
in the web, I got the following result

```auto
  const STLReader = vtkSTLReader.newInstance();
  await STLReader.setUrl("/stl/a_Cup.stl");
  const pointNum = STLReader.getOutputData().getNumberOfPoints();
  const CellsNum = STLReader.getOutputData().getNumberOfCells();
  console.log(pointNum); // 34848
  console.log(CellsNum); // 11616

```

in the python, I got the following result

```auto
    reader = vtkSTLReader()
    reader.SetFileName("a_Cup.stl")
    reader.Update()
    polyData = reader.GetOutput()
    print(polyData.GetNumberOfPoints()) #5802
    print(polyData.GetNumberOfCells()) #11616

```

As you can see, the Cells numbers are the same, but the Points numbers are different，Did the web version of STLReader do something special with stl files.  
I wanted to use some C++ libraries for vtkPolydata on the web via WebAssembly, but the PointsData I got in web was different from the C++ PointsData

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [May 9, 2023, 12:42pm UTC](https://discourse.vtk.org/t/the-web-version-of-stlreader-getnumberofpoints-results-are-different-from-the-python-version/11415/2 "2023-05-09T12:42:20Z")

</div>

The C++/Python implementation of the STL reader merge duplicated points by default. This is not the case in Javascript.

We would need to bring to VTK.js the “cleanPolyData” filter that can merge points afterwards.

Hth,  
Julien.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [May 9, 2023, 6:24pm UTC](https://discourse.vtk.org/t/the-web-version-of-stlreader-getnumberofpoints-results-are-different-from-the-python-version/11415/3 "2023-05-09T18:24:49Z")

</div>

@Sebastien_Jourdain, @will.schroeder I feel this is precisely where drop-in VTK-wasm components could improve feature parity on the web. `PolyData` inputs from vtk.js can be mapped to a wasm `vtkPolyData` object without memory transfers - because of similar data model concepts. The public-facing typescript definition of `cleanPolyData` can mirror existing filters. The underlying `js` code will forward function calls to `vtkCleanPolyData` filter.

---

<div class="post-metadata">

### Author: ![daker](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daker](https://discourse.vtk.org/u/daker)
#### Post date: [October 21, 2025, 2:23pm UTC](https://discourse.vtk.org/t/the-web-version-of-stlreader-getnumberofpoints-results-are-different-from-the-python-version/11415/4 "2025-10-21T14:23:01Z")

</div>

You can now use [vtkCleanPolyData](https://kitware.github.io/vtk-js/examples/CleanPolyData.html) in vtk.js
