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

Mike Jackson mike.jackson at imts.us
Mon Aug 11 08:18:26 EDT 2008


Begin forwarded message:

> From: Mike Jackson <mike.jackson at imts.us>
> Date: August 10, 2008 8:24:23 PM EDT
> To: HayamiSanjuro <sanjurohayami at hotmail.com>
> Subject: Re: [vtkusers] Question about the meaning of the text file  
> generated by vtkPolyDataWriter, which is for reading a vtkPolyData
>
> You are absolutely correct. Sorry about the confusion. This also  
> documented online at
>
> http://www.vtk.org/pdf/file-formats.pdf
>
> -- 
> Mike Jackson   Senior Research Engineer
> Innovative Management & Technology Services
>
>
> On Aug 10, 2008, at 5:38 PM, HayamiSanjuro wrote:
>
>> Hi Mike,
>>
>> Thanks for you fast reply!
>>
>> It very helpful :) For the polygon's explaination, I think it  
>> might not quite r8. Coz according to the points' position
>> [0] 0 0 0
>> [1] 2 2 0
>> [2] 4 2 0
>> [3] 6 0 0
>> [4] 3 1 0
>> Polygon 3 4 3 2 doesnt make sense.
>> I guess the first column might be the number of the points in the  
>> polygon.
>> but Im not sure now, still need more data to prove.
>>
>>
>> Cheers!
>>
>> YANG Rong
>>
>> 20 Orton,
>> Glenfield, AKL,
>> New Zealand
>>
>> Cell: +64 21 2355108
>> Home phone: 09 4434960
>>
>>
>> CC: vtkusers at vtk.org
>> From: mike.jackson at imts.us
>> Subject: Re: [vtkusers] Question about the meaning of the text  
>> file generated by vtkPolyDataWriter, which is for reading a  
>> vtkPolyData
>> Date: Sun, 10 Aug 2008 14:17:08 -0400
>> To: sanjurohayami at hotmail.com
>>
>> 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
>>
>>
>> “七件武器,七种完美” 立刻体验!
>





More information about the vtkusers mailing list