OGS
MeshAnalysisDialog Class Reference

Detailed Description

A dialog window for calling mesh analysis methods.

Definition at line 31 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. More...
 
void on_closeButton_pressed ()
 Closes the dialog. More...
 

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

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 23 of file MeshAnalysisDialog.cpp.

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 }
std::vector< std::unique_ptr< MeshLib::Mesh > > const & _mesh_vec
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow

◆ ~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 124 of file MeshAnalysisDialog.cpp.

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 }
static std::array< std::string, static_cast< std::size_t >ElementErrorFlag::MaxValue)> ElementErrorCodeOutput(const std::vector< ElementErrorCode > &error_codes)

References MeshLib::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 86 of file MeshAnalysisDialog.cpp.

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 }

Referenced by on_startButton_pressed().

◆ on_closeButton_pressed

void MeshAnalysisDialog::on_closeButton_pressed ( )
inlineprivateslot

Closes the dialog.

Definition at line 55 of file MeshAnalysisDialog.h.

55 { this->close(); }

◆ on_startButton_pressed

void MeshAnalysisDialog::on_startButton_pressed ( )
privateslot

Starts the analysis.

Definition at line 51 of file MeshAnalysisDialog.cpp.

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  MeshLib::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(MeshLib::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 }
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.
Node search class.
Definition: NodeSearch.h:25
static std::vector< ElementErrorCode > testElementGeometry(const MeshLib::Mesh &mesh, double min_volume=std::numeric_limits< double >::epsilon())
static unsigned detectHoles(MeshLib::Mesh const &mesh)

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

Member Data Documentation

◆ _mesh_vec

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

Definition at line 48 of file MeshAnalysisDialog.h.

Referenced by on_startButton_pressed().


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