예제 #1
0
파일: mop.cs 프로젝트: robgrz/matmill
        public override void PostProcess(MachineOpToGCode gcg)
        {
            gcg.DefaultStockHeight = base.StockSurface.Cached;

            if (_trajectories.Count == 0)
            {
                return;
            }

            CBValue <double> original_feedrate = base.CutFeedrate;

            // NOTE: toolpaths are emit in a hacky way to allow variable feedrate.
            // CutFeedrate base setting is patched before posting each toolpath item,
            // and should be restored in the end
            try
            {
                foreach (Toolpath path in _toolpaths)
                {
                    emit_toolpath(gcg, path);
                }
            }
            finally
            {
                base.CutFeedrate = original_feedrate;
            }
        }
예제 #2
0
파일: mop.cs 프로젝트: robgrz/matmill
        private void emit_toolpath(MachineOpToGCode gcg, Toolpath path)
        {
            // first item is the spiral by convention
            if (path.Trajectory[0].Item_type != Sliced_path_item_type.SPIRAL)
            {
                throw new Exception("no spiral in sliced path");
            }

            CBValue <double> normal_feedrate = base.CutFeedrate;
            CBValue <double> chord_feedrate  = _chord_feedrate != 0 ? new CBValue <double>(_chord_feedrate) : base.CutFeedrate;
            CBValue <double> spiral_feedrate = _spiral_feedrate != 0 ? new CBValue <double>(_spiral_feedrate) : base.CutFeedrate;
            CBValue <double> leadin_feedrate = _leadin.Cached != null && _leadin.Cached.LeadInFeedrate != 0 ? new CBValue <double>(_leadin.Cached.LeadInFeedrate) : base.CutFeedrate;

            if (path.Leadin != null)
            {
                base.CutFeedrate = leadin_feedrate;
                Polyline p = (Polyline)path.Leadin.Clone();
                p.ApplyTransformation(Matrix4x4F.Translation(0, 0, path.Bottom));
                gcg.AppendPolyLine(p, double.NaN);
            }

            foreach (Sliced_path_item item in path.Trajectory)
            {
                switch (item.Item_type)
                {
                case Sliced_path_item_type.SPIRAL:
                    base.CutFeedrate = spiral_feedrate;
                    break;

                case Sliced_path_item_type.SLICE:
                    base.CutFeedrate = normal_feedrate;
                    break;

                case Sliced_path_item_type.CHORD:
                case Sliced_path_item_type.SMOOTH_CHORD:
                case Sliced_path_item_type.SLICE_SHORTCUT:
                case Sliced_path_item_type.GUIDE:
                    base.CutFeedrate = chord_feedrate;
                    break;

                default:
                    throw new Exception("unknown item type in sliced trajectory");
                }

                Polyline p = (Polyline)item.Clone();
                p.ApplyTransformation(Matrix4x4F.Translation(0, 0, path.Bottom));
                gcg.AppendPolyLine(p, double.NaN);
            }

            base.CutFeedrate = normal_feedrate;
        }