Example #1
0
        private static bool ProcessFile()
        {
            string path     = Path.GetFullPath(INPUT_PATH);
            bool   isFolder = false;

            if (!Directory.Exists(path))
            {
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("[ERROR] Input file not found", INPUT_PATH);
                }
            }
            else
            {
                isFolder = true;
            }
            try
            {
                AbstractToSchematic converter;
                if (isFolder)
                {
                    if (SLICE)
                    {
                        converter = new FolderImageToSchematic(path, EXCAVATE, INPUT_COLOR_FILE, COLOR_LIMIT);
                        return(SchematicToVox(converter, OUTPUT_PATH));
                    }

                    string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(t => Path.GetExtension(t).ToLower() != ".vox").ToArray();
                    Console.WriteLine("[INFO] Processing folder " + files.Length + " files");
                    for (int i = 0; i < files.Length; i++)
                    {
                        string file = files[i];
                        Console.WriteLine("[INFO] Processing file: " + file);
                        converter = GetConverter(file);
                        if (converter != null)
                        {
                            SchematicToVox(converter, Path.Combine(OUTPUT_PATH, Path.GetFileNameWithoutExtension(file)));
                        }
                        else
                        {
                            Console.WriteLine("[ERROR] Unsupported file extension !");
                        }
                    }
                }
                else
                {
                    converter = GetConverter(path);
                    if (converter != null)
                    {
                        return(SchematicToVox(converter, OUTPUT_PATH));
                    }

                    Console.WriteLine("[ERROR] Unsupported file extension !");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadLine();
                return(false);
            }

            return(true);
        }
Example #2
0
        private static void ProcessFile()
        {
            string path     = Path.GetFullPath(_inputPath);
            bool   isFolder = false;

            if (!Directory.Exists(path))
            {
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("[ERROR] Input file not found", _inputPath);
                }
            }
            else
            {
                isFolder = true;
            }
            try
            {
                AbstractToSchematic converter;
                if (isFolder)
                {
                    if (_slice)
                    {
                        converter = new FolderImageToSchematic(path, _excavate, _inputColorFile);
                        SchematicToVox(converter, _outputPath);
                    }
                    else
                    {
                        string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(t => Path.GetExtension(t).ToLower() != ".vox").ToArray();
                        Console.WriteLine("[INFO] Processing folder " + files.Length + " files");
                        for (int i = 0; i < files.Length; i++)
                        {
                            string file = files[i];
                            Console.WriteLine("[INFO] Processing file: " + file);
                            converter = GetConverter(file);
                            if (converter != null)
                            {
                                SchematicToVox(converter, Path.Combine(_outputPath, Path.GetFileNameWithoutExtension(file)));
                            }
                            else
                            {
                                Console.WriteLine("[ERROR] Unsupported file extension !");
                            }
                        }
                    }
                }
                else
                {
                    converter = GetConverter(path);
                    if (converter != null)
                    {
                        SchematicToVox(converter, _outputPath);
                    }
                    else
                    {
                        Console.WriteLine("[ERROR] Unsupported file extension !");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadLine();
            }
        }
Example #3
0
        private static void ProcessFile()
        {
            string path     = Path.GetFullPath(_inputFile);
            bool   isFolder = false;

            if (!Directory.Exists(path))
            {
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("[ERROR] Input file not found", _inputFile);
                }
            }
            else
            {
                isFolder = true;
            }
            try
            {
                AbstractToSchematic converter;
                if (isFolder)
                {
                    converter = new FolderImageToSchematic(path, _excavate);
                }
                else
                {
                    switch (Path.GetExtension(_inputFile))
                    {
                    case ".schematic":
                        converter = new SchematicToSchematic(path, _ignoreMinY, _ignoreMaxY, _excavate, _scale);
                        break;

                    case ".png":
                        converter = new PNGToSchematic(path, _inputColorFile, _heightmap, _excavate, _color, _top);
                        break;

                    case ".tif":
                        converter = new TIFtoSchematic(path, _inputColorFile, _heightmap, _excavate, _color, _top);
                        break;

                    case ".asc":
                        converter = new ASCToSchematic(path);
                        break;

                    case ".binvox":
                        converter = new BinvoxToSchematic(path);
                        break;

                    case ".qb":
                        converter = new QBToSchematic(path);
                        break;

                    case ".obj":
                        converter = new OBJToSchematic(path, _gridSize, _excavate, _slow);
                        break;

                    case ".ply":
                        converter = new PLYToSchematic(path, _scale);
                        break;

                    case ".xyz":
                        converter = new XYZToSchematic(path, _scale);
                        break;

                    case ".csv":
                        converter = new CSVToSchematic(path, _scale);
                        break;

                    default:
                        Console.WriteLine("[ERROR] Unknown file extension !");
                        Console.ReadKey();
                        return;
                    }
                }

                Schematic schematic = converter.WriteSchematic();
                Console.WriteLine($"[INFO] Vox Width: {schematic.Width}");
                Console.WriteLine($"[INFO] Vox Length: {schematic.Length}");
                Console.WriteLine($"[INFO] Vox Height: {schematic.Heigth}");
                VoxWriter writer = new VoxWriter();
                writer.WriteModel(_outputFile + ".vox", schematic, _direction);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadLine();
            }
        }