Exemplo n.º 1
0
        public bool MoveNext()
        {
            if (stack.Count == 0)
            {
                return(false);
            }

            while (stack.Count != 0)
            {
                var currentIt = stack.Pop();
                if (currentIt.depth >= OctreeHelper.TreeMaxDepth)
                {
                    throw new MalformedOctreeException();
                }

                if (!currentIt.MoveNext())
                {
                    continue;
                }

                stack.Push(currentIt);

                switch (currentIt.ChildBits)
                {
                case BinNodeIterator.OccupiedNode:
                    if (currentIt.depth < maxDepth)
                    {
                        parent.KeyToPosition(currentIt.ChildKey, currentIt.depth + 1, out current);
                        return(true);
                    }

                    break;

                case BinNodeIterator.HasChildren:
                    ushort bitset = reader.ReadUshort();
                    currentIt.CreateChild(bitset, out var childIt);

                    stack.Push(childIt);
                    if (childIt.depth == maxDepth)
                    {
                        parent.KeyToPosition(childIt.key, childIt.depth, out current);
                        return(true);
                    }

                    break;
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool MoveNext()
        {
            if (stack.Count == 0)
            {
                return(false);
            }

            while (stack.Count != 0)
            {
                var currentIt = stack.Pop();
                if (currentIt.depth >= OctreeHelper.TreeMaxDepth)
                {
                    throw new MalformedOctreeException();
                }

                if (!currentIt.MoveNext())
                {
                    continue;
                }

                stack.Push(currentIt);

                if (!currentIt.HasChild)
                {
                    continue;
                }

                float logOdds = reader.ReadFloat();
                reader.Skip(strideAfterValue);
                sbyte bitset = reader.ReadByte();

                currentIt.CreateChild(bitset, out var childIt);
                if (!childIt.IsLeaf)
                {
                    stack.Push(childIt);
                }

                if (logOdds > MinLogOdds &&
                    (childIt.IsLeaf && childIt.depth <= maxDepth || childIt.depth == maxDepth))
                {
                    parent.KeyToPosition(childIt.key, childIt.depth, out current);
                    return(true);
                }
            }

            return(false);
        }