Pass a function to define regions with RegionManager#addRegions

Implements #1371.