MCPcopy Create free account
hub / github.com/MITK/MITK / IsNewInstanceAllowed

Method IsNewInstanceAllowed

Modules/Multilabel/src/mitkLabelSuggestionHelper.cpp:260–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Calls 4

GetLabelValuesByNameMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45