Exemplo n.º 1
0
        internal static bool Execute(com.epl.geometry.EditShape shape, com.epl.geometry.Envelope2D extent, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            if (!CanBeCracked(shape))
            {
                // make sure it contains some segments,
                // otherwise no need to crack.
                return(false);
            }
            com.epl.geometry.Cracker cracker = new com.epl.geometry.Cracker(progress_tracker);
            cracker.m_shape     = shape;
            cracker.m_tolerance = tolerance;
            // Use brute force for smaller shapes, and a planesweep for bigger
            // shapes.
            bool b_cracked = false;

            if (shape.GetTotalPointCount() < 15)
            {
                // what is a good number?
                b_cracked = cracker.CrackBruteForce_();
            }
            else
            {
                bool b_cracked_1 = cracker.CrackerPlaneSweep_();
                return(b_cracked_1);
            }
            return(b_cracked);
        }
Exemplo n.º 2
0
        // Used for IsSimple.
        internal static bool NeedsCracking(bool allowCoincident, com.epl.geometry.EditShape shape, double tolerance, com.epl.geometry.NonSimpleResult result, com.epl.geometry.ProgressTracker progress_tracker)
        {
            if (!CanBeCracked(shape))
            {
                return(false);
            }
            com.epl.geometry.Cracker cracker = new com.epl.geometry.Cracker(progress_tracker);
            cracker.m_shape            = shape;
            cracker.m_tolerance        = tolerance;
            cracker.m_bAllowCoincident = allowCoincident;
            if (cracker.NeedsCrackingImpl_())
            {
                if (result != null)
                {
                    result.Assign(cracker.m_non_simple_result);
                }
                return(true);
            }
            // Now swap the coordinates to catch horizontal cases.
            com.epl.geometry.Transformation2D transform = new com.epl.geometry.Transformation2D();
            transform.SetSwapCoordinates();
            shape.ApplyTransformation(transform);
            cracker                    = new com.epl.geometry.Cracker(progress_tracker);
            cracker.m_shape            = shape;
            cracker.m_tolerance        = tolerance;
            cracker.m_bAllowCoincident = allowCoincident;
            bool b_res = cracker.NeedsCrackingImpl_();

            transform.SetSwapCoordinates();
            shape.ApplyTransformation(transform);
            // restore shape
            if (b_res)
            {
                if (result != null)
                {
                    result.Assign(cracker.m_non_simple_result);
                }
                return(true);
            }
            return(false);
        }