Merge intersecting primitives

I have a bunch of flat primitives. Some of them intersect on an edge:
prims

I have a simple shader that renders a different color per primitive.

Goal: I want to combine primitives that touch each other so they get rendered the same color.

There was an almost-success with the surfsect SOP set to intersection, but it doesn’t seem to output any data that lets me associate the intersecting primitives with each other

BTW, I’m trying to do this procedurally, but only needs to cook once, not every frame (the incoming geometry is static, made from the trace SOP)

Did you ever figure this out? I have a similar issue.

Looking back on this, I don’t think TouchDesigner has any native tools to handle this operation unfortunately.
In this simplified case though, you may be able to assign a value based on its primitive normal, so all primitives facing the same direction could get the same color.

Cheers,
Rob.