From b905f3630ddd95e8e09bfc79e441289fbef38726 Mon Sep 17 00:00:00 2001 From: jkmnt Date: Sun, 4 Dec 2016 18:04:36 +0300 Subject: [PATCH] * fixes for the broken mat joins in some cases --- Properties/AssemblyInfo.cs | 4 ++-- matmill.cs | 8 +++++--- segpool.cs | 23 ++++++++++++----------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 907a044..4bef56d 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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")] diff --git a/matmill.cs b/matmill.cs index 7984444..05d85ca 100644 --- a/matmill.cs +++ b/matmill.cs @@ -267,8 +267,7 @@ private List 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); } @@ -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())); diff --git a/segpool.cs b/segpool.cs index aa9ae32..a87cd08 100644 --- a/segpool.cs +++ b/segpool.cs @@ -94,19 +94,20 @@ public List 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); } }