VTK/Tutorials/TriangleGeometryPolygon
<source lang="cpp"> void TestWriteTriSquare(const string &OutputFile, const char FileType) { //setup points vector<Point> Points; Points.push_back(Point(-1, 1, 0)); Points.push_back(Point(1, 1, 0)); Points.push_back(Point(1, -1, 0)); Points.push_back(Point(-1, -1, 0));
//setup triangles vector<vector<int> > VertexList;
vector<int> Tri1; vector<int> Tri2;
Tri1.push_back(0); Tri1.push_back(1); Tri1.push_back(2);
Tri2.push_back(0); Tri2.push_back(2); Tri2.push_back(3);
VertexList.push_back(Tri1); VertexList.push_back(Tri2);
//setup model ModelClass Model; Model.Points = Points; Model.VertexList = VertexList;
//write model if(FileType == 'u') VtuWrite(Model, OutputFile); else if(FileType == 'p') VtpWrite(Model, OutputFile);
} </source>