public static OctreeModel ToOctree(this IPointCloud pointCloud, int maxLevel) { var box = pointCloud.CalulateAABB(); var size = Math.Abs(box.HalfSize.ToArray().Max() * 2.0); IOctreeNode node = new OctreeNode(box.Center, size, 0, NodeType.Empty); return(new OctreeModel(pointCloud.Points.Aggregate(node, (current, point) => current.Intersect(point.In, maxLevel)))); }
public static OctreeModel ToOctreeParallel(this IPointCloud pointCloud, int maxLevel) { //unsure if this will work var box = pointCloud.CalulateAABB(); var size = Math.Abs(box.HalfSize.ToArray().Max() * 2.0); IOctreeNode node = new OctreeNode(box.Center, size, 0, NodeType.Empty); return(new OctreeModel(pointCloud.Points.AsParallel().WithDegreeOfParallelism(8).Aggregate(node, (current, point) => current.Intersect(point.In, maxLevel)))); }