Skip to content
Snippets Groups Projects
Commit c3335cc7 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[App/IO] Update for ptr version of getPropertyVec.

parent e5190055
No related branches found
No related tags found
No related merge requests found
......@@ -325,8 +325,7 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename)
MeshLib::Properties properties;
if (mat_ids.size() == elements.size())
{
boost::optional<MeshLib::PropertyVector<int> &> opt_pv
= properties.createNewPropertyVector<int>(
auto* const opt_pv = properties.createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell);
if (!opt_pv)
{
......
......@@ -244,16 +244,17 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
MeshLib::Mesh * mesh(new MeshLib::Mesh(
BaseLib::extractBaseNameWithoutExtension(fname), nodes, elements));
boost::optional<MeshLib::PropertyVector<int> &> opt_material_ids(
auto* const material_ids =
mesh->getProperties().createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell, 1)
);
if (!opt_material_ids) {
"MaterialIDs", MeshLib::MeshItemType::Cell, 1);
if (!material_ids)
{
WARN("Could not create PropertyVector for MaterialIDs in Mesh.");
} else {
MeshLib::PropertyVector<int> & material_ids(opt_material_ids.get());
material_ids.insert(material_ids.end(), materials.cbegin(),
materials.cend());
}
else
{
material_ids->insert(material_ids->end(), materials.cbegin(),
materials.cend());
}
MeshLib::ElementValueModification::condense(*mesh);
......
......@@ -781,8 +781,8 @@ bool SwmmInterface::readSwmmInputToLineMesh()
}
MeshLib::Properties props;
boost::optional< MeshLib::PropertyVector<int>& > mat_ids =
props.createNewPropertyVector<int>("MaterialIDs", MeshLib::MeshItemType::Cell, 1);
auto* const mat_ids = props.createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell, 1);
mat_ids->resize(elements.size(), 0);
for (std::size_t i=1; i<n_types; ++i)
{
......@@ -792,8 +792,8 @@ bool SwmmInterface::readSwmmInputToLineMesh()
if (nodes.size() == max_depth.size())
{
boost::optional< MeshLib::PropertyVector<double>& > depth =
props.createNewPropertyVector<double>("Max Depth", MeshLib::MeshItemType::Node, 1);
auto* const depth = props.createNewPropertyVector<double>(
"Max Depth", MeshLib::MeshItemType::Node, 1);
depth->reserve(max_depth.size());
std::copy(max_depth.cbegin(), max_depth.cend(), std::back_inserter(*depth));
}
......@@ -971,7 +971,7 @@ bool SwmmInterface::addResultsToMesh(MeshLib::Mesh &mesh, SwmmObject const swmm_
MeshLib::Properties& p = mesh.getProperties();
MeshLib::MeshItemType item_type = (swmm_type == SwmmObject::NODE) ?
MeshLib::MeshItemType::Node : MeshLib::MeshItemType::Cell;
boost::optional<MeshLib::PropertyVector<double>&> prop =
auto* const prop =
p.createNewPropertyVector<double>(vec_name, item_type, 1);
if (!prop)
{
......
......@@ -231,9 +231,8 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname,
// Transmit material values if there is any material value != 0
if (std::any_of(materials.cbegin(), materials.cend(), [](int m){ return m != 0; }))
{
boost::optional<MeshLib::PropertyVector<int>&> mat_props =
properties.createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell);
auto* const mat_props = properties.createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell);
mat_props->reserve(elements.size());
std::copy(materials.cbegin(),
materials.cend(),
......@@ -615,12 +614,14 @@ void TetGenInterface::write2dElements(std::ofstream &out,
out << nTotalTriangles << " 1\n";
const std::vector<MeshLib::Element*> &elements = mesh.getElements();
boost::optional< MeshLib::PropertyVector<int> const&> materialIds (mesh.getProperties().getPropertyVector<int>("MaterialIDs"));
auto const* const materialIds =
mesh.getProperties().getPropertyVector<int>("MaterialIDs");
const std::size_t nElements (elements.size());
unsigned element_count(0);
for (std::size_t i=0; i<nElements; ++i)
{
std::string matId = (materialIds) ? std::to_string((*materialIds)[i]) : "";
std::string matId =
materialIds ? std::to_string((*materialIds)[i]) : "";
this->writeElementToFacets(out, *elements[i], element_count, matId);
}
}
......@@ -638,7 +639,8 @@ void TetGenInterface::write3dElements(std::ofstream &out,
const std::streamoff before_elems_pos (out.tellp());
const unsigned n_spaces (static_cast<unsigned>(std::floor(log(nElements*8))) + 1);
out << std::string(n_spaces, ' ') << " 1\n";
boost::optional< MeshLib::PropertyVector<int> const&> materialIds = mesh.getProperties().getPropertyVector<int>("MaterialIDs");
auto const* const materialIds =
mesh.getProperties().getPropertyVector<int>("MaterialIDs");
unsigned element_count(0);
for (std::size_t i=0; i<nElements; ++i)
{
......@@ -646,7 +648,8 @@ void TetGenInterface::write3dElements(std::ofstream &out,
continue;
const unsigned nFaces (elements[i]->getNumberOfNeighbors());
std::string const mat_id_str = (materialIds) ? std::to_string((*materialIds)[i]) : "";
std::string const mat_id_str =
materialIds ? std::to_string((*materialIds)[i]) : "";
for (std::size_t j=0; j<nFaces; ++j)
{
MeshLib::Element const*const neighbor ( elements[i]->getNeighbor(j) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment