A Grammar for the Topological Analysis of Plane Figures