Skip to content
Snippets Groups Projects
Commit 765b79a4 authored by Tom Fischer's avatar Tom Fischer Committed by Dmitri Naumov
Browse files

[FileIO] GMSInterface: Using PropertyVector instead of Element::_value for material ids.

parent dd6c404a
No related branches found
No related tags found
No related merge requests found
...@@ -240,6 +240,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) ...@@ -240,6 +240,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename)
INFO("GMSInterface::readGMS3DMMesh(): Read GMS-3DM mesh."); INFO("GMSInterface::readGMS3DMMesh(): Read GMS-3DM mesh.");
std::vector<MeshLib::Node*> nodes; std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elements; std::vector<MeshLib::Element*> elements;
std::vector<int> mat_ids;
std::map<unsigned, unsigned> id_map; std::map<unsigned, unsigned> id_map;
// elements are listed before nodes in 3dm-format, therefore // elements are listed before nodes in 3dm-format, therefore
...@@ -280,7 +281,8 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) ...@@ -280,7 +281,8 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename)
for (unsigned k(0); k<6; k++) { for (unsigned k(0); k<6; k++) {
prism_nodes[k] = nodes[id_map.find(node_idx[k])->second]; prism_nodes[k] = nodes[id_map.find(node_idx[k])->second];
} }
elements.push_back(new MeshLib::Prism(prism_nodes, mat_id)); elements.push_back(new MeshLib::Prism(prism_nodes));
mat_ids.push_back(mat_id);
} }
else if (element_id.compare("E4T") == 0) // Tet else if (element_id.compare("E4T") == 0) // Tet
{ {
...@@ -290,7 +292,8 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) ...@@ -290,7 +292,8 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename)
for (unsigned k(0); k<4; k++) { for (unsigned k(0); k<4; k++) {
tet_nodes[k] = nodes[id_map.find(node_idx[k])->second]; tet_nodes[k] = nodes[id_map.find(node_idx[k])->second];
} }
elements.push_back(new MeshLib::Tet(tet_nodes, mat_id)); elements.push_back(new MeshLib::Tet(tet_nodes));
mat_ids.push_back(mat_id);
} }
else if ((element_id.compare("E4P") == 0) || (element_id.compare("E5P") == 0)) // Pyramid (both do exist for some reason) else if ((element_id.compare("E4P") == 0) || (element_id.compare("E5P") == 0)) // Pyramid (both do exist for some reason)
{ {
...@@ -300,7 +303,8 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) ...@@ -300,7 +303,8 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename)
for (unsigned k(0); k<5; k++) { for (unsigned k(0); k<5; k++) {
pyramid_nodes[k] = nodes[id_map.find(node_idx[k])->second]; pyramid_nodes[k] = nodes[id_map.find(node_idx[k])->second];
} }
elements.push_back(new MeshLib::Pyramid(pyramid_nodes, mat_id)); elements.push_back(new MeshLib::Pyramid(pyramid_nodes));
mat_ids.push_back(mat_id);
} }
else if (element_id.compare("ND ") == 0) // Node else if (element_id.compare("ND ") == 0) // Node
...@@ -317,7 +321,15 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) ...@@ -317,7 +321,15 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename)
INFO("GMSInterface::readGMS3DMMesh(): \tfinished."); INFO("GMSInterface::readGMS3DMMesh(): \tfinished.");
const std::string mesh_name = BaseLib::extractBaseNameWithoutExtension(filename); const std::string mesh_name = BaseLib::extractBaseNameWithoutExtension(filename);
return new MeshLib::Mesh(mesh_name, nodes, elements); MeshLib::Mesh* mesh(new MeshLib::Mesh(mesh_name, nodes, elements));
auto opt_pv = mesh->getProperties().createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell);
if (opt_pv) {
auto pv = *opt_pv;
pv.resize(mat_ids.size());
std::copy(mat_ids.cbegin(), mat_ids.cend(), pv.begin());
}
return mesh;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment