ommpfritt icon indicating copy to clipboard operation
ommpfritt copied to clipboard

Edge identity

Open pasbi opened this issue 2 years ago • 8 comments

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 PathPoints are unique per Path and because there could only be one Edge between two PathPoints within a Path.

Things become tricky when introducing joined points (without which faces would be impossible). When PathPoints 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.

broken-faces

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 PathPoints but a sequence of Edges. Those edges are not descriptors but they carry an identity. Edges share ownership of two PathPoints. 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, change Path 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 PathPoints now).
  • [ ] reimplement the conversion of Ellipse, Rectangle, etc. to PathObject
  • [x] reimplement unit tests (as soon as possible)

pasbi avatar Apr 11 '22 06:04 pasbi