diff --git a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp index d2e8ee3bafb8fdaa7a39e68221ca6e4dedab1bac..a3ec23d3bd5ab30d1ef0b4596d0a120c41dc8bb4 100644 --- a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp +++ b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp @@ -256,10 +256,10 @@ void CreateStructuredGridDialog::accept() return; } - boost::optional<MeshLib::PropertyVector<int>&> mat_ids ( - mesh->getProperties().createNewPropertyVector<int>("MaterialIDs", MeshLib::MeshItemType::Cell)); - mat_ids->reserve(mesh->getNumberOfElements()); - std::fill_n(std::back_inserter(*mat_ids), mesh->getNumberOfElements(), 0); + auto* const mat_ids = mesh->getProperties().createNewPropertyVector<int>( + "MaterialIDs", MeshLib::MeshItemType::Cell); + assert(mat_ids != nullptr); + mat_ids->resize(mesh->getNumberOfElements()); emit meshAdded(mesh); this->done(QDialog::Accepted); } diff --git a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp index cb3b05e3fdf5b5ec1f32a0d86d3b802e21ac5d50..ed179ccbd6e9cbf5b23d62f10f53edef611b561d 100644 --- a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp +++ b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp @@ -97,9 +97,10 @@ const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::di const std::size_t nNodes(surface_mesh->getNumberOfNodes()); const double no_data(raster->getHeader().no_data); - boost::optional<MeshLib::PropertyVector<int>&> const opt_node_id_pv( - surface_mesh->getProperties().getPropertyVector<int>(prop_name)); - if (!opt_node_id_pv) { + auto const* const node_id_pv = + surface_mesh->getProperties().getPropertyVector<int>(prop_name); + if (!node_id_pv) + { ERR( "Need subsurface node ids, but the property \"%s\" is not " "available.", @@ -107,13 +108,13 @@ const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::di return _direct_values; } - MeshLib::PropertyVector<int> const& node_id_pv(*opt_node_id_pv); _direct_values.reserve(nNodes); for (std::size_t i=0; i<nNodes; ++i) { double val(raster->getValueAtPoint(*surface_nodes[i])); val = (val == no_data) ? 0 : ((val*node_area_vec[i])/scaling); - _direct_values.push_back(std::pair<std::size_t, double>(node_id_pv[i], val)); + _direct_values.push_back( + std::pair<std::size_t, double>((*node_id_pv)[i], val)); } return _direct_values; diff --git a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp index 8c672a97030e1d2e6e0e18fa54697100209eb939..c2e37d1cf8a9449e2b4eeb1de3aea0366ef61ae1 100644 --- a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp @@ -171,20 +171,25 @@ void MeshElementRemovalDialog::on_materialIDCheckBox_toggled(bool is_checked) materialListWidget->clear(); _matIDIndex = _currentIndex; auto mesh = _project.getMesh(meshNameComboBox->currentText().toStdString()); - auto const opt_mat_ids = mesh->getProperties().getPropertyVector<int>("MaterialIDs"); - if (!opt_mat_ids) { + auto const* const mat_ids = + mesh->getProperties().getPropertyVector<int>("MaterialIDs"); + if (!mat_ids) + { INFO("Properties \"MaterialIDs\" not found in the mesh \"%s\".", mesh->getName().c_str()); return; } - auto const& mat_ids = opt_mat_ids.get(); - if (mat_ids.size() != mesh->getNumberOfElements()) { - INFO("Size mismatch: Properties \"MaterialIDs\" contains %u values," - " the mesh \"%s\" contains %u elements.", mat_ids.size(), - mesh->getName().c_str(), mesh->getNumberOfElements()); + if (mat_ids->size() != mesh->getNumberOfElements()) + { + INFO( + "Size mismatch: Properties \"MaterialIDs\" contains %u values," + " the mesh \"%s\" contains %u elements.", + mat_ids->size(), mesh->getName().c_str(), + mesh->getNumberOfElements()); return; } - auto max_material = std::max_element(mat_ids.cbegin(), mat_ids.cend()); + auto max_material = + std::max_element(mat_ids->cbegin(), mat_ids->cend()); for (unsigned i=0; i <= static_cast<unsigned>(*max_material); ++i) materialListWidget->addItem(QString::number(i)); @@ -200,7 +205,8 @@ void MeshElementRemovalDialog::on_meshNameComboBox_currentIndexChanged(int idx) this->materialListWidget->clearSelection(); if (this->boundingBoxCheckBox->isChecked()) this->on_boundingBoxCheckBox_toggled(true); auto mesh = _project.getMesh(meshNameComboBox->currentText().toStdString()); - auto materialIds = mesh->getProperties().getPropertyVector<int>("MaterialIDs"); + auto const* const materialIds = + mesh->getProperties().getPropertyVector<int>("MaterialIDs"); if (materialIds) { if (materialIds->size() != mesh->getNumberOfElements())