コード例 #1
0
        private void RunTriangulation_Click(object sender, EventArgs e)
        {
            switch (triangulationsComboBox.SelectedIndex)
            {
            case 0:
                return;

            case 1:
                ResetShading();
                ResetTriangulation();

                sw = Stopwatch.StartNew();
                SimpleIterativeTriangulation.Run(pivotPoints, triangulationSectionsList, trianglesHashSet);
                sw.Stop();
                label9.Text = sw.ElapsedMilliseconds.ToString();
                DrawOperations.SectionsToBitmap(triangulationSectionsList, triangulationGridBitmap);
                triangulationGridPictureBox.Image = triangulationGridBitmap;

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled   = true;
                showHidePPointsGroupBox.Enabled = true;
                showHideGridGroupBox.Enabled    = true;
                pPointsControlsGroupBox.Enabled = true;
                shadingControlsGroupBox.Enabled = true;
                showGrid.Checked            = true;
                label10.Text                = "";
                label14.Text                = trianglesHashSet.Count.ToString();
                standartDeviationLabel.Text = "";
                saveInPngButton.Enabled     = false;
                saveInTButton.Enabled       = true;
                return;

            case 2:
                ResetShading();
                ResetTriangulation();

                coefOfCacheExpand = float.Parse(coefOfCacheExpandTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                sw = Stopwatch.StartNew();
                DCIterativeTriangulation.Run(pivotPoints, triangulationSectionsList, trianglesHashSet, coefOfCacheExpand);
                sw.Stop();
                label9.Text = sw.ElapsedMilliseconds.ToString();
                DrawOperations.SectionsToBitmap(triangulationSectionsList, triangulationGridBitmap);
                triangulationGridPictureBox.Image = triangulationGridBitmap;

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled   = true;
                showHidePPointsGroupBox.Enabled = true;
                showHideGridGroupBox.Enabled    = true;
                pPointsControlsGroupBox.Enabled = true;
                shadingControlsGroupBox.Enabled = true;
                showGrid.Checked            = true;
                label10.Text                = "";
                label14.Text                = trianglesHashSet.Count.ToString();
                standartDeviationLabel.Text = "";
                saveInPngButton.Enabled     = false;
                saveInTButton.Enabled       = true;
                return;

            case 3:
                ResetShading();
                ResetTriangulation();

                stripingFactor = float.Parse(stripingFactorTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                sw             = Stopwatch.StartNew();
                StripIterativeTriangulation.Run(pivotPoints, triangulationSectionsList, trianglesHashSet, stripingFactor);
                sw.Stop();
                label9.Text = sw.ElapsedMilliseconds.ToString();
                DrawOperations.SectionsToBitmap(triangulationSectionsList, triangulationGridBitmap);
                triangulationGridPictureBox.Image = triangulationGridBitmap;

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled   = true;
                showHidePPointsGroupBox.Enabled = true;
                showHideGridGroupBox.Enabled    = true;
                pPointsControlsGroupBox.Enabled = true;
                shadingControlsGroupBox.Enabled = true;
                showGrid.Checked            = true;
                label10.Text                = "";
                label14.Text                = trianglesHashSet.Count.ToString();
                standartDeviationLabel.Text = "";
                saveInPngButton.Enabled     = false;
                saveInTButton.Enabled       = true;
                return;
            }
        }
コード例 #2
0
        private void RunPPMakerButton_Click(object sender, EventArgs e)
        {
            switch (pPMakersComboBox.SelectedIndex)
            {
            case 0:
                return;

            case 1:
                ResetShading();
                ResetTriangulation();
                ResetPivotPoints();

                pPMakerThreshold = byte.Parse(pPMakerThresholdTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                sectorSize       = int.Parse(sectorSizeTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                sw = Stopwatch.StartNew();

                ParallelSectorPPMaker ppm = new ParallelSectorPPMaker(sourceImageBitmap, pivotPoints, pPMakerThreshold, sectorSize);
                ppm.Run();

                //SectorPPMaker.Run(sourceImageBitmap, pivotPoints, pPMakerThreshold, sectorSize);

                sw.Stop();
                label8.Text = sw.ElapsedMilliseconds.ToString();
                DrawOperations.PixelsToBitmap(pivotPoints, pivotPointsBitmap);
                pivotPointsPictureBox.Image = pivotPointsBitmap;

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled         = true;
                showHidePPointsGroupBox.Enabled       = true;
                showHideGridGroupBox.Enabled          = false;
                triangulationControlsGroupBox.Enabled = true;
                shadingControlsGroupBox.Enabled       = false;
                showPivotPoints.Checked     = true;
                label9.Text                 = "";
                label10.Text                = "";
                label13.Text                = pivotPoints.Count.ToString();
                label14.Text                = "";
                standartDeviationLabel.Text = "";
                saveInPngButton.Enabled     = false;
                saveInTButton.Enabled       = true;

                // Код для вывода в файлы
                //using (StreamWriter thresholdFile = new StreamWriter(@"D:\VSProjects\image-triangulation\image-triangulation\threshold.txt", true, System.Text.Encoding.Default))
                //{
                //    thresholdFile.WriteLine(pPMakerThreshold);
                //}
                //using (StreamWriter pointsdFile = new StreamWriter(@"D:\VSProjects\image-triangulation\image-triangulation\points.txt", true, System.Text.Encoding.Default))
                //{
                //    pointsdFile.WriteLine(pivotPoints.Count);
                //}
                return;

            case 2:
                ResetShading();
                ResetTriangulation();
                ResetPivotPoints();

                pPMakerThreshold = byte.Parse(pPMakerThresholdTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                sw = Stopwatch.StartNew();
                SearchInTriangle.Run(sourceImageBitmap, pPMakerThreshold, pivotPoints, triangulationSectionsList, trianglesHashSet);
                sw.Stop();
                label8.Text = sw.ElapsedMilliseconds.ToString();

                DrawOperations.PixelsToBitmap(pivotPoints, pivotPointsBitmap);
                pivotPointsPictureBox.Image = pivotPointsBitmap;
                DrawOperations.SectionsToBitmap(triangulationSectionsList, triangulationGridBitmap);
                triangulationGridPictureBox.Image = triangulationGridBitmap;

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled         = true;
                showHidePPointsGroupBox.Enabled       = true;
                showHideGridGroupBox.Enabled          = true;
                triangulationControlsGroupBox.Enabled = true;
                shadingControlsGroupBox.Enabled       = true;
                showPivotPoints.Checked     = true;
                showGrid.Checked            = true;
                label9.Text                 = "";
                label10.Text                = "";
                label13.Text                = pivotPoints.Count.ToString();
                label14.Text                = trianglesHashSet.Count.ToString();
                standartDeviationLabel.Text = "";
                saveInPngButton.Enabled     = false;
                saveInTButton.Enabled       = true;

                // Код для вывода в файлы
                //using (StreamWriter thresholdFile = new StreamWriter(@"D:\VSProjects\image-triangulation\image-triangulation\threshold.txt", true, System.Text.Encoding.Default))
                //{
                //    thresholdFile.WriteLine(pPMakerThreshold);
                //}
                //using (StreamWriter pointsdFile = new StreamWriter(@"D:\VSProjects\image-triangulation\image-triangulation\points.txt", true, System.Text.Encoding.Default))
                //{
                //    pointsdFile.WriteLine(pivotPoints.Count);
                //}
                return;

            case 4:
                ResetShading();
                ResetTriangulation();
                ResetPivotPoints();

                int numberOfPivotPoints = int.Parse(textBoxNumberOfPivotPoints.Text, System.Globalization.CultureInfo.InvariantCulture);
                sw = Stopwatch.StartNew();
                RandomPPMaker.Run(sourceImageBitmap, pivotPoints, numberOfPivotPoints);
                sw.Stop();
                label8.Text = sw.ElapsedMilliseconds.ToString();
                DrawOperations.PixelsToBitmap(pivotPoints, pivotPointsBitmap);
                pivotPointsPictureBox.Image = pivotPointsBitmap;

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled         = true;
                showHidePPointsGroupBox.Enabled       = true;
                showHideGridGroupBox.Enabled          = false;
                triangulationControlsGroupBox.Enabled = true;
                shadingControlsGroupBox.Enabled       = false;
                showPivotPoints.Checked     = true;
                label9.Text                 = "";
                label10.Text                = "";
                label13.Text                = pivotPoints.Count.ToString();
                label14.Text                = "";
                standartDeviationLabel.Text = "";
                saveInPngButton.Enabled     = false;
                saveInTButton.Enabled       = true;
                return;
            }
        }