[vtkusers] Emulate vtkIdFilter
Gheorghe Postelnicu
gheorghe.postelnicu at gmail.com
Thu Aug 3 15:52:57 EDT 2006
Hi Mathieu,
Thanks for the quick reply! Looking at vtkIdFilter, here's the
solution that worked for me.
# declare points where to set labels
vtkPoints pts
# populate pts object with data
vtkPolyData pdata
[line2 GetRepresentation] GetPolyData pdata
eval pts InsertNextPoint [pdata GetPoint 0]
# populate label array data -> 1-2-1 corr. with added points
# need an array to hold it....
vtkIntArray lblArray
lblArray InsertNextValue 1
vtkPointData labels
labels AddArray lblArray
# final polydata object
vtkPolyData newData
newData SetPoints pts
newData SetFieldData labels
vtkLabeledDataMapper ldm
ldm SetInput newData
ldm SetLabelFormat "%g"
vtkActor2D pointLabels
pointLabels SetMapper ldm
ren1 AddActor2D pointLabels
renWin Render
On 8/3/06, Mathieu Malaterre <mathieu.malaterre at kitware.com> wrote:
> Gheorghe Postelnicu wrote:
> > Hi,
> >
> > I have a collection 3d points and some labels. What is the most
> > natural way to display the labels as a 2d actor?
>
> Hi Gheorghe,
>
> Have a look at:
> http://www.vtk.org/doc/nightly/html/classvtkLabeledDataMapper.html
>
> There are a couple of tests/examples that shows you how to use it. You
> may also want to have a look at vtkSelectVisiblePoints.
>
> HTH
> Mathieu
>
--
Gheorghe Postelnicu, PhD
MGH, Harvard Medical School
More information about the vtkusers
mailing list