예제 #1
0
        private static void minimax_test( IPoly subj, IPoly clip, OperationType op )
        {
            RectangleF[] s_bbox = create_contour_bboxes(subj);
            RectangleF[] c_bbox = create_contour_bboxes(clip);

            int subj_num_poly = subj.InnerPolygonCount;
            int clip_num_poly = clip.InnerPolygonCount;
            bool[,] o_table = new bool[subj_num_poly,clip_num_poly] ;

            /* Check all subject contour bounding boxes against clip boxes */
            for( int s = 0; s < subj_num_poly; s++ )
            {
                for( int c= 0; c < clip_num_poly ; c++ )
                {
                    o_table[s, c] =
                        (!((s_bbox[s].Right < c_bbox[c].Left) ||
                            (s_bbox[s].Left > c_bbox[c].Right))) &&
                        (!((s_bbox[s].Bottom < c_bbox[c].Top) ||
                            (s_bbox[s].Top > c_bbox[c].Bottom)));
                }
            }

            /* For each clip contour, search for any subject contour overlaps */
            for( int c = 0; c < clip_num_poly; c++ )
            {
                bool overlap = false;
                for( int s = 0; !overlap && (s < subj_num_poly) ; s++)
                {
                    overlap = o_table[s, c];
                }
                if (!overlap)
                {
                    clip.SetContributing( c, false ); // Flag non contributing status
                }
            }

            if (op == OperationType.GPC_INT)
            {
                /* For each subject contour, search for any clip contour overlaps */
                for ( int s= 0; s < subj_num_poly; s++)
                {
                    bool overlap = false;
                    for ( int c= 0; !overlap && (c < clip_num_poly); c++)
                    {
                        overlap = o_table[s, c];
                    }
                    if (!overlap)
                    {
                        subj.SetContributing( s, false ); // Flag non contributing status
                    }
                }
            }
        }