public long GetSegmentKey(Point p1, Point p2) { int p1Key = pe.GetPointKey(p1); int p2Key = pe.GetPointKey(p2); long multiplicator = pe.Image.Width * pe.Image.Height; int min = p1Key < p2Key ? p1Key : p2Key; int max = p1Key > p2Key ? p1Key : p2Key; return(min * multiplicator + max); }
private void FindEndVertex(Vertex startVertex, Point fromPoint, Segment nextSegment, List <Point> pointList) { Point nextPoint = (nextSegment.P2 == fromPoint) ? nextSegment.P1 : nextSegment.P2; int nextPointKey = PointExtractor.GetPointKey(nextPoint); if (ve.VertexMap.ContainsKey(nextPointKey)) { Vertex endVertex = ve.VertexMap[nextPointKey]; long pathKey = GetPathKey(startVertex, endVertex); if (!pathMap.ContainsKey(pathKey)) { pointList.Add(nextPoint); Path path = new Path(startVertex, endVertex, pointList); paths.Add(path); pathMap.Add(pathKey, path); InsertVertexPath(startVertex, path); InsertVertexPath(endVertex, path); } } else { List <Segment> toCheck = SegmentExtractor.PointSegments[nextPointKey]; foreach (Segment s in toCheck) { if (s != nextSegment && (s.P1 == nextPoint || s.P2 == nextPoint)) { pointList.Add(nextPoint); FindEndVertex(startVertex, nextPoint, s, pointList); } } } }
public int GetVertexKey(Point p) { return(PointExtractor.GetPointKey(p)); }