ommpfritt
ommpfritt copied to clipboard
Edge identity
Until now, edges did not have an identity but were defined to be the connection between two unique points (instances of PathPoint
).
There was a class Edge
, but it was merely a descriptor of a connection of two points that could be copied around.
Such an edge descriptor is unique because PathPoint
s are unique per Path
and because there could only be one Edge
between two PathPoint
s within a Path
.
Things become tricky when introducing joined points (without which faces would be impossible).
When PathPoint
s are joined, they act as the same point, i.e., they not only coincidentally have the same position, also their selection is synchronized and they are not distinguished by certain algorithms.
In this graph, the points 0
, 2
and 3
are joined and 1
and 5
are joined.
Hence the graph exhibits two faces: 0--1--2
and 3--4--5--3
.
Note that the blue face only exists if the blue path is closed, i.e., if considering the joined points 0
and 2
"the same".
This is okay in the first place.
After all, joined points were introduced to close paths.
However, if we consider 0
and 2
the same, then we cannot distinguish the two edges of the blue face anymore.
We might apply some tricks considering direction, which becomes very cumbersome quickly.
This PR proposes a fundamentally different approach:
A Path
does not own a sequence of PathPoint
s but a sequence of Edge
s.
Those edges are not descriptors but they carry an identity.
Edge
s share ownership of two PathPoint
s.
That is, a PathPoint
can be owned by more than one Edge
, which makes the concept of joined points superfluous (implementing joined points makes a lot of noise in many places).
Roadmap:
- [x] implement
Edge
, changePath
and related classes - [x] make it compile again by removing invalidated code
- [x] reimplement the path tool
- [x] reimplement the serialization
- [x] reimplement face detection (cross fingers that it works better this time)
- [ ] reimplement tools and actions like knife, join/disjoin points (those actions will destroy/create
PathPoint
s now). - [ ] reimplement the conversion of
Ellipse
,Rectangle
, etc. toPathObject
- [x] reimplement unit tests (as soon as possible)