Example #1
0
        public static int ProcessArgs(string[] args)
        {
            if (args.Length == 0)
            {
                print_usage();
                return(0);
            }

            ConfigSettings config    = new ConfigSettings();
            fffProcessor   processor = new fffProcessor(config);

            LogOutput.Log("\nMatterSlice version {0}\n\n".FormatWith(ConfigConstants.VERSION));

            if (ProcessArgs(args, config, processor) == 0)
            {
                return(0);
            }

            if (!Canceled)
            {
                processor.DoProcessing();
            }
            if (!Canceled)
            {
                processor.finalize();
            }
            if (Canceled)
            {
                processor.Cancel();
            }

            Canceled = true;

            return(0);
        }
Example #2
0
        private static int Main(string[] args)
        {
            ConfigSettings config    = new ConfigSettings();
            fffProcessor   processor = new fffProcessor(config);

            processor.SetTargetFile(@"I:\5mm.txt");
            processor.LoadStlFile(@"I:\5mm.stl");

            processor.DoProcessing();
            processor.finalize();
            processor.Cancel();

            Console.ReadLine();

            /////////////////////before is test code//////////////////////


            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentCulture     = CultureInfo.InvariantCulture;
            return(ProcessArgs(args));
        }
Example #3
0
        public static int ProcessArgs(string[] args)
        {
#if DEBUG
            Tests.BridgeTests.Run();
#endif
            ConfigSettings config    = new ConfigSettings();
            fffProcessor   processor = new fffProcessor(config);

            LogOutput.log("\nMatterSlice version {0}\n\n".FormatWith(ConfigConstants.VERSION));

            for (int argn = 0; argn < args.Length; argn++)
            {
                string str = args[argn];
                if (str[0] == '-')
                {
                    for (int stringIndex = 1; stringIndex < str.Length; stringIndex++)
                    {
                        switch (str[stringIndex])
                        {
                        case 'h':
                            print_usage();
                            return(0);

                        case 'v':
                            LogOutput.verbose_level++;
                            break;

                        case 'o':
                            argn++;
                            if (!processor.setTargetFile(args[argn]))
                            {
                                LogOutput.logError("Failed to open {0} for output.\n".FormatWith(args[argn]));
                                return(1);
                            }
                            break;

                        case 'c':
                        {
                            // Read a config file from the given path
                            argn++;
                            if (!config.ReadSettings(args[argn]))
                            {
                                LogOutput.logError("Failed to read config '{0}'\n".FormatWith(args[argn]));
                            }
                        }
                        break;

                        case 'd':
                            config.DumpSettings("settings.ini");
                            break;

                        case 's':
                        {
                            argn++;
                            int equalsPos = args[argn].IndexOf('=');
                            if (equalsPos != -1)
                            {
                                string key   = args[argn].Substring(0, equalsPos);
                                string value = args[argn].Substring(equalsPos + 1);
                                if (key.Length > 1)
                                {
                                    if (!config.SetSetting(key, value))
                                    {
                                        LogOutput.logError("Setting not found: {0} {1}\n".FormatWith(key, value));
                                    }
                                }
                            }
                        }
                        break;

                        case 'm':
                            argn++;
                            throw new NotImplementedException("m");
#if false
                            sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
                                   &config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2],
                                   &config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2],
                                   &config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]);
#endif
                            break;

                        default:
                            throw new NotImplementedException("Unknown option: {0}\n".FormatWith(str));
                            LogOutput.logError("Unknown option: {0}\n".FormatWith(str));
                            break;
                        }
                    }
                }
                else
                {
                    processor.processFile(args[argn]);
                }
            }

            processor.finalize();
            return(0);
        }
Example #4
0
        public static int ProcessArgs(string[] args)
        {
            if (args.Length == 0)
            {
                print_usage();
                return 0;
            }

            ConfigSettings config = new ConfigSettings();
            fffProcessor processor = new fffProcessor(config);

            LogOutput.Log("\nMatterSlice version {0}\n\n".FormatWith(ConfigConstants.VERSION));

            for (int argn = 0; argn < args.Length; argn++)
            {
                string str = args[argn];
                if (str[0] == '-')
                {
                    for (int stringIndex = 1; stringIndex < str.Length; stringIndex++)
                    {
                        switch (str[stringIndex])
                        {
                            case 'h':
                                print_usage();
                                return 0;

                            case 'v':
                                LogOutput.verbose_level++;
                                break;

                            case 'o':
                                argn++;
                                if (!processor.SetTargetFile(args[argn]))
                                {
                                    LogOutput.LogError("Failed to open {0} for output.\n".FormatWith(args[argn]));
                                    return 1;
                                }
                                break;

                            case 'c':
                                {
                                    // Read a config file from the given path
                                    argn++;
                                    if (!config.ReadSettings(args[argn]))
                                    {
                                        LogOutput.LogError("Failed to read config '{0}'\n".FormatWith(args[argn]));
                                    }
                                }
                                break;

                            case 'b':
                                argn++;
                                config.BooleanOpperations = args[argn];
                                break;

                            case 'd':
                                config.DumpSettings("settings.ini");
                                break;

                            case 's':
                                {
                                    argn++;
                                    int equalsPos = args[argn].IndexOf('=');
                                    if (equalsPos != -1)
                                    {
                                        string key = args[argn].Substring(0, equalsPos);
                                        string value = args[argn].Substring(equalsPos + 1);
                                        if (key.Length > 1)
                                        {
                                            if (!config.SetSetting(key, value))
                                            {
                                                LogOutput.LogError("Setting not found: {0} {1}\n".FormatWith(key, value));
                                            }
                                        }
                                    }
                                }
                                break;

                            case 'm':
                                argn++;
                                throw new NotImplementedException("m");
            #if false
                        sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
                        &config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2],
                        &config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2],
                        &config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]);
            #endif
                            //break;

                            default:
                                throw new NotImplementedException("Unknown option: {0}\n".FormatWith(str));
                            //LogOutput.logError("Unknown option: {0}\n".FormatWith(str));
                            //break;
                        }
                    }
                }
                else
                {
                    processor.LoadStlFile(args[argn]);
                }
            }

            if (!Canceled)
            {
                processor.DoProcessing();
            }
            if (!Canceled)
            {
                processor.finalize();
            }
            if (Canceled)
            {
                processor.Cancel();
            }

            return 0;
        }
Example #5
0
        public static int ProcessArgs(string[] args, ConfigSettings config, fffProcessor processor)
        {
            for (int argn = 0; argn < args.Length; argn++)
            {
                string str = args[argn];
                if (str[0] == '-')
                {
                    for (int stringIndex = 1; stringIndex < str.Length; stringIndex++)
                    {
                        switch (str[stringIndex])
                        {
                        case 'h':
                            print_usage();
                            return(0);

                        case 'v':
                            LogOutput.verbose_level++;
                            break;

                        case 'o':
                            argn++;
                            if (!processor.SetTargetFile(args[argn]))
                            {
                                LogOutput.LogError("Failed to open {0} for output.\n".FormatWith(args[argn]));
                                return(1);
                            }
                            break;

                        case 'c':
                        {
                            // Read a config file from the given path
                            argn++;
                            if (!config.ReadSettings(args[argn]))
                            {
                                LogOutput.LogError("Failed to read config '{0}'\n".FormatWith(args[argn]));
                            }

                            // process any matrix and mesh requested by config file
                            List <string> commands = new List <string>();
                            foreach (string command in SplitCommandLine.DoSplit(config.AdditionalArgsToProcess))
                            {
                                commands.Add(command);
                            }
                            string[] subArgs = commands.ToArray();
                            ProcessArgs(subArgs, config, processor);
                        }
                        break;

                        case 'd':
                            config.DumpSettings("settings.ini");
                            break;

                        case 's':
                        {
                            argn++;
                            int equalsPos = args[argn].IndexOf('=');
                            if (equalsPos != -1)
                            {
                                string key   = args[argn].Substring(0, equalsPos);
                                string value = args[argn].Substring(equalsPos + 1);
                                if (key.Length > 1)
                                {
                                    if (!config.SetSetting(key, value))
                                    {
                                        LogOutput.LogError("Setting not found: {0} {1}\n".FormatWith(key, value));
                                    }
                                }
                            }
                        }
                        break;

                        case 'm':
                            argn++;
                            string[] matrixValues = args[argn].Split(',');
                            var      loadedMatrix = Matrix4X4.Identity;
                            for (int i = 0; i < 4; i++)
                            {
                                for (int j = 0; j < 4; j++)
                                {
                                    string valueString = matrixValues[i * 4 + j];
                                    double value;
                                    if (double.TryParse(valueString, out value))
                                    {
                                        loadedMatrix[i, j] = value;
                                    }
                                }
                            }
                            config.ModelMatrix = loadedMatrix;
                            break;

                        default:
                            throw new NotImplementedException("Unknown option: {0}\n".FormatWith(str));
                            //LogOutput.logError("Unknown option: {0}\n".FormatWith(str));
                            //break;
                        }
                    }
                }
                else
                {
                    processor.LoadStlFile(args[argn]);
                }
            }

            return(1);
        }