Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: NullReferenceException in DTSweep finalization #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Triangulation/Delaunay/Sweep/DTSweep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ private static void FinalizationConvexHull( DTSweepContext tcx ) {
t1 = t1.NeighborCWFrom(tcx.Front.Head.Point);
do {
tcx.RemoveFromList(t1);
// NOTE: there was a NullReferenceException
// probably t1 was null
if (t1 == null)
{
break; // TODO: is this solution OK?
}
p1 = t1.PointCCWFrom(p1);
t1 = t1.NeighborCCWFrom(p1);
} while (p1 != first);
Expand Down Expand Up @@ -195,7 +201,21 @@ private static void FinalizationPolygon( DTSweepContext tcx ) {
// Get an Internal triangle to start with
DelaunayTriangle t = tcx.Front.Head.Next.Triangle;
TriangulationPoint p = tcx.Front.Head.Next.Point;
while (!t.GetConstrainedEdgeCW(p)) t = t.NeighborCCWFrom(p);
while (!t.GetConstrainedEdgeCW(p))
{
DelaunayTriangle nextTriangle = t.NeighborCCWFrom(p);
// NOTE: there was a NullReferenceException
// probably t was null
// TODO: is this solution ok?
if (nextTriangle != null)
{
t = nextTriangle;
}
else
{
break;
}
}

// Collect interior triangles constrained by edges
tcx.MeshClean(t);
Expand Down