#include "mitkImage.h"#include "mitkDataNodeFactory.h"#include "mitkImageTimeSelector.h"#include <itksys/SystemTools.hxx>#include <fstream>Go to the source code of this file.
Functions | |
| int | mitkImageTimeSelectorTest (int argc, char *argv[]) |
| int mitkImageTimeSelectorTest | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 25 of file mitkImageTimeSelectorTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::ImageTimeSelector::New(), and mitk::DataNodeFactory::New().
{
std::cout << "Loading file: ";
if(argc==0)
{
std::cout<<"no file specified [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
mitk::Image::Pointer image = NULL;
mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
try
{
factory->SetFileName( argv[1] );
factory->Update();
if(factory->GetNumberOfOutputs()<1)
{
std::cout<<"file could not be loaded [FAILED]"<<std::endl;
return EXIT_FAILURE;
}
mitk::DataNode::Pointer node = factory->GetOutput( 0 );
image = dynamic_cast<mitk::Image*>(node->GetData());
if(image.IsNull())
{
std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl;
std::cout<<"[TEST DONE]"<<std::endl;
return EXIT_SUCCESS;
}
}
catch ( itk::ExceptionObject & ex )
{
std::cout << "Exception: " << ex << "[FAILED]" << std::endl;
return EXIT_FAILURE;
}
//Take a time step
mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
timeSelector->SetInput(image);
timeSelector->SetTimeNr( 0 );
timeSelector->UpdateLargestPossibleRegion();
mitk::Image::Pointer result = timeSelector->GetOutput();
std::cout << "Testing IsInitialized(): ";
if(result->IsInitialized()==false)
{
std::cout<<"[FAILED]"<<std::endl;
return EXIT_FAILURE;
}
std::cout<<"[PASSED]"<<std::endl;
std::cout << "Testing if Volume is set ";
//result->DisconnectPipeline();
//timeSelector = NULL;
if( result->IsVolumeSet(0) == false)
{
std::cout<<"[FAILED]"<<std::endl;
return EXIT_FAILURE;
}
std::cout<<"[PASSED]"<<std::endl;
std::cout<<"[TEST DONE]"<<std::endl;
return EXIT_SUCCESS;
}
1.7.2