Example #1
0
        /// <summary>
        /// Shoots single primary ray only..
        /// </summary>
        /// <param name="x">X-coordinate inside the raster image.</param>
        /// <param name="y">Y-coordinate inside the raster image.</param>
        private void singleSample(int x, int y)
        {
            if (imf == null)
            {
                imf = FormSupport.getImageFunction(out scene, brepScene);
            }

            // determine output image size:
            int width = ImageWidth;

            if (width <= 0)
            {
                width = panel1.Width;
            }
            int height = ImageHeight;

            if (height <= 0)
            {
                height = panel1.Height;
            }
            imf.Width  = width;
            imf.Height = height;
            double[] color = new double[3];
            long     hash  = imf.GetSample(x, y, color);

            labelSample.Text = string.Format(CultureInfo.InvariantCulture, "Sample at [{0},{1}] = [{2:f},{3:f},{4:f}], {5:X}",
                                             x, y, color[0], color[1], color[2], hash);
        }
Example #2
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;
        }
Example #3
0
        /// <summary>
        /// Shoots single primary ray only..
        /// </summary>
        /// <param name="x">X-coordinate inside the raster image.</param>
        /// <param name="y">Y-coordinate inside the raster image.</param>
        private void singleSample(int x, int y)
        {
            if (imf == null)
            {
                imf = FormSupport.getImageFunction(out scene);
            }

            imf.Width  = panel1.Width;
            imf.Height = panel1.Height;
            double[] color = new double[3];
            long     hash  = imf.GetSample(x, y, color);

            labelSample.Text = string.Format(CultureInfo.InvariantCulture, "Sample at [{0},{1}] = [{2:f},{3:f},{4:f}], {5:X}",
                                             x, y, color[0], color[1], color[2], hash);
        }
Example #4
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;
        }