Пример #1
0
        /// <summary>
        /// Creates new voronoi and updates mesh and player area.
        /// </summary>
        private void UpdateVoronoi()
        {
            // create voronoi diagram from delaunay triangulation
            m_DCEL = Voronoi.Create(m_delaunay);

            UpdateMesh();
            UpdatePlayerAreaOwned();
        }
Пример #2
0
    /*
    public static Bitmap Apply(Bitmap original, Bitmap bmp, int n) {
      return original;
    }
    */
    public static Bitmap Apply(Bitmap original, Bitmap bmp, Point[] points, FilterInfo[] info) {
      Voronoi voronoi = new Voronoi(original.Width, original.Height);

      // TODO Threading
      for (int i = 0; i < points.Length; ++i) {
        Point[] polygon = Round(voronoi.GetPolygon(i, ToFloat(points)));
        //PointF[] polygon = voronoi.GetPolygon(i, ToFloat(points));
        PolygonFilter.Apply(original, bmp, polygon, info[i]);
      };

      return bmp;
    }
Пример #3
0
        private void voronoiButton_Click(object sender, EventArgs e)
        {
            if (sampler == null)
            {
                MessageBox.Show("You must load a original picture", "Original picture missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (timesCheckBox.Checked && MessageBox.Show("Are you sure, that interval 0-100% is right? Solving Voronoi diagram on this interval can be very slowly (tens of minutes, hours, ...).", "Is interval 0-100% right?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }

            voronoiButton.Enabled = false;

            AutoSample(e);

            BenTools.Data.HashSet <BenTools.Mathematics.Vector> data = sampler.GetSampledData();

            if (data == null && !resample.Checked)
            {
                MessageBox.Show("You must sample original picture", "Original picture isn't sampled.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            voronoi = new Voronoi(data);

            Thread t = new Thread(ComputeVoronoiMap);

            t.Start();

            while (t.ThreadState == ThreadState.Running)
            {
                Application.DoEvents();
                Thread.Sleep(200);
                voronoiProgress.Value = voronoi.GetProgressOfComputing();
            }

            voronoiButton.Enabled = true;
        }