/// <summary> /// Constructor for Plate Point. /// </summary> /// <param name="inPoint"> Input coordinates for new point.</param> /// <param name="inPlateNumber">Number for which plate this point is part of.</param> /// <param name="time">Time for point creation.</param> public PlatePoint(KeyPoint inPoint, int inPlateNumber = 0, int time = 0) { point = new BasePoint(inPoint); _birthDate = time; PlateNumber = inPlateNumber; _birthPlace = inPoint; History = new BoundaryHistory(); IsContinental = false; }
/// <summary> /// Constructor for plate expansion. /// </summary> /// <param name="inPoint">Input point.</param> public PlatePoint(OverlapPoint inPoint, int inBirthDate = 0) { _birthPlace = new KeyPoint(inPoint.X, inPoint.Y); point = new BasePoint(_birthPlace); _birthDate = inBirthDate; PlateNumber = inPoint.plateIndex[0]; IsContinental = false; History = new BoundaryHistory(); }
/// <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; }
/// <summary> /// Constructor for plate generation for saved data. /// </summary> /// <param name="inPosition">Current position for point.</param> /// <param name="inBirthPlace">Birthplace for point.</param> /// <param name="inBirthDate">Birthdate for point.</param> /// <param name="inPlate">Which plate point is part of.</param> /// <param name="inHistory">Boundary history for point.</param> /// <param name="inIsContinental">Whether or not the point is continental or oceanic.</param> public PlatePoint(KeyPoint inPosition, KeyPoint inBirthPlace, int inBirthDate, int inPlate, BoundaryHistory inHistory, bool inIsContinental) { point = new BasePoint(inPosition); _birthPlace = inBirthPlace; _birthDate = inBirthDate; PlateNumber = inPlate; History = inHistory; IsContinental = inIsContinental; }
/// <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); } }