| 565 | } |
| 566 | |
| 567 | void mitk::MultiLabelSegmentation::ReplaceLabels(const ConstLabelVectorType& newLabels) |
| 568 | { |
| 569 | for (auto& label : newLabels) |
| 570 | { |
| 571 | if (!this->ExistLabel(label->GetValue())) |
| 572 | { |
| 573 | mitkThrow() << "Trying to replace unknown label. Invalid label value: " << label->GetValue(); |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | { |
| 578 | std::lock_guard<std::shared_mutex> guard(m_LabelNGroupMapsMutex); |
| 579 | |
| 580 | for (auto label : newLabels) |
| 581 | { |
| 582 | auto clonedLabel = label->Clone(); |
| 583 | |
| 584 | this->ReleaseLabel(m_LabelMap[label->GetValue()]); |
| 585 | m_LabelMap[label->GetValue()] = clonedLabel; |
| 586 | this->RegisterLabel(clonedLabel); |
| 587 | clonedLabel->Modified(); //indicate a modification for the label as the |
| 588 | //replacement has overwritten old values |
| 589 | //e.g. relevant for the QmitkMultiLabelTreeModel |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | this->InvokeEvent(LabelsChangedEvent(ExtractLabelValuesFromLabelVector(newLabels))); |
| 594 | this->Modified(); |
| 595 | } |
| 596 | |
| 597 | void mitk::MultiLabelSegmentation::ReplaceLabels(const LabelVectorType& newLabels) |
| 598 | { |
no test coverage detected