Exemplo n.º 1
0
        /// <summary>
        /// initializes data manager with data from las file and fills QTree structure with preliminary data
        /// </summary>
        public void Initialize(QTreeWrapper qtree, bool forcePreprocessing)
        {
            if (forcePreprocessing)
            {
                Console.WriteLine("Preprocessing forced. Not using serialized even if available");
                PreprocessDataFromFile(qtree);
                SerializeQtreeToFile(qtree, true);
            }
            else
            {
                QTree des = DeserializeQtreeFromFile(qtree.filename);

                if (des == null)
                {
                    Console.WriteLine("Deserialization failed. Preprocessing.");
                    PreprocessDataFromFile(qtree);
                    SerializeQtreeToFile(qtree, true);
                }
                else
                {
                    qtree.qtree = des;
                }
            }

            if (loadingEndedEvent != null)
            {
                loadingEndedEvent(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// renders the QTree in current openGl context
        /// </summary>
        private void RenderingPass(QTreeWrapper qtree, float FOV, float near, float far, Vector3f eyeVector, Point2f position)
        {
            QTree lasTree = qtree.qtree;

            if (lasTree != null)
            {
                lasTree.RenderingPass(FOV, near, far, eyeVector, position - qtree.positionOffset);

                /*
                 *                      Point3D tempPoint = new Point3D();
                 *                      int pointSize = Marshal.SizeOf(tempPoint);
                 *
                 *                      int allowedPointsInMemory = dedicatedPointMemory / pointSize;
                 *
                 *                      float percent = (float)lasTree.numberOfLoadedPoints / (float)allowedPointsInMemory;
                 *
                 *                      //allow discrepancy of 15%
                 *                      if (Math.Abs(percent - LOD) > 0.1)
                 *                      {
                 *                              LOD = (float)allowedPointsInMemory / (float)qtree.lasFile.header.NumberOfPointRecords;
                 *                              //lasTree.CascadeLOD(LOD);
                 *                      }
                 */
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// deserializes the tree from the file
        /// </summary>
        /// <returns>true if successful, false otherwise</returns>
        private QTree DeserializeQtreeFromFile(string filename)
        {
            Console.WriteLine("Deserilaizing qtree from file");

            string srlFilename = filename + "." + serializiationExtension;

            if (!File.Exists(srlFilename))
            {
                Console.WriteLine("Deserialization failed. The file does not exist.");
                return(null);
            }

            FileStream fileStreamObject = null;
            QTree      tree             = null;

            try
            {
                fileStreamObject = new FileStream(srlFilename, FileMode.Open);
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                tree = (binaryFormatter.Deserialize(fileStreamObject)) as QTree;
            }
            catch (Exception e)
            {
                Console.WriteLine("Deserialization failed: {0}" + e.ToString());
            }
            finally
            {
                if (fileStreamObject != null)
                {
                    fileStreamObject.Close();
                }
            }

            Console.WriteLine("Deserialization finished");
            return(tree);
        }
Exemplo n.º 4
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);
            }
        }