public int[] GetDataIndices(ITimeSegment t)
        {
            var           intervals   = GetTimeIntervals(t);
            var           projections = intervals.Select(a => timeAxisProjection.ProjectIntervalToTheAxis(a));
            HashSet <int> indices     = new HashSet <int>();

            foreach (var projection in projections)
            {
                int[] indices1 = dataMaskProvider.GetIndices(grid, projection.Item1, projection.Item2);
                int   len      = indices1.Length;
                for (int i = 0; i < len; i++)
                {
                    indices.Add(indices1[i]);
                }
            }

            return(indices.ToArray());
        }
        public IPs GetTempIPs(ITimeSegment t)
        {
            var           intervals = GetTimeIntervals(t);
            var           projections = intervals.Select(a => timeAxisProjection.ProjectIntervalToTheAxis(a));
            List <int>    indecesList = new List <int>(1024);
            List <double> weightsList = new List <double>(1024);
            int           start, stop;

            double[] weights    = null;
            double   sumWeights = 0.0;

            foreach (var projection in projections)
            {
                weights = weightsProvider.GetWeights(grid, projection.Item1, projection.Item2, out start, out stop);
                if (weights.Length == 0)
                {
                    return new IPs {
                               Indices = new int[0], Weights = new double[0]
                    }
                }
                ;
                else
                {
                    weightsList.AddRange(weights);

                    indecesList.AddRange(Enumerable.Range(start, stop - start + 1));
                }
            }
            if (weights == null)
            {
                throw new InvalidOperationException("ProjectIntervalToTheAxis returned no intervals");
            }

            IPs integrationPoints;

            Dictionary <int, double> weightsDict = new Dictionary <int, double>(1024);
            int N = weightsList.Count;

            for (int i = 0; i < N; i++)
            {
                int    idx = indecesList[i];
                double w   = weightsList[i];
                if (weightsDict.ContainsKey(idx))
                {
                    weightsDict[idx] += w;
                }
                else
                {
                    weightsDict.Add(idx, w);
                }
                sumWeights += w;
            }
            int M = weightsDict.Count;

            double[] resultWeigths = new double[M];
            int[]    resultIdx     = new int[M];
            int      iter          = 0;
            double   multipier     = 1.0 / sumWeights;

            foreach (var item in weightsDict)
            {
                resultWeigths[iter] = item.Value * multipier;
                resultIdx[iter]     = item.Key;
                iter++;
            }
            integrationPoints = new IPs {
                Indices = resultIdx, Weights = resultWeigths, BoundingIndices = new IndexBoundingBox {
                    first = resultIdx.Min(), last = resultIdx.Max()
                }
            };

            Debug.Assert(Math.Abs(integrationPoints.Weights.Sum() - 1.0) < 1e-6, string.Format("the difference is {0}", Math.Abs(integrationPoints.Weights.Sum() - 1.0)));
            return(integrationPoints);
        }