public static int decompose_overlapping(RECT A, RECT B, RECT [] ra) { int overlaps = 0; RECT C; RECT i; if (A.overlaps_interior(B)) { if (B.y0 < A.y0) { //0 C = new RECT(B.x0, B.y0, B.w, A.y0 - B.y0); i = C.intersection(B); if (!is_sliver(i)) { ra[overlaps] = i; RECTTOOLS.CHECK_NO_INTERIOR_OVERLAP(C, A); overlaps++; } } if (B.x1 > A.x1) { //1 C = RECT.FromPoints(A.x1, A.y0, B.x1, A.y1); i = C.intersection(B); if (!is_sliver(i)) { RECTTOOLS.CHECK_NO_INTERIOR_OVERLAP(C, A); ra[overlaps] = i; overlaps++; } } if (B.x0 < A.x0) { //2 C = RECT.FromPoints(B.x0, A.y0, A.x0, A.y1); i = C.intersection(B); if (!is_sliver(i)) { RECTTOOLS.CHECK_NO_INTERIOR_OVERLAP(C, A); ra[overlaps] = i; overlaps++; } } if (B.y1 > A.y1) { //3 C = new RECT(B.x0, A.y1, B.w, B.y1 - A.y1); i = C.intersection(B); if (!is_sliver(i)) { ra[overlaps] = i; overlaps++; } } } return(overlaps); }
public static RECT get_bounding_box(RECT r0, RECT r1) { double x0 = System.Math.Min(r0.x0, r1.x0); double y0 = System.Math.Min(r0.y0, r1.y0); double x1 = System.Math.Max(r0.x1, r1.x1); double y1 = System.Math.Max(r0.y1, r1.y1); RECT bb = RECT.FromPoints(x0, y0, x1, y1); return(bb); }