diff --git a/Gui/DataView/CMakeLists.txt b/Gui/DataView/CMakeLists.txt index 79fe4b0f34e0eeacde3b4b15ea84fae43662d32c..390b058b2b07ec70197875c1291875f8f740adfe 100644 --- a/Gui/DataView/CMakeLists.txt +++ b/Gui/DataView/CMakeLists.txt @@ -20,6 +20,7 @@ set( SOURCES LineEditDialog.cpp ListPropertiesDialog.cpp MergeGeometriesDialog.cpp + MeshElementRemovalDialog.cpp MeshValueEditDialog.cpp ModellingTabWidget.cpp ModelTreeItem.cpp @@ -61,6 +62,7 @@ set( MOC_HEADERS LineEditDialog.h ListPropertiesDialog.h MergeGeometriesDialog.h + MeshElementRemovalDialog.h MeshValueEditDialog.h ModellingTabWidget.h MeshLayerEditDialog.h @@ -108,6 +110,7 @@ set( UIS MergeGeometries.ui MeshValueEdit.ui ModellingTabWidgetBase.ui + MeshElementRemoval.ui MeshLayerEdit.ui MshQualitySelection.ui MshTabWidgetBase.ui diff --git a/Gui/DataView/MeshElementRemoval.ui b/Gui/DataView/MeshElementRemoval.ui new file mode 100644 index 0000000000000000000000000000000000000000..06f755a5f2b54f1f4367fe29183c0b411fcbc81c --- /dev/null +++ b/Gui/DataView/MeshElementRemoval.ui @@ -0,0 +1,305 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MeshElementRemoval</class> + <widget class="QDialog" name="MeshElementRemoval"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>411</width> + <height>382</height> + </rect> + </property> + <property name="windowTitle"> + <string>Remove Mesh Elements</string> + </property> + <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0"> + <item row="7" column="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QComboBox" name="meshNameComboBox"/> + </item> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="meshNameLabel"> + <property name="text"> + <string>Select mesh to edit:</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="3"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Remove Elements based on</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="4" column="0"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="5" column="0"> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="yOutsideLabel"> + <property name="text"> + <string>Y outside of</string> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QLabel" name="yAndLabel"> + <property name="text"> + <string>and</string> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QLineEdit" name="xMaxEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2" alignment="Qt::AlignTop"> + <widget class="QCheckBox" name="materialIDCheckBox"> + <property name="text"> + <string>Material ID</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="xOutsideLabel"> + <property name="text"> + <string>X outside of</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2" alignment="Qt::AlignTop"> + <widget class="QCheckBox" name="elementTypeCheckBox"> + <property name="text"> + <string>Element Type</string> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <widget class="QCheckBox" name="zeroVolumeCheckBox"> + <property name="text"> + <string>Zero Area/Volume</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="zOutsideLabel"> + <property name="text"> + <string>Z outside of</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QLabel" name="xAndLabel"> + <property name="text"> + <string>and</string> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QLineEdit" name="zMinEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="4"> + <widget class="QLineEdit" name="yMaxEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="3"> + <widget class="QLabel" name="zAndLabel"> + <property name="text"> + <string>and</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="xMinEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLineEdit" name="yMinEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="4"> + <widget class="QLineEdit" name="zMaxEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="0"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="0" colspan="3"> + <widget class="QCheckBox" name="boundingBoxCheckBox"> + <property name="text"> + <string>Bounding Box, Nodes with</string> + </property> + </widget> + </item> + <item row="0" column="2" colspan="3"> + <widget class="QListWidget" name="elementTypeListWidget"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="alternatingRowColors"> + <bool>false</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::MultiSelection</enum> + </property> + <item> + <property name="text"> + <string>Line</string> + </property> + </item> + <item> + <property name="text"> + <string>Tri</string> + </property> + </item> + <item> + <property name="text"> + <string>Quad</string> + </property> + </item> + <item> + <property name="text"> + <string>Tetrahedron</string> + </property> + </item> + <item> + <property name="text"> + <string>Hexahedron</string> + </property> + </item> + <item> + <property name="text"> + <string>Pyramid</string> + </property> + </item> + <item> + <property name="text"> + <string>Prism</string> + </property> + </item> + </widget> + </item> + <item row="1" column="2" colspan="3"> + <widget class="QListWidget" name="materialListWidget"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="alternatingRowColors"> + <bool>false</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::MultiSelection</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="newMeshNameLabel"> + <property name="text"> + <string>Name of new mesh:</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="newMeshNameEdit"/> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>MeshElementRemoval</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>MeshElementRemoval</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/Gui/DataView/MeshElementRemovalDialog.cpp b/Gui/DataView/MeshElementRemovalDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8de54129d1a126805cd466e609b36c33cdc97433 --- /dev/null +++ b/Gui/DataView/MeshElementRemovalDialog.cpp @@ -0,0 +1,182 @@ +/** + * \file + * \author Karsten Rink + * \date 2013-10-16 + * \brief Implementation of the MeshElementRemovalDialog class. + * + * \copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "MeshElementRemovalDialog.h" + +#include "Mesh.h" +#include "Elements/Element.h" +#include "Node.h" +#include "MeshEditing/ElementExtraction.h" +#include "AABB.h" +#include "OGSError.h" + +#include <QList> +#include <QListWidgetItem> + +/// Constructor +MeshElementRemovalDialog::MeshElementRemovalDialog(const ProjectData &project, QDialog* parent) + : _project(project), _currentIndex(0), _aabbIndex(1), _matIDIndex(1), QDialog(parent) +{ + setupUi(this); + + const std::vector<MeshLib::Mesh*> mesh_vec (_project.getMeshObjects()); + + const std::size_t nMeshes (mesh_vec.size()); + for (std::size_t i=0; i<nMeshes; ++i) + { + std::string name = mesh_vec[i]->getName(); + this->meshNameComboBox->addItem(QString::fromStdString(name)); + } + + if (mesh_vec.empty()) + { + OGSError::box("No meshes available."); + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); + } + +} + +MeshElementRemovalDialog::~MeshElementRemovalDialog() +{ +} + +void MeshElementRemovalDialog::accept() +{ + if (this->newMeshNameEdit->text().size()==0) + { + OGSError::box("Please enter name for new mesh."); + return; + } + + bool anything_checked (false); + + MeshLib::ElementExtraction ex(*_project.getMesh(this->meshNameComboBox->currentText().toStdString())); + if (this->elementTypeCheckBox->isChecked()) + { + QList<QListWidgetItem*> items = this->elementTypeListWidget->selectedItems(); + for (int i=0; i<items.size(); ++i) + ex.searchByElementType(CompleteString2MeshElemType(items[i]->text().toStdString())); + anything_checked = true; + } + if (this->materialIDCheckBox->isChecked()) + { + QList<QListWidgetItem*> items = this->materialListWidget->selectedItems(); + for (int i=0; i<items.size(); ++i) + ex.searchByMaterialID(atoi(items[i]->text().toStdString().c_str())); + anything_checked = true; + } + if (this->boundingBoxCheckBox->isChecked()) + { + const MeshLib::Node min(strtod(this->xMinEdit->text().toStdString().c_str(), 0), + strtod(this->yMinEdit->text().toStdString().c_str(), 0), + strtod(this->zMinEdit->text().toStdString().c_str(), 0),0); + const MeshLib::Node max(strtod(this->xMaxEdit->text().toStdString().c_str(), 0), + strtod(this->yMaxEdit->text().toStdString().c_str(), 0), + strtod(this->zMaxEdit->text().toStdString().c_str(), 0),0); + ex.searchByBoundingBox(min, max); + anything_checked = true; + } + if (this->zeroVolumeCheckBox->isChecked()) + { + ex.searchByZeroContent(); + anything_checked = true; + } + + if (anything_checked) + { + MeshLib::Mesh* new_mesh = ex.removeMeshElements(this->newMeshNameEdit->text().toStdString()); + if (new_mesh) + emit meshAdded(new_mesh); + else + { + OGSError::box("All elements removed from mesh."); + delete new_mesh; + return; + } + } + else + { + OGSError::box("No condition set for elements to remove."); + return; + } + + this->done(QDialog::Accepted); +} + +void MeshElementRemovalDialog::reject() +{ + this->done(QDialog::Rejected); +} + +void MeshElementRemovalDialog::on_boundingBoxCheckBox_toggled(bool is_checked) +{ + this->xMinEdit->setEnabled(is_checked); this->xMaxEdit->setEnabled(is_checked); + this->yMinEdit->setEnabled(is_checked); this->yMaxEdit->setEnabled(is_checked); + this->zMinEdit->setEnabled(is_checked); this->zMaxEdit->setEnabled(is_checked); + + if (is_checked && (_currentIndex != _aabbIndex)) + { + _aabbIndex = _currentIndex; + const std::vector<MeshLib::Node*> nodes (_project.getMesh(this->meshNameComboBox->currentText().toStdString())->getNodes()); + GeoLib::AABB<MeshLib::Node> aabb(nodes.begin(), nodes.end()); + const MeshLib::Node minAABB = aabb.getMinPoint(); + const MeshLib::Node maxAABB = aabb.getMaxPoint(); + this->xMinEdit->setText(QString::number(minAABB[0], 'f')); + this->xMaxEdit->setText(QString::number(maxAABB[0], 'f')); + this->yMinEdit->setText(QString::number(minAABB[1], 'f')); + this->yMaxEdit->setText(QString::number(maxAABB[1], 'f')); + this->zMinEdit->setText(QString::number(minAABB[2], 'f')); + this->zMaxEdit->setText(QString::number(maxAABB[2], 'f')); + + } + +} + +void MeshElementRemovalDialog::on_elementTypeCheckBox_toggled(bool is_checked) +{ + this->elementTypeListWidget->setEnabled(is_checked); +} + +void MeshElementRemovalDialog::on_materialIDCheckBox_toggled(bool is_checked) +{ + this->materialListWidget->setEnabled(is_checked); + + if (is_checked && (_currentIndex != _matIDIndex)) + { + this->materialListWidget->clear(); + _matIDIndex = _currentIndex; + const std::vector<MeshLib::Element*> elements (_project.getMesh(this->meshNameComboBox->currentText().toStdString())->getElements()); + auto it = std::max_element(elements.begin(), elements.end(), + [](MeshLib::Element const*const x, MeshLib::Element const*const y) { return x->getValue() < y->getValue(); } + ); + unsigned max_material ((*it)->getValue()); + + for (unsigned i=0; i<=max_material; ++i) + this->materialListWidget->addItem(QString::number(i)); + } +} + +void MeshElementRemovalDialog::on_meshNameComboBox_currentIndexChanged(int idx) +{ + this->_currentIndex = this->meshNameComboBox->currentIndex(); + this->newMeshNameEdit->setText(this->meshNameComboBox->currentText() + "_new"); + this->elementTypeListWidget->clearSelection(); + this->materialListWidget->clearSelection(); + if (this->boundingBoxCheckBox->isChecked()) this->on_boundingBoxCheckBox_toggled(true); + if (this->materialIDCheckBox->isChecked()) this->on_materialIDCheckBox_toggled(true); +} + + + + diff --git a/Gui/DataView/MeshElementRemovalDialog.h b/Gui/DataView/MeshElementRemovalDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..99cfea143ca52043cde73ddc5922eb4481898b6f --- /dev/null +++ b/Gui/DataView/MeshElementRemovalDialog.h @@ -0,0 +1,52 @@ +/** + * \file + * \author Karsten Rink + * \date 2013-10-16 + * \brief Definition of the MeshElementRemovalDialog class. + * + * \copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef MESHELEMENTREMOVALDIALOG_H +#define MESHELEMENTREMOVALDIALOG_H + +#include "ui_MeshElementRemoval.h" +#include <QDialog> + +#include "ProjectData.h" + +class Node; + +/** + * \brief A dialog window for settung up a database connection + */ +class MeshElementRemovalDialog : public QDialog, private Ui_MeshElementRemoval +{ + Q_OBJECT + +public: + MeshElementRemovalDialog(const ProjectData &project, QDialog* parent = 0); + ~MeshElementRemovalDialog(void); + +private slots: + void on_boundingBoxCheckBox_toggled(bool is_checked); + void on_elementTypeCheckBox_toggled(bool is_checked); + void on_materialIDCheckBox_toggled(bool is_checked); + void on_meshNameComboBox_currentIndexChanged(int idx); + void accept(); + void reject(); + +private: + const ProjectData& _project; + unsigned _currentIndex, _aabbIndex, _matIDIndex; + +signals: + void meshAdded(MeshLib::Mesh* mesh); +}; + +#endif //MESHELEMENTREMOVALDIALOG_H diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index 60b504d50b83b5269b59e8f73db5484e14b9aeaf..6bbdbce52bce9bc11a8d7cf80f491b4635bc9473 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -40,6 +40,7 @@ #include "LineEditDialog.h" #include "ListPropertiesDialog.h" #include "MergeGeometriesDialog.h" +#include "MeshElementRemovalDialog.h" #include "MshQualitySelectionDialog.h" #include "NetCdfConfigureDialog.h" #include "NewProcessDialog.h" @@ -1132,6 +1133,13 @@ void MainWindow::showGeoNameDialog(const std::string &geometry_name, const GeoLi id, this->_geoModels->getElementNameByID(geometry_name, object_type, id)); } +void MainWindow::showMeshElementRemovalDialog() +{ + MeshElementRemovalDialog dlg(this->_project); + connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)), _meshModels, SLOT(addMesh(MeshLib::Mesh*))); + dlg.exec(); +} + void MainWindow::showCondSetupDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, size_t id, bool on_points) { std::string geo_name(""); diff --git a/Gui/mainwindow.h b/Gui/mainwindow.h index 7116d220a05387786f2dbdce6ad5681f67fc8c8b..58f706bdeefc0806d63498cf0ff6981fe4df57dd 100644 --- a/Gui/mainwindow.h +++ b/Gui/mainwindow.h @@ -85,6 +85,8 @@ protected slots: void showCondSetupDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, std::size_t id, bool on_points = false); /// Allows setting the name for a geometric object void showGeoNameDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, std::size_t id); + /// Removal of mesh elements based on a number of criteria. + void showMeshElementRemovalDialog(); /// Calls the diagram prefs dialog from the Tools menu. void showDiagramPrefsDialog(); /// Calls the diagram prefs dialog from the station list (i.e. for a specific station). diff --git a/Gui/mainwindow.ui b/Gui/mainwindow.ui index c83c9b0dba032bcc0c4c79de2e3003ddf88501d7..58e875c47f71d484f603b6500537d2601d9a872c 100644 --- a/Gui/mainwindow.ui +++ b/Gui/mainwindow.ui @@ -125,6 +125,7 @@ <string>Tools</string> </property> <addaction name="actionMesh_Generation"/> + <addaction name="actionRemove_Mesh_Elements"/> <addaction name="actionMerge_Geometries"/> <addaction name="actionFile_Converter"/> <addaction name="actionDiagram_Viewer"/> @@ -412,6 +413,11 @@ <string>Merge Geometries...</string> </property> </action> + <action name="actionRemove_Mesh_Elements"> + <property name="text"> + <string>Remove Mesh Elements...</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <customwidgets> @@ -630,6 +636,22 @@ </hint> </hints> </connection> + <connection> + <sender>actionRemove_Mesh_Elements</sender> + <signal>triggered()</signal> + <receiver>MainWindowClass</receiver> + <slot>showMeshElementRemovalDialog()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>400</x> + <y>372</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>open()</slot> @@ -643,5 +665,6 @@ <slot>about()</slot> <slot>showLicense()</slot> <slot>showMergeGeometriesDialog()</slot> + <slot>showMeshElementRemovalDialog()</slot> </slots> </ui> diff --git a/MeshLib/MeshEditing/ElementExtraction.cpp b/MeshLib/MeshEditing/ElementExtraction.cpp index 6c18fa0f5907bcb10860b2b5c8c2f02a5c41f85a..6358aeff7005d15c3545917557818708b026146e 100644 --- a/MeshLib/MeshEditing/ElementExtraction.cpp +++ b/MeshLib/MeshEditing/ElementExtraction.cpp @@ -30,7 +30,7 @@ ElementExtraction::~ElementExtraction() { } -MeshLib::Mesh* ElementExtraction::removeMeshElements() const +MeshLib::Mesh* ElementExtraction::removeMeshElements(const std::string &new_mesh_name) const { INFO("Removing total %d elements...", _marked_elements.size()); std::vector<MeshLib::Element*> tmp_elems = excludeElements(_mesh.getElements(), _marked_elements); @@ -40,11 +40,15 @@ MeshLib::Mesh* ElementExtraction::removeMeshElements() const copyNodesElements(_mesh.getNodes(), tmp_elems, new_nodes, new_elems); // create a new mesh object. Unsued nodes are removed during construction - return new MeshLib::Mesh(_mesh.getName(), new_nodes, new_elems); + if (!new_elems.empty()) + return new MeshLib::Mesh(new_mesh_name, new_nodes, new_elems); + else + return nullptr; } -void ElementExtraction::searchByMaterialID(const std::vector<MeshLib::Element*> & ele_vec, unsigned matID) +void ElementExtraction::searchByMaterialID(unsigned matID) { + const std::vector<MeshLib::Element*> &ele_vec (this->_mesh.getElements()); std::vector<std::size_t> matchedIDs; std::size_t i = 0; for (MeshLib::Element* ele : ele_vec) { @@ -55,8 +59,9 @@ void ElementExtraction::searchByMaterialID(const std::vector<MeshLib::Element*> this->updateUnion(matchedIDs); } -void ElementExtraction::searchByElementType(const std::vector<MeshLib::Element*> & ele_vec, MeshElemType eleType) +void ElementExtraction::searchByElementType(MeshElemType eleType) { + const std::vector<MeshLib::Element*> &ele_vec (this->_mesh.getElements()); std::vector<std::size_t> matchedIDs; std::size_t i = 0; for (MeshLib::Element* ele : ele_vec) { @@ -67,8 +72,9 @@ void ElementExtraction::searchByElementType(const std::vector<MeshLib::Element*> this->updateUnion(matchedIDs); } -void ElementExtraction::searchByZeroContent(const std::vector<MeshLib::Element*> & ele_vec) +void ElementExtraction::searchByZeroContent() { + const std::vector<MeshLib::Element*> &ele_vec (this->_mesh.getElements()); std::vector<std::size_t> matchedIDs; std::size_t i = 0; for (MeshLib::Element* ele : ele_vec) { @@ -79,8 +85,9 @@ void ElementExtraction::searchByZeroContent(const std::vector<MeshLib::Element*> this->updateUnion(matchedIDs); } -void ElementExtraction::searchByBoundingBox(const std::vector<MeshLib::Element*> & ele_vec, const MeshLib::Node &x1, const MeshLib::Node &x2) +void ElementExtraction::searchByBoundingBox(const MeshLib::Node &x1, const MeshLib::Node &x2) { + const std::vector<MeshLib::Element*> &ele_vec (this->_mesh.getElements()); std::vector<MeshLib::Node> extent; extent.push_back(x1); extent.push_back(x2); const GeoLib::AABB<MeshLib::Node> aabb(extent.begin(), extent.end()); diff --git a/MeshLib/MeshEditing/ElementExtraction.h b/MeshLib/MeshEditing/ElementExtraction.h index 30893c9223a72bc3e53a1eb620542680c143f385..1382516da856cf1d3c1b6d0da4b0f61f88a996ae 100644 --- a/MeshLib/MeshEditing/ElementExtraction.h +++ b/MeshLib/MeshEditing/ElementExtraction.h @@ -33,19 +33,19 @@ public: ~ElementExtraction(); /// Removes all mesh elements marked by search-methods. - MeshLib::Mesh* removeMeshElements() const; + MeshLib::Mesh* removeMeshElements(const std::string &new_mesh_name) const; /// Marks all elements with the given Material ID. - void searchByMaterialID(const std::vector<MeshLib::Element*> & ele_vec, unsigned matID); + void searchByMaterialID(unsigned matID); /// Marks all elements of the given element type. - void searchByElementType(const std::vector<MeshLib::Element*> & ele_vec, MeshElemType eleType); + void searchByElementType(MeshElemType eleType); /// Marks all elements with a volume smaller than std::numeric_limits<double>::epsilon(). - void searchByZeroContent(const std::vector<MeshLib::Element*> & ele_vec); + void searchByZeroContent(); /// Marks all elements with at least one node outside the bounding box spanned by x1 and x2; - void searchByBoundingBox(const std::vector<MeshLib::Element*> & ele_vec, const MeshLib::Node &x1, const MeshLib::Node &x2); + void searchByBoundingBox(const MeshLib::Node &x1, const MeshLib::Node &x2); private: diff --git a/MeshLib/MeshEnums.cpp b/MeshLib/MeshEnums.cpp index d0cb803a3ee702ca024f1f69fa07fe54548b6d13..e54bd48fbb6f2c918e755fab352189fd439f94fd 100644 --- a/MeshLib/MeshEnums.cpp +++ b/MeshLib/MeshEnums.cpp @@ -33,6 +33,25 @@ const std::string MeshElemType2String(const MeshElemType t) return "none"; } +MeshElemType CompleteString2MeshElemType(const std::string &s) +{ + if (s.compare("Line") == 0) + return MeshElemType::LINE; + if (s.compare("Quad") == 0) + return MeshElemType::QUAD; + if (s.compare("Hexahedron") == 0) + return MeshElemType::HEXAHEDRON; + if (s.compare("Triangle") == 0) + return MeshElemType::TRIANGLE; + if (s.compare("Tetrahedron") == 0) + return MeshElemType::TETRAHEDRON; + if (s.compare("Prism") == 0) + return MeshElemType::PRISM; + if (s.compare("Pyramid") == 0) + return MeshElemType::PYRAMID; + return MeshElemType::INVALID; +} + MeshElemType String2MeshElemType(const std::string &s) { if (s.compare("line") == 0) diff --git a/MeshLib/MeshEnums.h b/MeshLib/MeshEnums.h index 69950507a6a29eeb48693098624a2f81ef0ea2e9..528e5204198d89eb238724221c0d75a5829c5962 100644 --- a/MeshLib/MeshEnums.h +++ b/MeshLib/MeshEnums.h @@ -71,9 +71,12 @@ enum class MeshQualityType /// Given a MeshElemType this returns the appropriate string. const std::string MeshElemType2String(const MeshElemType t); -/// Given a string describing an element type this returns the corresponding MeshElemType. +/// Given a string of the shortened name of the element type, this returns the corresponding MeshElemType. MeshElemType String2MeshElemType(const std::string &s); +/// Given the full name of an element type this, returns the corresponding MeshElemType. +MeshElemType CompleteString2MeshElemType(const std::string &s); + const std::string MeshQualityType2String(const MeshQualityType t); #endif //MESHENUMS_H