コード例 #1
0
        /// <summary>
        /// Gets the x min and max value of a btree, used for resetting the view/zoom fit
        /// </summary>
        /// <returns>X min max of the current btree | 0 = Min | 1 = Max</returns>
        public double[] GetBtreeMinMax()
        {
            NodeStatistics rootNodeValues = rootNode.GetValues();

            double[] returnValues = new double[2];
            returnValues[0] = rootNodeValues.xMin;
            returnValues[1] = rootNodeValues.xMax;
            return(returnValues);
        }
コード例 #2
0
        /// <summary>
        /// calculates averages in for current node
        /// </summary>
        public void CalculateAverages()
        {
            NodeStatistics recentNodeValues = nodeList[nodeList.Count - 1].GetValues();

            if (nodeList.Count == 1)
            {
                NodeStatistics values = nodeList[0].GetValues();
                localNodeVariables.yAvg            = values.yAvg;
                localNodeVariables.yMin            = values.yMin;
                localNodeVariables.yMax            = values.yMax;
                localNodeVariables.xAvg            = values.xAvg;
                localNodeVariables.xMin            = values.xMin;
                localNodeVariables.xMax            = values.xMax;
                localNodeVariables.totalPointCount = values.nodeCount;
            }
            else
            {
                if (localNodeVariables.yMax < recentNodeValues.yMax) //update max value
                {
                    localNodeVariables.yMax = recentNodeValues.yMax;
                }
                if (localNodeVariables.yMin > recentNodeValues.yMin) //update min value
                {
                    localNodeVariables.yMin = recentNodeValues.yMin;
                }
                localNodeVariables.xMax = recentNodeValues.xMax; //x value will always be max

                //update x average
                double tempX      = 0;
                double tempCountX = 0;
                for (int i = 0; i < nodeList.Count; i++)
                {
                    NodeStatistics values = nodeList[i].GetValues();
                    tempCountX = tempCountX + values.nodeCount;
                    tempX      = tempX + (values.xAvg * values.nodeCount);
                }
                localNodeVariables.xAvg = tempX / tempCountX;


                //update y average
                double tempY      = 0;
                double tempCountY = 0;
                for (int i = 0; i < nodeList.Count; i++)
                {
                    NodeStatistics values = nodeList[i].GetValues();
                    tempCountY = tempCountY + values.nodeCount;
                    tempY      = tempY + (values.yAvg * values.nodeCount);
                }
                localNodeVariables.yAvg = tempY / tempCountY;
            }
        }
コード例 #3
0
        public override List <Node> GetChildNodesInRange(double minX, double maxX)
        {
            List <Node> returnNode = new List <Node>();

            for (int i = 0; i < nodeList.Count; i++)
            {
                NodeStatistics tempValues = nodeList[i].GetValues();
                if (tempValues.xMin < maxX && tempValues.xMax > minX)
                {
                    returnNode.Add(nodeList[i]);
                }
            }
            return(returnNode);
        }
コード例 #4
0
        /// <summary>
        /// Gets data from the btree in a specific x min and max. First it gets the rootnode, and then goes down the btree until it has enough points according to "displayPointSize"
        /// </summary>
        /// <param name="minX">min display value</param>
        /// <param name="maxX">max display value</param>
        /// <returns>List of NodeVariables, this also includes leafPoint at the leafNode level</returns>
        public List <NodeStatistics> GetData(double minX, double maxX)
        {
            List <Node> results = new List <Node>();

            results.AddRange(rootNode.GetChildNodesInRange(minX, maxX));

            while (results.Count < displayPointSize && results.Count != 0 && results != null)
            {
                int         j        = results.Count;
                List <Node> tempList = new List <Node>();
                tempList.AddRange(results);
                results.Clear();
                NodeStatistics values = tempList[0].GetValues();
                if (values.currentNodeLevel != 0)
                {
                    for (int i = 0; i < j; i++)
                    {
                        results.AddRange(tempList[i].GetChildNodesInRange(minX, maxX));
                    }
                }
                else
                {
                    break;
                }
            }
            if (results.Count == 0)
            {
                return(null);
            }

            List <NodeStatistics> returnList = new List <NodeStatistics>();

            for (int i = 0; i < results.Count; i++)
            {
                returnList.Add(results[i].GetValues());
            }

            return(returnList);
        }