Piece generator

This is the groundwork, the generic piece-based generator (#753) that will be used by most of the structure generators that use individual pieces from the Gallery server.

Merging now before it diverts too far away from master; individual generators will be written later on in separate PRs.