private static void RecordSuitableImage(string pythonExecutable, string dataFileName, double centerR, double centerI, double range, ulong maximumRecursionDepth) { //TODO - record the position and range (perhaps as text in a file or perhaps as a saved image) //TODO - remove below once done testing Console.WriteLine($"Suitable image found: {centerR}+{centerI}i {range} {maximumRecursionDepth}"); GeneratePPM.Generate(dataFileName, $"tmp_image.ppm", "jet-inverse"); Process.Start(pythonExecutable, Program.saveImageAsProgramFileName + " tmp_image.ppm " + $"\"found {centerR},{centerI} range {range} mrd {maximumRecursionDepth}.png\""); }
public static void Main(string[] args) { Mode mode; double minR, maxR, stepR, minI, maxI, stepI; ulong maximumRecursionDepth; ulong bufferSize; if (args.Length == 3) //Image searching with less parameters { mode = ParseMode(args[0]); if (mode != Mode.ImageSearching) { Console.WriteLine("Only use 3 arguments when trying to use image searching"); return; } if (!int.TryParse(args[1], out int seed)) { Console.WriteLine("Invalid seed provided"); } if (!int.TryParse(args[2], out int maximumResults)) { Console.WriteLine("Invalid maximum results passed"); } ImageSearching.SearchForImages(@"C:\Python39\python", seed, maximumResults, dataFileName); return; } else if (args.Length == 6) //Image searching with more parameters { mode = ParseMode(args[0]); if (mode != Mode.ImageSearching) { Console.WriteLine("Only use 6 arguments when trying to use image searching"); return; } if (!int.TryParse(args[1], out int seed)) { Console.WriteLine("Invalid seed provided"); } if (!int.TryParse(args[2], out int maximumResults)) { Console.WriteLine("Invalid maximum results passed"); } if (!double.TryParse(args[3], out double maxCenterRange)) { Console.WriteLine("Invalid maximum center range passed"); } if (!double.TryParse(args[4], out double maxRange)) { Console.WriteLine("Invalid maximum range passed"); } string pythonExecutable = args[5]; ImageSearching.SearchForImages(pythonExecutable, seed, maximumResults, dataFileName, maxCenterRange, maxRange); return; } else if (args.Length == 4) { mode = ParseMode(args[0]); if (mode != Mode.Generate_PPM) { Console.WriteLine("Only use 4 arguments when trying to generate PPM"); return; } string dataFileName = args[1]; if (!File.Exists(dataFileName)) { Console.WriteLine("Passed data file name doesn't exist"); return; } string outputFileName = args[2]; string colorGradientName = args[3]; Console.WriteLine("Starting PPM generation"); GeneratePPM.Generate(dataFileName, outputFileName, colorGradientName); Console.WriteLine("PPM generation finished"); return; } else if (args.Length == 9) //Specifying by corners and step size { mode = ParseMode(args[0]); minR = double.Parse(args[1]); maxR = double.Parse(args[2]); stepR = double.Parse(args[3]); minI = double.Parse(args[4]); maxI = double.Parse(args[5]); stepI = double.Parse(args[6]); maximumRecursionDepth = ulong.Parse(args[7]); bufferSize = GetBufferSizeFromInput(args[8]); } else if (args.Length == 7) //Specifying by center, range and definition { mode = ParseMode(args[0]); double centerR, centerI, range; ushort definition; centerR = double.Parse(args[1]); centerI = double.Parse(args[2]); range = double.Parse(args[3]); definition = ushort.Parse(args[4]); GetGenerationParametersFromCenterRange( centerR, centerI, range, definition, out minR, out maxR, out stepR, out minI, out maxI, out stepI ); maximumRecursionDepth = ulong.Parse(args[5]); bufferSize = GetBufferSizeFromInput(args[6]); } else { Console.Write("Mode> "); mode = ParseMode(Console.ReadLine()); Console.Write("Min R> "); minR = double.Parse(Console.ReadLine()); Console.Write("Max R> "); maxR = double.Parse(Console.ReadLine()); Console.Write("Step R> "); stepR = double.Parse(Console.ReadLine()); Console.Write("Min I> "); minI = double.Parse(Console.ReadLine()); Console.Write("Max I> "); maxI = double.Parse(Console.ReadLine()); Console.Write("Step I> "); stepI = double.Parse(Console.ReadLine()); Console.Write("Maximum Recursion Depth> "); maximumRecursionDepth = ulong.Parse(Console.ReadLine()); Console.Write("Buffer Size (Generic size = 65535)> "); string bufferSizeInput = Console.ReadLine(); bufferSize = GetBufferSizeFromInput(bufferSizeInput); } Console.WriteLine("Estimated total file size: " + GetEstimatedFileSize(minR, maxR, stepR, minI, maxI, stepI).ToString() + "KB"); switch (mode) { case Mode.Standard: Run_Standard(minR, maxR, stepR, minI, maxI, stepI, maximumRecursionDepth, bufferSize, true); break; case Mode.DontVisualise: Run_Standard(minR, maxR, stepR, minI, maxI, stepI, maximumRecursionDepth, bufferSize, false); break; case Mode.Distributed_Server: DistributedComputation.Run_Server(minR, maxR, stepR, minI, maxI, stepI, maximumRecursionDepth, bufferSize); break; case Mode.Distributed_Client: DistributedComputation.Run_Client(minR, maxR, stepR, minI, maxI, stepI, maximumRecursionDepth, bufferSize); break; default: throw new Exception("Unknown mode - " + mode.ToString()); } }