| 696 | } |
| 697 | |
| 698 | void mitk::SegTool2D::WriteSliceToVolume(Image* workingImage, const PlaneGeometry* planeGeometry, const Image* slice, TimeStepType timeStep) |
| 699 | { |
| 700 | if (nullptr == workingImage) |
| 701 | { |
| 702 | mitkThrow() << "Cannot write slice to working image. Working image is null."; |
| 703 | } |
| 704 | |
| 705 | if (nullptr == planeGeometry) |
| 706 | { |
| 707 | mitkThrow() << "Cannot write slice to working image. Plane geometry is null."; |
| 708 | } |
| 709 | |
| 710 | if (nullptr == slice) |
| 711 | { |
| 712 | mitkThrow() << "Cannot write slice to working image. Slice is null."; |
| 713 | } |
| 714 | |
| 715 | // Make sure that for reslicing and overwriting the same algorithm is used. We can specify the mode of the vtk |
| 716 | // reslicer |
| 717 | vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New(); |
| 718 | |
| 719 | // Set the slice as 'input' |
| 720 | // casting const away is needed and OK as long the OverwriteMode of |
| 721 | // mitkVTKImageOverwrite is true. |
| 722 | // Reason: because then the input slice is not touched but |
| 723 | // used to overwrite the input of the ExtractSliceFilter. |
| 724 | auto noneConstSlice = const_cast<Image*>(slice); |
| 725 | reslice->SetInputSlice(noneConstSlice->GetVtkImageData()); |
| 726 | |
| 727 | // set overwrite mode to true to write back to the image volume |
| 728 | reslice->SetOverwriteMode(true); |
| 729 | reslice->Modified(); |
| 730 | |
| 731 | mitk::ExtractSliceFilter::Pointer extractor = mitk::ExtractSliceFilter::New(reslice); |
| 732 | extractor->SetInput(workingImage); |
| 733 | extractor->SetTimeStep(timeStep); |
| 734 | extractor->SetWorldGeometry(planeGeometry); |
| 735 | extractor->SetVtkOutputRequest(false); |
| 736 | extractor->SetResliceTransformByGeometry(workingImage->GetGeometry(timeStep)); |
| 737 | |
| 738 | extractor->Modified(); |
| 739 | extractor->Update(); |
| 740 | |
| 741 | // the image was modified within the pipeline, but not marked so |
| 742 | workingImage->Modified(); |
| 743 | workingImage->GetVtkImageData()->Modified(); |
| 744 | } |
| 745 | |
| 746 | void mitk::SegTool2D::WriteSliceToVolume(Image* workingImage, const SliceInformation &sliceInfo) |
| 747 | { |
nothing calls this directly
no test coverage detected