using PixelType = float;
using CellType = MeshType::CellType;
#ifndef CustomTriangleVisitorDefine
# define CustomTriangleVisitorDefine
class CustomTriangleVisitor
{
public:
void
Visit(unsigned long cellId, TriangleType * t)
{
std::cout << "Cell # " << cellId << " is a TriangleType ";
}
CustomTriangleVisitor() = default;
virtual ~CustomTriangleVisitor() = default;
};
#endif // CustomTriangleVisitorDefine
int
main(int, char *[])
{
point0[0] = -1;
point0[1] = -1;
point0[2] = -1;
point1[0] = 1;
point1[1] = 1;
point1[2] = -1;
point2[0] = 1;
point2[1] = -1;
point2[2] = 1;
point3[0] = -1;
point3[1] = 1;
point3[2] = 1;
mesh->SetPoint(0, point0);
mesh->SetPoint(1, point1);
mesh->SetPoint(2, point2);
mesh->SetPoint(3, point3);
CellType::CellAutoPointer cellpointer;
cellpointer.TakeOwnership(new TetrahedronType);
cellpointer->SetPointId(0, 0);
cellpointer->SetPointId(1, 1);
cellpointer->SetPointId(2, 2);
cellpointer->SetPointId(3, 3);
mesh->SetCell(0, cellpointer);
cellpointer.TakeOwnership(new TriangleType);
cellpointer->SetPointId(0, 0);
cellpointer->SetPointId(1, 1);
cellpointer->SetPointId(2, 2);
mesh->SetCell(1, cellpointer);
cellpointer.TakeOwnership(new TriangleType);
cellpointer->SetPointId(0, 0);
cellpointer->SetPointId(1, 2);
cellpointer->SetPointId(2, 3);
mesh->SetCell(2, cellpointer);
cellpointer.TakeOwnership(new TriangleType);
cellpointer->SetPointId(0, 0);
cellpointer->SetPointId(1, 3);
cellpointer->SetPointId(2, 1);
mesh->SetCell(3, cellpointer);
cellpointer.TakeOwnership(new TriangleType);
cellpointer->SetPointId(0, 3);
cellpointer->SetPointId(1, 2);
cellpointer->SetPointId(2, 1);
mesh->SetCell(4, cellpointer);
cellpointer.TakeOwnership(new LineType);
cellpointer->SetPointId(0, 0);
cellpointer->SetPointId(1, 1);
mesh->SetCell(5, cellpointer);
cellpointer.TakeOwnership(new LineType);
cellpointer->SetPointId(0, 1);
cellpointer->SetPointId(1, 2);
mesh->SetCell(6, cellpointer);
cellpointer.TakeOwnership(new LineType);
cellpointer->SetPointId(0, 2);
cellpointer->SetPointId(1, 0);
mesh->SetCell(7, cellpointer);
cellpointer.TakeOwnership(new LineType);
cellpointer->SetPointId(0, 1);
cellpointer->SetPointId(1, 3);
mesh->SetCell(8, cellpointer);
cellpointer.TakeOwnership(new LineType);
cellpointer->SetPointId(0, 3);
cellpointer->SetPointId(1, 2);
mesh->SetCell(9, cellpointer);
cellpointer.TakeOwnership(new LineType);
cellpointer->SetPointId(0, 3);
cellpointer->SetPointId(1, 0);
mesh->SetCell(10, cellpointer);
cellpointer.TakeOwnership(new VertexType);
cellpointer->SetPointId(0, 0);
mesh->SetCell(11, cellpointer);
cellpointer.TakeOwnership(new VertexType);
cellpointer->SetPointId(0, 1);
mesh->SetCell(12, cellpointer);
cellpointer.TakeOwnership(new VertexType);
cellpointer->SetPointId(0, 2);
mesh->SetCell(13, cellpointer);
cellpointer.TakeOwnership(new VertexType);
cellpointer->SetPointId(0, 3);
mesh->SetCell(14, cellpointer);
std::cout << "# Points= " << mesh->GetNumberOfPoints() << std::endl;
std::cout << "# Cell = " << mesh->GetNumberOfCells() << std::endl;
using TriangleVisitorInterfaceType =
MeshType::CellTraits,
TriangleType,
CustomTriangleVisitor>;
using CellMultiVisitorType = CellType::MultiVisitor;
multiVisitor->AddVisitor(triangleVisitor);
mesh->Accept(multiVisitor);
return EXIT_SUCCESS;
}