/// <summary> /// Run the given stage on a sketch. This method is guaranteed not to modify /// the given sketch. /// </summary> /// <param name="stage">the stage</param> /// <param name="sketch">the sketch</param> /// <param name="filename">the name of the file the sketch was loaded from</param> /// <param name="writeIntermediary">true if intermediate files should be written</param> private void runStageOnSketch(ProcessStage stage, Sketch.Sketch sketch, string filename, bool writeIntermediary) { Sketch.Sketch mutable = new Sketch.Sketch(sketch); if (verbose) { Console.WriteLine("Executing stage " + stage.name); } stage.run(mutable, filename); if (writeIntermediary) { TextWriter handle; if (consoleOutput) { handle = Console.Out; } else { handle = new StreamWriter(intermediaryPath + "\\" + stage.shortname + "_" + fileTimeStamp() + stage.outputFiletype); } stage.finalize(handle, intermediaryPath); if (!consoleOutput) { handle.Close(); } } }