Exemple #1
0
        /// <summary>
        /// Returns new octree with LOD data created.
        /// </summary>
        public static PointSet GenerateLod(this PointSet self, ImportConfig config)
        {
            if (self.Root == null)
            {
                return(self);
            }

            var nodeCount        = self.Root?.Value?.CountNodes(true) ?? 0;
            var loddedNodesCount = 0L;
            var result           = self.GenerateLod(config.Key, () =>
            {
                config.CancellationToken.ThrowIfCancellationRequested();
                var i = Interlocked.Increment(ref loddedNodesCount);
                if (config.Verbose)
                {
                    Console.Write($"[Lod] {i}/{nodeCount}\r");
                }
                if (i % 100 == 0)
                {
                    config.ProgressCallback(loddedNodesCount / (double)nodeCount);
                }
            }, config.CancellationToken);

            result.Wait();

            config.ProgressCallback(1.0);

            return(result.Result);
        }
Exemple #2
0
        /// <summary>
        /// Creates PointSet from given points and colors.
        /// </summary>
        public static PointSet Create(Storage storage, string key,
                                      IList <V3d> positions, IList <C4b> colors, IList <V3f> normals, IList <int> intensities, IList <byte> classifications,
                                      int octreeSplitLimit, bool generateLod, bool isTemporaryImportNode, CancellationToken ct
                                      )
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            var bounds  = new Box3d(positions);
            var builder = InMemoryPointSet.Build(positions, colors, normals, intensities, classifications, bounds, octreeSplitLimit);
            var root    = builder.ToPointSetNode(storage, isTemporaryImportNode);

            var result = new PointSet(storage, key, root.Id, octreeSplitLimit);

            if (result.Root.Value == null)
            {
                throw new InvalidOperationException("Invariant 5492d57b-add1-48bf-9721-5087c957d81e.");
            }

            var config = ImportConfig.Default
                         .WithRandomKey()
                         .WithCancellationToken(ct)
            ;

            if (generateLod)
            {
                result = result.GenerateLod(config);
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        public static PointSet GenerateLod(this PointSet self, ImportConfig config)
        {
            if (config.CreateOctreeLod == false)
            {
                return(self);
            }

            var nodeCount        = self.Root.Value.CountNodes();
            var loddedNodesCount = 0L;
            var result           = self.GenerateLod(config.Key, () =>
            {
                config.CancellationToken.ThrowIfCancellationRequested();
                var i = Interlocked.Increment(ref loddedNodesCount);
                if (config.Verbose)
                {
                    Console.Write($"[Lod] {i}/{nodeCount}\r");
                }
                if (i % 100 == 0)
                {
                    config.ProgressCallback(i / (double)nodeCount);
                }
            }, config.MaxDegreeOfParallelism, config.CancellationToken);

            config.ProgressCallback(1.0);

            return(result);
        }
        /// <summary>
        /// Creates PointSet from given points and colors.
        /// </summary>
        public static PointSet Create(Storage storage, string key, IList <V3d> positions, IList <C4b> colors, IList <V3f> normals, IList <int> intensities, int octreeSplitLimit, bool generateLod, CancellationToken ct)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            var bounds  = new Box3d(positions);
            var builder = InMemoryPointSet.Build(positions, colors, normals, intensities, bounds, octreeSplitLimit);
            var root    = builder.ToPointSetCell(storage, ct: ct);
            var result  = new PointSet(storage, key, root.Id, octreeSplitLimit);
            var config  = ImportConfig.Default
                          .WithRandomKey()
                          .WithCancellationToken(ct)
            ;

            if (generateLod)
            {
                result = result.GenerateLod(config);
            }
            return(result);
        }