int
main(int, char *[])
{
using PixelType = float;
using CellType = MeshType::CellType;
using CellAutoPointer = CellType::CellAutoPointer;
MeshType::Pointer mesh = MeshType::New();
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;
using CellIterator = MeshType::CellsContainer::Iterator;
CellIterator cellIterator = mesh->GetCells()->
Begin();
CellIterator end = mesh->GetCells()->End();
while (cellIterator != end)
{
MeshType::CellType * cellptr = cellIterator.Value();
auto * line = dynamic_cast<LineType *>(cellptr);
if (line == nullptr)
{
continue;
}
std::cout << line->GetNumberOfPoints() << std::endl;
++cellIterator;
}
return EXIT_SUCCESS;
}