OS: Windows 11
VTK Version: 9.6
Compiler: Visual Studio Professional 2026 (v18.7.1)
Hi everyone,
Since updating Visual Studio to the latest version, my C++ project using VTK 9.6 has stopped compiling. I am encountering the following build error:
Common\DataModel\vtkUnstructuredGrid.h(134,8): error C4996: ‘vtkDataSet::GetCellTypes’: Use GetDistinctCellTypes(vtkCellTypes* types) instead.
searched my entire project but could not find any explicit calls to GetCellTypes in my code, so I suspect this warning/error is originating internally from another VTK file.
The only part of my codebase that utilizes vtkUnstructuredGrid is the following snippet, which makes me think the issue might be triggered when interacting with vtkGeometryFilter:
`auto plusSource = vtkSmartPointer<vtkGlyphSource2D>::New();
plusSource->SetGlyphTypeToCross();
m_glyphSources.insert({ GlyphTypes::Plus, plusSource });
std::vector<std::array<double, 3>> truncPyramidCoord;
truncPyramidCoord.push_back({ {-0.5, -0.5, 0.0} }); // Bottom Face
truncPyramidCoord.push_back({ {0.5, -0.5, 0.0} });
truncPyramidCoord.push_back({ {0.5, 0.5, 0.0} });
truncPyramidCoord.push_back({ {-0.5, 0.5, 0.0} });
truncPyramidCoord.push_back({ {-0.3, -0.3, 1.0} }); // Top Face
truncPyramidCoord.push_back({ {0.3, -0.3, 1.0} });
truncPyramidCoord.push_back({ {0.3, 0.3, 1.0} });
truncPyramidCoord.push_back({ {-0.3, 0.3, 1.0} });
vtkNew<vtkPoints> truncPyramidPoints;
vtkNew<vtkHexahedron> hexahedron;
for (auto i = 0; i < truncPyramidCoord.size(); ++i)
{
truncPyramidPoints->InsertNextPoint(truncPyramidCoord[i].data());
hexahedron->GetPointIds()->SetId(i, i);
}
vtkNew<vtkUnstructuredGrid> truncPyramidUGrid;
truncPyramidUGrid->SetPoints(truncPyramidPoints);
truncPyramidUGrid->InsertNextCell(hexahedron->GetCellType(), hexahedron->GetPointIds());
auto truncated_pyramid = vtkSmartPointer<vtkGeometryFilter>::New();
truncated_pyramid->SetInputData(truncPyramidUGrid);
m_glyphSources.insert({ GlyphTypes::TruncatedPyramid, truncated_pyramid });`
As workarounds, I have already tried adding #define VTK_LEGACY_SILENT at the very top of my source (.cpp) files, my engine header file before any other include directives. Unfortunately, the error persists.
Has anyone encountered this problem recently with the latest MSVC updates, and is there a known fix or workaround for it?
Thank you in advance for your help!
C.R.
