Ejemplo n.º 1
0
        /// <summary>
        /// Redraws the whole image.
        /// </summary>
        private void redraw()
        {
            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, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            if (imf == null)
            {
                imf = FormSupport.getImageFunction(out scene, brepScene);
            }
            imf.Width  = width;
            imf.Height = height;

            if (rend == null)
            {
                rend = FormSupport.getRenderer(imf);
            }
            rend.Width  = width;
            rend.Height = height;
            CSGInnerNode.ResetStatistics();
            MT.InitThreadData();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            rend.RenderRectangle(newImage, 0, 0, width, height);

            sw.Stop();
            labelElapsed.Text = string.Format(CultureInfo.InvariantCulture, "{0:f1}s  [ {1}x{2}, r{3:#,#}k, i{4:#,#}k, bb{5:#,#}k, t{6:#,#}k ]",
                                              1.0e-3 * sw.ElapsedMilliseconds, width, height,
                                              (Intersection.countRays + 500L) / 1000L,
                                              (Intersection.countIntersections + 500L) / 1000L,
                                              (CSGInnerNode.countBoundingBoxes + 500L) / 1000L,
                                              (CSGInnerNode.countTriangles + 500L) / 1000L);

            setImage(ref outputImage, newImage);

            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Redraws the whole image.
        /// </summary>
        private void redraw()
        {
            Cursor.Current = Cursors.WaitCursor;

            int width  = panel1.Width;
            int height = panel1.Height;

            Bitmap newImage = new Bitmap(width, height, PixelFormat.Format24bppRgb);

            if (imf == null)
            {
                imf = FormSupport.getImageFunction(out scene);
            }
            imf.Width  = width;
            imf.Height = height;

            if (rend == null)
            {
                rend = FormSupport.getRenderer(imf);
            }
            rend.Width    = width;
            rend.Height   = height;
            rend.Adaptive = 0;

            MT.InitThreadData();
            Stopwatch sw = new Stopwatch();

            sw.Start();

            rend.RenderRectangle(newImage, 0, 0, width, height);

            sw.Stop();
            labelElapsed.Text = string.Format(CultureInfo.InvariantCulture, "Elapsed: {0:f2}s",
                                              1.0e-3 * sw.ElapsedMilliseconds);

            setImage(ref outputImage, newImage);

            Cursor.Current = Cursors.Default;
        }