# Selection v2

Previously to this point actual vertices were used for selection. A new selection system was needed that would widen (or create) an abstraction gap between geometry and identifiable element used in grammar. Because edge to vertex relationship remains the same we discuss vertex indexing only.

### Indexing

Index array is used to access polygon vertices instead of dereferencing actual geometry. For instance vertex 0 is not the first vertex in a container of the polygon representation, but the first element in the index array, value of of which points to the container element. This way any geometrical operation does not violate logical or spacial order of the elements.

##### Current Indexing Problem

Auto selection (for instance that of Peel rule) is still not stable because the rule stores a set of vertices, but the selecting rule manipulates on ranges, which are edge based. Vertex to edge conversion looses selection of single vertices. In addition edge to vertex selection mutilates selection where two intervals are separated by one edge – both vertices of that edge are contained in adjacent selections, so reverse conversion unites the two selections into one.

### Symmetry

Grid operation now enforces symmetry based on vertex indexing. Because the direction for x or y-mirrored regions change the direction (for instance to counter clockwise from default clockwise) and the geometrical representation uses requires of the same implementation for all elements – indexed orientation may differ from the actual one. Hence we can save indexing with two items, start vertex and direction. Start vertex is computed based on the outgoing edge orientation of one of 4 types. This works well for nearly grid aligned (of course also for perfectly aligned) shapes, but near diagonal shapes, for instance rhombus centres this technique does not work.

### Path Parametrisation

In a previous approach to specify positions of the objects along the polyline for Insert/Place rules one would write for instance [0.3, 0.5, 0.7] – three objects in the centre separated by 0.2 (20%) of the selected path length. However it is quite tedious to specify each individual positions and not very algorithmic. New parameter subrule allows a shortcut: 0.3:n3:0.3 – meaning there is distance of 30% from each sides and three objects in the middle; an alternative form 0.3:l0.2:0.3 also works. In fact we can omit the last number as well 0.3:n3.