| 258 | } |
| 259 | |
| 260 | bool LabelSuggestionHelper::IsNewInstanceAllowed(const MultiLabelSegmentation *segmentation, |
| 261 | const std::string_view labelName) const |
| 262 | { |
| 263 | if (segmentation == nullptr) |
| 264 | mitkThrow() << "Invalid use of IsNewInstanceAllowed. Passed segmentation pointer is null."; |
| 265 | if (labelName.empty()) |
| 266 | mitkThrow() << "Invalid use of IsNewInstanceAllowed. Passed label name is empty."; |
| 267 | |
| 268 | auto maxInstance = GetMaxInstanceOccurrence(labelName); |
| 269 | if (!maxInstance.has_value()) |
| 270 | return true; // Unlimited |
| 271 | |
| 272 | auto currentCount = segmentation->GetLabelValuesByName(labelName).size(); |
| 273 | return currentCount < maxInstance.value(); |
| 274 | } |
| 275 | |
| 276 | LabelSuggestionHelper::ConstLabelVectorType LabelSuggestionHelper::GetAllSuggestions() const |
| 277 | { |