Skip to content

Commit

Permalink
* fixes for the broken mat joins in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmnt committed Dec 4, 2016
1 parent 63879a7 commit b905f36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]
8 changes: 5 additions & 3 deletions matmill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ private List<Line2F> get_mat_segments()
foreach (GraphEdge e in edges)
{
Line2F seg = new Line2F(e.x1, e.y1, e.x2, e.y2);

if (seg.Length() < _general_tolerance) continue; // extra small segment, discard
if (seg.Length() < double.Epsilon) continue; // extra small segment, discard
if (! is_line_inside_region(seg, ANALIZE_INNER_INTERSECTIONS)) continue;
inner_segments.Add(seg);
}
Expand Down Expand Up @@ -578,7 +577,10 @@ private void attach_segments(Branch me, Segpool pool)
b.Curve.Add(pt);
attach_segments(b, pool);

me.Children.Add(b);
if (b.Deep_distance() > _general_tolerance) // attach only 'long enough'
me.Children.Add(b);
else
Host.log("skipping short branch");
}
// prefer a shortest branch
me.Children.Sort((a, b) => a.Deep_distance().CompareTo(b.Deep_distance()));
Expand Down
23 changes: 12 additions & 11 deletions segpool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,20 @@ public List<Point2F> Pull_follow_points(Point2F join_pt)

foreach (Line2F seg in _pool[h[i]])
{
if (processed.Contains(seg))
continue; // already got it
if (processed.Contains(seg))
continue; // already got it

if (join_pt.DistanceTo(seg.p1) < _tolerance)
{
double d1 = join_pt.DistanceTo(seg.p1);
double d2 = join_pt.DistanceTo(seg.p2);

if (d1 > _tolerance && d2 > _tolerance)
continue;

if (d1 < d2)
followers.Add(seg.p2);
processed.Add(seg);
}
else if (join_pt.DistanceTo(seg.p2) < _tolerance)
{
followers.Add(seg.p1);
processed.Add(seg);
}
else
followers.Add(seg.p1);
processed.Add(seg);
}
}

Expand Down

0 comments on commit b905f36

Please sign in to comment.