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 22, 2023
1 parent 646b363 commit 1695019
Show file tree
Hide file tree
Showing 38 changed files with 329 additions and 228 deletions.
23 changes: 12 additions & 11 deletions src/Aardvark.Algodat.Tests/ChunkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Chunk_EmptyChunk1()
[Test]
public void Chunk_EmptyChunk2()
{
var x = new Chunk(new V3d[0], new C4b[0]);
var x = new Chunk(Array.Empty<V3d>(), Array.Empty<C4b>(), null, null, null, null, null);
Assert.IsTrue(x.IsEmpty);
Assert.IsTrue(x.HasPositions);
Assert.IsTrue(x.HasColors);
Expand All @@ -51,7 +51,7 @@ public void ChunkFromPositionsOnly()
[Test]
public void Chunk_ChunkFromPositionsAndColors()
{
var x = new Chunk(new V3d[1], new C4b[1]);
var x = new Chunk(new V3d[1], new C4b[1], null, null, null, null, null);
Assert.IsTrue(x.Count == 1);
Assert.IsTrue(x.HasPositions);
Assert.IsTrue(x.HasColors);
Expand All @@ -70,6 +70,7 @@ public void Chunk_BoundingBoxIsNotComputedFromPositions()
{
var x = new Chunk(
new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) },
null, null, null, null, null,
bbox: new Box3d(new V3d(0, 0, 0), new V3d(8, 8, 8))
);
Assert.IsTrue(x.Count == 2);
Expand All @@ -81,7 +82,7 @@ public void Chunk_MismatchingNumberOfColorsDoesNotFail1()
{
Assert.DoesNotThrow(() =>
{
var chunk = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) }, Array.Empty<C4b>());
var chunk = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) }, Array.Empty<C4b>(), null, null, null, null, null);
Assert.IsTrue(chunk.Count == 0);
Assert.IsTrue(chunk.Positions.Count == 0);
Assert.IsTrue(chunk.Colors.Count == 0);
Expand All @@ -93,7 +94,7 @@ public void Chunk_MismatchingNumberOfColorsDoesNotFail2()
{
Assert.DoesNotThrow(() =>
{
var chunk = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) }, new C4b[123]);
var chunk = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) }, new C4b[123], null, null, null, null, null);
Assert.IsTrue(chunk.Count == 2);
Assert.IsTrue(chunk.Positions.Count == 2);
Assert.IsTrue(chunk.Colors.Count == 2);
Expand All @@ -105,30 +106,30 @@ public void Chunk_MismatchingNumberOfColorsFails3()
{
Assert.Catch(() =>
{
new Chunk(null, new C4b[123]);
new Chunk(null, new C4b[123],null, null, null, null, null);
});
}

[Test]
public void Chunk_EmptyColors()
{
new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) }, null);
new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) });
}

[Test]
public void Chunk_EmptyPositionsButNonEmptyColorsFails()
{
Assert.Catch(() =>
{
new Chunk(null, new C4b[1]);
new Chunk(null, new C4b[1], null, null, null, null, null);
});
}

[Test]
public void Chunk_ImmutableFilterSequentialMinDistL2()
{
var ps = new[] { new V3d(1, 2, 3), new V3d(1.5, 2, 3), new V3d(2, 2, 3), new V3d(2.5, 2, 3) };
var a = new Chunk(ps.Copy(), null);
var a = new Chunk(ps.Copy());
var b = a.ImmutableFilterSequentialMinDistL2(0.75);

for (var i = 0; i < ps.Length; i++)
Expand All @@ -142,7 +143,7 @@ public void Chunk_ImmutableFilterSequentialMinDistL2()
[Test]
public void Chunk_ImmutableMapPositions()
{
var a = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) }, null);
var a = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6) });
var b = a.ImmutableMapPositions(p => p + new V3d(10, 20, 30));

Assert.IsTrue(a.Positions[0] == new V3d(1, 2, 3));
Expand All @@ -155,7 +156,7 @@ public void Chunk_ImmutableMapPositions()
[Test]
public void Chunk_ImmutableDeduplicate_1()
{
var a = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6), new V3d(1, 2, 3), new V3d(4, 5, 6) }, null);
var a = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6), new V3d(1, 2, 3), new V3d(4, 5, 6) });
var b = a.ImmutableDeduplicate(verbose: false);

Assert.IsTrue(a.Positions.Count == 4);
Expand All @@ -167,7 +168,7 @@ public void Chunk_ImmutableDeduplicate_1()
[Test]
public void Chunk_ImmutableDeduplicate_2()
{
var a = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6), new V3d(4, 5, 7), new V3d(4, 5, 8) }, null);
var a = new Chunk(new[] { new V3d(1, 2, 3), new V3d(4, 5, 6), new V3d(4, 5, 7), new V3d(4, 5, 8) });
var b = a.ImmutableDeduplicate(verbose: false);

Assert.IsTrue(a.Positions.Count == 4);
Expand Down
6 changes: 3 additions & 3 deletions src/Aardvark.Algodat.Tests/DeleteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static PointSet CreateRandomPointsInUnitCube(int n, int splitLimit)
.WithKey("test")
.WithOctreeSplitLimit(splitLimit)
;
return PointCloud.Chunks(new Chunk(ps, null), config);
return PointCloud.Chunks(new Chunk(ps), config);
}

public static PointSet CreateRegularPointsInUnitCube(int n, int splitLimit)
Expand All @@ -59,7 +59,7 @@ public static PointSet CreateRegularPointsInUnitCube(int n, int splitLimit)
.WithKey("test")
.WithOctreeSplitLimit(splitLimit)
;
return PointCloud.Chunks(new Chunk(ps, null), config);
return PointCloud.Chunks(new Chunk(ps), config);
}

public static PointSet CreateRandomClassifiedPoints(int n, int splitLimit)
Expand All @@ -77,7 +77,7 @@ public static PointSet CreateRandomClassifiedPoints(int n, int splitLimit)
.WithKey("testaa")
.WithOctreeSplitLimit(splitLimit)
;
return PointCloud.Chunks(new Chunk(ps, null, null, null, ks), config);
return PointCloud.Chunks(new Chunk(ps, null, null, null, ks, null, null), config);
}

[Test]
Expand Down
14 changes: 7 additions & 7 deletions src/Aardvark.Algodat.Tests/ImportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void CanImportChunkWithoutColor()
var r = new Random();
var ps = new V3d[n];
for (var i = 0; i < n; i++) ps[i] = new V3d(r.NextDouble(), r.NextDouble(), r.NextDouble());
var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);

Assert.IsTrue(chunk.Count == 100);

Expand All @@ -92,7 +92,7 @@ public void CanImportChunk_MinDist()
var r = new Random();
var ps = new V3d[n];
for (var i = 0; i < n; i++) ps[i] = new V3d(r.NextDouble(), r.NextDouble(), r.NextDouble());
var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);

Assert.IsTrue(chunk.Count == 100);

Expand All @@ -114,7 +114,7 @@ public void CanImportChunk_Reproject()
for (var i = 0; i < n; i++) ps[i] = new V3d(i, 0, 0);
var bb = new Box3d(ps);

var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);
Assert.IsTrue(chunk.Count == 10);
Assert.IsTrue(chunk.BoundingBox == bb);

Expand All @@ -135,7 +135,7 @@ public void CanImport_WithKey()
var ps = new V3d[n];
for (var i = 0; i < n; i++) ps[i] = new V3d(i, 0, 0);

var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);
Assert.IsTrue(chunk.Count == 10);

var config = ImportConfig.Default
Expand All @@ -160,7 +160,7 @@ public void CanImportWithKeyAndThenLoadAgainFromStore()
var ps = new V3d[n];
for (var i = 0; i < n; i++) ps[i] = new V3d(i, 0, 0);

var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);
Assert.IsTrue(chunk.Count == 10);

var config = ImportConfig.Default
Expand All @@ -185,7 +185,7 @@ public void CanImport_WithoutKey()
var ps = new V3d[n];
for (var i = 0; i < n; i++) ps[i] = new V3d(i, 0, 0);

var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);
Assert.IsTrue(chunk.Count == 10);

var config = ImportConfig.Default
Expand All @@ -206,7 +206,7 @@ public void CanImport_DuplicateKey()
var ps = new V3d[n];
for (var i = 0; i < n; i++) ps[i] = new V3d(i, 0, 0);

var chunk = new Chunk(ps);
var chunk = new Chunk(ps, null, null, null, null, null, null);
Assert.IsTrue(chunk.Count == 10);

var config = ImportConfig.Default
Expand Down
10 changes: 5 additions & 5 deletions src/Aardvark.Algodat.Tests/LodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void HasCentroid()
};

var config = ImportConfig.Default.WithStorage(storage).WithRandomKey();
var n = PointCloud.Chunks(new Chunk(ps, null), config).Root.Value;
var n = PointCloud.Chunks(new Chunk(ps), config).Root.Value;

Assert.IsTrue(n.HasCentroidLocal);
Assert.IsTrue(n.HasCentroidLocalStdDev);
Expand All @@ -217,7 +217,7 @@ public void HasBoundingBoxExact()
};

var config = ImportConfig.Default.WithStorage(storage).WithRandomKey();
var n = PointCloud.Chunks(new Chunk(ps, null), config).Root.Value;
var n = PointCloud.Chunks(new Chunk(ps), config).Root.Value;

Assert.IsTrue(n.HasBoundingBoxExactLocal);
Assert.IsTrue(n.BoundingBoxExactLocal == new Box3f(new V3f(-0.4f), new V3f(0.4f)));
Expand All @@ -237,7 +237,7 @@ public void HasTreeDepth()
var ps = new V3d[10].SetByIndex(_ => new V3d(r.NextDouble(), r.NextDouble(), r.NextDouble()));

var config = ImportConfig.Default.WithStorage(storage).WithRandomKey();
var n = PointCloud.Chunks(new Chunk(ps, null), config).Root.Value;
var n = PointCloud.Chunks(new Chunk(ps), config).Root.Value;

Assert.IsTrue(n.HasMinTreeDepth);
Assert.IsTrue(n.HasMaxTreeDepth);
Expand All @@ -255,7 +255,7 @@ public void HasTreeDepth2()
var ps = new V3d[20000].SetByIndex(_ => new V3d(r.NextDouble(), r.NextDouble(), r.NextDouble()));

var config = ImportConfig.Default.WithStorage(storage).WithRandomKey();
var n = PointCloud.Chunks(new Chunk(ps, null), config).Root.Value;
var n = PointCloud.Chunks(new Chunk(ps), config).Root.Value;

Assert.IsTrue(n.HasMinTreeDepth);
Assert.IsTrue(n.HasMaxTreeDepth);
Expand Down Expand Up @@ -283,7 +283,7 @@ public void HasPointDistance()
};

var config = ImportConfig.Default.WithStorage(storage).WithRandomKey();
var n = PointCloud.Chunks(new Chunk(ps, null), config).Root.Value;
var n = PointCloud.Chunks(new Chunk(ps), config).Root.Value;

Assert.IsTrue(n.HasPointDistanceAverage);
Assert.IsTrue(n.HasPointDistanceStandardDeviation);
Expand Down
Loading

0 comments on commit 1695019

Please sign in to comment.