private static void Save(Size size, Xyzi xyzi, ITopoArray <byte> topArray) { // TODO size.SizeX = topArray.Topology.Width; size.SizeY = topArray.Topology.Height; size.SizeZ = topArray.Topology.Depth; xyzi.Voxels = new List <Voxel>(); for (var z = 0; z < size.SizeZ; z++) { for (var y = 0; y < size.SizeY; y++) { for (var x = 0; x < size.SizeX; x++) { var colorIndex = topArray.Get(x, y, z); if (colorIndex != 0) { xyzi.Voxels.Add(new Voxel { X = (byte)x, Y = (byte)y, Z = (byte)z, ColorIndex = colorIndex, }); } } } } }
private static ITopoArray <byte> Load(Size size, Xyzi xyzi) { var data = new byte[size.SizeX, size.SizeY, size.SizeZ]; foreach (var voxel in xyzi.Voxels) { data[voxel.X, voxel.Y, voxel.Z] = voxel.ColorIndex; } return(TopoArray.Create(data, false)); }