Skip to content

Commit

Permalink
5.3.0-prerelease012
Browse files Browse the repository at this point in the history
  • Loading branch information
aszabo314 committed Dec 18, 2023
1 parent d131181 commit e558c15
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 5.3.0-prerelease012
- structured point clouds: filtered nodes
- structured point clouds: chunk TryGetPartIndices

### 5.3.0-prerelease011
- updated base packages to 5.2.28

Expand Down
5 changes: 5 additions & 0 deletions src/Aardvark.Data.Points.Base/Chunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public GenericChunk ToGenericChunk()
[MemberNotNullWhen(true, nameof(PartIndexRange))]
public bool HasPartIndexRange => PartIndexRange != null;

public IList<int>? TryGetPartIndices()
{
return PartIndexUtils.Expand(PartIndices, Count);
}

public static Chunk ImmutableMerge(Chunk a, Chunk b)
{
if (a is null || a.IsEmpty) return b;
Expand Down
21 changes: 21 additions & 0 deletions src/Aardvark.Data.Points.Base/PartIndexUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ public static bool HasValidPartIndexData(IReadOnlyDictionary<Durable.Def, object
return i == 1; // exactly one of the above must exist
}

/// <summary>
/// Expands part indices: All input types are expanded into an int array.
/// </summary>
public static int[]? Expand(object? o, int ct)
{
switch (o)
{
case null: return null;
case int x: return new int[ct].Set(x);
case uint x: checked { return new int[ct].Set((int)x); }
case byte[] xs: return xs.Map(x => (int)x);
case short[] xs: return xs.Map(x => (int)x);
case int[] xs: return xs;
default:
throw new Exception(
$"Unexpected type {o.GetType().FullName}. " +
$"Error 278c88f6-d504-4a17-9752-8cca614505f1."
);
}
}

/// <summary>
/// Compacts part indices.
/// If per-point indices are all identical, then return per-cell index.
Expand Down
15 changes: 2 additions & 13 deletions src/Aardvark.Geometry.PointSet/Octrees/PointSetNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -940,19 +940,8 @@ public object? PartIndices
/// </summary>
public bool TryGetPartIndices([NotNullWhen(true)] out int[]? result)
{
switch (PartIndices)
{
case null: result = null; return false;
case int x: result = new int[PointCountCell].Set(x); return true;
case uint x: checked { result = new int[PointCountCell].Set((int)x); return true; }
case byte[] xs: result = xs.Map(x => (int)x); return true;
case short[] xs: result = xs.Map(x => (int)x); return true;
case int[] xs: result = xs; return true;
default: throw new Exception(
$"Unexpected type {PartIndices.GetType().FullName}. " +
$"Error 278c88f6-d504-4a17-9752-8cca614505f1."
);
}
result = PartIndexUtils.Expand(PartIndices, PointCountCell);
return result != null;
}

#endregion
Expand Down
12 changes: 6 additions & 6 deletions src/Aardvark.Geometry.PointSet/Views/FilteredNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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/>.
*/
using Aardvark.Base;
using Aardvark.Base.Sorting;
using Aardvark.Data;
using Aardvark.Data.Points;
using System;
Expand Down Expand Up @@ -499,15 +500,15 @@ public Range1i? PartIndexRange
/// <summary>
/// Octree. Per-point or per-cell part indices.
/// </summary>
public object? PartIndices => PartIndexUtils.Subset(Node.PartIndices, null!);
public object? PartIndices => SubsetIndexArray != null ? PartIndexUtils.Subset(Node.PartIndices, SubsetIndexArray) : Node.PartIndices;

/// <summary>
/// Get per-point part indices as an int array (regardless of internal representation).
/// Returns false if node has no part indices.
/// </summary>
public bool TryGetPartIndices([NotNullWhen(true)] out int[]? result)
{
var qs = SubsetIndexArray != null ? PartIndexUtils.Subset(PartIndices, SubsetIndexArray) : PartIndices;
var qs = PartIndices;

if (m_cache.TryGetValue(Octree.PerPointPartIndex1i.Id, out var _result))
{
Expand Down Expand Up @@ -635,10 +636,9 @@ private int[]? SubsetIndexArray
if (_subsetIndexArray != null) return _subsetIndexArray;
if (m_activePoints == null) return null;

var imax = PointCountCell;
var xs = new List<int>();
for (var i = 0; i < imax; i++) if (m_activePoints.Contains(i)) xs.Add(i);
return _subsetIndexArray = xs.ToArray();
var xs = m_activePoints.ToArray();
xs.QuickSortAscending();
return _subsetIndexArray = xs;
}
}

Expand Down

0 comments on commit e558c15

Please sign in to comment.