Skip to content

Commit

Permalink
enable interop with other software
Browse files Browse the repository at this point in the history
- moved IPointCloudNode to Aardvark.Data.Points.Base
- moved PersistentRef to Aardvark.Data.Points.Base (dependency)
- aligned Aardvark.Geometry.PointTree license to Aardvark.Data.Points.Base license (AGPL -> Apache2.0)
  • Loading branch information
stefanmaierhofer committed Jan 14, 2024
1 parent 0721504 commit bb41659
Show file tree
Hide file tree
Showing 23 changed files with 422 additions and 163 deletions.
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 5.3.0-prerelease001
- enable interop with other software
- moved IPointCloudNode to Aardvark.Data.Points.Base
- moved PersistentRef to Aardvark.Data.Points.Base (dependency)
- aligned Aardvark.Geometry.PointTree license to Aardvark.Data.Points.Base license (AGPL -> Apache2.0)

### 5.2.28
- updated base packages to 5.2.28 (LinearRegression missing method hotfix)

Expand Down
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>11</LangVersion>
<RootNamespace>Aardvark.Data.Points</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -15,4 +15,7 @@
<DocumentationFile>..\..\bin\Debug\netstandard2.0\Aardvark.Data.Points.Import.xml</DocumentationFile>
</PropertyGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
<ItemGroup>
<ProjectReference Include="..\Aardvark.Geometry.PointTree\Aardvark.Geometry.PointTree.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/Chunk.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/GenericChunk.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/*
Copyright (C) 2006-2023. Aardvark Platform Team. http://github.com/aardvark-platform.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Aardvark Platform
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Aardvark.Base;
using Aardvark.Data;
Expand Down Expand Up @@ -45,6 +49,8 @@ public interface IPointCloudNode
/// </summary>
IPointCloudNode WriteToStore();

/// <summary>
/// </summary>
byte[] Encode();

/// <summary>
Expand Down Expand Up @@ -169,6 +175,8 @@ public interface IPointCloudNode

#endregion

/// <summary>
/// </summary>
Box3d BoundingBoxApproximate { get; }

#region KdTree
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/KeepAliveCache.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/LruDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/ParseConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/ParsingStats.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
131 changes: 131 additions & 0 deletions src/Aardvark.Data.Points.Base/PersistentRef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
Aardvark Platform
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;

namespace Aardvark.Geometry.Points
{

/// <summary>
/// </summary>
public class PersistentRef<T> where T : notnull
{
private readonly Func<string, T> f_get;
private readonly Func<string, (bool, T?)> f_tryGet;

/// <summary>
/// </summary>
public PersistentRef(Guid id, Func<string, T> get, Func<string, (bool, T?)> tryGet)
: this(id.ToString(), get, tryGet)
{
}

/// <summary>
/// </summary>
public PersistentRef(Func<string, T> get, Func<string, (bool, T?)> tryGet)
: this(default(string), get, tryGet)
{
}

/// <summary>
/// </summary>
public PersistentRef(string? id, Func<string, T> get, Func<string, (bool, T?)> tryGet)
{
Id = id;
f_get = get ?? throw new ArgumentNullException(nameof(get));
f_tryGet = tryGet ?? throw new ArgumentNullException(nameof(tryGet));
}

/// <summary>
/// </summary>
public PersistentRef<A> Cast<A>() where A : notnull
{
var get = f_get;
var tryGet = f_tryGet;
return new PersistentRef<A>(
Id,
s =>
{
return (A)(object)get(s);
},
s =>
{
var (w, t) = tryGet(s);
if (w)
{
if (t == null) throw new InvalidOperationException("Invariant 9b67fe44-679b-443c-8621-a32884eea50e.");
return (w, (A)(object)t);
}
else
{
return (false, default(A));
}
}
);
}

/// <summary>
/// </summary>
public static PersistentRef<T> FromValue(T value) => new(null, s => value, s => (true, value));

/// <summary>
/// </summary>
public string? Id { get; }

/// <summary>
/// </summary>
public bool TryGetValue(out T? value)
{
if (Id != null)
{
(var isSome, value) = f_tryGet(Id);
return isSome;
}
else
{
value = default;
return false;
}
}

/// <summary>
/// </summary>
public (bool hasValue, T? value) TryGetValue()
{
if (Id != null)
{
return f_tryGet(Id);
}
else
{
return (false, default);
}
}

/// <summary>
/// </summary>
public T Value
{
get
{
if (Id == null) throw new InvalidOperationException("Invariant c96befc0-9dd4-4b38-b301-9d9c59d6685a.");
var result = f_get(Id);
return result == null ? throw new InvalidOperationException("Invariant e73282a1-45c0-4cb3-bccf-e6d416163abc.") : result;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/PointCloudFileFormat.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/PointFileInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/Storage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/Unmix.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Points.Base/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Aardvark Platform
Copyright (C) 2006-2023 Aardvark Platform Team
Copyright (C) 2006-2024 Aardvark Platform Team
https://aardvark.graphics
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
19 changes: 10 additions & 9 deletions src/Aardvark.Geometry.PointSet/Octrees/Inline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static IEnumerable<InlinedNode> EnumerateRecImpl(IPointCloudNode node, HashSet<G
{
if (x != null && x.TryGetValue(out var subnode))
{
if (subnode == null) throw new Exception("Invariant 4a0f4796-1a70-4457-9564-16919f534ac6.");
foreach (var n in EnumerateRecImpl(subnode, survive, config, processedNodeCount)) yield return n;
}
}
Expand Down Expand Up @@ -423,7 +424,7 @@ static byte[] rescaleIntensities(int[] js32)
ps = nonEmptySubNodes
.SelectMany(n =>
{
var nCell = n.Cell;
var nCell = n!.Cell;
var nCenter = nCell.GetCenter();
var delta = nCenter - cellCenter;
var xs = n.Positions.Value.Map(x => (V3f)((V3d)x + delta));
Expand All @@ -434,21 +435,21 @@ static byte[] rescaleIntensities(int[] js32)
if (hasColors)
{
cs = nonEmptySubNodes
.SelectMany(n => n.Colors.Value)
.SelectMany(n => n!.Colors.Value)
.ToArray();
}

if (hasClassifications)
{
ks = nonEmptySubNodes
.SelectMany(n => n.Classifications.Value)
.SelectMany(n => n!.Classifications.Value)
.ToArray();
}

if (hasIntensities)
{
var js32 = nonEmptySubNodes
.SelectMany(n => n.Intensities.Value)
.SelectMany(n => n!.Intensities.Value)
.ToArray();

js = rescaleIntensities(js32);
Expand All @@ -460,7 +461,7 @@ static byte[] rescaleIntensities(int[] js32)
if (nref.HasValue && nref.Value.hasValue)
{
var n = nref.Value.value;
return !n.IsLeaf ? n.Id : Guid.Empty;
return !n!.IsLeaf ? n.Id : Guid.Empty;
}
else
{
Expand All @@ -471,22 +472,22 @@ static byte[] rescaleIntensities(int[] js32)
var isNewLeaf = guids2.All(k => k == Guid.Empty);
if (!isNewLeaf)
{
subnodeGuids = subnodes.Map(x => x.HasValue && x.Value.hasValue ? x.Value.value.Id : Guid.Empty);
foreach (var g in nonEmptySubNodes) survive.Add(g.Id);
subnodeGuids = subnodes.Map(x => x.HasValue && x.Value.hasValue ? x.Value.value!.Id : Guid.Empty);
foreach (var g in nonEmptySubNodes) survive.Add(g!.Id);
}
}
else
{
if (isNotLeaf)
{
subnodeGuids = subnodes.Map(x => x.HasValue && x.Value.hasValue ? x.Value.value.Id : Guid.Empty);
subnodeGuids = subnodes.Map(x => x.HasValue && x.Value.hasValue ? x.Value.value!.Id : Guid.Empty);
}

ps = node.Positions.Value;
if (hasColors) cs = node.Colors.Value;
if (hasClassifications) ks = node.Classifications.Value;
if (hasIntensities) js = rescaleIntensities(node.Intensities.Value);
if (isNotLeaf) subnodeGuids = subnodes.Map(x => x.HasValue && x.Value.hasValue ? x.Value.value.Id : Guid.Empty);
if (isNotLeaf) subnodeGuids = subnodes.Map(x => x.HasValue && x.Value.hasValue ? x.Value.value!.Id : Guid.Empty);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Geometry.PointSet/Queries/QueriesCells.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ private ColZ[] Split()
? new ColZ(
Footprint.GetQuadrant(i),
nss[i].Count > 0 ? nss[i].ToArray() : Array.Empty<IPointCloudNode>(),
rs.GetValueOrDefault(i, Chunk.Empty)
rs.GetOrDefault(i, Chunk.Empty)
)
: null
);
Expand Down
Loading

0 comments on commit bb41659

Please sign in to comment.