From 5efa30f136724e885ccfa66568b068dc6fef0cc7 Mon Sep 17 00:00:00 2001
From: Karsten Rink <karsten.rink@ufz.de>
Date: Tue, 4 Sep 2012 16:06:05 +0200
Subject: [PATCH] changed default mesh-open-type to vtu; mode points-array name
 attribute in VTKInterface optional

---
 FileIO/ImportFileTypes.h      | 2 +-
 FileIO/XmlIO/VTKInterface.cpp | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/FileIO/ImportFileTypes.h b/FileIO/ImportFileTypes.h
index 449092e3a08..9b4551ee024 100644
--- a/FileIO/ImportFileTypes.h
+++ b/FileIO/ImportFileTypes.h
@@ -62,7 +62,7 @@ public:
 		else if (t==ImportFileType::NETCDF) 
 			return "NetCDF files (*.nc)";
 		else if (t==ImportFileType::OGS) 
-			return "Geosys files (*.gsp *.gli *.gml *.msh *.stn);;Project files (*.gsp);;GeoSys FEM Conditions (*.cnd *.bc *.ic *.st);;GLI files (*.gli);;MSH files (*.msh);;STN files (*.stn);;All files (* *.*)";
+			return "OpenGeosys files (*.gsp *.gml *.vtu *.stn);;GeoSys legacy files (*.gli *.msh);;GeoSys FEM Conditions (*.cnd *.bc *.ic *.st);;All files (* *.*)";
 		else if (t==ImportFileType::PETREL) 
 			return "Petrel files (*)";
 		else if (t==ImportFileType::RASTER) 
diff --git a/FileIO/XmlIO/VTKInterface.cpp b/FileIO/XmlIO/VTKInterface.cpp
index 710a6db67e4..d706be51d0f 100644
--- a/FileIO/XmlIO/VTKInterface.cpp
+++ b/FileIO/XmlIO/VTKInterface.cpp
@@ -82,7 +82,9 @@ MeshLib::Mesh* VTKInterface::readVTUFile(const std::string &file_name)
 			std::vector<unsigned> cell_types(nElems);
 
 			const rapidxml::xml_node<>* mat_id_node (piece_node->first_node("CellData")->first_node("DataArray"));
-			if (mat_id_node && (std::string(mat_id_node->first_attribute("Name")->value()).compare("MaterialIDs") == 0))
+			if (mat_id_node && 
+				((std::string(mat_id_node->first_attribute("Name")->value()).compare("MaterialIDs") == 0) ||
+				 (std::string(mat_id_node->first_attribute("Name")->value()).compare("MatGroup") == 0)))
 			{
 				if (std::string(mat_id_node->first_attribute("format")->value()).compare("ascii") == 0)
 				{
@@ -96,7 +98,9 @@ MeshLib::Mesh* VTKInterface::readVTUFile(const std::string &file_name)
 
 
 			const rapidxml::xml_node<>* points_node (piece_node->first_node("Points")->first_node("DataArray"));
-			if (points_node && (std::string(points_node->first_attribute("Name")->value()).compare("Points") == 0))
+			// This _may_ have an attribute "Name" with the value "Points" but you cannot count on it. 
+			// However, there shouldn't be any other DataArray nodes so most likely not checking the name isn't a problem.
+			if (points_node) 
 			{
 				if (std::string(points_node->first_attribute("format")->value()).compare("ascii") == 0)
 				{
-- 
GitLab