private void TraceVRightLines(List <BorderPoint> points, HashSet <BorderLine> result) { int index = 0, y1, y2, x, start; while (points.Count > index) { start = index; x = points[index].mX; y1 = points[index].mY; y2 = y1; do { y1 = y2; index++; if (points.Count > index) { y2 = points[index].mY; } else { break; } } while ((y2 - y1 == 1) && (points[index].mX == x) && (index < points.Count)); index--; BorderLine line = new BorderLine(new Point(points[start].mX + 1, points[start].mY), new Point(points[index].mX + 1, points[index].mY + 1)); Thread.MemoryBarrier(); result.Add(line); index++; } }
private void TraceHBottomLines(List <BorderPoint> points, HashSet <BorderLine> result) { int index = 0, x1, x2, y, start; while (points.Count > index) { start = index; y = points[index].mY; x1 = points[index].mX; x2 = x1; do { x1 = x2; index++; if (points.Count > index) { x2 = points[index].mX; } else { break; } } while ((x2 - x1 == 1) && (points[index].mY == y) && (index < points.Count)); index--; BorderLine line = new BorderLine(new Point(points[start].mX, points[start].mY + 1), new Point(points[index].mX + 1, points[index].mY + 1)); Thread.MemoryBarrier(); result.Add(line); index++; } }
private GraphicsPath BuildPath(HashSet <BorderLine> lines) { lines = new HashSet <BorderLine>(lines); GraphicsPath path = new GraphicsPath(); int x; BorderLine points = lines.First(); path.StartFigure(); path.AddLine(points.mStart, points.mEnd); lines.Remove(points); while (lines.Count > 0) { x = lines.Count; foreach (BorderLine line in lines.Where(line => path.GetLastPoint() == (PointF)line.mStart)) { path.AddLine(line.mStart, line.mEnd); lines.Remove(line); break; } if (x == lines.Count) { path.StartFigure(); points = lines.First(); path.AddLine(points.mStart, points.mEnd); lines.Remove(points); } } return(path); }