vtkSTLReader crashes when merging is off
For context, I quote the VTK documentation of vtkSTLReader:
.stl files are quite inefficient since they duplicate vertex definitions. By setting the Merging boolean you can control whether the point data is merged after reading. Merging is performed by default, however, merging requires a large amount of temporary storage since a 3D hash table must be constructed.
However, when switching off merging, vtkSTLReader crashes when it is updated. This bug is at least present in VTK 9 and affects all STL files, no matter how simple they are.
Read access violation is thrown in vtkAbstractArray here:
inline vtkIdType GetNumberOfValues() const { return (this->MaxId + 1); }
Call stack:
vtkCommonDataModel-9.0d.dll!vtkCellArray::GetNumberOfCells() Line 317 C++
vtkCommonDataModel-9.0d.dll!vtkPolyData::GetNumberOfPolys() Line 206 C++
vtkFiltersCore-9.0d.dll!vtkPolyDataNormals::RequestData(vtkInformation * __formal, vtkInformationVector * * inputVector, vtkInformationVector * outputVector) Line 100 C++
vtkCommonExecutionModel-9.0d.dll!vtkPolyDataAlgorithm::ProcessRequest(vtkInformation * request, vtkInformationVector * * inputVector, vtkInformationVector * outputVector) Line 87 C++
vtkCommonExecutionModel-9.0d.dll!vtkExecutive::CallAlgorithm(vtkInformation * request, int direction, vtkInformationVector * * inInfo, vtkInformationVector * outInfo) Line 746 C++
vtkCommonExecutionModel-9.0d.dll!vtkDemandDrivenPipeline::ExecuteData(vtkInformation * request, vtkInformationVector * * inInfo, vtkInformationVector * outInfo) Line 462 C++
vtkCommonExecutionModel-9.0d.dll!vtkCompositeDataPipeline::ExecuteData(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 161 C++
vtkCommonExecutionModel-9.0d.dll!vtkDemandDrivenPipeline::ProcessRequest(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 261 C++
vtkCommonExecutionModel-9.0d.dll!vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 343 C++
vtkCommonExecutionModel-9.0d.dll!vtkCompositeDataPipeline::ForwardUpstream(vtkInformation * request) Line 726 C++
vtkCommonExecutionModel-9.0d.dll!vtkDemandDrivenPipeline::ProcessRequest(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 247 C++
vtkCommonExecutionModel-9.0d.dll!vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation * request, vtkInformationVector * * inInfoVec, vtkInformationVector * outInfoVec) Line 343 C++
vtkCommonExecutionModel-9.0d.dll!vtkDemandDrivenPipeline::UpdateData(int outputPort) Line 421 C++
vtkCommonExecutionModel-9.0d.dll!vtkStreamingDemandDrivenPipeline::Update(int port, vtkInformationVector * requests) Line 417 C++
vtkCommonExecutionModel-9.0d.dll!vtkStreamingDemandDrivenPipeline::Update(int port) Line 381 C++
vtkCommonExecutionModel-9.0d.dll!vtkAlgorithm::Update(int port) Line 1422 C++
vtkCommonExecutionModel-9.0d.dll!vtkAlgorithm::Update() Line 1416 C++