private bool ResolveDuplicateLines(Shape s, List<ILine> lines) { bool ret = false; List<ILine> l = s.GetLines(); int nLine = l.Count; for (int i = 0; i < nLine; i++) { for (int j = i+1; j < nLine; j++) { if (l[i].IsCongruentTo(l[j])) { KillLine(l[i], lines); ret = true; } } } return ret; }
private void MapShape(MyLineQueue q, List<ILine> lines) { Shape s = new Shape(); try { ILine start = q.Dequeue(); int qSize = q.Count; FollowLine(start, s, q, lines); if (ShapeAlreadyExists(s)) { int nRemove = q.Count - qSize; if (nRemove > 0) q.Remove(nRemove); } else if (ResolveDuplicateLines(s, lines)) { int remove = q.Count - qSize; if (remove > 0) q.Remove(remove); } else if (!ShapeIsValid(s)) { int remove = q.Count - qSize; if (remove > 0) { q.Remove(remove); } ILine li = (s.GetLines())[0]; q.Enqueue(Line.Flip(li), shapes); } else { AddShape(s); } } catch { } }