Blank areas with fill and patch in 2014b
8 views (last 30 days)
After updating to version 2014b, my code containing fill or patch functions does not work properly. Try this example:
The internal area is not filled properly, and the problem seems related to polygons with holes. In Matlab 2014a everything was ok.
Doug Hull on 6 Nov 2014
Thank you for this simple reproduction case. Our developers in this area have noted this:
Our current rule for in-out test is a purely topological test based on Jordan-curve. Crossing of a single edge represents a flip in parity. Crossing of a double overlapping edge is ignored and does not change parity – such an edge is typically a bridge-edge that connects outer and inner loops – inner ones being holes.
If you have more about your intent, please contact me at email@example.com so I can note it in our internal database.
Image Analyst on 8 Nov 2014
I suggest that whenever you have polygons where the edge intersects or crosses another edge, you plot it as two or more separate regions.
Amro on 4 Dec 2014
Edited: Amro on 4 Dec 2014
The problem happens after the patch face is internally triangulated , when deciding which triangles are filled vs. holes. Try the following:
dt = delaunayTriangulation(poly);
text(poly(:,1), poly(:,2), cellstr(num2str((1:size(poly,1))')), ...
'Color','m', 'HorizontalAlign','left', 'VerticalAlign','bottom')
You can see that the triangle (2,3,4) corresponds to the one not filled in your example...
A simple workaround is to nudge the coordinates of the shared vertex 8, e.g:
poly(8,2) = poly(8,2) + 1e-6;
The offset is too small for you notice, but it should fix the bug for now.