Automate recognition of toroidal geometries