From 6fa02509cc062e23bfa4419aa70c37d1d0fced6c Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Wed, 18 Mar 2015 12:11:49 +0100 Subject: [PATCH] [MeL/ME] Preparations for simplifyMesh(). reduceElement returns the number of elements the given element is reduces to. --- MeshLib/MeshEditing/MeshRevision.cpp | 27 +++++++++++++++++---------- MeshLib/MeshEditing/MeshRevision.h | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index 0f0b280998d..a57193cbda2 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -266,7 +266,7 @@ std::size_t MeshRevision::subdivideElement( return 0; } -void MeshRevision::reduceElement(MeshLib::Element const*const element, +std::size_t MeshRevision::reduceElement(MeshLib::Element const*const element, unsigned n_unique_nodes, std::vector<MeshLib::Node*> const& nodes, std::vector<MeshLib::Element*> & elements, @@ -276,23 +276,30 @@ void MeshRevision::reduceElement(MeshLib::Element const*const element, * TODO: modify neighbouring elements if one elements has been subdivided ***************/ if (element->getGeomType() == MeshElemType::TRIANGLE && min_elem_dim == 1) + { elements.push_back (this->constructLine(element, nodes)); - else if ((element->getGeomType() == MeshElemType::QUAD) || - (element->getGeomType() == MeshElemType::TETRAHEDRON)) + return 1; + } else + if ((element->getGeomType() == MeshElemType::QUAD) || + (element->getGeomType() == MeshElemType::TETRAHEDRON)) { if (n_unique_nodes == 3 && min_elem_dim < 3) elements.push_back (this->constructTri(element, nodes)); else if (min_elem_dim == 1) elements.push_back (this->constructLine(element, nodes)); + return 1; } - else if (element->getGeomType() == MeshElemType::HEXAHEDRON) - this->reduceHex(element, n_unique_nodes, nodes, elements, min_elem_dim); - else if (element->getGeomType() == MeshElemType::PYRAMID) + else if (element->getGeomType() == MeshElemType::HEXAHEDRON) { + return reduceHex(element, n_unique_nodes, nodes, elements, min_elem_dim); + } else if (element->getGeomType() == MeshElemType::PYRAMID) { this->reducePyramid(element, n_unique_nodes, nodes, elements, min_elem_dim); - else if (element->getGeomType() == MeshElemType::PRISM) - this->reducePrism(element, n_unique_nodes, nodes, elements, min_elem_dim); - else - ERR ("Error: Unknown element type."); + return 1; + } else if (element->getGeomType() == MeshElemType::PRISM) { + return reducePrism(element, n_unique_nodes, nodes, elements, min_elem_dim); + } + + ERR ("Error: Unknown element type."); + return 0; } unsigned MeshRevision::subdivideQuad(MeshLib::Element const*const quad, diff --git a/MeshLib/MeshEditing/MeshRevision.h b/MeshLib/MeshEditing/MeshRevision.h index 621a476a04c..dd7c5b9251e 100644 --- a/MeshLib/MeshEditing/MeshRevision.h +++ b/MeshLib/MeshEditing/MeshRevision.h @@ -96,7 +96,7 @@ private: std::vector<MeshLib::Element*> & elements) const; // Revises an element by removing collapsed nodes, using the nodes vector from the result mesh. - void reduceElement(MeshLib::Element const*const element, + std::size_t reduceElement(MeshLib::Element const*const element, unsigned n_unique_nodes, const std::vector<MeshLib::Node*> &nodes, std::vector<MeshLib::Element*> &elements, -- GitLab