示例#1
0
        public ILayoutLine GetExtendedFretLine(Measure amount)
        {
            if ((Length + (amount * 2)).NormalizedValue > 0)
            {
                if (IsStraight)
                {
                    var layoutLine = new LayoutLine(Points.First(), Points.Last());
                    layoutLine.P2 += (layoutLine.Direction * amount);
                    layoutLine.P1 += (layoutLine.Direction * (amount * -1));
                    return(layoutLine);
                }
                else
                {
                    RebuildSpline();

                    var tmpLine = new LayoutPolyLine(Points);
                    var bounds  = GetFretBoundaries(false);
                    var offset1 = LayoutLine.Offset(bounds.Item1, amount * -1);
                    var offset2 = LayoutLine.Offset(bounds.Item2, amount);

                    tmpLine.TrimBetween(offset1, offset2, true);
                    if (Spline != null)
                    {
                        tmpLine.InterpolateSpline(0.5);
                    }

                    return(tmpLine);
                }
            }

            return(null);
        }
示例#2
0
        public bool Intersects(LayoutPolyLine line, out PointM intersection)
        {
            intersection = PointM.Empty;
            for (int i = 0; i < line.Points.Count - 1; i++)
            {
                var segLine = Line.FromPoints(line.Points[i].ToVector(), line.Points[i + 1].ToVector());
                if (Intersects(segLine, out Vector virtualInter, false))
                {
                    intersection = PointM.FromVector(virtualInter, UnitOfMeasure.Mm);
                    return(true);
                }
            }

            return(false);
        }