[vtkusers] Custom point data labels for unstructured grids‎

Ola Skavhaug skavhaug at simula.no
Wed Jan 28 05:20:38 EST 2009


Hi,

I am trying to debug some mesh partitioning algorithm, and need to label the
points of the new a unstructured vtk (sub-)grid according to the global
numbering of the old mesh. I have tried the vtkLabeledDataMapper in
combination with vtkIdFilter after setting the global numbering as field
data of the unstructured mesh given as input to the vtkIdFilter, but I guess
this is not the way to go (at least, I can't get it to work).

This is my, probably retarded, attempt:

    def add_point_labels(self, labels=None):
        ldm = vtk.vtkLabeledDataMapper()
        ldm.SetLabelFormat("%g")
        ids = vtk.vtkIdFilter()
        if labels != None:
            arr = vtk.vtkIdTypeArray()
            arr.SetVoidArray(labels, len(labels), 1)
            arr.SetName("point labels")
            self.vtkgrid.GetFieldData().AddArray(arr)
            ids.SetInput(self.vtkgrid)
            ids.SetFieldData(1)
            ldm.SetFieldDataArray(0)
            ldm.SetLabelModeToLabelFieldData()
        else:
            ids.SetInput(self.vtkgrid)
            ids.PointIdsOn()
            ids.FieldDataOn()

        ldm.SetInputConnection(ids.GetOutputPort())
        ldm.GetLabelTextProperty().SetColor(0, 0, 0)
        ldm.GetLabelTextProperty().BoldOn()
        pointLabels = vtk.vtkActor2D()

>From my understanding of the nightly documentation, it should be possible to
do what I want, but the example provided online doesn't cover this corner.
Any help is greatly appreciated.

Sincerely,

-- 
Ola Skavhaug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090128/112df5c2/attachment.htm>


More information about the vtkusers mailing list