Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }