OGS
MeshAnalysisDialog Class Reference

Detailed Description

A dialog window for calling mesh analysis methods.

Definition at line 20 of file MeshAnalysisDialog.h.

#include <MeshAnalysisDialog.h>

Inheritance diagram for MeshAnalysisDialog:
[legend]
Collaboration diagram for MeshAnalysisDialog:
[legend]

Public Member Functions

 MeshAnalysisDialog (std::vector< std::unique_ptr< MeshLib::Mesh > > const &mesh_vec, QDialog *parent=nullptr)
 ~MeshAnalysisDialog () override

Private Slots

void on_startButton_pressed ()
 Starts the analysis.
void on_closeButton_pressed ()
 Closes the dialog.

Private Member Functions

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.
void elementsMsgOutput (const std::vector< ElementErrorCode > &error_codes)
 Prepares the output for the node message window.

Private Attributes

std::vector< std::unique_ptr< MeshLib::Mesh > > const & _mesh_vec

Constructor & Destructor Documentation

◆ MeshAnalysisDialog()

MeshAnalysisDialog::MeshAnalysisDialog ( std::vector< std::unique_ptr< MeshLib::Mesh > > const & mesh_vec,
QDialog * parent = nullptr )
explicit

Definition at line 12 of file MeshAnalysisDialog.cpp.

15 : QDialog(parent), _mesh_vec(mesh_vec)
16{
17 setupUi(this);
18
19 if (mesh_vec.empty())
20 {
21 this->startButton->setDisabled(true);
22 }
23
24 for (const auto& mesh : mesh_vec)
25 {
26 this->meshListBox->addItem(QString::fromStdString(mesh->getName()));
27 }
28
29 auto* collapse_threshold_validator =
30 new StrictDoubleValidator(0, 1000000, 7, this);
31 this->collapsibleNodesThreshold->setValidator(collapse_threshold_validator);
32
33 auto* volume_threshold_validator =
34 new StrictDoubleValidator(0, 1e10, 10, this);
35 this->zeroVolumeThreshold->setValidator(volume_threshold_validator);
36}
std::vector< std::unique_ptr< MeshLib::Mesh > > const & _mesh_vec

References _mesh_vec.

◆ ~MeshAnalysisDialog()

MeshAnalysisDialog::~MeshAnalysisDialog ( )
overridedefault

Member Function Documentation

◆ elementsMsgOutput()

void MeshAnalysisDialog::elementsMsgOutput ( const std::vector< ElementErrorCode > & error_codes)
private

Prepares the output for the node message window.

Definition at line 113 of file MeshAnalysisDialog.cpp.

115{
116 std::array<std::string,
117 static_cast<std::size_t>(ElementErrorFlag::MaxValue)>
119 element_error_codes));
120
121 this->zeroVolumeText->setText(QString::fromStdString(output_str[0]));
122 this->nonPlanarText->setText(QString::fromStdString(output_str[1]));
123 this->nonConvexText->setText(QString::fromStdString(output_str[2]));
124 this->nodeOrderText->setText(QString::fromStdString(output_str[3]));
125}
static std::array< std::string, static_cast< std::size_t >(ElementErrorFlag::MaxValue)> ElementErrorCodeOutput(const std::vector< ElementErrorCode > &error_codes)

References MeshToolsLib::MeshValidation::ElementErrorCodeOutput(), and MaxValue.

Referenced by on_startButton_pressed().

◆ nodesMsgOutput()

void MeshAnalysisDialog::nodesMsgOutput ( std::vector< std::size_t > const & node_ids,
std::vector< std::size_t > const & collapsibleNodeIds )
private

Prepares the output for the node message window.

Definition at line 75 of file MeshAnalysisDialog.cpp.

78{
79 const std::size_t nNodeIds(node_ids.size());
80 QString nodes_output("");
81 if (node_ids.empty())
82 {
83 nodes_output += "No unused nodes found.";
84 }
85 else
86 {
87 nodes_output += (QString::number(nNodeIds) +
88 " nodes are not part of any element:\n");
89 for (std::size_t i = 0; i < nNodeIds; ++i)
90 {
91 nodes_output += (QString::number(node_ids[i]) + ", ");
92 }
93 }
94 this->unusedNodesText->setText(nodes_output);
95
96 std::size_t const nNodes(collapsibleNodeIds.size());
97 QString node_ids_str("");
98 unsigned count(0);
99 for (std::size_t i = 0; i < nNodes; ++i)
100 {
101 if (i != collapsibleNodeIds[i])
102 {
103 node_ids_str.append(QString::number(i) + ", ");
104 count++;
105 }
106 }
107 nodes_output = (count > 0) ? QString::number(count) + " nodes found:\n"
108 : "No nodes found.";
109 nodes_output.append(node_ids_str);
110 this->collapsibleNodesText->setText(nodes_output);
111}

Referenced by on_startButton_pressed().

◆ on_closeButton_pressed

void MeshAnalysisDialog::on_closeButton_pressed ( )
inlineprivateslot

Closes the dialog.

Definition at line 44 of file MeshAnalysisDialog.h.

44{ this->close(); }

◆ on_startButton_pressed

void MeshAnalysisDialog::on_startButton_pressed ( )
privateslot

Starts the analysis.

Definition at line 40 of file MeshAnalysisDialog.cpp.

41{
42 MeshLib::Mesh const& mesh(
43 *_mesh_vec[this->meshListBox->currentIndex()].get());
44
45 MeshLib::NodeSearch ns(mesh);
46 ns.searchUnused();
47 const std::vector<std::size_t> unusedNodesIdx(ns.getSearchedNodeIDs());
48 MeshToolsLib::MeshRevision rev(const_cast<MeshLib::Mesh&>(mesh));
49 std::vector<std::size_t> const& collapsibleNodeIds(rev.collapseNodeIndices(
50 this->collapsibleNodesThreshold->text().toDouble() +
51 std::numeric_limits<double>::epsilon()));
52 this->nodesGroupBox->setTitle(
53 "Nodes (out of " + QString::number(mesh.getNumberOfNodes()) + ")");
54 this->nodesMsgOutput(unusedNodesIdx, collapsibleNodeIds);
55
56 const std::vector<ElementErrorCode> element_error_codes(
58 mesh,
59 this->zeroVolumeThreshold->text().toDouble() +
60 std::numeric_limits<double>::epsilon()));
61 this->elementsGroupBox->setTitle(
62 "Elements (out of " + QString::number(mesh.getNumberOfElements()) +
63 ")");
64 this->elementsMsgOutput(element_error_codes);
65
66 unsigned const n_holes(MeshToolsLib::MeshValidation::detectHoles(mesh));
67 if (n_holes > 0)
68 {
69 this->meshHoleOutputLabel->setText(
70 "<strong>" + QString::number(n_holes) +
71 " hole(s) found within the mesh</strong>");
72 }
73}
void elementsMsgOutput(const std::vector< ElementErrorCode > &error_codes)
Prepares the output for the node message window.
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.
static unsigned detectHoles(MeshLib::Mesh const &mesh)
static std::vector< ElementErrorCode > testElementGeometry(const MeshLib::Mesh &mesh, double min_volume=std::numeric_limits< double >::epsilon())

References _mesh_vec, MeshToolsLib::MeshRevision::collapseNodeIndices(), MeshToolsLib::MeshValidation::detectHoles(), elementsMsgOutput(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), MeshLib::NodeSearch::getSearchedNodeIDs(), nodesMsgOutput(), MeshLib::NodeSearch::searchUnused(), and MeshToolsLib::MeshValidation::testElementGeometry().

Member Data Documentation

◆ _mesh_vec

std::vector<std::unique_ptr<MeshLib::Mesh> > const& MeshAnalysisDialog::_mesh_vec
private

Definition at line 37 of file MeshAnalysisDialog.h.

Referenced by MeshAnalysisDialog(), and on_startButton_pressed().


The documentation for this class was generated from the following files: