#2127 Clamp sim well branch index to valid range

This commit is contained in:
Magne Sjaastad
2017-12-08 10:23:36 +01:00
parent 0e5e88008a
commit 46bad03c4a
6 changed files with 41 additions and 10 deletions

View File

@@ -106,3 +106,23 @@ void RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName(c
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaSimWellBranchTools::clampBranchIndex(const QString& simWellName, int branchIndexValue, bool branchDetection)
{
auto branches = RiaSimWellBranchTools::simulationWellBranches(simWellName, branchDetection);
if (branches.size() == 0)
{
return -1;
}
if (branchIndexValue >= branches.size())
{
branchIndexValue = static_cast<int>(branches.size()) - 1;
}
return branchIndexValue;
}