25 for (
int model_index = 0; model_index < mesh_model.
rowCount();
28 auto const* mesh = mesh_model.
getMesh(mesh_model.
index(model_index, 0));
29 MeshList.append(QString::fromStdString(mesh->getName()));
34 MeshList.append(
"[No Mesh available.]");
35 this->expectedVoxelLabel->setText(
36 "Expected number of voxels: undefined");
41 this->allMeshView->setDragDropMode(QAbstractItemView::InternalMove);
76 QModelIndex selected = this->allMeshView->selectionModel()->currentIndex();
78 int row = selected.row();
79 if (row < list.size() - 1 && row != -1)
81 QString list_item = list[row + 1];
82 list[row + 1] = selected.data().toString();
83 list[row] = list_item;
86 this->allMeshView->selectionModel()->setCurrentIndex(
87 _layeredMeshes.index(row + 1), QItemSelectionModel::SelectCurrent);
92 QString
const xin = this->xlineEdit->text();
93 QString
const yin = this->ylineEdit->text();
94 QString
const zin = this->zlineEdit->text();
96 double const xinput = xin.toDouble();
97 double const yinput = (yin.toDouble(&ok)) ? yin.toDouble() : xin.toDouble();
98 double const zinput = (zin.toDouble(&ok)) ? zin.toDouble() : xin.toDouble();
102 this->expectedVoxelLabel->setText(
"approximated Voxel: undefined");
105 if (xin.isEmpty() || xinput == 0)
107 this->expectedVoxelLabel->setText(
"approximated Voxel: undefined");
111 std::vector<std::string> layered_meshes =
113 auto*
const mesh_top =
_mesh_model.getMesh(layered_meshes.front());
114 auto*
const mesh_bottom =
_mesh_model.getMesh(layered_meshes.back());
115 auto const& nodes_top = mesh_top->getNodes();
117 GeoLib::AABB const aabb_top(nodes_top.cbegin(), nodes_top.cend());
118 auto const& nodes_bottom = mesh_bottom->getNodes();
119 GeoLib::AABB const aabb_bottom(nodes_bottom.cbegin(), nodes_bottom.cend());
123 double const expectedVoxel = (max_b[0] - min_b[0]) * (max_b[1] - min_b[1]) *
124 (max_t[2] - min_b[2]) / xinput / yinput /
127 int const exponent = std::floor(std::log10(abs(expectedVoxel)));
128 this->expectedVoxelLabel->setText(
129 "approximated Voxel = " +
130 QString::number(std::round(expectedVoxel / std::pow(10, exponent))) +
131 " x 10^" + QString::number(exponent));
154 "Please specify the input meshes. \n At least two layers are "
155 "required to create a 3D Mesh");
159 QString
const xin = this->xlineEdit->text();
160 QString
const yin = this->ylineEdit->text();
161 QString
const zin = this->zlineEdit->text();
164 if (!xin.toDouble(&ok))
167 "At least the x-length of a voxel must be specified.\n If "
169 "are not specified, equal to 0, or not a real number, they are "
174 double const xinput = xin.toDouble();
175 double const yinput = (yin.toDouble(&ok)) ? yin.toDouble() : xin.toDouble();
176 double const zinput = (zin.toDouble(&ok)) ? zin.toDouble() : xin.toDouble();
178 std::vector<std::string> layered_meshes =
181 std::vector<const MeshLib::Mesh*> layers;
182 layers.reserve(layered_meshes.size());
184 for (
auto const& layer : layered_meshes)
189 OGSError::box(
"Input layer " + QString::fromStdString(layer) +
190 " not found. Aborting...");
193 layers.push_back(mesh);
196 bool const dilate = this->dilateBox->isChecked();
197 std::array<double, 3>
const cellsize = {xinput, yinput, zinput};
198 constexpr double minval = std::numeric_limits<double>::max();
199 constexpr double maxval = std::numeric_limits<double>::lowest();
200 std::pair<MathLib::Point3d, MathLib::Point3d> extent(
204 createVoxelFromLayeredMesh(extent, layers, cellsize, dilate));
214 this->done(QDialog::Accepted);