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; }
private Surface polyline_to_surface(Polyline p, double z) { if (base.Transform.Cached != null && !Transform.Cached.IsIdentity()) { p = (Polyline)p.Clone(); p.ApplyTransformation(Transform.Cached); } PolylineToMesh mesh = new PolylineToMesh(p); Surface surface = mesh.ToWideLine(base.ToolDiameter.Cached); surface.ApplyTransformation(Matrix4x4F.Translation(0.0, 0.0, z - 0.001)); return(surface); }