Skip to content

Commit

Permalink
Add debug display of zero area triangles in TessBed
Browse files Browse the repository at this point in the history
  • Loading branch information
speps committed Feb 4, 2016
1 parent b2e9f0c commit 7572f7b
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
7 changes: 7 additions & 0 deletions TessBed/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ protected override void OnPaint(PaintEventArgs pe)
using (var brushPoint = new SolidBrush(Color.FromArgb(255, 0, 0, 0)))
using (var penOutput = new Pen(Color.FromArgb(32, 0, 0, 0), 1.0f))
using (var penPolys = new Pen(Color.FromArgb(64, 0, 0, 0), 1.0f))
using (var penZeroArea = new Pen(Color.FromArgb(255, 255, 0, 0), 1.0f))
using (var brushPolys = new SolidBrush(Color.FromArgb(64, 255, 207, 130)))
{
penWinding.EndCap = LineCap.ArrowAnchor;
Expand Down Expand Up @@ -133,12 +134,18 @@ protected override void OnPaint(PaintEventArgs pe)
{
g.FillPolygon(brushPolys, pts);
}

float area = SignedArea(polygon);
for (int i = 0; i < pts.Length; i++)
{
var p0 = pts[i];
var p1 = pts[(i + 1) % polygon.Count];

g.DrawLine(ShowInput ? penOutput : penPolys, p0, p1);
if (Math.Abs(area) < float.Epsilon)
{
g.DrawLine(penZeroArea, p0, p1);
}
}
}
}
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions TessBed/Data/issue6-plus.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
2,0,4
2,0,2
4,0,2
4,0,0
2,0,0
2,0,-2
0,0,-2
0,0,0
-2,0,0
-2,0,2
0,0,2
0,0,4
6 changes: 4 additions & 2 deletions TessBed/TessBed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
<EmbeddedResource Include="Data\diamond.dat" />
<EmbeddedResource Include="Data\dude.dat" />
<EmbeddedResource Include="Data\funny.dat" />
<EmbeddedResource Include="Data\issue6.dat" />
<EmbeddedResource Include="Data\issue6-L.dat" />
<EmbeddedResource Include="Data\issue6-plus.dat" />
<EmbeddedResource Include="Data\nazca_heron.dat" />
<EmbeddedResource Include="Data\nazca_monkey.dat" />
<EmbeddedResource Include="Data\sketchup.dat" />
Expand Down Expand Up @@ -124,7 +125,8 @@
<EmbeddedResource Include="TestData\dude.testdat" />
<EmbeddedResource Include="TestData\force-winding.testdat" />
<EmbeddedResource Include="TestData\funny.testdat" />
<EmbeddedResource Include="TestData\issue6.testdat" />
<EmbeddedResource Include="TestData\issue6-L.testdat" />
<EmbeddedResource Include="TestData\issue6-plus.testdat" />
<EmbeddedResource Include="TestData\letterE.testdat" />
<EmbeddedResource Include="TestData\nazca_heron.testdat" />
<EmbeddedResource Include="TestData\nazca_monkey.testdat" />
Expand Down
File renamed without changes.
40 changes: 40 additions & 0 deletions TessBed/TestData/issue6-plus.testdat
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
EvenOdd 3
0 1 2
1 0 3
4 5 6
4 7 5
8 7 4
2 7 8
1 7 2
7 1 9
6 10 11
10 6 5

NonZero 3
0 1 2
1 0 3
4 5 6
4 7 5
8 7 4
2 7 8
1 7 2
7 1 9
6 10 11
10 6 5

Positive 3
0 1 2
1 0 3
4 5 6
4 7 5
8 7 4
2 7 8
1 7 2
7 1 9
6 10 11
10 6 5

Negative 3

AbsGeqTwo 3

0 comments on commit 7572f7b

Please sign in to comment.