From 8b74f13a2ac8ab0b39a466e4197a96aa097ee1fb Mon Sep 17 00:00:00 2001 From: Stefan Zellmann Date: Sun, 25 Jan 2026 11:57:20 +0100 Subject: [PATCH] If VTU reader fails parsing file as XML, try with legacy reader --- tsd/src/tsd/io/importers/import_VTU.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tsd/src/tsd/io/importers/import_VTU.cpp b/tsd/src/tsd/io/importers/import_VTU.cpp index 935c1a00..d90baca7 100644 --- a/tsd/src/tsd/io/importers/import_VTU.cpp +++ b/tsd/src/tsd/io/importers/import_VTU.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #endif // std @@ -47,13 +48,26 @@ static ArrayRef makeFloatArray1D( SpatialFieldRef import_VTU(Scene &scene, const char *filepath) { + vtkUnstructuredGrid *grid{nullptr}; + // Read .vtu file vtkSmartPointer reader = vtkSmartPointer::New(); - reader->SetFileName(filepath); - reader->Update(); - vtkUnstructuredGrid *grid = reader->GetOutput(); + vtkSmartPointer legacyReader = + vtkSmartPointer::New(); + + if (reader->CanReadFile(filepath)) { + reader->SetFileName(filepath); + reader->Update(); + grid = reader->GetOutput(); + } else { + // legacy reader has no CanReadFile + legacyReader->SetFileName(filepath); + legacyReader->Update(); + grid = legacyReader->GetOutput(); + } + if (!grid) { logError("[import_VTU] failed to load .vtu file '%s'", filepath); return {};