private bool ShouldErase(Shape s, List<PointT> mouseInput)
{
var mouseBBox = mouseInput.ToBoundingBox();
var line = s as LineOrArrow;
if (line != null)
{
// Count the number of crossings
int crossings = 0;
float lineLen = 0;
if (line.BBox.Overlaps(mouseBBox))
foreach (var seg in AsLineSegments(line.Points))
{
lineLen += seg.Length();
if (seg.ToBoundingBox().Overlaps(mouseBBox))
crossings += FindIntersectionsWith(seg, mouseInput, false).Count();
}
if (crossings * 40.0f > lineLen)
return true;
}
else
{
// Measure how much of the mouse input is inside the bbox
var bbox = s.BBox;
if (bbox != null)
{
var amtInside = mouseInput.AdjacentPairs()
.Select(seg => seg.A.To(seg.B).ClipTo(bbox))
.WhereNotNull()
.Sum(seg => seg.Length());
if (amtInside * EraseBoxThreshold > bbox.Area())
return true;
}
}
return false;
}