Coloration of polyhedra in a pipeline dependend on some coordination value

Hi ovito team,

I’m trying to generate a sequence of images (some silicate structures) with polyhedrons,
this works so far nicely, even with the AnariRenderer under Windows. As far I can see,
there is no obvious way to color the (translucent) polyhedra, they appear in a tone of gray.

Currently, I use this sequence of commands to set up the pipeline for the polyhedron renderer:

Si_O_Bond_L_1 = 1.8
pipeline.modifiers.append(SelectTypeModifier(types={1})) # should be Si in the center of tetrahedrons
bondmod = CreateBondsModifier(cutoff=Si_O_Bond_L_1)      # Create bonds between nearby atoms.
pipeline.modifiers.append(bondmod)
bondmod.vis.enabled = False               # Hide the bonds.
polymod = CoordinationPolyhedraModifier() # modifier constructs coordination polyhedra
pipeline.modifiers.append(polymod)        # around selected atoms
polymod.vis.surface_transparency = 0.35 
polymod.vis.highlight_edges = True
polymod.vis.smooth_shading  = False        # does not work with anari

Is there some way to set up a color value in the CoordinationPolyhedraModifier() that depends on the value of polyhedral faces the modifier computes for the current atom?

Thanks & best wishes!

With “value of polyhedral faces” you mean their number? Would you like to visualize the face counts of the coordination polyhedra?

[quote=“stukowski, post:2, topic:58632, full:true”]

Yes, exactly.
In my case, for example, green: tetrahedron (value around 4), red: octahedron (value around 6).

Thanks!

Then you’ll need to write a user-defined modifier function that counts the faces per polyhedron. The counts can be output as a new “region” property, which makes them usable for color mapping, for example. Here is a code snippet to get your started:

...
polymod.vis.color_mapping_mode = SurfaceMeshVis.ColorMappingMode.Region
polymod.vis.color_mapping_property = 'FaceCount'
polymod.vis.color_mapping_interval = (4, 6)
...
def count_faces_per_region(frame, data):
    surface = data.surfaces['coord-polyhedra_']
    faces_per_region = np.bincount(surface.faces['Region'], minlength=surface.regions.count)
    surface.regions_.create_property('FaceCount', data=faces_per_region)
pipeline.modifiers.append(count_faces_per_region)