| 16 | |
| 17 | #include <fstream> |
| 18 | int mitkImageSliceSelectorTest(int argc, char *argv[]) |
| 19 | { |
| 20 | int slice_nr = 1; |
| 21 | std::cout << "Loading file: "; |
| 22 | if (argc == 0) |
| 23 | { |
| 24 | std::cout << "no file specified [FAILED]" << std::endl; |
| 25 | return EXIT_FAILURE; |
| 26 | } |
| 27 | |
| 28 | mitk::Image::Pointer image; |
| 29 | try |
| 30 | { |
| 31 | image = mitk::IOUtil::Load<mitk::Image>(argv[1]); |
| 32 | } |
| 33 | catch (const mitk::Exception &) |
| 34 | { |
| 35 | std::cout << "file not an image - test will not be applied [PASSED]" << std::endl; |
| 36 | std::cout << "[TEST DONE]" << std::endl; |
| 37 | return EXIT_SUCCESS; |
| 38 | } |
| 39 | catch ( const itk::ExceptionObject &ex ) |
| 40 | { |
| 41 | std::cout << "Exception: " << ex.GetDescription() << "[FAILED]" << std::endl; |
| 42 | return EXIT_FAILURE; |
| 43 | } |
| 44 | |
| 45 | if (image->GetDimension(2) < 2) |
| 46 | slice_nr = 0; |
| 47 | |
| 48 | // Take a slice |
| 49 | mitk::ImageSliceSelector::Pointer slice = mitk::ImageSliceSelector::New(); |
| 50 | slice->SetInput(image); |
| 51 | slice->SetSliceNr(slice_nr); |
| 52 | slice->Update(); |
| 53 | |
| 54 | std::cout << "Testing IsInitialized(): "; |
| 55 | if (slice->GetOutput()->IsInitialized() == false) |
| 56 | { |
| 57 | std::cout << "[FAILED]" << std::endl; |
| 58 | return EXIT_FAILURE; |
| 59 | } |
| 60 | std::cout << "[PASSED]" << std::endl; |
| 61 | |
| 62 | std::cout << "Testing IsSliceSet(): "; |
| 63 | if (slice->GetOutput()->IsSliceSet(0) == false) |
| 64 | { |
| 65 | std::cout << "[FAILED]" << std::endl; |
| 66 | return EXIT_FAILURE; |
| 67 | } |
| 68 | std::cout << "[PASSED]" << std::endl; |
| 69 | |
| 70 | try |
| 71 | { |
| 72 | slice->UpdateLargestPossibleRegion(); |
| 73 | } |
| 74 | catch (const itk::ExceptionObject &) |
| 75 | { |
nothing calls this directly
no test coverage detected