Exemple #1
0
        private static bool RecordEars(EarPolygon poly)
        {
            LinkedListNode <EarPoint> active = poly.Get();

            while (poly.NumPoints() >= 3)
            {
                int idx = active.Value.mIndex;
                do
                {
                    if (IsConvex(active, poly))
                    {
                        if (IsEar(active, poly))
                        {
                            break;
                        }
                    }
                    active = poly.Next(active);
                } while (idx != active.Value.mIndex);

                poly.AddResult(poly.Previous(active).Value[0], poly.Previous(active).Value[1], active.Value[0], active.Value[1], poly.Next(active).Value[0], poly.Next(active).Value[1]);
                active = poly.Next(active);
                poly.Remove(poly.Previous(active));
                continue;
            }
            return(true);
        }
Exemple #2
0
        private static bool IsEar(LinkedListNode <EarPoint> ele, EarPolygon poly)
        {
            LinkedListNode <EarPoint> checkerN1 = poly.Next(ele);
            LinkedListNode <EarPoint> checker   = poly.Next(checkerN1);

            while (checker.Value.mIndex != poly.Previous(ele).Value.mIndex)
            {
                if (InTriangle(checker.Value, ele.Value, poly.Next(ele).Value, poly.Previous(ele).Value))
                {
                    return(false);
                }
                checker = poly.Next(checker);
            }
            return(true);
        }
Exemple #3
0
        private static bool IsConvex(LinkedListNode <EarPoint> ele, EarPolygon poly)
        {
            LinkedListNode <EarPoint> a = poly.Previous(ele);
            LinkedListNode <EarPoint> b = ele;
            LinkedListNode <EarPoint> c = poly.Next(ele);

            return(GeoPolygonUtils.IsConvex(a.Value.mPoint, b.Value.mPoint, c.Value.mPoint));
        }