diff --git a/Gui/DataView/MeshAnalysis.ui b/Gui/DataView/MeshAnalysis.ui index e34a188dc280cab5b740ba52f53daf29fde26434..ba792eaeae565ef6f48a37a9c29a38a4a793a51c 100644 --- a/Gui/DataView/MeshAnalysis.ui +++ b/Gui/DataView/MeshAnalysis.ui @@ -6,22 +6,101 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>300</height> + <width>438</width> + <height>470</height> </rect> </property> <property name="windowTitle"> <string>Mesh Analysis</string> </property> <layout class="QGridLayout" name="gridLayout"> + <item row="2" column="0" colspan="4"> + <widget class="QGroupBox" name="nodesGroupBox"> + <property name="title"> + <string>Nodes</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="unusedNodesLabel"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Unused nodes:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="collapsableNodesLabel"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>150</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Collapsable nodes:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QTextEdit" name="unusedNodesText"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="collapsableNodesText"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> <item row="1" column="0"> <widget class="QLabel" name="meshListLabel"> + <property name="minimumSize"> + <size> + <width>110</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>110</width> + <height>16777215</height> + </size> + </property> <property name="text"> - <string>Select Mesh:</string> + <string> Select Mesh:</string> </property> </widget> </item> - <item row="5" column="2"> + <item row="5" column="3"> <widget class="QPushButton" name="closeButton"> <property name="maximumSize"> <size> @@ -44,53 +123,7 @@ </property> </widget> </item> - <item row="3" column="1" colspan="2"> - <widget class="QTextEdit" name="nodesMsg"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>50</height> - </size> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="1" colspan="2"> - <widget class="QTextEdit" name="elementsMsg"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="nodesMsgLabel"> - <property name="text"> - <string>Unused nodes:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="elementsMsgLabel"> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Non-valid elements:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="2"> + <item row="1" column="3"> <widget class="QPushButton" name="startButton"> <property name="maximumSize"> <size> @@ -103,6 +136,102 @@ </property> </widget> </item> + <item row="3" column="0" colspan="4"> + <widget class="QGroupBox" name="elementsGroupBox"> + <property name="title"> + <string>Elements</string> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="1" column="0"> + <widget class="QLabel" name="zeroVolumeLabel"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Zero volume:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="nonConvexLabel"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Non-convex:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="nonPlanarLabel"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Non-planar:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QTextEdit" name="zeroVolumeText"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QTextEdit" name="nonPlanarText"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QTextEdit" name="nonConvexText"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <resources/> diff --git a/Gui/DataView/MeshAnalysisDialog.cpp b/Gui/DataView/MeshAnalysisDialog.cpp index ca2cb61e85259739909c3c51ecc435bf9dfe1e12..89e5bbb3767554439c5141a98cd076c52580ff35 100644 --- a/Gui/DataView/MeshAnalysisDialog.cpp +++ b/Gui/DataView/MeshAnalysisDialog.cpp @@ -47,9 +47,7 @@ void MeshAnalysisDialog::on_startButton_pressed() this->nodesMsgOutput(unusedNodesIdx, nCollapsableNodes); const std::vector<ElementErrorCode> element_error_codes (MeshLib::MeshValidation::testElementGeometry(*mesh)); - //this->elementMsgOutput(element_error_codes); - QString elementMsgOutput = QString::fromStdString(MeshLib::MeshValidation::ElementErrorCodeOutput(element_error_codes)); - this->elementsMsg->setText(elementMsgOutput); + this->elementsMsgOutput(element_error_codes); } void MeshAnalysisDialog::nodesMsgOutput(const std::vector<std::size_t> &node_ids, unsigned nCollapsableNodes) @@ -64,8 +62,17 @@ void MeshAnalysisDialog::nodesMsgOutput(const std::vector<std::size_t> &node_ids for (std::size_t i=0; i<nNodeIds; ++i) nodes_output += (QString::number(node_ids[i]) + ", "); } - - nodes_output += "\nFound " + QString::number(nCollapsableNodes) + " potentially collapsable nodes."; - this->nodesMsg->setText(nodes_output); + this->unusedNodesText->setText(nodes_output); + + nodes_output = QString::number(nCollapsableNodes) + " nodes found."; + this->collapsableNodesText->setText(nodes_output); } +void MeshAnalysisDialog::elementsMsgOutput(const std::vector<ElementErrorCode> &element_error_codes) +{ + std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> output_str(MeshLib::MeshValidation::ElementErrorCodeOutput(element_error_codes)); + + this->zeroVolumeText->setText(QString::fromStdString(output_str[0])); + this-> nonPlanarText->setText(QString::fromStdString(output_str[1])); + this-> nonConvexText->setText(QString::fromStdString(output_str[2])); +} diff --git a/Gui/DataView/MeshAnalysisDialog.h b/Gui/DataView/MeshAnalysisDialog.h index 4fc4920b74a0b04a08c088dd2f344d3f903022f5..e25f718bc3dbfcf7473deafd4ebef1af720071d5 100644 --- a/Gui/DataView/MeshAnalysisDialog.h +++ b/Gui/DataView/MeshAnalysisDialog.h @@ -39,6 +39,9 @@ private: /// Prepares the output for the node message window void nodesMsgOutput(const std::vector<std::size_t> &node_ids, unsigned nCollapsableNodes); + /// Prepares the output for the node message window + void elementsMsgOutput(const std::vector<ElementErrorCode> &error_codes); + const std::vector<MeshLib::Mesh*>& _mesh_vec; private slots: diff --git a/MeshLib/MeshQuality/MeshValidation.cpp b/MeshLib/MeshQuality/MeshValidation.cpp index 7e56826657cbc0580928b5017e7c75fcdbaef13a..c96aaa022cda6fba5601d7c2181076ebcce2d9eb 100644 --- a/MeshLib/MeshQuality/MeshValidation.cpp +++ b/MeshLib/MeshQuality/MeshValidation.cpp @@ -35,7 +35,9 @@ MeshValidation::MeshValidation(MeshLib::Mesh &mesh) INFO ("Found %d potentially collapsable nodes.", rev.getNCollapsableNodes()); const std::vector<ElementErrorCode> codes (this->testElementGeometry(mesh)); - this->ElementErrorCodeOutput(codes); + std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> output_str (this->ElementErrorCodeOutput(codes)); + for (std::size_t i = 0; i < output_str.size(); ++i) + INFO (output_str[i].c_str()); } std::vector<std::size_t> MeshValidation::findUnusedMeshNodes(const MeshLib::Mesh &mesh) @@ -109,13 +111,14 @@ std::vector<std::size_t> MeshValidation::removeUnusedMeshNodes(MeshLib::Mesh &me return error_code_vector; } -std::string MeshValidation::ElementErrorCodeOutput(const std::vector<ElementErrorCode> &error_codes) +std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> +MeshValidation::ElementErrorCodeOutput(const std::vector<ElementErrorCode> &error_codes) { const std::size_t nErrorFlags (static_cast<std::size_t>(ElementErrorFlag::MaxValue)); ElementErrorFlag flags[nErrorFlags] = { ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder }; const std::size_t nElements (error_codes.size()); - std::string output(""); + std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> output; for (std::size_t i=0; i<nErrorFlags; ++i) { @@ -132,10 +135,10 @@ std::string MeshValidation::ElementErrorCodeOutput(const std::vector<ElementErro } const std::string nErrorsStr = (count) ? BaseLib::number2str(count) : "No"; - output += (nErrorsStr + " elements found with " + ElementErrorCode::toString(flags[i]) + "\n"); + output[i] = (nErrorsStr + " elements found with " + ElementErrorCode::toString(flags[i]) + ".\n"); if (count) - output += ("ElementIDs: " + elementIdStr + "\n"); + output[i] += ("ElementIDs: " + elementIdStr + "\n"); } return output; } diff --git a/MeshLib/MeshQuality/MeshValidation.h b/MeshLib/MeshQuality/MeshValidation.h index da0a23d3e6aafc19523762357429c9f5890d274e..f795e323be427a39a3dc35863393dbd35f660ee2 100644 --- a/MeshLib/MeshQuality/MeshValidation.h +++ b/MeshLib/MeshQuality/MeshValidation.h @@ -15,6 +15,7 @@ #ifndef MESHVALIDATION_H #define MESHVALIDATION_H +#include <array> #include <vector> #include "ElementErrorCode.h" @@ -56,7 +57,8 @@ public: * Detailed output which ElementID is associated with which error(s) * @return String containing the report */ - static std::string ElementErrorCodeOutput(const std::vector<ElementErrorCode> &error_codes); + static std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> + ElementErrorCodeOutput(const std::vector<ElementErrorCode> &error_codes); private: