diff --git a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp index a801c0f3db2e47c109d14c72b4baf08bf037e7f9..7db648a40673c829cf4dc5991fa0133e3dc4dfd8 100644 --- a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp +++ b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp @@ -79,17 +79,15 @@ template <typename PT> void resetMeshElementProperty(MeshLib::Mesh &mesh, GeoLib::Polygon const& polygon, std::string const& property_name, PT new_property_value) { - boost::optional<MeshLib::PropertyVector<PT> &> opt_pv( - mesh.getProperties().getPropertyVector<PT>(property_name) - ); - if (!opt_pv) { + auto* const pv = mesh.getProperties().getPropertyVector<PT>(property_name); + if (!pv) { WARN("Did not find a PropertyVector with name \"%s\".", property_name.c_str()); return; } - MeshLib::PropertyVector<PT> & pv(opt_pv.get()); - if (pv.getMeshItemType() != MeshLib::MeshItemType::Cell) { + if (pv->getMeshItemType() != MeshLib::MeshItemType::Cell) + { ERR("Values of the PropertyVector are not assigned to cells."); return; } @@ -108,7 +106,7 @@ void resetMeshElementProperty(MeshLib::Mesh &mesh, GeoLib::Polygon const& polygo } } if (!elem_out) { - pv[j] = new_property_value; + (*pv)[j] = new_property_value; } } } @@ -206,14 +204,14 @@ int main (int argc, char* argv[]) char new_property_val(char_property_arg.getValue()); // check if PropertyVector exists - boost::optional<MeshLib::PropertyVector<char> &> opt_pv( - mesh->getProperties().getPropertyVector<char>(property_name) - ); - if (!opt_pv) { - opt_pv = mesh->getProperties().createNewPropertyVector<char>( + auto* pv = mesh->getProperties().getPropertyVector<char>(property_name); + if (!pv) + { + pv = mesh->getProperties().createNewPropertyVector<char>( property_name, MeshLib::MeshItemType::Cell, 1); - opt_pv.get().resize(mesh->getElements().size()); - INFO("Created PropertyVector with name \"%s\".", property_name.c_str()); + pv->resize(mesh->getElements().size()); + INFO("Created PropertyVector with name \"%s\".", + property_name.c_str()); } resetMeshElementProperty(*mesh, polygon, property_name, new_property_val); } @@ -222,13 +220,12 @@ int main (int argc, char* argv[]) int int_property_val(int_property_arg.getValue()); // check if PropertyVector exists - boost::optional<MeshLib::PropertyVector<int> &> opt_pv( - mesh->getProperties().getPropertyVector<int>(property_name) - ); - if (!opt_pv) { - opt_pv = mesh->getProperties().createNewPropertyVector<int>( + auto* pv = mesh->getProperties().getPropertyVector<int>(property_name); + if (!pv) + { + pv = mesh->getProperties().createNewPropertyVector<int>( property_name, MeshLib::MeshItemType::Cell, 1); - opt_pv.get().resize(mesh->getElements().size()); + pv->resize(mesh->getElements().size()); INFO("Created PropertyVector with name \"%s\".", property_name.c_str()); } diff --git a/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp b/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp index 0cc67a81c92a0297671e5f8c197fa4fc54ccd18e..c0d8fc0eea880fb28f7ecda148e2e6542bc558a6 100644 --- a/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp +++ b/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp @@ -83,21 +83,22 @@ int main (int argc, char* argv[]) // ToDo check if mesh is read correct and if the mesh is a surface mesh // check if a node property containing the subsurface ids is available - boost::optional<MeshLib::PropertyVector<std::size_t>&> orig_node_ids( + auto* orig_node_ids = surface_mesh->getProperties().getPropertyVector<std::size_t>( - id_prop_name.getValue())); + id_prop_name.getValue()); // if the node property is not available generate it - if (!orig_node_ids) { - boost::optional<MeshLib::PropertyVector<std::size_t>&> node_ids( + if (!orig_node_ids) + { + orig_node_ids = surface_mesh->getProperties().createNewPropertyVector<std::size_t>( - id_prop_name.getValue(), MeshLib::MeshItemType::Node, 1)); - if (!node_ids) { + id_prop_name.getValue(), MeshLib::MeshItemType::Node, 1); + if (!orig_node_ids) + { ERR("Fatal error: could not create property."); return EXIT_FAILURE; } - node_ids->resize(surface_mesh->getNumberOfNodes()); - std::iota(node_ids->begin(), node_ids->end(), 0); - orig_node_ids = node_ids; + orig_node_ids->resize(surface_mesh->getNumberOfNodes()); + std::iota(orig_node_ids->begin(), orig_node_ids->end(), 0); } std::vector<double> areas( diff --git a/Applications/Utils/ModelPreparation/createNeumannBc.cpp b/Applications/Utils/ModelPreparation/createNeumannBc.cpp index 15400f60a58166469a784e92b4cecba391f441fc..bfb4f8b70d1911f49aef32970aa8fe3505dff8b6 100644 --- a/Applications/Utils/ModelPreparation/createNeumannBc.cpp +++ b/Applications/Utils/ModelPreparation/createNeumannBc.cpp @@ -38,8 +38,8 @@ std::vector<double> getSurfaceIntegratedValuesForNodes( return std::vector<double>(); } - boost::optional<MeshLib::PropertyVector<double> const&> elem_pv( - mesh.getProperties().getPropertyVector<double>(prop_name)); + auto const* const elem_pv = + mesh.getProperties().getPropertyVector<double>(prop_name); if (!elem_pv) { ERR("Need element property, but the property \"%s\" is not " @@ -131,9 +131,8 @@ int main(int argc, char* argv[]) MeshLib::IO::readMeshFromFile(in_mesh.getValue())); std::string const prop_name("OriginalSubsurfaceNodeIDs"); - boost::optional<MeshLib::PropertyVector<std::size_t>&> const node_id_pv( - surface_mesh->getProperties().getPropertyVector<std::size_t>( - prop_name)); + auto const* const node_id_pv = + surface_mesh->getProperties().getPropertyVector<std::size_t>(prop_name); if (!node_id_pv) { ERR( @@ -156,10 +155,10 @@ int main(int argc, char* argv[]) direct_values.push_back(std::make_pair(subsurface_node_id, val)); } - boost::optional<MeshLib::PropertyVector<double>&> pv( + auto* const pv = surface_mesh->getProperties().createNewPropertyVector<double>( - property_out_arg.getValue(), MeshLib::MeshItemType::Node, 1)); - (*pv).resize(surface_mesh->getNodes().size()); + property_out_arg.getValue(), MeshLib::MeshItemType::Node, 1); + pv->resize(surface_mesh->getNodes().size()); for (std::size_t k(0); k<surface_mesh->getNodes().size(); ++k) { (*pv)[k] = direct_values[k].second; }