Exemplo n.º 1
0
		public bool LoadStlFile(string input_filename)
		{
			preSetup(config.extrusionWidth_um);
			timeKeeper.Restart();
			LogOutput.Log("Loading {0} from disk...\n".FormatWith(input_filename));
			if (!SimpleModel.loadModelFromFile(simpleModel, input_filename, config.modelRotationMatrix))
			{
				LogOutput.LogError("Failed to load model: {0}\n".FormatWith(input_filename));
				return false;
			}
			LogOutput.Log("Loaded from disk in {0:0.0}s\n".FormatWith(timeKeeper.Elapsed.Seconds));
			return true;
		}
Exemplo n.º 2
0
 private static void print_usage()
 {
     LogOutput.LogError("usage: MatterSlice [-h] [-d] [-v] [-t] [-m 3x3matrix]\n       [-b boolean math] [-c <config file>]\n       [-s <settingkey>=<value>] -o <output.gcode> <model.stl>\n\n");
     LogOutput.LogError("    [] enclose optional settings, <> are required.\n\n");
     LogOutput.LogError("    -h Show this message.\n");
     LogOutput.LogError("    -d Save the currently loaded settings to settings.ini (useful to see\n       all settings).\n");
     LogOutput.LogError("    -v Increment verbose level.\n");
     LogOutput.LogError("    -t Run unit tests.\n");
     LogOutput.LogError("    -m A 3x3 matrix for translating and rotating the layers.\n");
     LogOutput.LogError("    -c A config file to apply to the current settings.\n       Can be applied multiple times.\n       Formated like the default.ini (partial settings are fine).\n");
     LogOutput.LogError("    -s Specify a setting on the command line.\n       Uses the same names and values as default.ini.\n");
     LogOutput.LogError("    model.stl, the file that will be loaded and sliced.\n");
 }
Exemplo n.º 3
0
 private static void print_usage()
 {
     LogOutput.LogError("usage: MatterSlice [-h] [-d] [-v] [-t] [-m 3x3matrix]\n       [-b boolean math] [-c <config file>]\n       [-s <settingkey>=<value>] -o <output.gcode> <model.stl>\n\n");
     LogOutput.LogError("    [] enclose optional settings, <> are required.\n\n");
     LogOutput.LogError("    -h Show this message.\n");
     LogOutput.LogError("    -d Save the currently loaded settings to settings.ini (useful to see\n       all settings).\n");
     LogOutput.LogError("    -v Increment verbose level.\n");
     LogOutput.LogError("    -t Run unit tests.\n");
     LogOutput.LogError("    -m A 3x3 matrix for translating and rotating the layers.\n");
     LogOutput.LogError("    -b A string describing the boolean math to do on the loaded models.\n       (indexA,indexB) - parentheses = union\n       {indexA,indexBToRemove} - curly brackets = difference\n       [indexA,indexB] - square brackets = intersection\n       Example: b (0,[1,{2,3}]) intersect 2+3, remove from 1, union with 0\n");
     LogOutput.LogError("    -c A config file to apply to the current settings.\n       Can be applied multiple times.\n       Formated like the default.ini (partial settings are fine).\n");
     LogOutput.LogError("    -s Specify a setting on the command line.\n       Uses the same names and values as default.ini.\n");
     LogOutput.LogError("    -o Specify the path and filename to save 'output.gcode'.\n");
     LogOutput.LogError("    model.stl, the file that will be loaded and sliced.\n");
 }
Exemplo n.º 4
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
                {
                    using (new QuickTimer2("LoadStlFile"))
                    {
                        processor.LoadStlFile(args[argn]);
                    }
                }
            }

            return(1);
        }
Exemplo n.º 5
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 '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);
        }