void MeshLayerEditDialog::accept() { if (this->_edits.isEmpty()) { OGSError::box("Please specifiy the number and\n type of layers and press \"Next\""); return; } bool all_paths_set (true); if (_n_layers==0) { if (_edits[0]->text().isEmpty()) all_paths_set = false; } else { int start_idx = (_use_rasters) ? 1:0; for (int i=start_idx; i<_edits.size(); ++i) if (_edits[i]->text().isEmpty()) all_paths_set = false; } if (!all_paths_set) { OGSError::box("Please specifiy raster files for all layers."); return; } const unsigned nLayers = _layerEdit->text().toInt(); MeshLib::Mesh* new_mesh (NULL); if (nLayers==0) { new_mesh = new MeshLib::Mesh(*_msh); const std::string imgPath ( this->_edits[0]->text().toStdString() ); const double noDataReplacementValue = this->_noDataReplacementEdit->text().toDouble(); if (!MeshLib::MeshLayerMapper::layerMapping(*new_mesh, imgPath, noDataReplacementValue)) { delete new_mesh; return; } } else { if (_ogsMeshButton->isChecked()) new_mesh = this->createPrismMesh(); else new_mesh = this->createTetMesh(); } if (new_mesh) emit mshEditFinished(new_mesh); else OGSError::box("Error creating mesh"); this->done(QDialog::Accepted); }
void MeshLayerEditDialog::accept() { if (this->_edits.isEmpty()) { OGSError::box("Please specifiy the number and\n type of layers and press \"Next\""); return; } bool all_paths_set (true); if (_n_layers==0) { if (_edits[0]->text().isEmpty()) all_paths_set = false; } else { int start_idx = (_use_rasters) ? 1:0; for (int i=start_idx; i<_edits.size(); ++i) if (_edits[i]->text().isEmpty()) all_paths_set = false; } if (!all_paths_set) { OGSError::box("Please specifiy raster files for all layers."); return; } MeshLib::Mesh* new_mesh (nullptr); if (_ogsMeshButton->isChecked()) new_mesh = createPrismMesh(); else new_mesh = createTetMesh(); if (new_mesh) emit mshEditFinished(new_mesh); else OGSError::box("Error creating mesh"); this->done(QDialog::Accepted); }
void MshEditDialog::accept() { if (this->_labels.size()>0) { bool all_paths_set (true); if ((_n_layers==0) && _use_rasters && (_edits[0]->text().length()==0)) all_paths_set = false; else { int start_idx = (_use_rasters) ? 1:0; for (int i=start_idx; i<_labels.size(); ++i) if (_edits[i]->text().length()==0) all_paths_set = false; } if (all_paths_set) { int result(1); const unsigned nLayers = _layerEdit->text().toInt(); MeshLib::Mesh* new_mesh (NULL); if (nLayers==0) { new_mesh = new MeshLib::Mesh(*_msh); const std::string imgPath ( this->_edits[0]->text().toStdString() ); if (!imgPath.empty()) result = MshLayerMapper::LayerMapping(new_mesh, imgPath, nLayers, 0, _noDataDeleteBox->isChecked()); } else { std::vector<float> layer_thickness(_n_layers); for (unsigned i=0; i<nLayers; ++i) layer_thickness[i] = (_use_rasters) ? 100 : this->_edits[i]->text().toFloat(); new_mesh = MshLayerMapper::CreateLayers(_msh, layer_thickness); if (_use_rasters) { for (unsigned i=0; i<=nLayers; ++i) { const std::string imgPath ( this->_edits[i+1]->text().toStdString() ); if (!imgPath.empty()) { result = MshLayerMapper::LayerMapping(new_mesh, imgPath, nLayers, i, _noDataDeleteBox->isChecked()); if (result==0) break; } } if (this->_edits[0]->text().length()>0) { MeshLib::Mesh* final_mesh = MshLayerMapper::blendLayersWithSurface(new_mesh, nLayers, this->_edits[0]->text().toStdString()); delete new_mesh; new_mesh = final_mesh; } } } if (new_mesh) emit mshEditFinished(new_mesh); if (!new_mesh || result==0) OGSError::box("Error creating mesh"); this->done(QDialog::Accepted); } else OGSError::box("Please specifiy raster files for all layers."); } else OGSError::box("Please specifiy the number and\n type of layers and press \"Next\""); }
void MshEditDialog::accept() { int tabIndex = this->tabWidget->currentIndex(); if (tabIndex >= 0) { MeshLib::CFEMesh* new_mesh = NULL; switch (tabIndex) { case 0: { const int nLayers = atoi(this->editNLayers->text().toStdString().c_str()); const double thickness = strtod(replaceString(",", ".", this->editThickness->text().toStdString()).c_str(), 0); new_mesh = MshLayerMapper::CreateLayers(_msh, nLayers, thickness); break; } case 1: { new_mesh = new MeshLib::CFEMesh(*_msh); const size_t nLayers = _msh->getNumberOfMeshLayers(); if (nLayers==0) { const std::string imgPath ( this->_edits[0]->text().toStdString() ); if (!imgPath.empty()) MshLayerMapper::LayerMapping(new_mesh, imgPath, nLayers, 0, _noDataDeleteBox->isChecked()); } else { for (size_t i = 1; i <= nLayers+1; i++) { const std::string imgPath ( this->_edits[i]->text().toStdString() ); if (!imgPath.empty()) { int result = MshLayerMapper::LayerMapping(new_mesh, imgPath, nLayers, i-1, _noDataDeleteBox->isChecked()); if (result==0) break; } } } if (nLayers>0 && this->_edits[0]->text().length()>0) { MeshLib::CFEMesh* final_mesh = MshLayerMapper::blendLayersWithSurface(new_mesh, nLayers, this->_edits[0]->text().toStdString()); delete new_mesh; new_mesh = final_mesh; } break; } default: std::cout << "Error in MshEditDialog::accept() - No instructions found for selected tab..." << std::endl; } if (new_mesh) { std::string mshname("NewMesh"); emit mshEditFinished(new_mesh, mshname); } else OGSError::box("Error creating mesh"); } else std::cout << "Error in MshEditDialog::accept() - No tab selected... " << std::endl; this->done(QDialog::Accepted); }