/// <summary>
 /// Constructor that sets the position and initial indexes.
 /// </summary>
 /// <param name="iPoint">Input Point.</param>
 public OverlapPoint(PlatePoint iPoint)
 {
     _position          = new KeyPoint(iPoint.X, iPoint.Y);
     plateIndex         = new List <int>();
     isContinentalIndex = new List <bool>();
     plateIndex.Add(iPoint.PlateNumber);
     isContinentalIndex.Add(iPoint.IsContinental);
 }
Exemple #2
0
 /// <summary>
 /// Constructor for Plate Point.
 /// </summary>
 /// <param name="point">Point to copy.</param>
 public PlatePoint(PlatePoint inPoint)
 {
     point = new BasePoint(inPoint.point);
     PlateNumber = inPoint.PlateNumber;
     _birthDate = inPoint._birthDate;
     _birthPlace = inPoint._birthPlace;
     History = inPoint.History;
     IsContinental = inPoint.IsContinental;
 }
Exemple #3
0
        /// <summary>
        /// Converts plate sorted plate point data into a map array.
        /// </summary>
        /// <returns>Map array of plate point data.</returns>
        private static PlatePoint[,] CompileData()
        {
            var output = new PlatePoint[2 * rules.xHalfSize, rules.ySize];

            Parallel.For(0, (rules.plateCount), (i) =>
            {
                foreach (KeyPoint iPoint in platePoints[i])
                {
                    output[iPoint.X, iPoint.Y] = new PlatePoint(iPoint, i, rules.currentTime);
                }
            });
            return(output);
        }
        /// <summary>
        /// Finds the height given an input point.
        /// </summary>
        /// <param name="iPoint">Point to find height for.</param>
        /// <param name="randomNumber">Random value to determine height.</param>
        /// <returns>Height of point.</returns>
        private static double GetHeight(PlatePoint iPoint, double randomNumber)
        {
            double height = 0;

            if (!iPoint.IsContinental)
            {
                return(height);
            }
            else
            {
                //Some math depending on concentration and density of initial point
                height += 1000 + 100 * randomNumber;
                //Some math depending on collision history
                height += 10 * iPoint.History.ContinentalBuildup * (iPoint.History.ContinentalRecency + 1) / rules.currentTime;
                height += 10 * iPoint.History.OceanicBuildup * (iPoint.History.OceanicRecency + 1) / rules.currentTime;
                return(height);
            }
        }
        /// <summary>
        /// Compiles data from Plates into an array of points for output.
        /// </summary>
        /// <returns>Array of points for output.</returns>
        private static PlatePoint[,] CompileData()
        {
            var output = new PlatePoint[2 * rules.xHalfSize, rules.ySize];

            Parallel.For(0, (rules.plateCount), (i) =>
            {
                foreach (PlatePoint iPoint in plates[i].PlatePoints)
                {
                    output[iPoint.X, iPoint.Y] = iPoint;
                    if (newContinentalCollision[iPoint.X, iPoint.Y] != 0)
                    {
                        iPoint.History.ContinentalBuildup += newContinentalCollision[iPoint.X, iPoint.Y];
                        iPoint.History.ContinentalRecency  = rules.currentTime;
                    }
                    if (newOceanicCollision[iPoint.X, iPoint.Y] != 0)
                    {
                        iPoint.History.OceanicBuildup += newOceanicCollision[iPoint.X, iPoint.Y];
                        iPoint.History.OceanicRecency  = rules.currentTime;
                    }
                }
            });
            return(output);
        }
Exemple #6
0
        /// <summary>
        /// Opens point data located at given file.
        /// </summary>
        /// <param name="fileName">File to open.</param>
        /// <param name="rules">Rules for how data will be read.</param>
        /// <returns>Data to output.</returns>
        /// <exception cref="InvalidDataException">File is not formatted correctly.</exception>
        /// <exception cref="FileNotFoundException">File could not be found.</exception>
        public static PlatePoint[,] OpenPointData(string fileName, GeneralRules rules)
        {
            var pointData = new PlatePoint[2 * rules.xHalfSize, rules.ySize];

            try
            {
                var plateNumbers       = CheapBinaryIO.Read(fileName + plateNumberExtension, rules.plateCount, 2 * rules.xHalfSize, rules.ySize);
                var isContinental      = CheapBinaryIO.ReadBinary(fileName + isContinentalExtension, 2 * rules.xHalfSize, rules.ySize);
                var birthTime          = CheapBinaryIO.Read(fileName + birthTimeExtension, rules.currentTime, 2 * rules.xHalfSize, rules.ySize);
                var xBirthPlace        = CheapBinaryIO.Read(fileName + xBirthPlaceExtension, 2 * rules.xHalfSize, 2 * rules.xHalfSize, rules.ySize);
                var yBirthPlace        = CheapBinaryIO.Read(fileName + yBirthPlaceExtension, rules.ySize, 2 * rules.xHalfSize, rules.ySize);
                var continentalBuildup = CheapBinaryIO.Read(fileName + continentalBuildupExtension, rules.maxBuildup, 2 * rules.xHalfSize, rules.ySize);
                var continentalRecency = CheapBinaryIO.Read(fileName + continentalRecencyExtension, rules.currentTime, 2 * rules.xHalfSize, rules.ySize);
                var oceanicBuildup     = CheapBinaryIO.Read(fileName + oceanicBuildupExtension, rules.maxBuildup, 2 * rules.xHalfSize, rules.ySize);
                var oceanicRecency     = CheapBinaryIO.Read(fileName + oceanicRecencyExtension, rules.currentTime, 2 * rules.xHalfSize, rules.ySize);

                for (int x = 0; x < 2 * rules.xHalfSize; x++)
                {
                    for (int y = 0; y < rules.ySize; y++)
                    {
                        var point      = new KeyPoint(x, y);
                        var birthPoint = new KeyPoint(xBirthPlace[x, y], yBirthPlace[x, y]);
                        var history    = new BoundaryHistory(continentalBuildup[x, y], continentalRecency[x, y], oceanicBuildup[x, y], oceanicRecency[x, y]);
                        pointData[x, y] = new PlatePoint(point, birthPoint, birthTime[x, y], plateNumbers[x, y], history, isContinental[x, y]);
                    }
                }
                return(pointData);
            }
            catch (FileNotFoundException e)
            {
                throw new FileNotFoundException("Data file missing. Can't find: " + e.Message, e.InnerException);
            }
            catch (Exception e) when(e is NullReferenceException || e is EndOfStreamException)
            {
                throw new InvalidDataException("Data file not formatted correctly. See: " + e.Message, e.InnerException);
            }
        }