File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 1717#include < vtkPointData.h>
1818#include < vtkSmartPointer.h>
1919#include < vtkUnstructuredGrid.h>
20+ #include < vtkUnstructuredGridReader.h>
2021#include < vtkXMLUnstructuredGridReader.h>
2122#endif
2223// std
@@ -47,13 +48,26 @@ static ArrayRef makeFloatArray1D(
4748
4849SpatialFieldRef import_VTU (Scene &scene, const char *filepath)
4950{
51+ vtkUnstructuredGrid *grid{nullptr };
52+
5053 // Read .vtu file
5154 vtkSmartPointer<vtkXMLUnstructuredGridReader> reader =
5255 vtkSmartPointer<vtkXMLUnstructuredGridReader>::New ();
53- reader->SetFileName (filepath);
54- reader->Update ();
5556
56- vtkUnstructuredGrid *grid = reader->GetOutput ();
57+ vtkSmartPointer<vtkUnstructuredGridReader> legacyReader =
58+ vtkSmartPointer<vtkUnstructuredGridReader>::New ();
59+
60+ if (reader->CanReadFile (filepath)) {
61+ reader->SetFileName (filepath);
62+ reader->Update ();
63+ grid = reader->GetOutput ();
64+ } else {
65+ // legacy reader has no CanReadFile
66+ legacyReader->SetFileName (filepath);
67+ legacyReader->Update ();
68+ grid = legacyReader->GetOutput ();
69+ }
70+
5771 if (!grid) {
5872 logError (" [import_VTU] failed to load .vtu file '%s'" , filepath);
5973 return {};
You can’t perform that action at this time.
0 commit comments