예제 #1
0
        internal void LoadImageCenterline(Bitmap bmp, string filename, bool useCornerThreshold, int cornerThreshold, bool useLineThreshold, int lineThreshold, L2LConf conf, bool append)
        {
            RiseOnFileLoading(filename);

            DateTime start = DateTime.Now;

            if (!append)
            {
                list.Clear();
            }

            mRange.ResetRange();

            string content = "";

            // Should throw
            //try
            //{
            content = Autotrace.BitmapToSvgString(bmp, useCornerThreshold, cornerThreshold, useLineThreshold, lineThreshold);
            //}
            //catch (Exception ex) { Logger.LogException("Centerline", ex); }

            SvgConverter.GCodeFromSVG converter = new SvgConverter.GCodeFromSVG();
            converter.GCodeXYFeed   = Settings.GetObject("GrayScaleConversion.VectorizeOptions.BorderSpeed", 1000);
            converter.SvgScaleApply = true;
            converter.SvgMaxSize    = (float)Math.Max(bmp.Width / 10.0, bmp.Height / 10.0);
            converter.UserOffset.X  = Settings.GetObject("GrayScaleConversion.Gcode.Offset.X", 0F);
            converter.UserOffset.Y  = Settings.GetObject("GrayScaleConversion.Gcode.Offset.Y", 0F);

            string gcode = converter.convertFromText(content);

            string[] lines = gcode.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string l in lines)
            {
                string line = l;
                if ((line = line.Trim()).Length > 0)
                {
                    GrblCommand cmd = new GrblCommand(line);
                    if (!cmd.IsEmpty)
                    {
                        list.Add(cmd);
                    }
                }
            }

            Analyze();
            long elapsed = (long)(DateTime.Now - start).TotalMilliseconds;

            RiseOnFileLoaded(filename, elapsed);
        }
예제 #2
0
        public void LoadImportedGcode(string filename, bool append)
        {
            RiseOnFileLoading(filename);

            long start = Tools.HiResTimer.TotalMilliseconds;

            if (!append)
            {
                list.Clear();
            }

            mRange.ResetRange();

            SvgConverter.GCodeFromSVG converter = new SvgConverter.GCodeFromSVG();
            converter.GCodeXYFeed = (float)(int)Settings.GetObject("GrayScaleConversion.VectorizeOptions.BorderSpeed", 1000);

            string gcode = converter.convertFromFile(filename);

            string[] lines = gcode.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string l in lines)
            {
                string line = l;
                if ((line = line.Trim()).Length > 0)
                {
                    GrblCommand cmd = new GrblCommand(line);
                    if (!cmd.IsEmpty)
                    {
                        list.Add(cmd);
                    }
                }
            }

            Analyze();
            long elapsed = Tools.HiResTimer.TotalMilliseconds - start;

            RiseOnFileLoaded(filename, elapsed);
        }