int
main(int argc, char * argv[])
{
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " outputimagefile " << std::endl;
return EXIT_FAILURE;
}
using PixelType = short;
using SpatialObjectToImageFilterType =
size[0] = 50;
size[1] = 50;
size[2] = 200;
ImageType::SpacingType spacing;
spacing[0] = 100.0 / size[0];
spacing[1] = 100.0 / size[1];
spacing[2] = 400.0 / size[2];
imageFilter->SetSpacing(spacing);
metaBall1->SetRadiusInObjectSpace(size[0] * spacing[0] * 0.2);
metaBall2->SetRadiusInObjectSpace(size[0] * spacing[0] * 0.2);
metaBall3->SetRadiusInObjectSpace(size[0] * spacing[0] * 0.2);
metaBall1->SetMaximum(1000.0);
metaBall2->SetMaximum(1000.0);
metaBall3->SetMaximum(1000.0);
using TransformType = GroupType::TransformType;
transform1->SetIdentity();
transform2->SetIdentity();
transform3->SetIdentity();
TransformType::OutputVectorType translation;
translation[0] = size[0] * spacing[0] / 2.0;
translation[1] = size[1] * spacing[1] / 4.0;
translation[2] = size[2] * spacing[2] / 2.0;
transform1->Translate(translation, false);
translation[1] = size[1] * spacing[1] / 2.0;
translation[2] = size[2] * spacing[2] * 0.22;
transform2->Translate(translation, false);
translation[2] = size[2] * spacing[2] * 0.78;
transform3->Translate(translation, false);
metaBall1->SetObjectToParentTransform(transform1);
metaBall2->SetObjectToParentTransform(transform2);
metaBall3->SetObjectToParentTransform(transform3);
group->AddChild(metaBall1);
group->AddChild(metaBall2);
group->AddChild(metaBall3);
metaBall1->Update();
metaBall2->Update();
metaBall3->Update();
imageFilter->SetInput(group);
const PixelType airHounsfieldUnits = -1000;
imageFilter->SetUseObjectValue(true);
imageFilter->SetOutsideValue(airHounsfieldUnits);
writer->SetFileName(argv[1]);
writer->SetInput(imageFilter->GetOutput());
try
{
imageFilter->Update();
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}