Example #1
0
        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);
                    }
                }
            }
        }
Example #2
0
 public SegmentExtractor(PointExtractor pointExtractor)
 {
     pe = pointExtractor;
 }
 public SegmentExtractor(PointExtractor pointExtractor)
 {
     pe = pointExtractor;
 }
Example #4
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            pointExt = new PointExtractor(bmp);
            points = pointExt.Points;
            pointMap = pointExt.PointMap;
            stopWatch.Stop();
            Log("Done extracting points in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            segExt = new SegmentExtractor(pointExt);
            segments = segExt.ExtractSegments();
            pointSegments = segExt.PointSegments;
            stopWatch.Stop();
            Log("Done extracting segments in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            vertExt = new VertexExtractor(segExt);
            vertices = vertExt.Vertices;
            vertexMap = vertExt.VertexMap;
            stopWatch.Stop();
            Log("Done extracting vertices in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            pathExt = new PathExtractor(vertExt);
            paths = pathExt.Paths;
            vertexPaths = pathExt.VertexPaths;
            stopWatch.Stop();
            Log("Done extracting paths in " + stopWatch.ElapsedMilliseconds + "ms");

            double ct = Double.Parse(textBoxCollapse.Text, CultureInfo.InvariantCulture);
            stopWatch.Restart();
            int collapsed = pathExt.CollapseVertices(ct);
            stopWatch.Stop();
            Log("Collapsed " + collapsed + " vertices in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            int loose = pathExt.RemoveLooseEnds();
            stopWatch.Stop();
            Log("Removed " + loose + " loose ends in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            int merged = pathExt.MergeConsecutivePaths();
            stopWatch.Stop();
            Log("Merged " + merged + " consecutive paths in " + stopWatch.ElapsedMilliseconds + "ms");

            double st = Double.Parse(textBoxSimplify.Text, CultureInfo.InvariantCulture);
            stopWatch.Restart();
            pathExt.SimplifyPaths(st);
            stopWatch.Stop();
            Log("Simplified paths in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            polyExt = new PolygonExtractor(pathExt.Paths, bmp);
            polygons = polyExt.ExtractPolygons();
            stopWatch.Stop();
            Log("Extracted polygons in " + stopWatch.ElapsedMilliseconds + "ms");

            jsonExport = new JsonExport(polyExt, bmp);

            labelPoints.Text = points.Count.ToString();
            labelSegments.Text = segments.Count.ToString();
            labelVertices.Text = vertices.Count.ToString();
            labelPaths.Text = paths.Count.ToString();
            labelPolygons.Text = polygons.Count.ToString();
        }
Example #5
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            pointExt = new PointExtractor(bmp);
            points   = pointExt.Points;
            pointMap = pointExt.PointMap;
            stopWatch.Stop();
            Log("Done extracting points in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            segExt        = new SegmentExtractor(pointExt);
            segments      = segExt.ExtractSegments();
            pointSegments = segExt.PointSegments;
            stopWatch.Stop();
            Log("Done extracting segments in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            vertExt   = new VertexExtractor(segExt);
            vertices  = vertExt.Vertices;
            vertexMap = vertExt.VertexMap;
            stopWatch.Stop();
            Log("Done extracting vertices in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            pathExt     = new PathExtractor(vertExt);
            paths       = pathExt.Paths;
            vertexPaths = pathExt.VertexPaths;
            stopWatch.Stop();
            Log("Done extracting paths in " + stopWatch.ElapsedMilliseconds + "ms");

            double ct = Double.Parse(textBoxCollapse.Text, CultureInfo.InvariantCulture);

            stopWatch.Restart();
            int collapsed = pathExt.CollapseVertices(ct);

            stopWatch.Stop();
            Log("Collapsed " + collapsed + " vertices in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            int loose = pathExt.RemoveLooseEnds();

            stopWatch.Stop();
            Log("Removed " + loose + " loose ends in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            int merged = pathExt.MergeConsecutivePaths();

            stopWatch.Stop();
            Log("Merged " + merged + " consecutive paths in " + stopWatch.ElapsedMilliseconds + "ms");

            double st = Double.Parse(textBoxSimplify.Text, CultureInfo.InvariantCulture);

            stopWatch.Restart();
            pathExt.SimplifyPaths(st);
            stopWatch.Stop();
            Log("Simplified paths in " + stopWatch.ElapsedMilliseconds + "ms");

            stopWatch.Restart();
            polyExt  = new PolygonExtractor(pathExt.Paths, bmp);
            polygons = polyExt.ExtractPolygons();
            stopWatch.Stop();
            Log("Extracted polygons in " + stopWatch.ElapsedMilliseconds + "ms");

            jsonExport = new JsonExport(polyExt, bmp);

            labelPoints.Text   = points.Count.ToString();
            labelSegments.Text = segments.Count.ToString();
            labelVertices.Text = vertices.Count.ToString();
            labelPaths.Text    = paths.Count.ToString();
            labelPolygons.Text = polygons.Count.ToString();
        }
Example #6
0
 public int GetVertexKey(Point p)
 {
     return(PointExtractor.GetPointKey(p));
 }