[vtkusers] get length of vtkpolyline

Hentschel, Bernd hentschel at rz.rwth-aachen.de
Fri Aug 25 03:14:26 EDT 2006


Hi Johannes,

In order to compute the length of the line, you'll have to sum up the
lengths of all its segments. This is done as follows: VTK saves
polylines internally as a vtkCellArray (vtkPolyData::GetLines()). The
format for a single line is (n, i_0...i_{n-1}), where n is the number of
points in the line and i_0 ... i_{n-1} are the point's indices. Several
lines can be saved in one cell array by appending such entries. 
With the point indices you can retrieve the points and determine their
pairwise distances. Sum up these and you are done. You'll find
implementation details in vtkPolyData and vtkCellArray online
documentation. One note, though: When summing over more than one line,
use the iterator methods provided by vtkCellArray to traverse the line
array (vtkCellArray::InitTraversal, vtkCellArray::GetNextCell).

Regards,
	Bernd




More information about the vtkusers mailing list