int main(int, char *[])
{
TSphere::Pointer source = TSphere::New();
TSphere::VectorType scale;
scale.Fill( 5.0 );
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;
}
}
TConvert::Pointer convert = TConvert::New();
convert->SetInput( source->GetOutput() );
convert->Update();
TVolume::Pointer volume = TVolume::New();
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;
}