private Polyline gen_leadin(Toolpath path) { Sliced_path_item spiral = path.Trajectory[0]; if (spiral.Item_type != Sliced_path_item_type.SPIRAL) { throw new Exception("no spiral in sliced path"); } Vector2F start_normal = Vector2F.Undefined; if (path.Trajectory.Extension != null && path.Trajectory.Extension is Traj_metainfo) { Traj_metainfo meta = (Traj_metainfo)path.Trajectory.Extension; start_normal = meta.Start_normal; } LeadMoveInfo move = _leadin.Cached; Polyline p = move.GetLeadInToolPath(spiral, spiral.Direction, start_normal, base.PlungeFeedrate.Cached, base.CutFeedrate.Cached, base.StockSurface.Cached, _depth_increment.Cached, path.Bottom, move.ValidSpiralAngle, path.Top - path.Bottom); return(p); }
private List <Sliced_path> gen_profile(Polyline poly, bool is_inside, Point2F startpoint) { if (!startpoint.IsUndefined) { poly = new Polyline(poly); if (poly.Closed) { poly = adjust_closed_startpoint(poly, startpoint); } else { if (should_flip_opened_startpoint(poly, startpoint)) { poly.Reverse(); is_inside = !is_inside; // preserve side if flipped ! } } } List <Sliced_path> trajectories = new List <Sliced_path>(); double cut_width = _cut_width.Cached; if (cut_width == 0) { cut_width = base.ToolDiameter.Cached * 2; } double offset = cut_width / 2 + base.RoughingClearance.Cached; if (is_inside) { offset = -offset; } Polyline[] array; // special case - simulation of engrave. do not offset poly at all to allow exact follow of path if (Math.Abs(offset) < (double)CamBamConfig.Defaults.GeneralTolerance) { array = new Polyline[] { poly }; } else { array = poly.CreateOffsetPolyline(offset, (double)CamBamConfig.Defaults.GeneralTolerance, _should_overcut_corners.Cached, false); } if (array == null) { return(trajectories); } foreach (Polyline p in array) { if (trajectories.Count != 0) { startpoint = lastpt(trajectories); } Sliced_path toolpath = gen_toolpath(p, cut_width); if (toolpath != null) { Traj_metainfo meta = new Traj_metainfo(); meta.Start_normal = new Vector2F((Point2F)toolpath[0].FirstPoint, (Point2F)poly.FirstPoint); toolpath.Extension = meta; trajectories.Add(toolpath); } } return(trajectories); }
private List <Sliced_path> gen_fine_profile(Polyline poly, bool is_inside, Point2F startpoint) { if (!startpoint.IsUndefined) { poly = adjust_closed_startpoint(poly, startpoint); } double cut_width = _cut_width.Cached; if (cut_width == 0) { cut_width = base.ToolDiameter.Cached * 2; } double clearance_offset = base.RoughingClearance.Cached; double offset = cut_width + clearance_offset; if (is_inside) { offset = -offset; clearance_offset = -clearance_offset; } Polyline[] profile_walls; if (clearance_offset != 0) { profile_walls = poly.CreateOffsetPolyline(clearance_offset, (double)CamBamConfig.Defaults.GeneralTolerance, false, false); } else { profile_walls = new Polyline[] { poly } }; Polyline[] pseudo_walls = poly.CreateOffsetPolyline(offset, (double)CamBamConfig.Defaults.GeneralTolerance, false, false); ShapeList shapes = new ShapeList(); shapes.ApplyTransformations = true; shapes.AddEntities(profile_walls); shapes.AddEntities(pseudo_walls); shapes = shapes.DetectRegions(); List <Sliced_path> trajectories = new List <Sliced_path>(); Vector2F start_tangent = calc_start_tangent(poly); foreach (ShapeListItem shape in shapes) { if (shape.Shape is Polyline && !((Polyline)shape.Shape).Closed) { Logger.warn("got open polyline while offsetting profile. ignoring"); continue; } if (trajectories.Count != 0) { startpoint = lastpt(trajectories); } Sliced_path toolpath = gen_pocket_toolpath(shape, startpoint, start_tangent); if (toolpath != null) { Traj_metainfo meta = new Traj_metainfo(); meta.Start_normal = new Vector2F((Point2F)toolpath[0].FirstPoint, (Point2F)poly.FirstPoint); toolpath.Extension = meta; trajectories.Add(toolpath); } } return(trajectories); }