Skip to content

Commit

Permalink
debugging (sync)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmaierhofer committed Nov 25, 2023
1 parent 2143686 commit d8cd03f
Show file tree
Hide file tree
Showing 11 changed files with 397 additions and 197 deletions.
91 changes: 80 additions & 11 deletions src/Aardvark.Algodat.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,22 @@ namespace Aardvark.Geometry.Tests
{
public class Program
{
internal static Task CreateStore(string filename, string storeDir, double minDist)
#region CreateStore

internal static Task<string> CreateStore(string filename, string storeDir, double minDist)
=> CreateStore(filename, new DirectoryInfo(storeDir), minDist);

internal static Task CreateStore(string filename, DirectoryInfo storeDir, double minDist)
internal static Task<string> CreateStore(IEnumerable<Chunk> chunks, string storeDir, double minDist, int? splitLimit = null)
=> CreateStore(chunks, new DirectoryInfo(storeDir), minDist, splitLimit);

internal static Task<string> CreateStore(string filename, DirectoryInfo storeDir, double minDist)
{
if (!storeDir.Exists) storeDir.Create();

var key = Path.GetFileName(filename);

using var store = new SimpleDiskStore(Path.Combine(storeDir.FullName, "data.uds")).ToPointCloudStore();

var config = ImportConfig.Default
.WithStorage(store)
.WithKey(key)
Expand All @@ -53,6 +59,7 @@ internal static Task CreateStore(string filename, DirectoryInfo storeDir, double
.WithNormalizePointDensityGlobal(true)
//.WithMaxChunkPointCount(32 * 1024 * 1024)
//.WithOctreeSplitLimit(8192*4)
//.WithEnabledPartIndices(false)
;

Report.BeginTimed($"importing {filename}");
Expand All @@ -61,9 +68,42 @@ internal static Task CreateStore(string filename, DirectoryInfo storeDir, double

File.WriteAllText(Path.Combine(storeDir.FullName, "key.txt"), key);

return Task.CompletedTask;
return Task.FromResult(key);
}

internal static Task<string> CreateStore(IEnumerable<Chunk> chunks, DirectoryInfo storeDir, double minDist, int? splitLimit = null)
{
if (!storeDir.Exists) storeDir.Create();

var filename = storeDir.FullName;
var key = Path.GetFileName(filename);

using var store = new SimpleDiskStore(Path.Combine(storeDir.FullName, "data.uds")).ToPointCloudStore();

var config = ImportConfig.Default
.WithStorage(store)
.WithKey(key)
.WithVerbose(true)
.WithMaxDegreeOfParallelism(0)
.WithMinDist(minDist)
.WithNormalizePointDensityGlobal(true)
//.WithMaxChunkPointCount(32 * 1024 * 1024)
//.WithEnabledPartIndices(false)
;

if (splitLimit.HasValue) config = config.WithOctreeSplitLimit(splitLimit.Value);

Report.BeginTimed($"importing {filename}");
var pcl = PointCloud.Import(chunks, config);
Report.EndTimed();

File.WriteAllText(Path.Combine(storeDir.FullName, "key.txt"), key);

return Task.FromResult(key);
}

#endregion

internal static void PerfTestJuly2019()
{
var filename = @"T:\Vgm\Data\2017-10-20_09-44-27_1mm_shade_norm_5pp - Cloud.pts";
Expand Down Expand Up @@ -2689,22 +2729,51 @@ static Task Parts_Test_20231006()

return Task.CompletedTask;
}
static async Task Parts_Test_20231006_Merge()
{
V3d[] randomPoints(int n, Box3d bb)
{
var size = bb.Size;
var ps = new V3d[n];
for (var i = 0; i < n; i++)
{
ps[i] = bb.Min + new V3d(Random.Shared.NextDouble(), Random.Shared.NextDouble(), Random.Shared.NextDouble()) * size;
}

return ps;
}

var c0 = new Chunk(positions: randomPoints(10, Box3d.Unit ), null, null, null, null, partIndices: 0, null, null);
var c1 = new Chunk(positions: randomPoints(10, Box3d.Unit + V3d.IOO), null, null, null, null, partIndices: 1, null, null);

var storeDir = @"W:\Datasets\Vgm\Stores\test_partindex";
var key = await CreateStore(
new [] { c0, c1 },
storeDir,
minDist: 0.01,
splitLimit: 10
);

using var store = new SimpleDiskStore(Path.Combine(storeDir, "data.uds")).ToPointCloudStore();
var ps = store.GetPointSet(key);
var root = ps.Root.Value;
}

public static async Task Main(string[] _)
{
await Task.Delay(0); // avoid warnings if main contains no await
//await Task.Delay(0); // avoid warnings if main contains no await

await CreateStore(
@"W:\Datasets\Vgm\Data\structured_pointclouds\lowergetikum 20230321.e57",
@"W:\Datasets\Vgm\Stores\lowergetikum 20230321.e57_0.01",
minDist: 0.01
);

//await Parts_Test_20231006_Merge();

//await Parts_Test_20231006();

Test_Import_Regression();

//await CreateStore(
// @"T:\Kindergarten.pts",
// @"W:\Aardworx\pointshare2\testdata\2023-08-01_kindergarten.store",
// minDist: 0.0
// );
//Test_Import_Regression();

//await Ranges_Test_20230802();

Expand Down
1 change: 1 addition & 0 deletions src/Aardvark.Data.E57/Aardvark.Data.E57.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\bin\Debug</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.E57/ImportE57.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static IEnumerable<Chunk> Chunks(this Stream stream, long streamLengthInB
var yieldedRecordCount = 0L;

var partIndex = config.PartIndexOffset;
foreach (var data3d in header.E57Root.Data3D)
foreach (var data3d in header.E57Root.Data3D.Take(2))
{
foreach (var (Positions, Properties) in data3d.StreamPointsFull(config.MaxChunkPointCount, config.Verbose, exclude))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<DocumentationFile>..\..\bin\Release\netstandard2.0\Aardvark.Geometry.PointSet.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>Aardvark.Geometry.Points</RootNamespace>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\bin\Debug</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ IEnumerable<Chunk> QueryRec(IPointCloudNode n)
public static void CheckDerivedAttributes(this IPointCloudNode self)
{
var isTmpNode = self.Has(PointSetNode.TemporaryImportNode);

if (self.HasPositions)
{
if (!self.HasKdTree && !isTmpNode) throw new InvalidOperationException(
Expand All @@ -863,12 +864,34 @@ public static void CheckDerivedAttributes(this IPointCloudNode self)
// "Missing PointDistanceStandardDeviation. Invariant 4a03c3f5-a625-4124-91f6-6f79fd1b5d0e."
// );
}

if (!self.HasMaxTreeDepth) throw new InvalidOperationException(
"Missing MaxTreeDepth. Invariant c7c3c337-5404-4773-aae3-01d213e575b0."
);
if (!self.HasMinTreeDepth) throw new InvalidOperationException(
"Missing MinTreeDepth. Invariant 2df9fb7b-684a-4103-8f14-07785607d2f4."
);

if (self.HasPartIndexRange && !self.HasPartIndices) throw new InvalidOperationException(
"Missing part indices. Invariant fc4ff983-151f-4956-b882-54d649245049."
);

if (self.HasPartIndices)
{
if (!self.HasPartIndexRange) throw new InvalidOperationException(
"Missing PartIndexRange. Invariant 90571267-b593-4458-83d6-5448dd9c5257."
);

if (self.Has(Durable.Octree.PerPointPartIndex1b)) throw new InvalidOperationException(
"PerPointPartIndex1b should be PerPointPartIndex1bReference. Invariant 85879fd8-7ee8-45a0-b221-67f826bc42df."
);
if (self.Has(Durable.Octree.PerPointPartIndex1s)) throw new InvalidOperationException(
"PerPointPartIndex1s should be PerPointPartIndex1sReference. Invariant 598f615b-289a-4bfe-b5cf-b61e4bd380d5."
);
if (self.Has(Durable.Octree.PerPointPartIndex1i)) throw new InvalidOperationException(
"PerPointPartIndex1i should be PerPointPartIndex1iReference. Invariant d5391b75-bbc1-4c83-b963-50fd0f409931."
);
}
}

/// <summary>
Expand Down
Loading

0 comments on commit d8cd03f

Please sign in to comment.