Skip to content
Snippets Groups Projects
Commit fa26adf1 authored by Tom Fischer's avatar Tom Fischer Committed by Dmitri Naumov
Browse files

[A/DE] Use new {exists,get}PropertyVector.

This versions check if the PropertyVector is
assigned to the requested mesh item type and has
the required number of components.
parent afe82275
No related branches found
No related tags found
No related merge requests found
......@@ -97,22 +97,23 @@ 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);
auto const* const node_id_pv =
surface_mesh->getProperties().getPropertyVector<int>(prop_name);
if (!node_id_pv)
MeshLib::PropertyVector<int> const* node_id_pv = nullptr;
try
{
ERR(
"Need subsurface node ids, but the property \"%s\" is not "
"available.",
prop_name.c_str());
node_id_pv = surface_mesh->getProperties().getPropertyVector<int>(
prop_name, MeshLib::MeshItemType::Node, 1);
}
catch (std::runtime_error const& e)
{
WARN("%s", e.what());
return _direct_values;
}
_direct_values.reserve(nNodes);
for (std::size_t i=0; i<nNodes; ++i)
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);
val = (val == no_data) ? 0 : ((val * node_area_vec[i]) / scaling);
_direct_values.emplace_back((*node_id_pv)[i], val);
}
......
......@@ -65,9 +65,11 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid,
auto* typeItem = new TreeItem(typeData, elemItem);
elemItem->appendChild(typeItem);
MeshLib::PropertyVector<int> const*const mat_ids =
mesh->getProperties().existsPropertyVector<int>("MaterialIDs")
? mesh->getProperties().getPropertyVector<int>("MaterialIDs")
MeshLib::PropertyVector<int> const* const mat_ids =
mesh->getProperties().existsPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell, 1)
? mesh->getProperties().getPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell, 1)
: nullptr;
QString matIdString = !mat_ids ? QString("not defined") : QString::number((*mat_ids)[elem->getID()]);
QList<QVariant> materialData;
......
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