/// <summary>
        /// Export the mesh to PNG format.
        /// </summary>
        /// <param name="mesh">The current mesh.</param>
        /// <param name="width">The desired width (pixel) of the image.</param>
        /// <param name="file">The PNG filename.</param>
        /// <param name="regions">Enable rendering of regions.</param>
        /// <param name="points">Enable rendering of points.</param>
        public static void Save(Mesh mesh, string file = null, int width = 800,
            bool regions = false, bool points = true)
        {
            // Check file name
            if (String.IsNullOrWhiteSpace(file))
            {
                file = String.Format("mesh-{0}.png", DateTime.Now.ToString("yyyy-M-d-hh-mm-ss"));
            }

            // Ensure .png extension.
            if (!file.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
            {
                Path.ChangeExtension(file, ".png");
            }

            var renderer = new ImageRenderer();

            renderer.EnableRegions = regions;
            renderer.EnablePoints = points;

            var bitmap = renderer.Render(mesh, width);

            bitmap.Save(file, ImageFormat.Png);
        }
Exemple #2
0
        /// <summary>
        /// Export the mesh to PNG format.
        /// </summary>
        /// <param name="mesh">The current mesh.</param>
        /// <param name="width">The desired width (pixel) of the image.</param>
        /// <param name="file">The PNG filename.</param>
        /// <param name="regions">Enable rendering of regions.</param>
        /// <param name="points">Enable rendering of points.</param>
        public static void Save(IMesh mesh, string file = null, int width    = 800,
                                bool regions            = false, bool points = true)
        {
            // Check file name
            if (string.IsNullOrWhiteSpace(file))
            {
                file = string.Format("mesh-{0}.png", DateTime.Now.ToString("yyyy-M-d-hh-mm-ss"));
            }

            // Ensure .png extension.
            if (!file.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
            {
                Path.ChangeExtension(file, ".png");
            }

            var renderer = new ImageRenderer();

            renderer.EnableRegions = regions;
            renderer.EnablePoints  = points;

            var bitmap = renderer.Render(mesh, width);

            bitmap.Save(file, ImageFormat.Png);
        }