OGS
MeshAnalysisDialog.cpp
Go to the documentation of this file.
1
15#include "MeshAnalysisDialog.h"
16
18#include "MeshLib/Mesh.h"
22
24 std::vector<std::unique_ptr<MeshLib::Mesh>> const& mesh_vec,
25 QDialog* parent)
26 : QDialog(parent), _mesh_vec(mesh_vec)
27{
28 setupUi(this);
29
30 if (mesh_vec.empty())
31 {
32 this->startButton->setDisabled(true);
33 }
34
35 for (const auto& mesh : mesh_vec)
36 {
37 this->meshListBox->addItem(QString::fromStdString(mesh->getName()));
38 }
39
40 auto* collapse_threshold_validator =
41 new StrictDoubleValidator(0, 1000000, 7, this);
42 this->collapsibleNodesThreshold->setValidator(collapse_threshold_validator);
43
44 auto* volume_threshold_validator =
45 new StrictDoubleValidator(0, 1e10, 10, this);
46 this->zeroVolumeThreshold->setValidator(volume_threshold_validator);
47}
48
50
52{
53 MeshLib::Mesh const& mesh(
54 *_mesh_vec[this->meshListBox->currentIndex()].get());
55
56 MeshLib::NodeSearch ns(mesh);
57 ns.searchUnused();
58 const std::vector<std::size_t> unusedNodesIdx(ns.getSearchedNodeIDs());
59 MeshToolsLib::MeshRevision rev(const_cast<MeshLib::Mesh&>(mesh));
60 std::vector<std::size_t> const& collapsibleNodeIds(rev.collapseNodeIndices(
61 this->collapsibleNodesThreshold->text().toDouble() +
62 std::numeric_limits<double>::epsilon()));
63 this->nodesGroupBox->setTitle(
64 "Nodes (out of " + QString::number(mesh.getNumberOfNodes()) + ")");
65 this->nodesMsgOutput(unusedNodesIdx, collapsibleNodeIds);
66
67 const std::vector<ElementErrorCode> element_error_codes(
69 mesh,
70 this->zeroVolumeThreshold->text().toDouble() +
71 std::numeric_limits<double>::epsilon()));
72 this->elementsGroupBox->setTitle(
73 "Elements (out of " + QString::number(mesh.getNumberOfElements()) +
74 ")");
75 this->elementsMsgOutput(element_error_codes);
76
77 unsigned const n_holes(MeshToolsLib::MeshValidation::detectHoles(mesh));
78 if (n_holes > 0)
79 {
80 this->meshHoleOutputLabel->setText(
81 "<strong>" + QString::number(n_holes) +
82 " hole(s) found within the mesh</strong>");
83 }
84}
85
87 std::vector<std::size_t> const& node_ids,
88 std::vector<std::size_t> const& collapsibleNodeIds)
89{
90 const std::size_t nNodeIds(node_ids.size());
91 QString nodes_output("");
92 if (node_ids.empty())
93 {
94 nodes_output += "No unused nodes found.";
95 }
96 else
97 {
98 nodes_output += (QString::number(nNodeIds) +
99 " nodes are not part of any element:\n");
100 for (std::size_t i = 0; i < nNodeIds; ++i)
101 {
102 nodes_output += (QString::number(node_ids[i]) + ", ");
103 }
104 }
105 this->unusedNodesText->setText(nodes_output);
106
107 std::size_t const nNodes(collapsibleNodeIds.size());
108 QString node_ids_str("");
109 unsigned count(0);
110 for (std::size_t i = 0; i < nNodes; ++i)
111 {
112 if (i != collapsibleNodeIds[i])
113 {
114 node_ids_str.append(QString::number(i) + ", ");
115 count++;
116 }
117 }
118 nodes_output = (count > 0) ? QString::number(count) + " nodes found:\n"
119 : "No nodes found.";
120 nodes_output.append(node_ids_str);
121 this->collapsibleNodesText->setText(nodes_output);
122}
123
125 const std::vector<ElementErrorCode>& element_error_codes)
126{
127 std::array<std::string,
128 static_cast<std::size_t>(ElementErrorFlag::MaxValue)>
130 element_error_codes));
131
132 this->zeroVolumeText->setText(QString::fromStdString(output_str[0]));
133 this->nonPlanarText->setText(QString::fromStdString(output_str[1]));
134 this->nonConvexText->setText(QString::fromStdString(output_str[2]));
135 this->nodeOrderText->setText(QString::fromStdString(output_str[3]));
136}
Definition of the MeshAnalysisDialog class.
Definition of the MeshRevision class.
Definition of the MeshValidation class.
Definition of the Mesh class.
Implementation of the StrictDoubleValidator class.
void on_startButton_pressed()
Starts the analysis.
MeshAnalysisDialog(std::vector< std::unique_ptr< MeshLib::Mesh > > const &mesh_vec, QDialog *parent=nullptr)
void elementsMsgOutput(const std::vector< ElementErrorCode > &error_codes)
Prepares the output for the node message window.
~MeshAnalysisDialog() override
std::vector< std::unique_ptr< MeshLib::Mesh > > const & _mesh_vec
void nodesMsgOutput(std::vector< std::size_t > const &node_ids, std::vector< std::size_t > const &collapsibleNodeIds)
Prepares the output for the node message window.
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:100
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
Node search class.
Definition NodeSearch.h:25
const std::vector< std::size_t > & getSearchedNodeIDs() const
return marked node IDs
Definition NodeSearch.h:30
std::size_t searchUnused()
Marks all unused nodes.
std::vector< std::size_t > collapseNodeIndices(double eps) const
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow
static unsigned detectHoles(MeshLib::Mesh const &mesh)
static std::array< std::string, static_cast< std::size_t >(ElementErrorFlag::MaxValue)> ElementErrorCodeOutput(const std::vector< ElementErrorCode > &error_codes)
static std::vector< ElementErrorCode > testElementGeometry(const MeshLib::Mesh &mesh, double min_volume=std::numeric_limits< double >::epsilon())