int main(int, char *[])
{
typedef float PixelType;
typedef MeshType::CellType CellType;
typedef CellType::CellAutoPointer CellAutoPointer;
MeshType::Pointer mesh = MeshType::New();
MeshType::PointType p0;
MeshType::PointType p1;
MeshType::PointType p2;
p0[0] = -1.0; p0[1] = 0.0; p0[2] = 0.0;
p1[0] = 1.0; p1[1] = 0.0; p1[2] = 0.0;
p2[0] = 1.0; p2[1] = 1.0; p2[2] = 0.0;
mesh->SetPoint( 0, p0 );
mesh->SetPoint( 1, p1 );
mesh->SetPoint( 2, p2 );
CellAutoPointer line0;
CellAutoPointer line1;
line0.TakeOwnership( new LineType );
line1.TakeOwnership( new LineType );
line0->SetPointId( 0, 0 );
line0->SetPointId( 1, 1 );
line1->SetPointId( 0, 1 );
line1->SetPointId( 1, 2 );
mesh->SetCell( 0, line0 );
mesh->SetCell( 1, line1 );
std::cout << "Points = " << mesh->GetNumberOfPoints() << std::endl;
std::cout << "Cells = " << mesh->GetNumberOfCells() << std::endl;
typedef MeshType::CellsContainer::Iterator CellIterator;
CellIterator cellIterator = mesh->GetCells()->Begin();
CellIterator end = mesh->GetCells()->End();
while( cellIterator != end )
{
MeshType::CellType * cellptr = cellIterator.Value();
LineType * line = dynamic_cast<LineType *>( cellptr );
if(line == ITK_NULLPTR)
{
continue;
}
std::cout << line->GetNumberOfPoints() << std::endl;
++cellIterator;
}
return EXIT_SUCCESS;
}