Skip to content

Commit

Permalink
[Queries] PointsNearObject.PartIndices
Browse files Browse the repository at this point in the history
  • Loading branch information
aszabo314 committed Nov 29, 2023
1 parent 947a836 commit bb24265
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/Aardvark.Geometry.PointSet/Octrees/PointsNearObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class PointsNearObject<T>
public static readonly PointsNearObject<T> Empty = new(
default!, 0.0,
Array.Empty<V3d>(), Array.Empty<C4b>(), Array.Empty<V3f>(),
Array.Empty<int>(), Array.Empty<byte>(),
Array.Empty<int>(), Array.Empty<int>(), Array.Empty<byte>(),
Array.Empty<double>()
);

Expand All @@ -76,15 +76,18 @@ public class PointsNearObject<T>

/// <summary></summary>
public int[]? Intensities { get; }


/// <summary></summary>
public int[]? PartIndices { get; }

/// <summary></summary>
public byte[]? Classifications { get; }

/// <summary></summary>
public double[]? Distances { get; }

/// <summary></summary>
public PointsNearObject(T obj, double maxDistance, V3d[] positions, C4b[]? colors, V3f[]? normals, int[]? intensities, byte[]? classifications, double[]? distances)
public PointsNearObject(T obj, double maxDistance, V3d[] positions, C4b[]? colors, V3f[]? normals, int[]? intensities, int[]? partIndices, byte[]? classifications, double[]? distances)
{
if (maxDistance < 0.0) throw new ArgumentOutOfRangeException(nameof(maxDistance), $"Parameter 'maxDistance' must not be less than 0.0, but is {maxDistance}.");

Expand All @@ -94,6 +97,7 @@ public PointsNearObject(T obj, double maxDistance, V3d[] positions, C4b[]? color
Colors = colors;
Normals = normals;
Intensities = intensities;
PartIndices = partIndices;
Classifications = classifications;
Distances = distances;
}
Expand Down Expand Up @@ -121,6 +125,7 @@ public PointsNearObject<T> Merge(PointsNearObject<T> other, int maxCount)
Colors?.Append(other.Colors),
Normals.Append(other.Normals),
Intensities.Append(other.Intensities),
PartIndices.Append(other.PartIndices),
Classifications.Append(other.Classifications),
Distances.Append(other.Distances)
);
Expand Down Expand Up @@ -153,6 +158,7 @@ public PointsNearObject<T> Merge(PointsNearObject<T> other, int maxCount)
Colors?.Length > 0 ? Colors.Reordered(ia) : Colors,
Normals?.Length > 0 ? Normals.Reordered(ia) : Normals,
Intensities?.Length > 0 ? Intensities.Reordered(ia) : Intensities,
PartIndices?.Length > 0 ? PartIndices.Reordered(ia) : PartIndices,
Classifications?.Length > 0 ? Classifications.Reordered(ia) : Classifications,
Distances!.Reordered(ia)
);
Expand All @@ -165,13 +171,13 @@ public PointsNearObject<T> Take(int count)
if (count >= Count) return this;
var ds = Distances!.Take(count);
return new PointsNearObject<T>(Object, ds.Max(),
Positions.Take(count), Colors?.Take(count), Normals?.Take(count), Intensities?.Take(count), Classifications!.Take(count), ds
Positions.Take(count), Colors?.Take(count), Normals?.Take(count), Intensities?.Take(count), PartIndices?.Take(count), Classifications!.Take(count), ds
);
}

/// <summary>
/// </summary>
public PointsNearObject<U> WithObject<U>(U other)
=> new(other, MaxDistance, Positions, Colors, Normals, Intensities, Classifications, Distances);
=> new(other, MaxDistance, Positions, Colors, Normals, Intensities, PartIndices, Classifications, Distances);
}
}
4 changes: 3 additions & 1 deletion src/Aardvark.Geometry.PointSet/Queries/QueriesV3d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ public static PointsNearObject<V3d> QueryPointsNearPoint(
var cs = node.Colors?.Value?.Subset(ia);
var ns = node.Normals?.Value?.Subset(ia);
var js = node.Intensities?.Value?.Subset(ia);
node.TryGetPartIndices(out var pis);
pis = pis?.Subset(ia);
var ks = node.Classifications?.Value?.Subset(ia);
var chunk = new PointsNearObject<V3d>(query, maxDistanceToPoint, ps, cs, ns, js, ks, ds);
var chunk = new PointsNearObject<V3d>(query, maxDistanceToPoint, ps, cs, ns, js, pis, ks, ds);
return chunk;
}
else
Expand Down

0 comments on commit bb24265

Please sign in to comment.