Exemplo n.º 1
0
        public QTree(LasDataManager dMgr, LASFile lasfile)
        {
            TreeID = Guid.NewGuid();

            las_header = lasfile.header;

            int num_Leafs = (int)las_header.NumberOfPointRecords / POINTS_PER_LEAF;

            double d = Math.Sqrt((double)las_header.NumberOfPointRecords / POINTS_PER_LEAF);

            NumberOfTreeLevels = (int)Math.Ceiling(Math.Log(d, 2)) + 1;
            double nodesOneSide = Math.Pow(2, NumberOfTreeLevels - 1);

            double currLeafs = nodesOneSide * nodesOneSide;

            double dWidth  = las_header.MaxX - las_header.MinX;
            double dHeight = las_header.MaxY - las_header.MinY;

            QTreeNode.MAX_WIDTH  = (float)(dWidth / nodesOneSide);
            QTreeNode.MAX_HEIGHT = (float)(dHeight / nodesOneSide);

            Console.WriteLine("Creating QTree");
            Console.WriteLine("Map width={0} height={1}", dWidth, dHeight);
            Console.WriteLine("Calculated points per leaf: {0} , actual: {1}, leafs: {2}", POINTS_PER_LEAF, (double)las_header.NumberOfPointRecords / (double)currLeafs, currLeafs);
            Console.WriteLine("Node width={0} height={1}", QTreeNode.MAX_WIDTH, QTreeNode.MAX_HEIGHT);

            //init qleaf direct access array
            numberOfLeafs = (int)currLeafs;

            root = new QTreeNode(new BoundingBox(0, 0, (float)dWidth, (float)dHeight), this, null, 0);

            Console.WriteLine("Created nodes={0}", QTreeNode.NUM_NODES);
        }
Exemplo n.º 2
0
        public QTreeLeaf(BoundingBox bb, Guid parentTreeID, QTreeNode parentNode)
        {
            ParentTreeID    = parentTreeID;
            this.ParentNode = parentNode;

            QTreeWrapper parent = LasDataManager.GetInstance().GetQtreeByGuid(parentTreeID);

            parentVBOs = new Stack <VBOStorageInformation>(); //stored on this level

            ListInfos = new List <ListInfo>();
            LasMetrics.GetInstance().numberOfLeafs++;

            boundingBox = bb;

            if (randArray == null)
            {
                randArray = new float[3000];

                for (int i = 0; i < randArray.Length; i++)
                {
                    randArray[i] = (float)rand.NextDouble();
                }
            }
        }
Exemplo n.º 3
0
        private List <VBOStorageInformation> serverBufferIds = new List <VBOStorageInformation>(); //VBOS from all children

        public QTreeNode(BoundingBox boundingBox, QTree parentTree, QTreeNode parentNode, int hierarchyLevel)
        {
            NUM_NODES++;

            this.ParentNodeID = parentNode;
            this.boundingBox  = boundingBox;

            nodeHierarchyLevel = (float)hierarchyLevel / parentTree.NumberOfTreeLevels;

            //if bounding box is bigger than allowed split it nodes
            if (boundingBox.width > MAX_WIDTH || boundingBox.height > MAX_HEIGHT)
            {
                nodes = new QTreeNode[4];

                BoundingBox bb = new BoundingBox();
                bb.width  = boundingBox.width / 2.0f;
                bb.height = boundingBox.height / 2.0f;
                bb.x      = boundingBox.x + bb.width;
                bb.y      = boundingBox.y;
                nodes[NE] = new QTreeNode(bb, parentTree, this, hierarchyLevel + 1);

                bb.x      = boundingBox.x;
                nodes[NW] = new QTreeNode(bb, parentTree, this, hierarchyLevel + 1);

                bb.y     += bb.height;
                nodes[SW] = new QTreeNode(bb, parentTree, this, hierarchyLevel + 1);

                bb.x     += bb.width;
                nodes[SE] = new QTreeNode(bb, parentTree, this, hierarchyLevel + 1);
            }
            else
            {
                //node is final - contains only data which is present in QTreeLeaf
                leaf = new QTreeLeaf(boundingBox, parentTree.TreeID, this);
            }
        }