Skip to content
Snippets Groups Projects
Commit 4dae8ca5 authored by Karsten Rink's avatar Karsten Rink
Browse files

Fixed issue where mesh to surface conversion would fail if points had been...

Fixed issue where mesh to surface conversion would fail if points had been collapsed when creating geometry point vector; current solution allows for triangles with A=0.
parent ea201d93
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,10 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects* geo_objects ...@@ -43,6 +43,10 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects* geo_objects
for (unsigned i=0; i<nNodes; ++i) for (unsigned i=0; i<nNodes; ++i)
(*points)[i] = new GeoLib::Point(static_cast<GeoLib::Point>(*nodes[i])); (*points)[i] = new GeoLib::Point(static_cast<GeoLib::Point>(*nodes[i]));
std::string mesh_name (mesh.getName());
geo_objects->addPointVec(points, mesh_name);
const std::vector<std::size_t> id_map (geo_objects->getPointVecObj(mesh_name)->getIDMap());
// elements to surface triangles conversion // elements to surface triangles conversion
const std::vector<MeshLib::Element*> &elements = mesh.getElements(); const std::vector<MeshLib::Element*> &elements = mesh.getElements();
GeoLib::Surface* sfc = new GeoLib::Surface(*points); GeoLib::Surface* sfc = new GeoLib::Surface(*points);
...@@ -52,11 +56,11 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects* geo_objects ...@@ -52,11 +56,11 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects* geo_objects
{ {
MeshLib::Element* e (elements[i]); MeshLib::Element* e (elements[i]);
if (e->getGeomType() == MeshElemType::TRIANGLE) if (e->getGeomType() == MeshElemType::TRIANGLE)
sfc->addTriangle(e->getNodeIndex(0), e->getNodeIndex(1), e->getNodeIndex(2)); sfc->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]);
if (e->getGeomType() == MeshElemType::QUAD) if (e->getGeomType() == MeshElemType::QUAD)
{ {
sfc->addTriangle(e->getNodeIndex(0), e->getNodeIndex(1), e->getNodeIndex(2)); sfc->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]);
sfc->addTriangle(e->getNodeIndex(0), e->getNodeIndex(2), e->getNodeIndex(3)); sfc->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(2)], id_map[e->getNodeIndex(3)]);
} }
// all other element types are ignored (i.e. lines) // all other element types are ignored (i.e. lines)
} }
...@@ -64,8 +68,6 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects* geo_objects ...@@ -64,8 +68,6 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects* geo_objects
std::vector<GeoLib::Surface*> *sfcs = new std::vector<GeoLib::Surface*>(1); std::vector<GeoLib::Surface*> *sfcs = new std::vector<GeoLib::Surface*>(1);
(*sfcs)[0] = sfc; (*sfcs)[0] = sfc;
std::string mesh_name (mesh.getName());
geo_objects->addPointVec(points, mesh_name);
geo_objects->addSurfaceVec(sfcs, mesh_name); geo_objects->addSurfaceVec(sfcs, mesh_name);
return true; return true;
} }
......
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