I adjusted the PolyDataPointSampler to use the PoissonDiskSampler (lines 45-48):
vtkNew<vtkPoissonDiskSampler> sample;
sample->SetInputData(polyData);
sample->SetRadius(1);
sample->Update();
std::cout << "# of points after sampling: "
<< sample->GetOutput()->GetNumberOfPoints() << std::endl;
While this example works fine with the default sphere, it doesn’t when I provide an STL[1]. I get a segmentation fault and wonder what I’m doing wrong:
(gdb) run ../Cube\ with\ Cube-Body.stl
Starting program: [...]/build/PolyDataPointSampler ../Cube\ with\ Cube-Body.stl
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Range: 20, 20, 20
# of original points: 16
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f24921 in vtkPoissonDiskSampler::RequestData(vtkInformation*, vtkInformationVector**, vtkInformatio
(gdb) bt
(gdb) bt
#0 0x00007ffff7f24921 in vtkPoissonDiskSampler::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) ()
from /usr/local/lib/libvtkFiltersPoints-9.1.so.1
#1 0x00007ffff65c98e0 in vtkExecutive::CallAlgorithm(vtkInformation*, int, vtkInformationVector**, vtkInformationVector*) ()
from /usr/local/lib/libvtkCommonExecutionModel-9.1.so.1
#2 0x00007ffff65c3ac9 in vtkDemandDrivenPipeline::ExecuteData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) ()
from /usr/local/lib/libvtkCommonExecutionModel-9.1.so.1
#3 0x00007ffff65c0701 in vtkCompositeDataPipeline::ExecuteData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) ()
from /usr/local/lib/libvtkCommonExecutionModel-9.1.so.1
#4 0x00007ffff65c678f in vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) ()
from /usr/local/lib/libvtkCommonExecutionModel-9.1.so.1
#5 0x00007ffff6608b81 in vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/local/lib/libvtkCommonExecutionModel-9.1.so.1
#6 0x00007ffff6609f17 in vtkStreamingDemandDrivenPipeline::Update(int, vtkInformationVector*) ()
from /usr/local/lib/libvtkCommonExecutionModel-9.1.so.1
#7 0x0000555555559824 in main ()
[1] mentioned STL