Display scalar value on points

I, I’d like to display scalar values on points but it gets displayed on cells
Here is is my code :

def setMeshVertexAttribute(self, id, name):
        reader = self.get_object(id)["reader"] # reader is a vtkXMLGenericDataObjectReader
        points = reader.GetOutput().GetPointData()
        points.SetActiveScalars(name)
        mapper = self.get_object(id)["mapper"] # mapper is a vtkDataSetMapper()
        mapper.ScalarVisibilityOn()
        mapper.SetScalarModeToUsePointData()
        mapper.SetScalarRange(points.GetScalars().GetRange())
        self.get_protocol("vtkWebPublishImageDelivery").imagePush({"view": -1})

Any idea what might be causing this?

Thanks

Hello,

You need to align your scalar data with the vertexes, but we need you to tell which dataset you’re using (vtkUnstructuredGrid, vtkPolyData, etc.).

best,

PC

Hi,

Thanks for the reply.

It works when we display the scalars on the polygon vertices with interpolation on the polygons but we cannot manage to display the same scalar data on the points only.

The data is a Polydata made of triangles.

Which class? vtkPolyData?

That’s the way VTK handles point scalars by default, it’s not possible to use scalars to color the points but not the faces.

The only way to avoid coloring the faces is to not show the faces:

actor.GetProperty().SetRepresentationToPoints()
actor.GetProperty().RenderPointsAsSpheresOn() # also recommended

To show the faces with a flat color, and use the scalars to color the points, you might need to use two mappers: one for the faces with ScalarVisibilityOff(), and one for the points with ScalarVisibilityOn() and with SetRepresentationToPoints() on the property.