21 #include "itkPSMProject.h" 22 #include "itkPSMProjectReader.h" 23 #include "itkPSMProjectWriter.h" 26 int itkPSMProjectTest(
int argc,
char* argv[] )
29 std::string errstring =
"";
34 std::cout <<
"Wrong number of arguments. \nUse: " 35 <<
"itkPSMProjectTest PSMProjectFile.xml <outputfile.xml (optional>\n" 36 <<
"See itk::PSMProject and itk::PSMDOMNode for documentation on the parameter file format." 44 itk::PSMProjectReader::Pointer reader = itk::PSMProjectReader::New();
45 reader->SetFileName(argv[1]);
47 itk::PSMProject::Pointer project = reader->GetOutput();
50 std::cout << project << std::endl;
53 project->Stream(std::cout);
57 const std::vector<std::string> &dt = project->GetDistanceTransforms();
58 std::cout << itk::PSMProject::distance_transforms_tag << std::endl;
59 for (
unsigned int i = 0; i < dt.size(); i++)
61 std::cout <<
" " << dt[i] << std::endl;
65 const std::vector<std::string> &model = project->GetModel(std::string(
"my_model"));
66 std::cout << itk::PSMProject::model_tag << std::endl;
67 for (
unsigned int i = 0; i < model.size(); i++)
69 std::cout <<
" " << model[i] << std::endl;
77 itk::PSMProjectWriter::Pointer writer = itk::PSMProjectWriter::New();
78 writer->SetFileName(argv[2]);
79 writer->SetInput(project);
83 catch(itk::ExceptionObject &e)
85 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
86 + std::string(
"\n at location:") + std::string(e.GetLocation())
87 + std::string(
"\n in file:") + std::string(e.GetFile());
92 errstring =
"Unknown exception thrown";
98 std::cout <<
"All tests passed" << std::endl;
103 std::cout <<
"Test failed with the following error:" << std::endl;
104 std::cout << errstring << std::endl;