/// <summary> /// Adds another point for the octree. /// </summary> /// <param name="point">The point to add.</param> public void AddPoint(Common.Point point) { _pointCounter++; if (_pointCounter % COMPUTE_EVERY != 0 && COMPUTE_EVERY != 1) { return; } _octree.Add(point.Position, OctreeNodeStates.Occupied); }
/// <summary> /// Reads the asset. /// </summary> private static void StreamFromAsset() { Stream storage = IO.StreamFromFile("Assets/" + _assetName, FileMode.Open); using (var sr = new StreamReader(storage)) { string line; while ((line = sr.ReadLine()) != null) // read per line { Common.Point point = ConvertTextToPoint(line); if (point != null) { OnNewPointCallbacks?.Invoke(point); } } OnAssetLoadedCallbacks?.Invoke(); } }
/// <summary> /// Called from StreamFromAsset(). /// </summary> /// <param name="line">Text line.</param> /// <returns>Point object</returns> private static Common.Point ConvertTextToPoint(string line) { string delimiter = "\t"; string[] textElements = line.Split(delimiter.ToCharArray()); if (textElements.Length == 1) // empty line { return(null); } Common.Point point = new Common.Point(); // convert each string to float float[] numbers = new float[textElements.Length]; for (var i = 0; i < numbers.Length; i++) { numbers[i] = float.Parse(textElements[i], CultureInfo.InvariantCulture.NumberFormat); // prevent fusee from the same thing that happend to ariane 5 // because e.g. 16 - 0.0000001f = 16, but Math.Floor(0.1E-06 / 16) = -1 and that isn't what we want if (numbers[i] < 0.000001f && numbers[i] > -0.000001f) { numbers[i] = 0; } } point.Position = new float3(numbers[0], numbers[2], numbers[1]); if (numbers.Length == 9) { point.Color = new float3(numbers[3], numbers[4], numbers[5]); point.EchoId = numbers[6]; point.ScanNr = numbers[8]; } return(point); }
private void ReadContents() { using (StringReader sr = new StringReader(Contents)) { while (sr.Peek() >= 0) { string l = sr.ReadLine(); switch (l.Substring(0, 1)) { case "A": ARecord = new ARecord(l); break; case "B": BRecord b = new BRecord(l, FlightDate, IRecord); if (!BRecords.ContainsKey(b.Time)) { BRecords.Add(b.Time, b); } break; case "C": break; case "D": break; case "E": ERecord e = new ERecord(l, FlightDate); ERecords.Add(e); if (e.Code == "STA") { DetectedStart = e.Time; } break; case "F": break; case "G": GRecord = GRecord + l.Substring(1); break; case "H": HRecord h = new HRecord(l); HRecords.Add(h.Code, h); if (HRecords.ContainsKey("DTE")) { FlightDate = new DateTime(2000 + int.Parse(HRecords["DTE"].Value.Substring(4, 2)), int.Parse(HRecords["DTE"].Value.Substring(2, 2)), int.Parse(HRecords["DTE"].Value.Substring(0, 2))); } break; case "I": IRecord = new ExtensionRecord(l); break; case "J": JRecord = new ExtensionRecord(l); break; } } } if (DetectedStart == null && BRecords.Count > 0) { DetectedStart = BRecords.First().Key; } // Process other H records if (HRecords.ContainsKey("PLT")) { PilotName = HRecords["PLT"].Value.CutOffUntilCharacter(":").Trim(); } if (HRecords.ContainsKey("GTY")) { GliderType = HRecords["GTY"].Value.CutOffUntilCharacter(":").Trim(); } if (HRecords.ContainsKey("GID")) { GliderRegistration = HRecords["GID"].Value.CutOffUntilCharacter(":").Trim(); } if (HRecords.ContainsKey("CCL")) { GliderClass = HRecords["CCL"].Value.CutOffUntilCharacter(":").Trim(); } // Process B records BRecord currentRecord = null; foreach (DateTime k in BRecords.Keys) { if (k > DetectedStart & currentRecord != null) { if (Takeoff == null) { Takeoff = new Common.Point(currentRecord); } BRecords[k].CompareWith(currentRecord); if (BRecords[k].GnssAltitude > MaxAltitude) { MaxAltitude = BRecords[k].GnssAltitude; } if (BRecords[k].GnssAltitude < MinAltitude) { MinAltitude = BRecords[k].GnssAltitude; } if (BRecords[k].Vario > MaxVario) { MaxVario = BRecords[k].Vario; } if (BRecords[k].Vario < MinVario) { MinVario = BRecords[k].Vario; } if (BRecords[k].Speed > MaxSpeed) { MaxSpeed = BRecords[k].Speed; } Distance = Distance + BRecords[k].Distance; } currentRecord = BRecords[k]; } DetectedLandingTime = currentRecord.Time; FlightTime = DetectedLandingTime.Subtract(DetectedStart); Landing = new Common.Point(currentRecord); AverageSpeed = Convert.ToSingle((float)Distance / (float)FlightTime.TotalSeconds); }
void noForm_LocationChanged(Common.Point obj) { winForm.Location = new System.Drawing.Point((int)noForm.Location.X, (int)noForm.Location.Y); }
/// <summary> /// Adds another point to this point cloud. /// </summary> /// <param name="point">The point to add.</param> public void AddPoint(Common.Point point) { AddPoint(point.Position); }