17 #include <Eigen/StdVector>
19 #include <QListWidgetItem>
38 _aabbIndex(std::numeric_limits<unsigned>::max()),
39 _scalarIndex(std::numeric_limits<unsigned>::max())
45 const std::size_t nMeshes(mesh_vec.size());
46 for (std::size_t i = 0; i < nMeshes; ++i)
48 std::string
name = mesh_vec[i]->getName();
49 this->meshNameComboBox->addItem(QString::fromStdString(
name));
55 QMetaObject::invokeMethod(
this,
"close", Qt::QueuedConnection);
63 if (this->newMeshNameEdit->text().size() == 0)
69 bool anything_checked(
false);
74 if (this->elementTypeCheckBox->isChecked())
76 QList<QListWidgetItem*> items =
77 this->elementTypeListWidget->selectedItems();
78 for (
auto& item : items)
83 anything_checked =
true;
85 if (this->scalarArrayCheckBox->isChecked())
87 std::string
const array_name =
88 this->scalarArrayComboBox->currentText().toStdString();
91 bool outside = this->outsideButton->isChecked();
94 min_val = this->outsideScalarMinEdit->text().toDouble();
95 max_val = this->outsideScalarMaxEdit->text().toDouble();
99 min_val = this->insideScalarMinEdit->text().toDouble();
100 max_val = this->insideScalarMaxEdit->text().toDouble();
103 std::size_t n_marked_elements(0);
107 array_name, min_val, max_val, outside);
111 int const lbound =
static_cast<int>(min_val);
112 int const rbound =
static_cast<int>(max_val);
114 array_name, lbound, rbound, outside);
117 if (n_marked_elements > 0)
119 anything_checked =
true;
122 if (this->boundingBoxCheckBox->isChecked())
124 std::vector<MeshLib::Node*>
const& nodes(
126 .getMesh(this->meshNameComboBox->currentText().toStdString())
135 (
aabb_edits[0]) ? this->xMinEdit->text().toDouble() : (minAABB[0]);
137 (
aabb_edits[1]) ? this->xMaxEdit->text().toDouble() : (maxAABB[0]);
139 (
aabb_edits[2]) ? this->yMinEdit->text().toDouble() : (minAABB[1]);
141 (
aabb_edits[3]) ? this->yMaxEdit->text().toDouble() : (maxAABB[1]);
143 (
aabb_edits[4]) ? this->zMinEdit->text().toDouble() : (minAABB[2]);
145 (
aabb_edits[5]) ? this->zMaxEdit->text().toDouble() : (maxAABB[2]);
146 std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d>>
147 extent{minAABB, maxAABB};
148 const GeoLib::AABB updated_aabb(extent.begin(), extent.end());
150 anything_checked =
true;
153 if (this->zeroVolumeCheckBox->isChecked())
156 anything_checked =
true;
159 if (anything_checked)
163 this->newMeshNameEdit->text().toStdString());
173 "The current selection removes NO mesh elements.");
184 this->done(QDialog::Accepted);
189 this->done(QDialog::Rejected);
201 this->scalarArrayComboBox->addItem(QString::fromStdString(
name));
204 return this->scalarArrayComboBox->count();
209 this->scalarArrayComboBox->setEnabled(enable);
210 this->outsideButton->setEnabled(enable);
211 this->insideButton->setEnabled(enable);
212 this->outsideScalarMinEdit->setEnabled(enable &&
213 this->outsideButton->isChecked());
214 this->outsideScalarMaxEdit->setEnabled(enable &&
215 this->outsideButton->isChecked());
216 this->insideScalarMinEdit->setEnabled(enable &&
217 this->insideButton->isChecked());
218 this->insideScalarMaxEdit->setEnabled(enable &&
219 this->insideButton->isChecked());
224 this->outsideScalarMinEdit->setEnabled(outside);
225 this->outsideScalarMaxEdit->setEnabled(outside);
226 this->insideScalarMinEdit->setEnabled(!outside);
227 this->insideScalarMaxEdit->setEnabled(!outside);
237 this->xMinEdit->setEnabled(is_checked);
238 this->xMaxEdit->setEnabled(is_checked);
239 this->yMinEdit->setEnabled(is_checked);
240 this->yMaxEdit->setEnabled(is_checked);
241 this->zMinEdit->setEnabled(is_checked);
242 this->zMaxEdit->setEnabled(is_checked);
247 std::vector<MeshLib::Node*>
const& nodes(
249 .getMesh(this->meshNameComboBox->currentText().toStdString())
254 this->xMinEdit->setText(QString::number(minAABB[0],
'f'));
255 this->xMaxEdit->setText(QString::number(maxAABB[0],
'f'));
256 this->yMinEdit->setText(QString::number(minAABB[1],
'f'));
257 this->yMaxEdit->setText(QString::number(maxAABB[1],
'f'));
258 this->zMinEdit->setText(QString::number(minAABB[2],
'f'));
259 this->zMaxEdit->setText(QString::number(maxAABB[2],
'f'));
266 this->elementTypeListWidget->setEnabled(is_checked);
294 this->
_currentIndex = this->meshNameComboBox->currentIndex();
295 this->newMeshNameEdit->setText(this->meshNameComboBox->currentText() +
297 this->elementTypeListWidget->clearSelection();
298 this->scalarArrayComboBox->clear();
299 this->outsideScalarMinEdit->setText(
"");
300 this->outsideScalarMaxEdit->setText(
"");
301 this->insideScalarMinEdit->setText(
"");
302 this->insideScalarMaxEdit->setText(
"");
311 std::string
const vec_name(
312 scalarArrayComboBox->currentText().toStdString());
313 if (vec_name.empty())
336 template <
typename T>
340 auto min = std::min_element(vec.cbegin(), vec.cend());
341 auto max = std::max_element(vec.cbegin(), vec.cend());
342 this->outsideScalarMinEdit->setText(QString::number(*min));
343 this->outsideScalarMaxEdit->setText(QString::number(*max));
344 this->insideScalarMinEdit->setText(QString::number(*min));
345 this->insideScalarMaxEdit->setText(QString::number(*max));
Definition of the AABB class.
Definition of the Element class.
Definition of the MeshElementRemovalDialog class.
Definition of the class Properties that implements a container of properties.
Definition of the Mesh class.
Definition of the Node class.
Definition of the OGSError class.
const std::vector< std::unique_ptr< MeshLib::Mesh > > & getMeshObjects() const
Returns all the meshes with their respective names.
const MeshLib::Mesh * getMesh(const std::string &name) const
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Eigen::Vector3d const & getMinPoint() const
Eigen::Vector3d const & getMaxPoint() const
~MeshElementRemovalDialog() override
void setRangeValues(MeshLib::PropertyVector< T > const &vec)
void on_elementTypeCheckBox_toggled(bool is_checked)
MeshElementRemovalDialog(DataHolderLib::Project const &project, QDialog *parent=nullptr)
Constructor.
void toggleScalarEdits(bool outside) const
DataHolderLib::Project const & _project
void on_insideButton_toggled(bool is_checked)
void on_meshNameComboBox_currentIndexChanged(int idx)
void meshAdded(MeshLib::Mesh *mesh)
void on_scalarArrayCheckBox_toggled(bool is_checked)
void on_scalarArrayComboBox_currentIndexChanged(int idx)
std::size_t addScalarArrays(MeshLib::Mesh const &mesh) const
void enableScalarArrayWidgets(bool enable) const
std::array< bool, 6 > aabb_edits
void on_boundingBoxCheckBox_toggled(bool is_checked)
std::size_t searchByElementType(MeshElemType eleType)
Marks all elements of the given element type.
std::size_t searchByPropertyValueRange(std::string const &property_name, PROPERTY_TYPE const min_property_value, PROPERTY_TYPE const max_property_value, bool outside_of)
std::size_t searchByContent(double eps=std::numeric_limits< double >::epsilon())
Marks all elements with a volume smaller than eps.
std::size_t searchByBoundingBox(GeoLib::AABB const &aabb)
Marks all elements with at least one node outside the bounding box spanned by x1 and x2;.
const std::vector< std::size_t > & getSearchedElementIDs() const
return marked elements
Properties & getProperties()
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
PropertyVector< T > const * getPropertyVector(std::string const &name) const
bool existsPropertyVector(std::string const &name) const
static void box(const QString &e)
MeshLib::Mesh * removeElements(const MeshLib::Mesh &mesh, const std::vector< std::size_t > &removed_element_ids, const std::string &new_mesh_name)
MeshElemType String2MeshElemType(const std::string &s)
Given a string of the shortened name of the element type, this returns the corresponding MeshElemType...