Skip to content

Commit

Permalink
structured point clouds: implementation (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmaierhofer committed Sep 20, 2023
1 parent 69c600c commit fe6e332
Show file tree
Hide file tree
Showing 69 changed files with 1,193 additions and 612 deletions.
366 changes: 366 additions & 0 deletions src/Aardvark.Algodat.Tests/ImportTests.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Aardvark.Algodat.Tests/LodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void LodCreationSetsLodPointCountCell()
var cs = ps.Map(_ => C4b.White);

var pointset = PointSet.Create(
storage, "test", ps.ToList(), cs.ToList(), null, null, null, 5000,
storage, "test", ps.ToList(), cs.ToList(), null, null, null, null, 5000,
generateLod: false, isTemporaryImportNode: true, ct: default
);
pointset.Root.Value.ForEachNode(true, cell =>
Expand Down Expand Up @@ -64,7 +64,7 @@ public void LodPositions()
var cs = ps.Map(_ => C4b.White);

var pointset = PointSet.Create(
storage, "test", ps.ToList(), cs.ToList(), null, null, null, 5000,
storage, "test", ps.ToList(), cs.ToList(), null, null, null, null, 5000,
generateLod: true, isTemporaryImportNode: true, default
);
pointset.Root.Value.ForEachNode(true, cell =>
Expand Down
24 changes: 16 additions & 8 deletions src/Aardvark.Algodat.Tests/MergeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void CanMergePointSets_0()
var ns1 = ps1.Map(_ => V3f.XAxis);
var is1 = ps1.Map(_ => 123);
var ks1 = ps1.Map(_ => (byte)0);
var qs1 = ps1.Map(_ => (byte)17);
var pointset1 = PointSet.Create(
storage, "test1", ps1, cs1, ns1, is1, ks1, splitLimit,
storage, "test1", ps1, cs1, ns1, is1, ks1, qs1, splitLimit,
generateLod: false, isTemporaryImportNode: true, default
);
var pointset1Count = pointset1.Root.Value.CountPoints();
Expand All @@ -55,8 +56,9 @@ public void CanMergePointSets_0()
var ns2 = ps2.Map(_ => V3f.XAxis);
var is2 = ps2.Map(_ => 456);
var ks2 = ps2.Map(_ => (byte)1);
var qs2 = ps2.Map(_ => (byte)18);
var pointset2 = PointSet.Create(
storage, "test2", ps2, cs2, ns2, is2, ks2, splitLimit,
storage, "test2", ps2, cs2, ns2, is2, ks2, qs2, splitLimit,
generateLod: false, isTemporaryImportNode: true, default
);
var pointset2Count = pointset2.Root.Value.CountPoints();
Expand Down Expand Up @@ -89,8 +91,9 @@ public void CanMergePointSets()
var ns1 = ps1.Map(_ => V3f.XAxis);
var is1 = ps1.Map(_ => 123);
var ks1 = ps1.Map(_ => (byte)42);
var qs1 = ps1.Map(_ => (byte)17);
var pointset1 = PointSet.Create(
storage, "test1", ps1, cs1, ns1, is1, ks1, 1000,
storage, "test1", ps1, cs1, ns1, is1, ks1, qs1, 1000,
generateLod: false, isTemporaryImportNode: true, default
);

Expand All @@ -99,8 +102,9 @@ public void CanMergePointSets()
var ns2 = ps2.Map(_ => V3f.XAxis);
var is2 = ps2.Map(_ => 456);
var ks2 = ps1.Map(_ => (byte)7);
var qs2 = ps1.Map(_ => (byte)18);
var pointset2 = PointSet.Create(
storage, "test2", ps2, cs2, ns2, is2, ks2, 1000,
storage, "test2", ps2, cs2, ns2, is2, ks2, qs2, 1000,
generateLod: false, isTemporaryImportNode: true, default
);

Expand Down Expand Up @@ -129,17 +133,19 @@ public void CanMergePointSets_WithoutColors()
var ns1 = ps1.Map(_ => V3f.XAxis);
var is1 = ps1.Map(_ => 123);
var ks1 = ps1.Map(_ => (byte)42);
var qs1 = ps1.Map(_ => (byte)17);
var pointset1 = PointSet.Create(
storage, "test1", ps1, null, ns1, is1, ks1, 1000,
storage, "test1", ps1, null, ns1, is1, ks1, qs1, 1000,
generateLod: false, isTemporaryImportNode: true, default
);

var ps2 = new V3d[42000].SetByIndex(_ => new V3d(r.NextDouble() + 0.3, r.NextDouble() + 0.3, r.NextDouble() + 0.3));
var ns2 = ps2.Map(_ => V3f.XAxis);
var is2 = ps2.Map(_ => 456);
var ks2 = ps1.Map(_ => (byte)7);
var qs2 = ps1.Map(_ => (byte)18);
var pointset2 = PointSet.Create(
storage, "test2", ps2, null, ns2, is2, ks2, 1000,
storage, "test2", ps2, null, ns2, is2, ks2, qs2, 1000,
generateLod: false, isTemporaryImportNode: true, default
);

Expand Down Expand Up @@ -168,17 +174,19 @@ public void CanMergePointSets_WithoutNormals()
var cs1 = ps1.Map(_ => C4b.White);
var is1 = ps1.Map(_ => 123);
var ks1 = ps1.Map(_ => (byte)42);
var qs1 = ps1.Map(_ => (byte)17);
var pointset1 = PointSet.Create(
storage, "test1", ps1, cs1, null, is1, ks1, 1000,
storage, "test1", ps1, cs1, null, is1, ks1, qs1, 1000,
generateLod: false, isTemporaryImportNode: true, default
);

var ps2 = new V3d[42000].SetByIndex(_ => new V3d(r.NextDouble() + 0.3, r.NextDouble() + 0.3, r.NextDouble() + 0.3));
var cs2 = ps2.Map(_ => C4b.White);
var is2 = ps2.Map(_ => 456);
var ks2 = ps2.Map(_ => (byte)7);
var qs2 = ps2.Map(_ => (byte)18);
var pointset2 = PointSet.Create(
storage, "test2", ps2, cs2, null, is2, ks2, 1000,
storage, "test2", ps2, cs2, null, is2, ks2, qs2, 1000,
generateLod: false, isTemporaryImportNode: true, default
);

Expand Down
52 changes: 36 additions & 16 deletions src/Aardvark.Algodat.Tests/PointSetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void CanCreatePointSetFromSinglePoint()
var ps = new List<V3d> { new(0.1, 0.2, 0.3) };
var cs = new List<C4b> { C4b.White };
var pointset = PointSet.Create(
store, "id", ps, cs, null, null, null, 1000,
store, "id", ps, cs, null, null, null, null, 1000,
generateLod: false, isTemporaryImportNode: true, default
);
Assert.IsTrue(pointset.PointCount == 1);
Expand All @@ -77,7 +77,8 @@ public void CanCreateInMemoryPointSet()
var ns = new List<V3f> { V3f.ZAxis };
var js = new List<int> { 123 };
var ks = new List<byte> { 42 };
_ = InMemoryPointSet.Build(ps, cs, ns, js, ks, Cell.Unit, 1);
var qs = new List<byte> { 17 };
_ = InMemoryPointSet.Build(ps, cs, ns, js, ks, qs, Cell.Unit, 1);
}

[Test]
Expand All @@ -87,7 +88,8 @@ public void CanCreateInMemoryPointSetWithoutColors()
var ns = new List<V3f> { V3f.ZAxis };
var js = new List<int> { 123 };
var ks = new List<byte> { 42 };
_ = InMemoryPointSet.Build(ps, null, ns, js, ks, Cell.Unit, 1);
var qs = new List<byte> { 17 };
_ = InMemoryPointSet.Build(ps, null, ns, js, ks, qs, Cell.Unit, 1);
}

[Test]
Expand All @@ -97,7 +99,8 @@ public void CanCreateInMemoryPointSetWithoutNormals()
var cs = new List<C4b> { C4b.White };
var js = new List<int> { 123 };
var ks = new List<byte> { 42 };
_ = InMemoryPointSet.Build(ps, cs, null, js, ks, Cell.Unit, 1);
var qs = new List<byte> { 17 };
_ = InMemoryPointSet.Build(ps, cs, null, js, ks, qs, Cell.Unit, 1);
}

[Test]
Expand All @@ -107,7 +110,8 @@ public void CanCreateInMemoryPointSetWithoutIntensities()
var cs = new List<C4b> { C4b.White };
var ns = new List<V3f> { V3f.ZAxis };
var ks = new List<byte> { 42 };
_ = InMemoryPointSet.Build(ps, cs, ns, null, ks, Cell.Unit, 1);
var qs = new List<byte> { 17 };
_ = InMemoryPointSet.Build(ps, cs, ns, null, ks, qs, Cell.Unit, 1);
}

[Test]
Expand All @@ -117,7 +121,19 @@ public void CanCreateInMemoryPointSetWithoutClassifications()
var cs = new List<C4b> { C4b.White };
var ns = new List<V3f> { V3f.ZAxis };
var js = new List<int> { 123 };
_ = InMemoryPointSet.Build(ps, cs, ns, js, null, Cell.Unit, 1);
var qs = new List<byte> { 17 };
_ = InMemoryPointSet.Build(ps, cs, ns, js, null, qs, Cell.Unit, 1);
}

[Test]
public void CanCreateInMemoryPointSetWithoutPartIndices()
{
var ps = new List<V3d> { new(0.5, 0.5, 0.5) };
var cs = new List<C4b> { C4b.White };
var ns = new List<V3f> { V3f.ZAxis };
var js = new List<int> { 123 };
var ks = new List<byte> { 42 };
_ = InMemoryPointSet.Build(ps, cs, ns, js, ks, null, Cell.Unit, 1);
}

[Test]
Expand All @@ -136,7 +152,7 @@ public void CanCreateInMemoryPointSet_Many()

Assert.IsTrue(ps.Count == 4 * 4 * 4);

var imps = InMemoryPointSet.Build(ps, null, ns, null, null, new Cell(0, 0, 0, 0), 1);
var imps = InMemoryPointSet.Build(ps, null, ns, null, null, null, new Cell(0, 0, 0, 0), 1);
var root = imps.ToPointSetNode(storage, isTemporaryImportNode: false);
Assert.IsTrue(root.PointCountTree == 4 * 4 * 4);
var countNodes = root.CountLeafNodes(true);
Expand Down Expand Up @@ -165,13 +181,15 @@ public void PointSetAttributes_All()
var ns = new List<V3f> { V3f.ZAxis };
var js = new List<int> { 123 };
var ks = new List<byte> { 42 };
var qs = new List<byte> { 17 };
var storage = PointCloud.CreateInMemoryStore(cache: default);
var pointset = PointSet.Create(storage, "test", ps, cs, ns, js, ks, 1, generateLod: true, isTemporaryImportNode: false, default);
var pointset = PointSet.Create(storage, "test", ps, cs, ns, js, ks, qs, 1, generateLod: true, isTemporaryImportNode: false, default);
Assert.IsTrue(pointset.HasColors == true);
Assert.IsTrue(pointset.HasIntensities == true);
Assert.IsTrue(pointset.HasClassifications == true);
Assert.IsTrue(pointset.HasIntensities == true);
Assert.IsTrue(pointset.HasKdTree == true);
Assert.IsTrue(pointset.HasNormals == true);
Assert.IsTrue(pointset.HasPartIndexRange == true);
Assert.IsTrue(pointset.HasPositions == true);
pointset.ValidateTree();
}
Expand All @@ -184,13 +202,15 @@ public void PointSetAttributes_NoLod()
var ns = new List<V3f> { V3f.ZAxis };
var js = new List<int> { 123 };
var ks = new List<byte> { 42 };
var qs = new List<byte> { 17 };
var storage = PointCloud.CreateInMemoryStore(cache: default);
var pointset = PointSet.Create(storage, "test", ps, cs, ns, js, ks, 1, generateLod: false, isTemporaryImportNode: true, default);
var pointset = PointSet.Create(storage, "test", ps, cs, ns, js, ks, qs, 1, generateLod: false, isTemporaryImportNode: true, default);
Assert.IsTrue(pointset.HasColors == true);
Assert.IsTrue(pointset.HasIntensities == true);
Assert.IsTrue(pointset.HasClassifications == true);
Assert.IsTrue(pointset.HasIntensities == true);
//Assert.IsTrue(pointset.HasKdTree == true);
Assert.IsTrue(pointset.HasNormals == true);
Assert.IsTrue(pointset.HasPartIndexRange == true);
Assert.IsTrue(pointset.HasPositions == true);
pointset.ValidateTree();
}
Expand All @@ -201,7 +221,7 @@ public void PointSetAttributes_PositionsAndColors()
var ps = new List<V3d> { new(0.5, 0.5, 0.5) };
var cs = new List<C4b> { C4b.White };
var storage = PointCloud.CreateInMemoryStore(cache: default);
var pointset = PointSet.Create(storage, "test", ps, cs, null, null, null, 1, generateLod: true, isTemporaryImportNode: true, default);
var pointset = PointSet.Create(storage, "test", ps, cs, null, null, null, null, 1, generateLod: true, isTemporaryImportNode: true, default);
Assert.IsTrue(pointset.HasColors == true);
Assert.IsTrue(pointset.HasIntensities == false);
Assert.IsTrue(pointset.HasKdTree == true);
Expand All @@ -214,7 +234,7 @@ public void PointSet_PartIndexRange_No()
{
var ps = new List<V3d> { new(0.5, 0.5, 0.5) };
var storage = PointCloud.CreateInMemoryStore(cache: default);
var pointset = PointSet.Create(storage, "test", ps, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true, default);
var pointset = PointSet.Create(storage, "test", ps, null, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true, default);
Assert.IsTrue(pointset.PartIndexRange == Range1i.Invalid);
Assert.IsTrue(pointset.HasPartIndexRange == false);
}
Expand All @@ -225,7 +245,7 @@ public void PointSet_PartIndexRange()
var ps = new List<V3d> { new(0.5, 0.5, 0.5) };
var storage = PointCloud.CreateInMemoryStore(cache: default);
var pointset = PointSet.Create(
storage, "test", ps, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true
storage, "test", ps, null, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true
)
.WithPartIndexRange(new(7, 11))
;
Expand All @@ -240,7 +260,7 @@ public void PointSet_PartIndexRange_Serialization()
var storage = PointCloud.CreateInMemoryStore(cache: default);

var pointset = PointSet.Create(
storage, "test", ps, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true
storage, "test", ps, null, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true
)
.WithPartIndexRange(new(7, 11))
;
Expand All @@ -261,7 +281,7 @@ public void PointSet_PartIndexRange_Serialization_NoRange()
var storage = PointCloud.CreateInMemoryStore(cache: default);

var pointset = PointSet.Create(
storage, "test", ps, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true
storage, "test", ps, null, null, null, null, null, 1, generateLod: false, isTemporaryImportNode: true
);

var json = pointset.ToJson();
Expand Down
4 changes: 2 additions & 2 deletions src/Aardvark.Algodat.Tests/PointSetTests/NormalsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Aardvark.Geometry.Tests
[TestFixture]
public class NormalsTests
{
private Storage CreateInMemoryStore() => new SimpleMemoryStore().ToPointCloudStore(cache: default);
private static Storage CreateInMemoryStore() => new SimpleMemoryStore().ToPointCloudStore(cache: default);

[Test]
public void CanCreateChunkWithNormals()
Expand Down Expand Up @@ -51,7 +51,7 @@ public void CanCreateInMemoryPointSetWithNormals()
public void CanCreatePointSetWithNormals()
{
var ps = PointSet.Create(CreateInMemoryStore(), Guid.NewGuid().ToString(),
new[] { V3d.IOO }, new[] { C4b.White }, new[] { V3f.OIO }, null, null, 8192,
new[] { V3d.IOO }, new[] { C4b.White }, new[] { V3f.OIO }, null, null, null, 8192,
generateLod: false, isTemporaryImportNode: true, default
);

Expand Down
10 changes: 5 additions & 5 deletions src/Aardvark.Algodat.Tests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ private static PointSet InternalCreateRandomPointSetForOctreeLevelTests()
var config = ImportConfig.Default.WithKey("Test").WithOctreeSplitLimit(1);
return PointSet
.Create(
storage, "test", ps.ToList(), cs.ToList(), null, null, null, 100,
storage, "test", ps.ToList(), cs.ToList(), null, null, null, null, 100,
generateLod: false, isTemporaryImportNode: true, default
)
.GenerateLod(config)
Expand Down Expand Up @@ -947,8 +947,8 @@ public void GetMaxOctreeLevelWithLessThanGivenPointCount()
public void CanQueryPointsWithEverythingInside_Single()
{
var storage = PointCloud.CreateInMemoryStore(cache: default);
var ps = new List<V3d> { new V3d(0.5, 0.5, 0.5) };
var root = InMemoryPointSet.Build(ps, null, null, null, null, Cell.Unit, 1).ToPointSetNode(storage, isTemporaryImportNode: false);
var ps = new List<V3d> { new(0.5, 0.5, 0.5) };
var root = InMemoryPointSet.Build(ps, null, null, null, null, null, Cell.Unit, 1).ToPointSetNode(storage, isTemporaryImportNode: false);

var rs = root.QueryPoints(cell => true, cell => false, p => true).SelectMany(x => x.Positions).ToArray();
Assert.IsTrue(rs.Length == 1);
Expand All @@ -972,8 +972,8 @@ public void CanQueryPointsWithEverythingInside_Many()
public void CanQueryPointsWithEverythingOutside_Single()
{
var storage = PointCloud.CreateInMemoryStore(cache: default);
var ps = new List<V3d> { new V3d(0.5, 0.5, 0.5) };
var root = InMemoryPointSet.Build(ps, null, null, null, null, Cell.Unit, 1).ToPointSetNode(storage, isTemporaryImportNode: false);
var ps = new List<V3d> { new(0.5, 0.5, 0.5) };
var root = InMemoryPointSet.Build(ps, null, null, null, null, null, Cell.Unit, 1).ToPointSetNode(storage, isTemporaryImportNode: false);

var rs = root.QueryPoints(cell => false, cell => true, p => false).SelectMany(x => x.Positions).ToArray();
Assert.IsTrue(rs.Length == 0);
Expand Down
Binary file added src/Aardvark.Algodat.Tests/TestData/test.las
Binary file not shown.
Binary file added src/Aardvark.Algodat.Tests/TestData/test.laz
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Aardvark.Algodat.sln
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aardvark.Data.Wavefront", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Unofficial.laszip.netstandard", "Unofficial.laszip.netstandard\Unofficial.laszip.netstandard.csproj", "{AC84C458-5A8A-4EC9-A1B3-15CC52DA2E91}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "import", "import\import.csproj", "{000B3CDA-C67B-4F6A-B6F8-69A1B5052343}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "import", "import\import.csproj", "{000B3CDA-C67B-4F6A-B6F8-69A1B5052343}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -207,7 +207,7 @@ Global
{000B3CDA-C67B-4F6A-B6F8-69A1B5052343} = {6CA9BC7A-0123-43E9-A26B-5FF0B9E01B08}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8;packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45
SolutionGuid = {E996B5E6-49B2-4479-9DDE-455A40509F43}
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8;packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<LangVersion>10</LangVersion>
<RootNamespace>Aardvark.Data.Points</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Loading

0 comments on commit fe6e332

Please sign in to comment.