Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions tsd/src/tsd/io/importers/import_VTU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <vtkPointData.h>
#include <vtkSmartPointer.h>
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridReader.h>
#endif
// std
Expand Down Expand Up @@ -47,13 +48,26 @@ static ArrayRef makeFloatArray1D(

SpatialFieldRef import_VTU(Scene &scene, const char *filepath)
{
vtkUnstructuredGrid *grid{nullptr};

// Read .vtu file
vtkSmartPointer<vtkXMLUnstructuredGridReader> reader =
vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
reader->SetFileName(filepath);
reader->Update();

vtkUnstructuredGrid *grid = reader->GetOutput();
vtkSmartPointer<vtkUnstructuredGridReader> legacyReader =
vtkSmartPointer<vtkUnstructuredGridReader>::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 {};
Expand Down