diff --git a/SchematicToVoxCore/Converter/PointCloud/CSVToSchematic.cs b/SchematicToVoxCore/Converter/PointCloud/CSVToSchematic.cs index ecb5c4d..09fa15a 100644 --- a/SchematicToVoxCore/Converter/PointCloud/CSVToSchematic.cs +++ b/SchematicToVoxCore/Converter/PointCloud/CSVToSchematic.cs @@ -35,10 +35,12 @@ public CSVToSchematic(string path, int scale) : base(path, scale) string s = data[i]; values[i] = float.Parse(s, CultureInfo.InvariantCulture); } - bodyVertices.Add(new Vector3(values[2], values[3], values[4])); - bodyColors.Add(Color.FromArgb((byte)Math.Round(values[6] * 255), - (byte)Math.Round(values[7] * 255), - (byte)Math.Round(values[8] * 255))); + + Vector3 vertice = new Vector3(values[11], values[12], values[13]); + bodyVertices.Add(vertice); + bodyColors.Add(Color.FromArgb((byte)Math.Round(values[7] * 255), + (byte)Math.Round(values[8] * 255), + (byte)Math.Round(values[9] * 255))); } catch (Exception e) { diff --git a/SchematicToVoxCore/Converter/PointCloud/PLYToSchematic.cs b/SchematicToVoxCore/Converter/PointCloud/PLYToSchematic.cs index 67ab6ff..e1313ba 100644 --- a/SchematicToVoxCore/Converter/PointCloud/PLYToSchematic.cs +++ b/SchematicToVoxCore/Converter/PointCloud/PLYToSchematic.cs @@ -417,7 +417,7 @@ public override Schematic WriteSchematic() List list = Quantization.ApplyQuantization(_blocks); list.ApplyOffset(new Vector3(minX, minY, minZ)); HashSet hashSet = list.ToHashSet(); - RemoveHoles(ref hashSet, schematic); + //RemoveHoles(ref hashSet, schematic); schematic.Blocks = hashSet; return schematic; diff --git a/SchematicToVoxCore/Converter/PointCloud/XYZToSchematic.cs b/SchematicToVoxCore/Converter/PointCloud/XYZToSchematic.cs index ed9acc9..5001f84 100644 --- a/SchematicToVoxCore/Converter/PointCloud/XYZToSchematic.cs +++ b/SchematicToVoxCore/Converter/PointCloud/XYZToSchematic.cs @@ -122,7 +122,7 @@ public override Schematic WriteSchematic() List list = Quantization.ApplyQuantization(_blocks); list.ApplyOffset(new Vector3(minX, minY, minZ)); HashSet hashSet = list.ToHashSet(); - RemoveHoles(ref hashSet, schematic); + //RemoveHoles(ref hashSet, schematic); schematic.Blocks = hashSet; return schematic; diff --git a/SchematicToVoxCore/Extensions/Quantization.cs b/SchematicToVoxCore/Extensions/Quantization.cs index 16e8fac..862d3cb 100644 --- a/SchematicToVoxCore/Extensions/Quantization.cs +++ b/SchematicToVoxCore/Extensions/Quantization.cs @@ -13,20 +13,30 @@ public static class Quantization public static List ApplyQuantization(List blocks) { WuQuantizer quantizer = new WuQuantizer(); - using (Bitmap bitmap = CreateBitmapFromColors(blocks)) + try { - using (Image quantized = quantizer.QuantizeImage(bitmap)) + using (Bitmap bitmap = CreateBitmapFromColors(blocks)) { - Bitmap reducedBitmap = new Bitmap(quantized); - int width = reducedBitmap.Size.Width; - for (int i = 0; i < blocks.Count; i++) + using (Image quantized = quantizer.QuantizeImage(bitmap)) { - int x = i % width; - int y = i / width; - blocks[i] = new Block(blocks[i].X, blocks[i].Y, blocks[i].Z, reducedBitmap.GetPixel(x, y).ColorToUInt()); + Bitmap reducedBitmap = (Bitmap) quantized; + //Console.WriteLine(quantized.PixelFormat); + //Bitmap reducedBitmap = new Bitmap(quantized); + int width = reducedBitmap.Size.Width; + for (int i = 0; i < blocks.Count; i++) + { + int x = i % width; + int y = i / width; + blocks[i] = new Block(blocks[i].X, blocks[i].Y, blocks[i].Z, + reducedBitmap.GetPixel(x, y).ColorToUInt()); + } } } } + catch (Exception e) + { + Console.WriteLine(e); + } return blocks; }