int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: IsoSurfaceExtraction inputImageFile objectValue "
<< std::endl;
return EXIT_FAILURE;
}
using PixelType = unsigned char;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
try
{
reader->Update();
}
catch (const itk::ExceptionObject & exp)
{
std::cerr << "Exception thrown while reading the input file "
<< std::endl;
std::cerr << exp << std::endl;
return EXIT_FAILURE;
}
MeshSourceType::Pointer meshSource = MeshSourceType::New();
const auto objectValue = static_cast<PixelType>(std::stod(argv[2]));
meshSource->SetObjectValue(objectValue);
meshSource->SetInput(reader->GetOutput());
try
{
meshSource->Update();
}
catch (const itk::ExceptionObject & exp)
{
std::cerr << "Exception thrown during Update() " << std::endl;
std::cerr << exp << std::endl;
return EXIT_FAILURE;
}
std::cout << "Nodes = " << meshSource->GetNumberOfNodes() << std::endl;
std::cout << "Cells = " << meshSource->GetNumberOfCells() << std::endl;
return EXIT_SUCCESS;
}