# Possible bug with the Slice filter: duplicating node points

**URL:** https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366
**Category:** ParaView Support
**Created:** [July 27, 2018, 2:44am UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366 "2018-07-27T02:44:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![shuhao](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shuhao/32/195_2.png) [@shuhao](https://discourse.paraview.org/u/shuhao)
#### Post date: [July 27, 2018, 2:44am UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366/1 "2018-07-27T02:44:18Z")

</div>

I have an issue with the slice filter in my specific mesh. The mesh in question is 2D and I want to take a slice of it, effectively getting an 1D line back. I’m setting the origin of the slice to snap to a mesh node point. When I do this on this mesh, the resulting 1D line has a duplicate point per each node in the 2D mesh. If I plotted the PointID against the Y coordinate of this 1D slice, I get:

 ![test-surface-slice](https://discourse.paraview.org/uploads/default/original/1X/f19db7c1d994f52ea5dd8f642f336a47f2503986.png)

I also tried to extract selection to extract the same node points (via a query like `coord-epsilon < z < coord + epsilon`), using that I can see that the points are not duplicated. Plotting the same as above gives me:

 ![test-surface-extract-selection](https://discourse.paraview.org/uploads/default/original/1X/10fdc5a2107c8bfe03af8cd7e80a929f7328b4da.png)

For the record, the mesh looks like the below. The blue dots are the ones I’m trying to extract:

 ![test-surface](https://discourse.paraview.org/uploads/default/original/1X/38fbec37153cd424c53dc2387ea14c52ae127373.png)

All of this is reproduced from the two files below:

[test-surface.vtp](https://discourse.paraview.org/uploads/default/original/1X/5577587390442cd7814f81ff36aaddf14ef8162e.vtp) (450.4 KB)  
[test-surface.pvsm](https://discourse.paraview.org/uploads/default/original/1X/90c588c264e226bc0ccfb913b3e8f2aa6b2af494.pvsm) (645.1 KB)

Is this a bug? I can’t seem to reproduce this if I created a mesh from the builtin paraview sources like UnstructuredCellTypes. What’s going on here?

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 31, 2018, 2:11pm UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366/2 "2018-07-31T14:11:14Z")

</div>

`Slice` filter may add new points. Running a filter like `Clean` with non-zero tolerance can cleanup the duplicate points.

Alternatively, you can do the following:

1. Apply Calculator with expression “coordsY” to generate a “result” array with the y coordinate
2. Apply Threshold to threshold the points in the range of interest for the value of the “result” array.

---

<div class="post-metadata">

### Author: ![shuhao](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shuhao/32/195_2.png) [@shuhao](https://discourse.paraview.org/u/shuhao)
#### Post date: [July 31, 2018, 6:30pm UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366/3 "2018-07-31T18:30:14Z")

</div>

I tried Clean (vtkCleanPolyData), which doesn’t quite work. It seems  
like the slice filter created essentially duplicate points, but at a  
slightly different coordinate than the points (difference is beyond the  
7th significant digit).

I tried a Clean to Grid as well (vtkCleanUnstructuredGrid), which  
produced the results that I wanted. However, there are not a lot of  
documentations for this filter and also no tunable parameters at all. So  
how does it work? How is it able to remove the slightly different, but  
nevertheless duplicate points while vtkCleanPolyData was not able to?

Shuhao

---

<div class="post-metadata">

### Author: ![shuhao](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shuhao/32/195_2.png) [@shuhao](https://discourse.paraview.org/u/shuhao)
#### Post date: [August 1, 2018, 2:36am UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366/4 "2018-08-01T02:36:59Z")

</div>

Actually I probably spoke a little too soon, I noticed there are still  
some duplicate points even with vtkCleanUnstructuredGrid so I’m assuming  
there’s still some sort of tolerance scheme at work.

Shuhao

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [August 6, 2018, 1:44pm UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366/5 "2018-08-06T13:44:50Z")

</div>

> [@shuhao](#):
>
> I tried Clean (vtkCleanPolyData), which doesn’t quite work.

Here’s a state file with `Clean` inserted in your state file. As far as I can tell, the duplicate points are indeed removed. I needed to set a non-zero tolerance (I used 0.000001). [fixed.pvsm](https://discourse.paraview.org/uploads/default/original/1X/fb0bb7354123c9592db4924dfb05534c63eb0e06.pvsm) (652.1 KB)

`vtkCleanUnstructuredGrid` and `vtkCleanPolyData` use slightly difference approaches. The former is intended to produce unstructure grids no matter the input, while the latter takes in PolyData to produce the same. Furthermore, CleanPolyData exposes options to provide finer control over point merging along with ability to cleanup degenerate cells resulting from point merging. See [VTK docs](https://www.vtk.org/doc/nightly/html/classvtkCleanPolyData.html) for more detail.

You are indeed correct that the difference between the two is erudite at best. Ultimately, we do want ParaView to automatically pick the best suited filter implementation for the task at hand – which in this case is simply merge duplicate points.

---

<div class="post-metadata">

### Author: ![shuhao](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shuhao/32/195_2.png) [@shuhao](https://discourse.paraview.org/u/shuhao)
#### Post date: [August 7, 2018, 1:41am UTC](https://discourse.paraview.org/t/possible-bug-with-the-slice-filter-duplicating-node-points/366/6 "2018-08-07T01:41:39Z")

</div>

Thanks for clarifying the distinctions between cleanStructuredGrid and cleanPolyData. I wasn’t quite sure what to make of them.

I wanted to avoid choosing thresholds as they can be somewhat arbitrary and difficult to detect if incorrectly set (say for some reason if 1e-6 was too big for one or two points, it would be difficult to detect those automatically). For future reference, I ended up manually writing code to pick out the node points as my grid is essentially rectangular.
