Skip to content
Snippets Groups Projects
Commit 4c68b26b authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MeL] Move addElementToSurface out.

parent cb0186d2
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,31 @@ std::string convertMeshNodesToGeoPoints(MeshLib::Mesh const& mesh, ...@@ -48,6 +48,31 @@ std::string convertMeshNodesToGeoPoints(MeshLib::Mesh const& mesh,
geo_objects.addPointVec(std::move(points), geoobject_name, nullptr, eps); geo_objects.addPointVec(std::move(points), geoobject_name, nullptr, eps);
return geoobject_name; return geoobject_name;
} }
void addElementToSurface(MeshLib::Element const& e,
std::vector<std::size_t> const& id_map,
GeoLib::Surface& surface)
{
if (e.getGeomType() == MeshLib::MeshElemType::TRIANGLE)
{
surface.addTriangle(id_map[e.getNodeIndex(0)],
id_map[e.getNodeIndex(1)],
id_map[e.getNodeIndex(2)]);
return;
}
if (e.getGeomType() == MeshLib::MeshElemType::QUAD)
{
surface.addTriangle(id_map[e.getNodeIndex(0)],
id_map[e.getNodeIndex(1)],
id_map[e.getNodeIndex(2)]);
surface.addTriangle(id_map[e.getNodeIndex(0)],
id_map[e.getNodeIndex(2)],
id_map[e.getNodeIndex(3)]);
return;
}
// all other element types are ignored (i.e. lines)
};
} // namespace } // namespace
namespace MeshLib namespace MeshLib
...@@ -99,36 +124,13 @@ bool convertMeshToGeo(const MeshLib::Mesh& mesh, ...@@ -99,36 +124,13 @@ bool convertMeshToGeo(const MeshLib::Mesh& mesh,
const std::vector<std::size_t>& id_map( const std::vector<std::size_t>& id_map(
geo_objects.getPointVecObj(geoobject_name)->getIDMap()); geo_objects.getPointVecObj(geoobject_name)->getIDMap());
geo_objects.getPointVecObj(mesh_name)->getIDMap());
auto add_element_to_surface = [&id_map](MeshLib::Element const& e,
GeoLib::Surface& surface) {
if (e.getGeomType() == MeshElemType::TRIANGLE)
{
surface.addTriangle(id_map[e.getNodeIndex(0)],
id_map[e.getNodeIndex(1)],
id_map[e.getNodeIndex(2)]);
return;
}
if (e.getGeomType() == MeshElemType::QUAD)
{
surface.addTriangle(id_map[e.getNodeIndex(0)],
id_map[e.getNodeIndex(1)],
id_map[e.getNodeIndex(2)]);
surface.addTriangle(id_map[e.getNodeIndex(0)],
id_map[e.getNodeIndex(2)],
id_map[e.getNodeIndex(3)]);
return;
}
// all other element types are ignored (i.e. lines)
};
const std::vector<MeshLib::Element*>& elements = mesh.getElements(); const std::vector<MeshLib::Element*>& elements = mesh.getElements();
const std::size_t nElems(mesh.getNumberOfElements()); const std::size_t nElems(mesh.getNumberOfElements());
for (unsigned i = 0; i < nElems; ++i) for (unsigned i = 0; i < nElems; ++i)
{ {
auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first); auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
add_element_to_surface(*elements[i], *(*sfcs)[surfaceId]); addElementToSurface(*elements[i], id_map, *(*sfcs)[surfaceId]);
} }
std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc) { std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc) {
......
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