Skip to content

Commit

Permalink
+ correct rendering of visual rapids under transforms
Browse files Browse the repository at this point in the history
+ correct toolpath analysis
* g-code generation check (seems to be ok)
  • Loading branch information
jkmnt committed Aug 16, 2018
1 parent ee7090f commit d71258e
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions mop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ private List<Polyline> calc_visual_rapids(List<Toolpath> toolpaths)
List<Polyline> rapids = new List<Polyline>();

double thres = base.GetDistanceThreshold();
Matrix4x4F mx = Transform.Cached != null ? Transform.Cached : Matrix4x4F.Identity;

Point3F lastpt = Point3F.Undefined;

Expand All @@ -341,6 +342,8 @@ private List<Polyline> calc_visual_rapids(List<Toolpath> toolpaths)
else
to = (Point3F)path.Trajectory[0].FirstPoint;

to = new Point3F(to.X, to.Y, to.Z + path.Bottom) * mx;

double dist = Point2F.Distance((Point2F)lastpt, (Point2F)to);

if (dist > thres + (double)CamBamConfig.Defaults.GeneralTolerance)
Expand All @@ -350,13 +353,13 @@ private List<Polyline> calc_visual_rapids(List<Toolpath> toolpaths)
p.Add(lastpt);
p.Add(new Point3F(lastpt.X, lastpt.Y, ClearancePlane.Cached));
p.Add(new Point3F(to.X, to.Y, ClearancePlane.Cached));
p.Add(new Point3F(to.X, to.Y, path.Bottom + to.Z));
p.Add(to);
rapids.Add(p);
}
}

lastpt = path.Trajectory[path.Trajectory.Count - 1].LastPoint;
lastpt = new Point3F(lastpt.X, lastpt.Y, path.Bottom);
lastpt = new Point3F(lastpt.X, lastpt.Y, path.Bottom) * mx;
}

return rapids;
Expand All @@ -370,15 +373,35 @@ private void print_toolpath_stats(List<Toolpath> toolpaths, List<Polyline> rapid
double moves_len = 0;
double rapids_len = 0;

Matrix4x4F mx = Transform.Cached != null ? Transform.Cached : Matrix4x4F.Identity;

// collect cut lengths
foreach (Toolpath path in toolpaths)
{
if (path.Leadin != null)
leadins_len += path.Leadin.GetPerimeter();
{
Polyline p = (Polyline)path.Leadin;
if (Transform.Cached != null)
{
p = (Polyline)p.Clone();
p.ApplyTransformation(Transform.Cached);
}

leadins_len += p.GetPerimeter();
}

foreach (Sliced_path_item item in path.Trajectory)
{
double len = item.GetPerimeter();
Polyline p = (Polyline)item;

if (Transform.Cached != null)
{
p = (Polyline)p.Clone();
p.ApplyTransformation(Transform.Cached);
}


double len = p.GetPerimeter();

switch (item.Item_type)
{
Expand Down Expand Up @@ -459,9 +482,7 @@ internal void insert_toolpaths(List<Sliced_path> trajectories)
_toolpaths = gen_ordered_toolpath(_trajectories, bottoms);
_visual_cut_widths = calc_visual_cut_widths(_toolpaths, bottoms[0], bottoms[bottoms.Length - 1]);
_visual_rapids = calc_visual_rapids(_toolpaths);

// XXX: transforms are not accounted for in stats calc or may print wrong results
print_toolpath_stats(_toolpaths, _visual_rapids);
print_toolpath_stats(_toolpaths, _visual_rapids);
}

private void emit_toolpath(MachineOpToGCode gcg, Toolpath path)
Expand Down

0 comments on commit d71258e

Please sign in to comment.