51{
52 if (this->newMeshNameEdit->text().size() == 0)
53 {
55 return;
56 }
57
58 bool anything_checked(false);
59
60 const MeshLib::Mesh* msh =
61 _project.getMesh(this->meshNameComboBox->currentText().toStdString());
62 MeshLib::ElementSearch ex(*msh);
63 if (this->elementTypeCheckBox->isChecked())
64 {
65 QList<QListWidgetItem*> items =
66 this->elementTypeListWidget->selectedItems();
67 for (auto& item : items)
68 {
69 ex.searchByElementType(
71 }
72 anything_checked = true;
73 }
74 if (this->scalarArrayCheckBox->isChecked())
75 {
76 std::string const array_name =
77 this->scalarArrayComboBox->currentText().toStdString();
78 double min_val;
79 double max_val;
80 bool outside = this->outsideButton->isChecked();
81 if (outside)
82 {
83 min_val = this->outsideScalarMinEdit->text().toDouble();
84 max_val = this->outsideScalarMaxEdit->text().toDouble();
85 }
86 else
87 {
88 min_val = this->insideScalarMinEdit->text().toDouble();
89 max_val = this->insideScalarMaxEdit->text().toDouble();
90 }
91
92 std::size_t n_marked_elements(0);
94 {
95 n_marked_elements = ex.searchByPropertyValueRange<double>(
96 array_name, min_val, max_val, outside);
97 }
99 {
100 int const lbound = static_cast<int>(min_val);
101 int const rbound = static_cast<int>(max_val);
102 n_marked_elements = ex.searchByPropertyValueRange<int>(
103 array_name, lbound, rbound, outside);
104 }
105
106 if (n_marked_elements > 0)
107 {
108 anything_checked = true;
109 }
110 }
111 if (this->boundingBoxCheckBox->isChecked())
112 {
113 std::vector<MeshLib::Node*> const& nodes(
115 .getMesh(this->meshNameComboBox->currentText().toStdString())
116 ->getNodes());
117 GeoLib::AABB const aabb(nodes.begin(), nodes.end());
118 auto [minAABB, maxAABB] = aabb.getMinMaxPoints();
119
120
121
122 minAABB[0] =
123 (
aabb_edits[0]) ? this->xMinEdit->text().toDouble() : (minAABB[0]);
124 maxAABB[0] =
125 (
aabb_edits[1]) ? this->xMaxEdit->text().toDouble() : (maxAABB[0]);
126 minAABB[1] =
127 (
aabb_edits[2]) ? this->yMinEdit->text().toDouble() : (minAABB[1]);
128 maxAABB[1] =
129 (
aabb_edits[3]) ? this->yMaxEdit->text().toDouble() : (maxAABB[1]);
130 minAABB[2] =
131 (
aabb_edits[4]) ? this->zMinEdit->text().toDouble() : (minAABB[2]);
132 maxAABB[2] =
133 (
aabb_edits[5]) ? this->zMaxEdit->text().toDouble() : (maxAABB[2]);
134 std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d>>
135 extent{minAABB, maxAABB};
136 const GeoLib::AABB updated_aabb(extent.begin(), extent.end());
137 ex.searchByBoundingBox(updated_aabb,
138 this->invertBoundingBoxCheckBox->isChecked());
139 anything_checked = true;
140 }
141
142 if (this->zeroVolumeCheckBox->isChecked())
143 {
144 ex.searchByContent();
145 anything_checked = true;
146 }
147
148 if (anything_checked)
149 {
151 *msh, ex.getSearchedElementIDs(),
152 this->newMeshNameEdit->text().toStdString());
153 if (new_mesh)
154 {
156 }
157 else
158 {
159 if (ex.getSearchedElementIDs().empty())
160 {
162 "The current selection removes NO mesh elements.");
163 }
164 return;
165 }
166 }
167 else
168 {
170 return;
171 }
172
173 this->done(QDialog::Accepted);
174}
void meshAdded(MeshLib::Mesh *mesh)
std::array< bool, 6 > aabb_edits
Properties & getProperties()
bool existsPropertyVector(std::string_view name) const
MeshElemType String2MeshElemType(const std::string &s)
Given a string of the shortened name of the element type, this returns the corresponding MeshElemType...