[vtkusers] Question about the meaning of the text file generated by vtkPolyDataWriter, which is for reading a vtkPolyData

Mike Jackson mike.jackson at imts.us
Sun Aug 10 14:17:08 EDT 2008


On Aug 10, 2008, at 5:34 AM, HayamiSanjuro wrote:

> Hi guys,
>
> I found I have a difficult to understand the text file generated by  
> vtkPolyDataWriter.
>
> The situation is I create a set of following 5 points to construct  
> a ploygon:
>
> vtkPoints *points = vtkPoints::New();
>     points->InsertPoint(0,0,0,0);
>     points->InsertPoint(1,2,2,0);
>     points->InsertPoint(2,4,2,0);
>     points->InsertPoint(3,6,0,0);
>     points->InsertPoint(4,3,1,0);
> vtkCellArray *polys = vtkCellArray::New();
>     polys->InsertNextCell(5);
>     polys->InsertCellPoint(4);
>     polys->InsertCellPoint(3);
>     polys->InsertCellPoint(2);
>     polys->InsertCellPoint(1);
>     polys->InsertCellPoint(0);
>
> Then, i performed the constrained Delaunay triangulation:
> vtkPolyData *polyData = vtkPolyData::New();
>  &nbs p;  polyData->SetPoints(points);
>     polyData->SetPolys(polys);
> vtkDelaunay2D *del = vtkDelaunay2D::New();
>     del->SetInput(polyData);
>     del->SetSource(polyData);
>
> At last, I tried to see the result of the triangulation by get the  
> output and write the result polygon to a text file by using  
> vtkPolyDataWriter
>
> vtkPolyData * outputPolyData = del->GetOutput();
>     outputPolyData->Update();
>     vtkPolyDataWriter *writer = vtkPolyDataWriter::New();
>     writer->SetInput(outputPolyData);
>     writer->SetFileName("test.txt");
>     writer->Write();
>
> The result text file is pretty confusing me:
> ----text.txt----------------------------------------
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET POLYDATA
> POINTS 5 float
> 0 0 0 2 2 0 4 2 0
> 6 0 0 3 1 0
> POLYGONS 3 12
> 3 4 2 1
> 3 4 3 2
> 3 4 1 0
>
> CELL_DATA 3
> POINT_DATA 5
> ------------------------------------------------------
> I can see the "POINTS 5 float" section is state the coordinate of 5  
> points
> but the "POLYGONS 3 12" really confused me. Can any1 explain it for  
> me PLZ!!!!!!!!!
>
> Cheers!
>
> YANG Rong
>
>


There are "3" polygons. Each Polygon has 4 points, for a total of  
"12" points. Each polygon is listed on its own line. The values for  
each point represents the index into the "points" array. So breaking  
this down more we have the following Points: (indices are in brackets):

[0] 0 0 0
[1] 2 2 0
[2] 4 2 0
[3] 6 0 0
[4] 3 1 0

And the following polygons:
3 4 2 1
3 4 3 2
3 4 1 0

So the first polygon has the points whose indices are 3,4,2,1.

Does this help?

Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080810/5f3df982/attachment.htm>


More information about the vtkusers mailing list