public static void Filter(SlabModel3D aSlab) { if (aSlab == null) { return; } if (aSlab.TopLines != null) { for (var i = 0; i < aSlab.TopLines.Length; ++i) { FilterLeftView(aSlab.TopLines[i]); } } if (aSlab.BottomLines != null) { for (var i = 0; i < aSlab.BottomLines.Length; ++i) { FilterLeftView(aSlab.BottomLines[i]); } } if (aSlab.LeftLines != null) { for (var i = 0; i < aSlab.LeftLines.Length; ++i) { FilterTopView(aSlab.LeftLines[i]); } } if (aSlab.RightLines != null) { for (var i = 0; i < aSlab.RightLines.Length; ++i) { FilterTopView(aSlab.RightLines[i]); } } }
private static int CalculateBumpLength(SlabModel3D aSlab, int aStart) { var topLine = aSlab.TopLines[aSlab.TopLines.Length / 2]; var bottomLine = aSlab.BottomLines[aSlab.BottomLines.Length / 2]; for (var i = aStart; i < topLine.Length - 1 && i < bottomLine.Length - 1; ++i) { var topDifference = topLine[i].Y - topLine[i + 1].Y; var bottomDifference = bottomLine[i].Y - bottomLine[i + 1].Y; if (topDifference * bottomDifference <= double.Epsilon) { // имеют разные направления или маленькие return i - aStart; } } return topLine.Length - 1 - aStart; }
public static void Filter(SlabModel3D aSlab) { if (aSlab == null) { return; } var line = aSlab.TopLines[aSlab.TopLines.Length/2]; for (var i = 0; i < line.Length - 1; ++i) { if (IsBump(aSlab, i)) { var bumpLength = CalculateBumpLength(aSlab, i); FilterBumping(aSlab, i, bumpLength); } } }
private const int WINDOW_SIZE = 10; // размер окна для вычисления среднего. #endregion Fields #region Methods public static void Filter(SlabModel3D aSlab) { if (aSlab == null) { return; } for (var i = 0; i < aSlab.TopLines.Length; ++i) { var segments = FindSegments(aSlab.TopLines[i]); FilterLine(aSlab.TopLines[i], segments); } for (var i = 0; i < aSlab.BottomLines.Length; ++i) { var segments = FindSegments(aSlab.BottomLines[i]); FilterLine(aSlab.BottomLines[i], segments); } }
private static bool IsBump(SlabModel3D aSlab, int aStart) { var topLine = aSlab.TopLines[aSlab.TopLines.Length/2]; var bottomLine = aSlab.BottomLines[aSlab.BottomLines.Length/2]; for (var i = aStart; i < aStart + BUMP_POINTS_LENGTH && i < topLine.Length - 1 && i < bottomLine.Length - 1; ++i) { var topDifference = topLine[i].Y - topLine[i + 1].Y; var bottomDifference = bottomLine[i].Y - bottomLine[i + 1].Y; if (topDifference*bottomDifference <= double.Epsilon) {// имеют разные направления return false; } } return true; }
private static void FilterBumping(SlabModel3D aSlab, int aStart, int aBumpLength) { var topLine = aSlab.TopLines[aSlab.TopLines.Length / 2]; if (aStart + aBumpLength >= topLine.Length) { return; } var topDifference = topLine[aStart].Y - topLine[aStart + aBumpLength].Y; var topLineFirstPointsY = topLine[aStart].Y; for (var i = 0; i < aSlab.TopLines.Length; ++i) { for (var j = aStart; j < aSlab.TopLines[i].Length; ++j) { if (j <= aStart + aBumpLength) { aSlab.TopLines[i][j].Y = topLineFirstPointsY; } else { aSlab.TopLines[i][j].Y += topDifference; } } } var bottomLine = aSlab.BottomLines[aSlab.BottomLines.Length / 2]; if (aStart + aBumpLength >= bottomLine.Length) { return; } var bottomDifference = bottomLine[aStart].Y - bottomLine[aStart + aBumpLength].Y; var bottomLineFirstPointsY = bottomLine[aStart].Y; for (var i = 0; i < aSlab.BottomLines.Length; ++i) { for (var j = aStart; j < aSlab.BottomLines[i].Length; ++j) { if (j <= aStart + aBumpLength) { aSlab.BottomLines[i][j].Y = bottomLineFirstPointsY; } else { aSlab.BottomLines[i][j].Y += bottomDifference; } } } }
public void SetSlabModel(SlabModel3D aSlabModel) { slabModel = aSlabModel; }
private void LoadSensorsValues(object sender, DoWorkEventArgs e) { if (client == null || !client.IsConnected) { isErrorLoading = true; return; } try { sensors = client.GetSensorInfos(); if (sensors != null) { var sensorPercens = 90/sensors.Length; points = new PointF[sensors.Length][]; for (var i = 0; i < sensors.Length; ++i) { var sensorValues = client.GetSensorValuesBySlabId(slabId, sensors[i].Id); if (sensorValues != null && sensorValues.Length > 0) { points[i] = new PointF[sensorValues.Length]; var startTime = DateTime.FromBinary(sensorValues[0].Time); for (var j = 0; j < sensorValues.Length; ++j) { var time = DateTime.FromBinary(sensorValues[j].Time).Subtract(startTime); points[i][j] = new PointF((float) time.TotalMilliseconds, (float) sensorValues[j].Value); } } loader.ReportProgress((i + 1)*sensorPercens); } slabModel = client.GetSlabModel3DBySlabId(slabId, isUseFilters); loader.ReportProgress(95); systemDimentions = client.GetDimentions(); slabDimentionsResults = client.GetDimentionResultsBySlabId(slabId); regulations = client.GetRegulations(); loader.ReportProgress(100); } isErrorLoading = false; } catch (Exception ex) { MessageBox.Show(@"Ошибка при загрузке данных слитка: " + ex.Message); isErrorLoading = true; } }
public SlabModel3D ToSlabModel() { var model = new SlabModel3D(); model.TopLines = new SlabPoint[TopLines.Length][]; model.BottomLines = new SlabPoint[BottomLines.Length][]; model.LeftLines = new SlabPoint[LeftLines.Length][]; model.RightLines = new SlabPoint[RightLines.Length][]; for (var i = 0; i < TopLines.Length; ++i) { var line = new List<SlabPoint>(); for (var j = 0; j < TopLines[i].Length; ++j) { var linePoint = TopLines[i][j]; var point = new SlabPoint { X = linePoint.X, Y = linePoint.Y, Z = linePoint.Z }; line.Add(point); } model.TopLines[i] = line.ToArray(); } for (var i = 0; i < BottomLines.Length; ++i) { var line = new List<SlabPoint>(); for (var j = 0; j < BottomLines[i].Length; ++j) { var linePoint = BottomLines[i][j]; var point = new SlabPoint { X = linePoint.X, Y = linePoint.Y, Z = linePoint.Z }; line.Add(point); } model.BottomLines[i] = line.ToArray(); } for (var i = 0; i < LeftLines.Length; ++i) { var line = new List<SlabPoint>(); for (var j = 0; j < LeftLines[i].Length; ++j) { var linePoint = LeftLines[i][j]; var point = new SlabPoint { X = linePoint.X, Y = linePoint.Y, Z = linePoint.Z }; line.Add(point); } model.LeftLines[i] = line.ToArray(); } for (var i = 0; i < RightLines.Length; ++i) { var line = new List<SlabPoint>(); for (var j = 0; j < RightLines[i].Length; ++j) { var linePoint = RightLines[i][j]; var point = new SlabPoint { X = linePoint.X, Y = linePoint.Y, Z = linePoint.Z }; line.Add(point); } model.RightLines[i] = line.ToArray(); } return model; }
private void Filtered(SlabModel3D aSlabModel) { if (aSlabModel == null) { return; } try { SplashFilter.Filter(aSlabModel); } catch { MessageBox.Show(@"Возникла ошибка в фильтре всплесков в начале и конце измерений."); } try { PickFilter.Filter(aSlabModel); } catch { MessageBox.Show(@"Возникла ошибка в фильтре пиков."); } try { BumpFilter.Filter(aSlabModel); } catch { MessageBox.Show(@"Возникла ошибка в фильтре подпрыгиваний."); } try { AverageFilter.Filter(aSlabModel); } catch { MessageBox.Show(@"Возникла ошибка в фильтре средних."); } }
/// <summary> /// Для передачи по сети. /// </summary> /// <returns></returns> public SlabModel3D ToSlabModel() { var model = new SlabModel3D(); model.CenterLine = new SlabPoint[CenterLine.Length]; for (var i = 0; i < CenterLine.Length; ++i) { model.CenterLine[i] = new SlabPoint { X = CenterLine[i].X, Y = CenterLine[i].Y, Z = CenterLine[i].Z }; } model.Diameters = new double[Diameters.Length]; for (var i = 0; i < Diameters.Length; ++i) { model.Diameters[i] = Diameters[i]; } var sensorsCount = 4; model.SensorsLines = new SlabPoint[sensorsCount][]; model.SensorsLines[0] = BuildSensorLine(TopSensorLine); model.SensorsLines[1] = BuildSensorLine(BottomSensorLine); model.SensorsLines[2] = BuildSensorLine(LeftSensorLine); model.SensorsLines[3] = BuildSensorLine(RightSensorLine); return model; }