コード例 #1
0
        private static bool ValidatePolygon(Vertices polygon)
        {
            PolygonError polygonError = polygon.CheckPolygon();
            bool         flag         = polygonError == PolygonError.InvalidAmountOfVertices || polygonError == PolygonError.AreaTooSmall || polygonError == PolygonError.SideTooSmall || polygonError == PolygonError.NotSimple;
            bool         result;

            if (flag)
            {
                result = false;
            }
            else
            {
                bool flag2 = polygonError == PolygonError.NotCounterClockWise;
                if (flag2)
                {
                    polygon.Reverse();
                }
                bool flag3 = polygonError == PolygonError.NotConvex;
                if (flag3)
                {
                    polygon = GiftWrap.GetConvexHull(polygon);
                    result  = Triangulate.ValidatePolygon(polygon);
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
コード例 #2
0
        private static bool ValidatePolygon(Vertices polygon)
        {
            PolygonError errorCode = polygon.CheckPolygon();

            if (errorCode == PolygonError.InvalidAmountOfVertices || errorCode == PolygonError.AreaTooSmall || errorCode == PolygonError.SideTooSmall || errorCode == PolygonError.NotSimple)
            {
                return(false);
            }

            if (errorCode == PolygonError.NotCounterClockWise) //NotCounterCloseWise is the last check in CheckPolygon(), thus we don't need to call ValidatePolygon again.
            {
                polygon.Reverse();
            }

            if (errorCode == PolygonError.NotConvex)
            {
                polygon = GiftWrap.GetConvexHull(polygon);
                return(ValidatePolygon(polygon));
            }

            return(true);
        }