pixelsandcandy / poly2tri

Automatically exported from code.google.com/p/poly2tri
Other
0 stars 0 forks source link

Null ref exception on simple test input #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Triangulate test point set:

0, 0
0, -1
-1, -1
-0.5, -1.2

What is the expected output? What do you see instead?

Get null ref exception in DTSweep Class FinalizationConvexHull method

What version of the product are you using? On what operating system?

C# 2010 feb version with fix for issue #7

Win 7

Please provide any additional information below.

Works very well on large random sets so this is just a 
"boundary condition" kind of issue

Original issue reported on code.google.com by de...@primethought.biz on 21 Aug 2010 at 12:54

GoogleCodeExporter commented 9 years ago
Thats what I get for quick fixing.
Sorry for the inconvenience.

Do this change to method:
private static void FinalizationConvexHull( DTSweepContext tcx )

Change line:
        TurnAdvancingFrontConvex( tcx, n2, n3 );
To:
        TurnAdvancingFrontConvex( tcx, n1, n2 );

Change previous patch to:
        n1 = tcx.Front.Tail.Prev;
        if( n1.Triangle.Contains( n1.Next.Point ) && n1.Triangle.Contains( n1.Prev.Point ) )
        {
            t1 = n1.Triangle.neighborAcross( n1.Point );
            RotateTrianglePair( n1.Triangle, n1.Point, t1, t1.OppositePoint( n1.Triangle, n1.Point ) );
            tcx.MapTriangleToNodes( n1.Triangle );
            tcx.MapTriangleToNodes( t1 );
        }                
        n1 = tcx.Front.Head.Next;
        if( n1.Triangle.Contains( n1.Prev.Point ) && n1.Triangle.Contains( n1.Next.Point ) )
        {
            t1 = n1.Triangle.NeighborAcross( n1.Point );
            RotateTrianglePair( n1.Triangle, n1.Point, t1, t1.OppositePoint( n1.Triangle, n1.Point ) );
            tcx.MapTriangleToNodes( n1.Triangle );
            tcx.MapTriangleToNodes( t1 );
        }

Original comment by thahlen@gmail.com on 21 Aug 2010 at 2:25