diff --git a/src/Aardvark.Data.Points.Base/ParseConfig.cs b/src/Aardvark.Data.Points.Base/ParseConfig.cs index 4b9be772..342f9135 100644 --- a/src/Aardvark.Data.Points.Base/ParseConfig.cs +++ b/src/Aardvark.Data.Points.Base/ParseConfig.cs @@ -187,6 +187,7 @@ public ParseConfig(ParseConfig x) MinDist = x.MinDist; ReadBufferSizeInBytes = x.ReadBufferSizeInBytes; EnabledProperties = x.EnabledProperties; + PartIndexOffset = x.PartIndexOffset; } /// diff --git a/src/Aardvark.Data.Points.Base/PartIndexUtils.cs b/src/Aardvark.Data.Points.Base/PartIndexUtils.cs index 7ffb6552..d66fb034 100644 --- a/src/Aardvark.Data.Points.Base/PartIndexUtils.cs +++ b/src/Aardvark.Data.Points.Base/PartIndexUtils.cs @@ -71,4 +71,23 @@ public static class PartIndexUtils } } + public static Range1i ExtendedBy(in Range1i range, object? partIndices) + { + checked + { + return partIndices switch + { + null => range, + uint x => range.ExtendedBy((int)x), + IList xs => range.ExtendedBy((Range1i)new Range1b(xs)), + IList xs => range.ExtendedBy((Range1i)new Range1s(xs)), + IList xs => range.ExtendedBy(new Range1i(xs)), + + _ => throw new Exception( + $"Unexpected part indices type {partIndices.GetType().FullName}. " + + $"Error 3915b996-1842-4418-9445-e4c4f1b678a6" + ) + }; + } + } } \ No newline at end of file diff --git a/src/Aardvark.Geometry.PointSet/Import/ImportChunks.cs b/src/Aardvark.Geometry.PointSet/Import/ImportChunks.cs index df6a0167..6a8a6a06 100644 --- a/src/Aardvark.Geometry.PointSet/Import/ImportChunks.cs +++ b/src/Aardvark.Geometry.PointSet/Import/ImportChunks.cs @@ -74,15 +74,21 @@ public static PointSet Chunks(IEnumerable chunks, ImportConfig config) { config.ProgressCallback(0.0); - if (config.Verbose) + var partIndicesRange = Range1i.Invalid; + var chunkCount = 0; + chunks = chunks.Do(chunk => { - var chunkCount = 0; - chunks = chunks.Do(chunk => + if (chunk.HasPartIndices) + { + partIndicesRange = PartIndexUtils.ExtendedBy(partIndicesRange, chunk.PartIndices); + } + + if (config.Verbose) { if (chunk.Count == 0) Report.Warn($"[PointCloud.Chunks] empty chunk"); Report.Line($"[PointCloud.Chunks] processing chunk {Interlocked.Increment(ref chunkCount)}"); - }); - } + } + }); // reproject positions if (config.Reproject != null) @@ -176,7 +182,15 @@ Chunk map(Chunk x, CancellationToken ct) // create final point set with specified key (or random key when no key is specified) var key = config.Key ?? Guid.NewGuid().ToString(); - final = new PointSet(config.Storage ?? throw new Exception($"No storage specified. Error 5b4ebfec-d418-4ddc-9c2f-646d270cf78c."), key, final.Root?.Value?.Id ?? Guid.Empty, config.OctreeSplitLimit); + final = new PointSet( + storage : config.Storage ?? throw new Exception($"No storage specified. Error 5b4ebfec-d418-4ddc-9c2f-646d270cf78c."), + pointSetId: key, + rootCellId: final.Root?.Value?.Id ?? Guid.Empty, + splitLimit: config.OctreeSplitLimit + ) + { + PartIndexRange = partIndicesRange + }; config.Storage.Add(key, final); return final; diff --git a/src/Aardvark.Geometry.PointSet/Octrees/InMemoryPointSet.cs b/src/Aardvark.Geometry.PointSet/Octrees/InMemoryPointSet.cs index f301f456..702f5b72 100644 --- a/src/Aardvark.Geometry.PointSet/Octrees/InMemoryPointSet.cs +++ b/src/Aardvark.Geometry.PointSet/Octrees/InMemoryPointSet.cs @@ -93,6 +93,7 @@ private InMemoryPointSet(ImmutableDictionary data, Cell cel foreach (var kv in data) { + if (kv.Key == Durable.Octree.PerCellPartIndex1ui) continue; if (kv.Value is not Array) throw new ArgumentException($"Entry {kv.Key} must be array."); } @@ -180,6 +181,7 @@ internal PointSetNode ToPointSetNode(Storage storage, bool isTemporaryImportNode foreach (var kv in _octree.m_data) { if (kv.Key == Durable.Octree.PositionsGlobal3d) continue; + if (kv.Key == Durable.Octree.PerCellPartIndex1ui) continue; var subset = kv.Value.Subset(_ia); attributes = attributes.Add(kv.Key, subset); }