Exemple #1
0
        /// <summary>
        /// When the user presses the Move Plate Button, retrieves inputs from text boxes and runs Plate Movement.
        /// </summary>
        private void MovePlateButton_Click(object sender, EventArgs e)
        {
            errorDisplay.Text = "";
            if (!Int32.TryParse(sizeInput.Text, out int size))
            {
                errorDisplay.Text += "Size is not an integer. ";
                return;
            }
            List <double>[] genParams = new List <double> [3];
            genParams = ProcessString(velocityInput.Text, 3);
            if (genParams == null || genParams[0].Count != genParams[1].Count || genParams[1].Count != genParams[2].Count)
            {
                errorDisplay.Text += "Velocity is input incorrectly. Format is: 12.3,4.56,789; . ";
                return;
            }
            double[] speeds = new double[genParams[0].Count];
            double[,] directions = new double[2, genParams[1].Count];
            for (int i = 0; i < genParams[2].Count; i++)
            {
                speeds[i]        = genParams[0][i];
                directions[0, i] = genParams[1][i];
                directions[1, i] = genParams[2][i];
            }
            if (!Double.TryParse(timeStepInput.Text, out double timeStep))
            {
                errorDisplay.Text += "Time Step is not a number. ";
                return;
            }
            PlateLayer PlateLayerI = new PlateLayer(size, speeds.Length);

            if (!PlateLayerI.OpenFiles(directoryInput.Text, heightMapInput.Text, plateMapInput.Text))
            {
                errorDisplay.Text += "Bin Map input is unreadable. ";
                return;
            }
            PlateLayerI.PlatesVelocityInputs(speeds, directions);
            PlateLayerI.PlateMove(timeStep);
            PointIO pointIO = new PointIO {
                directory = directoryInput.Text
            };

            pointIO.SaveHeightImage(heightMapInput.Text, PlateLayerI.PastHeights);
            pointIO.SaveMapData(heightMapInput.Text, PlateLayerI.PastHeights);

            pointIO.SavePlateImage(plateMapInput.Text, PlateLayerI.PastPlates);
            pointIO.SaveMapData(plateMapInput.Text, PlateLayerI.PastPlates);

            pictureBox.ImageLocation = directoryInput.Text + "\\" + heightMapInput.Text + ".png";
            errorDisplay.Text        = "No errors yet. Errors will be displayed here.";
        }
Exemple #2
0
        /// <summary>
        /// When the user presses the Generation Button, retrieves inputs from text boxes and runs Plate Generation.
        /// </summary>
        private void GenerationButton_Click(object sender, EventArgs e)
        {
            errorDisplay.Text = "";
            if (!Int32.TryParse(sizeInput.Text, out int size))
            {
                errorDisplay.Text += "Size is not an integer. ";
                return;
            }
            if (!Int32.TryParse(numberOfPlatesInput.Text, out int numberOfPlates))
            {
                errorDisplay.Text += "Number of Plates is not an integer. ";
                return;
            }
            List <double>[] genParams = new List <double> [3];
            genParams = ProcessString(genParamsInput.Text, 3);
            if (genParams == null || genParams[0].Count != genParams[1].Count || genParams[1].Count != genParams[2].Count)
            {
                errorDisplay.Text += "Magnitude is input incorrectly. Format is: 12.3,4.56,789; . ";
                return;
            }
            double[] magnitude          = new double[genParams[0].Count];
            double[] radius             = new double[genParams[1].Count];
            double[] pointConcentration = new double[genParams[2].Count];
            for (int i = 0; i < genParams[0].Count; i++)
            {
                magnitude[i]          = genParams[0][i];
                radius[i]             = genParams[1][i];
                pointConcentration[i] = genParams[2][i];
            }
            if (!Int32.TryParse(cutoffInput.Text, out int cutoff))
            {
                errorDisplay.Text += "Cutoff is not an integer. ";
                return;
            }
            PlateLayer PlateLayerI = new PlateLayer(size, numberOfPlates);

            PlateLayerI.PlateGeneration(magnitude, radius, pointConcentration, cutoff);
            PointIO pointIO = new PointIO {
                directory = directoryInput.Text
            };

            pointIO.SaveHeightImage(outNameInput.Text, PlateLayerI.PastHeights);
            pointIO.SaveMapData(outNameInput.Text, PlateLayerI.PastHeights);
            pictureBox.ImageLocation = directoryInput.Text + "\\" + outNameInput.Text + ".png";
            errorDisplay.Text        = "No errors yet. Errors will be displayed here.";
        }