18#include <QDoubleValidator>
19#include <QElapsedTimer>
24#include <QIntValidator>
27#include <QRadioButton>
44 _layerEdit(new QLineEdit(
"1", this)),
45 _noDataReplacementEdit(nullptr),
46 _minThicknessEdit(nullptr),
47 _nextButton(new QPushButton(
"Next", this)),
49 _radioButtonBox(nullptr),
50 _ogsMeshButton(nullptr),
51 _layerSelectionLayout(new QGridLayout(_layerBox)),
56 this->gridLayoutLayerMapping->addWidget(
57 new QLabel(
"Please specify the number of layers to add:",
this), 0, 0);
58 this->gridLayoutLayerMapping->addWidget(
_layerEdit, 0, 1);
59 this->gridLayoutLayerMapping->addWidget(
_nextButton, 0, 2);
79 OGSError::box(
"Add the number of layers to add (at least 1)");
87 QRadioButton* selectButton1(
89 QRadioButton* selectButton2(
92 _radiobuttonLayout->addWidget(selectButton1);
93 _radiobuttonLayout->addWidget(selectButton2);
97 connect(selectButton2, SIGNAL(pressed()),
this, SLOT(
createStatic()));
104 const QString selectText =
105 (
_n_layers > 0) ?
"Please specify a raster file for mapping each layer:"
106 :
"Please specify raster file for surface mapping:";
110 for (
unsigned i = 0; i <=
_n_layers; ++i)
119 text =
"Layer" + QString::number(
_n_layers) +
"-Bottom";
123 text =
"Layer" + QString::number(i + 1) +
"-Top";
125 auto* edit(
new QLineEdit(
this));
126 QPushButton* button(
new QPushButton(
"...",
_layerBox));
128 this->
_edits.push_back(edit);
130 connect(button, SIGNAL(clicked()),
this, SLOT(
getFileName()));
138 this->gridLayoutLayerMapping->addWidget(
_layerBox, 4, 0, 1, 3);
150 this->
_layerBox->setTitle(
"Please specify a thickness or each layer");
152 for (
unsigned i = 0; i < this->
_n_layers; ++i)
154 QString text(
"Layer" + QString::number(i) +
"-Thickness");
155 QLineEdit* staticLayerEdit =
new QLineEdit(
"10",
this);
156 staticLayerEdit->setValidator(
new QDoubleValidator(staticLayerEdit));
157 _edits.push_back(staticLayerEdit);
163 this->gridLayoutLayerMapping->addWidget(
_layerBox, 4, 0, 1, 3);
169 auto* meshToolSelectionBox(
new QGroupBox(
this));
170 meshToolSelectionBox->setTitle(
"Output element type");
171 auto* meshToolSelectionLayout(
new QGridLayout(meshToolSelectionBox));
172 _ogsMeshButton =
new QRadioButton(
"Prisms", meshToolSelectionBox);
173 QRadioButton* tetgenMeshButton =
174 new QRadioButton(
"Tetrahedra", meshToolSelectionBox);
175 tetgenMeshButton->setFixedWidth(150);
176 auto* minThicknessLabel =
new QLabel(meshToolSelectionBox);
177 minThicknessLabel->setText(
"Minimum thickness of layers:");
180 auto* min_thickness_validator =
186 meshToolSelectionLayout->addWidget(tetgenMeshButton, 0, 1);
187 meshToolSelectionLayout->addWidget(minThicknessLabel, 1, 0);
189 meshToolSelectionBox->setLayout(meshToolSelectionLayout);
192 gridLayoutLayerMapping->addWidget(meshToolSelectionBox, 5, 0, 1, 3);
197 const unsigned nLayers =
_layerEdit->text().toInt();
201 QElapsedTimer myTimer0;
206 if (minimum_thickness <= 0)
208 minimum_thickness = std::numeric_limits<float>::epsilon();
210 std::vector<std::string> raster_paths;
211 for (
int i = nLayers; i >= 0; --i)
213 raster_paths.push_back(this->
_edits[i]->text().toStdString());
219 INFO(
"Mesh construction time: {:d} ms.", myTimer0.elapsed());
220 return mapper.
getMesh(
"SubsurfaceMesh").release();
225 std::vector<float> layer_thickness;
226 for (
unsigned i = 0; i < nLayers; ++i)
228 layer_thickness.push_back(this->
_edits[i]->text().toFloat());
230 INFO(
"Mesh construction time: {:d} ms.", myTimer0.elapsed());
238 QString filename = QFileDialog::getSaveFileName(
239 this,
"Write TetGen input file to",
240 settings.value(
"lastOpenedTetgenFileDirectory").toString(),
241 "TetGen Geometry (*.smesh)");
242 if (filename.isEmpty())
247 const unsigned nLayers =
_layerEdit->text().toInt();
249 QElapsedTimer myTimer0;
255 if (minimum_thickness <= 0)
257 minimum_thickness = std::numeric_limits<float>::epsilon();
259 std::vector<std::string> raster_paths;
260 for (
int i = nLayers; i >= 0; --i)
262 raster_paths.push_back(this->
_edits[i]->text().toStdString());
269 tg_mesh = lv.
getMesh(
"SubsurfaceMesh").release();
282 std::vector<float> layer_thickness;
283 for (
unsigned i = 0; i < nLayers; ++i)
285 layer_thickness.push_back(this->
_edits[i]->text().toFloat());
288 *
_msh, layer_thickness);
289 std::vector<MeshLib::Node> tg_attr;
294 INFO(
"Mesh construction time: {:d} ms.", myTimer0.elapsed());
301 if (this->
_edits.isEmpty())
304 "Please specify the number and\n type of layers and press 'Next'");
308 bool all_paths_set(
true);
311 if (
_edits[0]->text().isEmpty())
313 all_paths_set =
false;
319 for (
int i = start_idx; i <
_edits.size(); ++i)
321 if (
_edits[i]->text().isEmpty())
323 all_paths_set =
false;
330 OGSError::box(
"Please specify raster files for all layers.");
353 this->done(QDialog::Accepted);
358 this->done(QDialog::Rejected);
363 auto* button =
dynamic_cast<QPushButton*
>(this->sender());
365 QString filename = QFileDialog::getOpenFileName(
366 this,
"Select raster file to open",
367 settings.value(
"lastOpenedRasterFileDirectory").toString(),
368 "ASCII raster files (*.asc *.grd *.xyz);;All files (* *.*)");
370 QFileInfo fi(filename);
371 settings.setValue(
"lastOpenedRasterFileDirectory", fi.absolutePath());
Definition of the AsciiRasterInterface class.
Definition of the LayeredVolume class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the MeshLayerEditDialog class.
Definition of the Mesh class.
Definition of the OGSError class.
Definition of the TetGenInterface class.
static bool writeTetGenSmesh(const std::string &file_name, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name, const std::vector< GeoLib::Point > &attribute_points)
virtual bool createLayers(MeshLib::Mesh const &mesh, std::vector< GeoLib::Raster const * > const &rasters, double minimum_thickness, double noDataReplacementValue=0.0) final
std::unique_ptr< MeshLib::Mesh > getMesh(std::string const &mesh_name) const
Returns a mesh of the subsurface representation.
Creates a volume geometry from 2D mesh layers based on raster data.
std::vector< MeshLib::Node > getAttributePoints() const
MeshLayerEditDialog(const MeshLib::Mesh *mesh, QDialog *parent=nullptr)
~MeshLayerEditDialog() override
void mshEditFinished(MeshLib::Mesh *)
QRadioButton * _ogsMeshButton
MeshLib::Mesh * createPrismMesh()
QMap< QPushButton *, QLineEdit * > _fileButtonMap
QPushButton * _nextButton
void reject() override
Instructions if the Cancel-Button has been pressed.
MeshLib::Mesh * createTetMesh()
QGridLayout * _layerSelectionLayout
QVector< QLineEdit * > _edits
void accept() override
Instructions if the OK-Button has been pressed.
void createMeshToolSelection()
const MeshLib::Mesh * _msh
QLineEdit * _minThicknessEdit
QGroupBox * _radioButtonBox
static void box(const QString &e)
std::optional< std::vector< GeoLib::Raster const * > > readRasters(std::vector< std::string > const &raster_paths)