private void AttachLines(PolygonPoint head, List <LineSegment> lines) { var tail = this.FindTail(head); while (lines.Count > 1) { LineSegment removeLine = null; foreach (var l in lines) { if (tail.Equals(l.P1)) { tail.Next = new PolygonPoint(l.P2.X, l.P2.Y); } else if (tail.Equals(l.P2)) { tail.Next = new PolygonPoint(l.P1.X, l.P1.Y); } if (tail.Next == null) { continue; } tail = tail.Next; removeLine = l; break; } if (removeLine == null) { throw new Exception("Shape is not polygon"); } lines.Remove(removeLine); } var line = lines[0]; if (!((head.Equals(line.P1) && tail.Equals(line.P2)) || (head.Equals(line.P2) && tail.Equals(line.P1)))) { throw new Exception("Shape is not connecting"); } lines.RemoveAt(0); }
public bool Equals(Area other) { return(name == other.name && priority == other.priority && areaTypeFlags == other.areaTypeFlags && closedPolygon.Equals(other.closedPolygon) && allowIntersectionFlags == other.allowIntersectionFlags && surfaceTypeFlags == other.surfaceTypeFlags && surfaceAttributeFlags == other.surfaceAttributeFlags && levelOffset == other.levelOffset && lower.Equals(other.lower) && upper.Equals(other.upper)); }