16#include <QStringListModel>
28 : QDialog(parent), _mesh_model(mesh_model)
33 for (
int model_index = 0; model_index < mesh_model.
rowCount();
36 auto const* mesh = mesh_model.
getMesh(mesh_model.
index(model_index, 0));
37 MeshList.append(QString::fromStdString(mesh->getName()));
42 MeshList.append(
"[No Mesh available.]");
43 this->expectedVoxelLabel->setText(
44 "Expected number of voxels: undefined");
49 this->allMeshView->setDragDropMode(QAbstractItemView::InternalMove);
54 QModelIndex
const selected =
55 this->allMeshView->selectionModel()->currentIndex();
68 QModelIndex selected = this->allMeshView->selectionModel()->currentIndex();
70 int row = selected.row();
73 QString list_item = list[row - 1];
74 list[row - 1] = selected.data().toString();
75 list[row] = list_item;
78 this->allMeshView->selectionModel()->setCurrentIndex(
79 _layeredMeshes.index(row - 1), QItemSelectionModel::SelectCurrent);
84 QModelIndex selected = this->allMeshView->selectionModel()->currentIndex();
86 int row = selected.row();
87 if (row < list.size() - 1 && row != -1)
89 QString list_item = list[row + 1];
90 list[row + 1] = selected.data().toString();
91 list[row] = list_item;
94 this->allMeshView->selectionModel()->setCurrentIndex(
95 _layeredMeshes.index(row + 1), QItemSelectionModel::SelectCurrent);
100 QString
const xin = this->xlineEdit->text();
101 QString
const yin = this->ylineEdit->text();
102 QString
const zin = this->zlineEdit->text();
104 double const xinput = xin.toDouble();
105 double const yinput = (yin.toDouble(&ok)) ? yin.toDouble() : xin.toDouble();
106 double const zinput = (zin.toDouble(&ok)) ? zin.toDouble() : xin.toDouble();
110 this->expectedVoxelLabel->setText(
"approximated Voxel: undefined");
113 if (xin.isEmpty() || xinput == 0)
115 this->expectedVoxelLabel->setText(
"approximated Voxel: undefined");
119 std::vector<std::string> layered_meshes =
123 auto const& nodes_top = mesh_top->
getNodes();
125 GeoLib::AABB const aabb_top(nodes_top.cbegin(), nodes_top.cend());
126 auto const& nodes_bottom = mesh_bottom->getNodes();
127 GeoLib::AABB const aabb_bottom(nodes_bottom.cbegin(), nodes_bottom.cend());
131 double const expectedVoxel = (max_b[0] - min_b[0]) * (max_b[1] - min_b[1]) *
132 (max_t[2] - min_b[2]) / xinput / yinput /
135 int const exponent = std::floor(std::log10(abs(expectedVoxel)));
136 this->expectedVoxelLabel->setText(
137 "approximated Voxel = " +
138 QString::number(std::round(expectedVoxel / std::pow(10, exponent))) +
139 " x 10^" + QString::number(exponent));
162 "Please specify the input meshes. \n At least two layers are "
163 "required to create a 3D Mesh");
167 QString
const xin = this->xlineEdit->text();
168 QString
const yin = this->ylineEdit->text();
169 QString
const zin = this->zlineEdit->text();
172 if (!xin.toDouble(&ok))
175 "At least the x-length of a voxel must be specified.\n If "
177 "are not specified, equal to 0, or not a real number, they are "
182 double const xinput = xin.toDouble();
183 double const yinput = (yin.toDouble(&ok)) ? yin.toDouble() : xin.toDouble();
184 double const zinput = (zin.toDouble(&ok)) ? zin.toDouble() : xin.toDouble();
186 std::vector<std::string> layered_meshes =
189 std::vector<const MeshLib::Mesh*> layers;
190 layers.reserve(layered_meshes.size());
192 for (
auto const& layer : layered_meshes)
197 OGSError::box(
"Input layer " + QString::fromStdString(layer) +
198 " not found. Aborting...");
201 layers.push_back(mesh);
204 bool const dilate = this->dilateBox->isChecked();
205 std::array<double, 3>
const cellsize = {xinput, yinput, zinput};
206 constexpr double minval = std::numeric_limits<double>::max();
207 constexpr double maxval = std::numeric_limits<double>::lowest();
208 std::pair<MathLib::Point3d, MathLib::Point3d> extent(
212 createVoxelFromLayeredMesh(extent, layers, cellsize, dilate));
222 this->done(QDialog::Accepted);
Definition of the AABB class.
Definition of the Layers2GridDialog class.
Definition of the MeshModel class.
Definition of the Mesh class.
Definition of the Node class.
Implementation of the StrictDoubleValidator class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Eigen::Vector3d const & getMaxPoint() const
Eigen::Vector3d const & getMinPoint() const
void on_xlineEdit_textChanged()
void on_upOrderButton_pressed()
Instructions if the "↑"-button has been pressed.
void on_zlineEdit_textChanged()
void on_downOrderButton_pressed()
Instructions if the "↓"-button has been pressed.
void on_ylineEdit_textChanged()
void on_deleteMeshButton_pressed()
Instructions if the ">>" button has been pressed.
void accept() override
Instructions if the OK-Button has been pressed.
void on_orderButton_pressed()
Instructions if the "order mesh"-button has been pressed.
QStringListModel _layeredMeshes
Layers2GridDialog(MeshModel &mesh_model, QDialog *parent=nullptr)
void updateExpectedVoxel()
As the x/y/z input changes an estimation of the expected Voxel is given.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
void addMesh(std::unique_ptr< MeshLib::Mesh > mesh)
Adds a new mesh.
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
static void box(const QString &e)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
std::vector< std::string > getSelectedObjects(QStringList const &list)