/// <summary> /// Returns lod points for given octree depth/front, where level 0 is the root node. /// Front will include leafs higher up than given level. /// </summary> public static IEnumerable <Chunk> QueryPointsInOctreeLevel( this IPointCloudNode node, int level ) { if (level < 0) { yield break; } if (level == 0 || node.IsLeaf()) { var ps = node.PositionsAbsolute; var cs = node?.TryGetColors4b()?.Value; if (ps != null && cs != null && ps.Length != cs.Length) { cs = new C4b[ps.Length]; Report.Warn("[Chunk] inconsistent length: pos.length = {0} vs cs.length = {1}", ps.Length, cs.Length); } var ns = node?.TryGetNormals3f()?.Value; var js = node?.TryGetIntensities()?.Value; var ks = node?.TryGetClassifications()?.Value; var chunk = new Chunk(ps, cs, ns, js, ks); yield return(chunk); } else { if (node.Subnodes == null) { yield break; } for (var i = 0; i < 8; i++) { var n = node.Subnodes[i]; if (n == null) { continue; } foreach (var x in QueryPointsInOctreeLevel(n.Value, level - 1)) { yield return(x); } } } }
/// <summary> /// Returns lod points for given octree depth/front of cells intersecting given bounds, where level 0 is the root node. /// Front will include leafs higher up than given level. /// </summary> public static IEnumerable <Chunk> QueryPointsInOctreeLevel( this IPointCloudNode node, int level, Box3d bounds ) { if (level < 0) { yield break; } if (!node.BoundingBoxExactGlobal.Intersects(bounds)) { yield break; } if (level == 0 || node.IsLeaf()) { var ps = node.PositionsAbsolute; var cs = node?.TryGetColors4b()?.Value; var ns = node?.TryGetNormals3f()?.Value; var js = node?.TryGetIntensities()?.Value; var ks = node?.TryGetClassifications()?.Value; var chunk = new Chunk(ps, cs, ns, js, ks); yield return(chunk); } else { if (node.Subnodes == null) { yield break; } for (var i = 0; i < 8; i++) { var n = node.Subnodes[i]; if (n == null) { continue; } foreach (var x in QueryPointsInOctreeLevel(n.Value, level - 1, bounds)) { yield return(x); } } } }