コード例 #1
0
        public static void RemoveSpikes(CurveItem ci, double s)
        {
            for (var i = 0; i < ci.Points.Count; i++)
            {
                if (!(Math.Abs(ci.Points[i].Y) > 2 * s))
                {
                    continue;
                }

                var max = i;
                for (var j = i + 1; j < ci.Points.Count; j++)
                {
                    if (Math.Abs(ci.Points[j].Y) < 2 * s)
                    {
                        break;
                    }

                    max = j;
                }

                if (i == 0 || max == ci.Points.Count - 1)
                {
                    for (var j = i; j <= max; j++)
                    {
                        ci.RemovePoint(j);
                        j--;
                        max--;
                    }
                }
                else
                {
                    var average = (ci.Points[i - 1].Y + ci.Points[max + 1].Y) / 2;
                    for (var j = i; j <= max; j++)
                    {
                        ci.Points[j].Y = average;
                    }

                    i += max - i;
                }
            }
        }