Display point coordinates in Paraview (the return)

The previous version was using the ProgrammableFilter of Paraview. This one is a macro that was tested with Paraview 4. Here are pros/cons compared to the previous version:

pros:

  • Automatic selection display mode configuration
  • Automatic selection of all points

cons: automatic selection of all points on large mesh is not what you want.

To install it go to Macros, Add new macro.

from paraview.simple import *

coord_prog_filter = ProgrammableFilter()
RenameSource("Coordinates", coord_prog_filter)
coord_prog_filter.Script = """
pdi = self.GetInput()
pdo = self.GetOutput()
coords = vtk.vtkDoubleArray()
coords.SetName("Coordinates")
coords.SetNumberOfComponents(3)
n = pdi.GetNumberOfPoints()
for i in xrange(n):
   p=pdi.GetPoint(i)
   coords.InsertNextTuple3(p[0], p[1], p[2])
pdo.GetPointData().AddArray(coords)
"""

sel = servermanager.sources.SelectionQuerySource()
sel.FieldType = "POINT"
sel.QueryString = "id >= 0"
coord_prog_filter.SMProxy.SetSelectionInput(coord_prog_filter.Port, sel.SMProxy, 0)

coord_repr = Show()
coord_repr.SelectionPointLabelColor = [0.0, 0.0, 0.0]
coord_repr.SelectionPointLabelFormat = '%g'
coord_repr.SelectionPointLabelVisibility = 1
coord_repr.SelectionPointFieldDataArrayName = 'Coordinates'
coord_repr.SelectionPointLabelVisibility = 1

Render()

#paraview