#define _USE_MATH_DEFINES // needed for Visual Studio (before #include <cmath>)
int
main()
{
source->SetScale(scale);
source->SetResolution(5);
source->Update();
for (TMesh::CellsContainerIterator it = source->GetOutput()->GetCells()->Begin();
it != source->GetOutput()->GetCells()->End();
++it)
{
TMesh::CellAutoPointer cell;
source->GetOutput()->GetCell(it->Index(), cell);
if (3 != cell->GetNumberOfPoints())
{
std::cerr << "ERROR: All cells must be trianglar." << std::endl;
return EXIT_FAILURE;
}
}
convert->SetInput(source->GetOutput());
convert->Update();
volume->SetSimplexMesh(convert->GetOutput());
volume->Compute();
std::cout << "Ideal Volume: " << 4.0 / 3.0 * M_PI * pow(5.0, 3) << std::endl;
std::cout << "Mesh Volume: " << volume->GetVolume() << std::endl;
std::cout << "Ideal Surface Area: " << 4.0 * M_PI * pow(5.0, 2) << std::endl;
std::cout << "Mesh Surface Area: " << volume->GetArea() << std::endl;
return EXIT_SUCCESS;
}