FilterIntermediatePoints
(
IEdge oEdge,
VertexDrawingHistory oVertex1DrawingHistory,
VertexDrawingHistory oVertex2DrawingHistory
)
{
Debug.Assert(oEdge != null);
Debug.Assert(oVertex1DrawingHistory != null);
Debug.Assert(oVertex2DrawingHistory != null);
AssertValid();
List<Point> oFilteredIntermediatePoints = new List<Point>();
System.Drawing.PointF [] aoIntermediateCurvePoints;
DrawingVisual oVertex1DrawingVisual =
oVertex1DrawingHistory.DrawingVisual;
DrawingVisual oVertex2DrawingVisual =
oVertex2DrawingHistory.DrawingVisual;
if ( EdgeUtil.TryGetIntermediateCurvePoints(oEdge,
out aoIntermediateCurvePoints) )
{
foreach (System.Drawing.PointF oIntermediateCurvePoint in
aoIntermediateCurvePoints)
{
Point oIntermediateCurveWpfPoint =
WpfGraphicsUtil.PointFToWpfPoint(oIntermediateCurvePoint);
// Check whether the point falls within the bounds of either
// vertex.
//
// This could be done more quickly but with more code by
// selectively hit-testing only vertex 1 or vertex 2 as we move
// along the curve. However, the hit-testing is so fast that
// it's probably not worth the extra complexity. On one test
// machine, for example, 200,000 hit tests took about 24 ms,
// and that didn't vary much with vertex shape or size.
if (
oVertex1DrawingVisual.HitTest(
oIntermediateCurveWpfPoint) == null
&&
oVertex2DrawingVisual.HitTest(
oIntermediateCurveWpfPoint) == null
)
{
oFilteredIntermediatePoints.Add(
oIntermediateCurveWpfPoint);
}
}
}
return (oFilteredIntermediatePoints);
}