| 1204 | } |
| 1205 | |
| 1206 | void QmitkSlicesInterpolator::OnReinit3DInterpolation() |
| 1207 | { |
| 1208 | // Step 1. Load from the isContourPlaneGeometry nodes the contourNodes. |
| 1209 | mitk::NodePredicateProperty::Pointer pred = |
| 1210 | mitk::NodePredicateProperty::New("isContourPlaneGeometry", mitk::BoolProperty::New(true)); |
| 1211 | mitk::DataStorage::SetOfObjects::ConstPointer contourNodes = |
| 1212 | m_DataStorage->GetDerivations(m_ToolManager->GetWorkingData(0), pred); |
| 1213 | |
| 1214 | if (contourNodes->Size() != 0) |
| 1215 | { |
| 1216 | if (m_ToolManager->GetWorkingData(0) != nullptr) |
| 1217 | { |
| 1218 | try |
| 1219 | { |
| 1220 | auto labelSetImage = GetData<mitk::MultiLabelSegmentation>(m_ToolManager->GetWorkingData(0)); |
| 1221 | if (!labelSetImage->GetTimeGeometry()->IsValidTimePoint(m_TimePoint)) |
| 1222 | { |
| 1223 | MITK_ERROR << "Invalid time point requested for interpolation pipeline."; |
| 1224 | return; |
| 1225 | } |
| 1226 | |
| 1227 | mitk::SurfaceInterpolationController::CPIVector newCPIs; |
| 1228 | // Adding label and timeStep information for the contourNodes. |
| 1229 | for (auto it = contourNodes->Begin(); it != contourNodes->End(); ++it) |
| 1230 | { |
| 1231 | auto contourNode = it->Value(); |
| 1232 | auto labelID = dynamic_cast<mitk::UShortProperty *>(contourNode->GetProperty("labelID"))->GetValue(); |
| 1233 | auto timeStep = dynamic_cast<mitk::IntProperty *>(contourNode->GetProperty("timeStep"))->GetValue(); |
| 1234 | |
| 1235 | auto planeGeometry = dynamic_cast<mitk::PlanarFigure *>(contourNode->GetData())->GetPlaneGeometry(); |
| 1236 | auto groupID = labelSetImage->GetGroupIndexOfLabel(labelID); |
| 1237 | auto sliceImage = ExtractSliceFromImage(labelSetImage->GetGroupImage(groupID), planeGeometry, timeStep); |
| 1238 | mitk::ImageToContourFilter::Pointer contourExtractor = mitk::ImageToContourFilter::New(); |
| 1239 | contourExtractor->SetInput(sliceImage); |
| 1240 | contourExtractor->SetContourValue(labelID); |
| 1241 | contourExtractor->Update(); |
| 1242 | mitk::Surface::Pointer contour = contourExtractor->GetOutput(); |
| 1243 | |
| 1244 | if (contour->GetVtkPolyData()->GetNumberOfPoints() == 0) |
| 1245 | continue; |
| 1246 | |
| 1247 | contour->DisconnectPipeline(); |
| 1248 | newCPIs.emplace_back(contour, planeGeometry->Clone(),labelID,timeStep); |
| 1249 | } |
| 1250 | m_SurfaceInterpolator->CompleteReinitialization(newCPIs); |
| 1251 | } |
| 1252 | catch(const std::exception& e) |
| 1253 | { |
| 1254 | MITK_ERROR << "Exception thrown casting toolmanager working data to labelsetImage"; |
| 1255 | } |
| 1256 | } |
| 1257 | } |
| 1258 | else |
| 1259 | { |
| 1260 | m_BtnApply3D->setEnabled(false); |
| 1261 | QMessageBox errorInfo; |
| 1262 | errorInfo.setWindowTitle("Reinitialize surface interpolation"); |
| 1263 | errorInfo.setIcon(QMessageBox::Information); |
nothing calls this directly
no test coverage detected