/// <summary> /// Initialize image synthesizer (responsible for raster image computation). /// </summary> public static IRenderer getRenderer(IImageFunction imf) { SupersamplingImageSynthesizer sis = new SupersamplingImageSynthesizer(); sis.ImageFunction = imf; return(sis); }
/// <summary> /// Initialize image synthesizer (responsible for raster image computation). /// </summary> public static IRenderer getRenderer(IImageFunction imf, int superSampling) { if (superSampling > 1) { SupersamplingImageSynthesizer sis = new SupersamplingImageSynthesizer(); sis.ImageFunction = imf; sis.Supersampling = superSampling; sis.Jittering = 1.0; return(sis); } SimpleImageSynthesizer s = new SimpleImageSynthesizer(); s.ImageFunction = imf; return(s); }
/// <summary> /// Initialize image synthesizer (responsible for raster image computation). /// </summary> public static IRenderer getRenderer(string param, IImageFunction imf) { Form1 f = Form1.singleton; if (f.superSampling > 1) { SupersamplingImageSynthesizer sis = new SupersamplingImageSynthesizer(); sis.ImageFunction = imf; sis.Supersampling = f.superSampling; sis.Jittering = 1.0; return(sis); } SimpleImageSynthesizer s = new SimpleImageSynthesizer(); s.ImageFunction = imf; return(s); }
/// <summary> /// Initialize image synthesizer (responsible for raster image computation). /// </summary> public static IRenderer getRenderer(IImageFunction imf, int superSampling, double jittering, string param) { Dictionary <string, string> p = Util.ParseKeyValueList(param); string isType; IRenderer r = null; if (p.TryGetValue("sampling", out isType) && superSampling > 1) { switch (isType) { case "adapt1": double threshold = 0.004; Util.TryParse(p, "threshold", ref threshold); AdaptiveSupersamplingJR adis = new AdaptiveSupersamplingJR(threshold); adis.ImageFunction = imf; adis.Supersampling = superSampling; adis.Jittering = jittering; r = adis; break; case "adapt2": AdaptiveSupersampling sis = new AdaptiveSupersampling(); sis.ImageFunction = imf; sis.Supersampling = superSampling; sis.Jittering = jittering; r = sis; break; } } if (r == null) { SupersamplingImageSynthesizer jit = new SupersamplingImageSynthesizer(); jit.ImageFunction = imf; jit.Supersampling = superSampling; jit.Jittering = jittering; r = jit; } return(r); }
private IRenderer getRenderer(IImageFunction imf, int width, int height) { IRenderer rend = FormSupport.getRenderer(imf); rend.Width = width; rend.Height = height; rend.Adaptive = 8; rend.ProgressData = progress; SupersamplingImageSynthesizer ss = rend as SupersamplingImageSynthesizer; if (ss != null) { ss.Supersampling = (int)numericSupersampling.Value; ss.Jittering = checkJitter.Checked ? 1.0 : 0.0; } return(rend); }
/// <summary> /// [Re]-renders the whole image (in separate thread). /// </summary> private void RenderImage() { Cursor.Current = Cursors.WaitCursor; // determine output image size: int width = ImageWidth; if (width <= 0) { width = panel1.Width; } int height = ImageHeight; if (height <= 0) { height = panel1.Height; } Bitmap newImage = new Bitmap(width, height, PixelFormat.Format24bppRgb); if (imf == null) { imf = FormSupport.getImageFunction(FormSupport.getScene()); rend = null; } imf.Width = width; imf.Height = height; RayTracing rt = imf as RayTracing; if (rt != null) { rt.DoShadows = checkShadows.Checked; rt.DoReflections = checkReflections.Checked; rt.DoRefractions = checkRefractions.Checked; } if (rend == null) { rend = FormSupport.getRenderer(imf); } rend.Width = width; rend.Height = height; rend.Adaptive = 8; rend.ProgressData = progress; SupersamplingImageSynthesizer ss = rend as SupersamplingImageSynthesizer; if (ss != null) { ss.Supersampling = (int)numericSupersampling.Value; ss.Jittering = checkJitter.Checked ? 1.0 : 0.0; } progress.SyncInterval = ((width * (long)height) > (2L << 20)) ? 30000L : 10000L; progress.Reset(); CSGInnerNode.ResetStatistics(); lock ( sw ) { sw.Reset(); sw.Start(); } if (checkMultithreading.Checked && Environment.ProcessorCount > 1) { Thread[] pool = new Thread[Environment.ProcessorCount]; int t; for (t = 0; t < pool.Length; t++) { pool[t] = new Thread(new ParameterizedThreadStart(this.RenderWorker)); } for (t = pool.Length; --t >= 0;) { pool[t].Start(new WorkerThreadInit(newImage, width, height, t, pool.Length)); } for (t = 0; t < pool.Length; t++) { pool[t].Join(); pool[t] = null; } } else { MT.InitThreadData(); rend.RenderRectangle(newImage, 0, 0, width, height); } long elapsed; lock ( sw ) { sw.Stop(); elapsed = sw.ElapsedMilliseconds; } string msg = string.Format(CultureInfo.InvariantCulture, "{0:f1}s [ {1}x{2}, f{3:#,#}, mt{4}, r{5:#,#}k, i{6:#,#}k, bb{7:#,#}k, t{8:#,#}k ]", 1.0e-3 * elapsed, width, height, CSGInnerNode.countFaces, checkMultithreading.Checked ? Environment.ProcessorCount : 1, (Intersection.countRays + 500L) / 1000L, (Intersection.countIntersections + 500L) / 1000L, (CSGInnerNode.countBoundingBoxes + 500L) / 1000L, (CSGInnerNode.countTriangles + 500L) / 1000L); SetText(msg); Console.WriteLine("Rendering finished: " + msg); SetImage(newImage); Cursor.Current = Cursors.Default; StopRendering(); }