# Generated points are not reduced when sampling spacing increases

**URL:** https://discourse.vtk.org/t/generated-points-are-not-reduced-when-sampling-spacing-increases/10344
**Category:** Development
**Created:** [December 30, 2022, 4:39pm UTC](https://discourse.vtk.org/t/generated-points-are-not-reduced-when-sampling-spacing-increases/10344 "2022-12-30T16:39:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lizemin2016](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lizemin2016/32/5266_2.png) [@lizemin2016](https://discourse.vtk.org/u/lizemin2016)
#### Post date: [December 30, 2022, 4:39pm UTC](https://discourse.vtk.org/t/generated-points-are-not-reduced-when-sampling-spacing-increases/10344/1 "2022-12-30T16:39:26Z")

</div>

[2D Interior Area.vtp](https://discourse.vtk.org/uploads/short-url/lHBWvJhNXZhKHvVOhUDb7ezBBid.vtp) (83.3 KB)  
I want to generate points from the above vtp file, I don’t know how to choose the suitable distance parameter, when I increase the distance it works at the beginning, but the points generated are not reduce when reach the 11166 number, as the picture below shows. this number is too big for me.

 ![sampler](https://discourse.vtk.org/uploads/default/original/2X/f/feef577d4644dfef70b57a455a547dc4b57cad62.png)  
here is my code:

```auto
void sampleFromPolylineTest()
{
	
	vtkNew<vtkXMLPolyDataReader> reader;
	reader->SetFileName("2D Interior Area.vtp");
	reader->Update();

	double bounds[6];
	reader->GetOutput()->GetBounds(bounds);
	double range[3];
	for (int i = 0; i < 3; ++i)
	{
		range[i] = bounds[2 * i + 1] - bounds[2 * i];
	}
	std::cout << "Range: " << range[0] << ", " << range[1] << ", " << range[2]
		<< std::endl;
	std::cout << "# of original points: " << reader->GetOutput()->GetNumberOfPoints()
		<< std::endl;
	vtkNew<vtkPolyDataPointSampler> sample;
	sample->SetInputData(reader->GetOutput());
	double distance = 150.0;
	sample->SetDistance(distance);
	sample->GenerateEdgePointsOff();
	sample->GenerateVertexPointsOff();
	/*sample->GenerateVerticesOff();
	sample->GenerateInteriorPointsOff();*/
	sample->SetPointGenerationModeToRandom();
	sample->Update();
	std::cout << "# of points after sampling: " << distance << ";"
		<< sample->GetOutput()->GetNumberOfPoints() << std::endl;

	vtkNew<vtkXMLPolyDataWriter> writer;
	writer->SetFileName("sample.vtp");
	writer->SetDataModeToBinary();
	writer->SetCompressionLevel(9);
	writer->SetInputData(sample->GetOutput());
	writer->Write();
}

```

Very grateful for your help！

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 31, 2022, 2:41pm UTC](https://discourse.vtk.org/t/generated-points-are-not-reduced-when-sampling-spacing-increases/10344/2 "2022-12-31T14:41:27Z")

</div>

Point sampling filter is for generating additional points. I don’t think it can reduce the number of points - see [documentation](https://vtk.org/doc/nightly/html/classvtkPolyDataPointSampler.html#details).

Poisson dusk sampler can also add random samples (see [Selecting random points of a PolyData (Stratified sampling)](https://discourse.vtk.org/t/selecting-random-points-of-a-polydata-stratified-sampling/7003)) but I don’t think it can reduce the number of points (simplify the mesh) either.

There are decimation filters in VTK that you can use to reduce the number of points, but the result is not uniform, but it will strive to preserve all details with less points, so sampling will be sparse in flat regions.

Unfortunately, VTK currently does not have a filter for uniform resampling, but you can use the ACVD algorithm for that, for example using the pyacvd package.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 31, 2022, 3:05pm UTC](https://discourse.vtk.org/t/generated-points-are-not-reduced-when-sampling-spacing-increases/10344/3 "2022-12-31T15:05:56Z")

</div>

I have posted a feature request here for making ACVD available in VTK - hopefully eventually it will be added at some point.

> [@Feature request: add ACVD uniform remeshing filter](https://discourse.vtk.org/t/feature-request-add-acvd-uniform-remeshing-filter/10346):
>
> A robust, high-quality uniform remeshing filter is an essential tool in any mesh modelling library. I know that VTK was originally not meant for modelling and probably there was no known open-source algorithm for uniform remeshing. But VTK has some excellent modelling tools now, VTK is widely used for modelling, and the open-source ACVD algorithm has proven to work very well for generating high quality uniform meshes. Therefore, it would be time to add [ACVD remeshing](https://github.com/valette/ACVD) to VTK. It has a BSD-type …
