# Blank areas with fill and patch in 2014b

조회 수: 16 (최근 30일)
dami . 2014년 11월 5일
댓글: Lisa Oberbroeckling . 2016년 4월 14일
After updating to version 2014b, my code containing fill or patch functions does not work properly. Try this example:
poly=[
6.00 0.00
6.00 4.00
7.00 5.00
8.00 5.00
8.00 0.50
9.00 0.50
9.00 5.00
7.00 5.00
8.00 6.00
9.50 5.00
9.50 0.50
10.0 0.50
10.0 0.00
9.50 0.00
6.00 0.00];
fill(poly(:,1),poly(:,2),'r')
The internal area is not filled properly, and the problem seems related to polygons with holes. In Matlab 2014a everything was ok.
##### 댓글 수: 1표시 없음숨기기 없음
Lisa Oberbroeckling 2016년 4월 14일
I've asked students to program their own Riemann Sum demo for years. Previous to R2014b, the following example code would work fine. Since then, it has the blank areas as discussed above. Taking out redundant vertices or adding vertices to "close the rectangles" does not help. Now the students have to use the fill command on each individual rectangle within their loops, as suggested by Image Analyst. This is unfortunate since we've been discussing "vectorization of code" in previous assignments. Any thoughts on when or if this may be fixed?
x=[0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4];
y=[0 1 1 0 0 2 2 0 0 3 3 0 0 4 4 0];
fill(x,y,'b')
Created using R2014a:
Created using R2015a:

댓글을 달려면 로그인하십시오.

### 답변 (4개)

Doug Hull 2014년 11월 6일
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.
##### 댓글 수: 0표시 이전 댓글 수: -1숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

dami 2014년 11월 8일
편집: dami 님. 2014년 11월 8일
The problem is that even if there is no intersection with the edges, as in my example, the area is not filled properly: the white triangle is not bordered by any edge, and it should be filled according to Jordan curve theorem.
It seems a technical issue, because moving slightly some points this blank area disappears.
##### 댓글 수: 0표시 이전 댓글 수: -1숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Image Analyst 2014년 11월 8일
I suggest that whenever you have polygons where the edge intersects or crosses another edge, you plot it as two or more separate regions.
##### 댓글 수: 0표시 이전 댓글 수: -1숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Amro 2014년 12월 4일
편집: Amro 님. 2014년 12월 4일
The problem happens after the patch face is internally triangulated , when deciding which triangles are filled vs. holes. Try the following:
dt = delaunayTriangulation(poly);
triplot(dt)
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.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by