int main(int, char *[])
{
typedef float PixelType;
typedef MeshType::CellType CellType;
MeshType::Pointer mesh = MeshType::New();
typedef MeshType::PointType PointType;
PointType point;
const unsigned int numberOfPoints = 10;
for(unsigned int id=0; id<numberOfPoints; id++)
{
point[0] = static_cast<PointType::ValueType>( id );
point[1] = std::log( static_cast<double>( id ) + vnl_math::eps );
mesh->SetPoint( id, point );
}
CellType::CellAutoPointer line;
const unsigned int numberOfCells = numberOfPoints-1;
for(unsigned int cellId=0; cellId<numberOfCells; cellId++)
{
line.TakeOwnership( new LineType );
line->SetPointId( 0, cellId );
line->SetPointId( 1, cellId+1 );
mesh->SetCell( cellId, line );
}
std::cout << "Points = " << mesh->GetNumberOfPoints() << std::endl;
std::cout << "Cells = " << mesh->GetNumberOfCells() << std::endl;
for(unsigned int cellId=0; cellId<numberOfCells; cellId++)
{
mesh->SetCellData( cellId, static_cast<PixelType>( cellId * cellId ) );
}
for(unsigned int cellId=0; cellId<numberOfCells; cellId++)
{
PixelType value = static_cast<PixelType>(0.0);
mesh->GetCellData( cellId, &value );
std::cout << "Cell " << cellId << " = " << value << std::endl;
}
typedef MeshType::CellDataContainer::ConstIterator CellDataIterator;
CellDataIterator cellDataIterator = mesh->GetCellData()->Begin();
CellDataIterator end = mesh->GetCellData()->End();
while( cellDataIterator != end )
{
PixelType cellValue = cellDataIterator.Value();
std::cout << cellValue << std::endl;
++cellDataIterator;
}
return 0;
}