Answered by Mike Danes on msdn:
https://social.msdn.microsoft.com/Forums/en-US/cf584e19-af0d-42d4-8aa5-bc9a2d06be3a/why-clipped-geometry-is-not-equal-to-drawn-geometry[
^]
But it's not necessarily related to drawing, geometry operations like Exclude play a part in this. Try the following example:
void Light()
{
canvas.Children.Clear();
Geometry linesgeom = this.lines.RenderedGeometry;
for (double i = thickness; i > 0; )
{
var geom1 = linesgeom.GetWidenedPathGeometry(new Pen(Brushes.Transparent, i--));
var geom2 = linesgeom.GetWidenedPathGeometry(new Pen(Brushes.Transparent, i));
var combined = Geometry.Combine(geom1, geom2, GeometryCombineMode.Exclude, null);
combined = Geometry.Combine(combined, geom1, GeometryCombineMode.Exclude, null);
if (!combined.IsEmpty())
{
canvas.Children.Add(new Path {
Data = combined,
Stroke = Brushes.Blue,
Fill = Brushes.Red
});
}
}
}
In this example geom2 is exclude from geom1 and then geom1 is excluded from the result. Theoretically the final result should be empty and if you try this with a straight line you'll see that nothing is displayed. But as soon you try it with a more complex line blue lines start to show up. Those lines reflect the inexact result of geometric operations.
Think about it, any such operations will require computing line intersection points. The coordinates of the intersection point of 2 lines are rational numbers even if the points that determine those 2 lines have integer coordinates. For example, lines (0,0)-(3,1) and (1,0)-(1,1) intersect at (1,1/3). That 1/3 cannot be represented exactly using standard numeric types like int, float and double.
It's technically possible to use custom rational types to perform such computations but in the end you still have to convert to float (because that's what DirectX understands) and ultimately to integer (because screen pixels have integer coordinates). Somewhere along the way some inaccuracies will sneak in.