// Evaluate the partition cost by considering the areas covered // by the new sub-regions. internal virtual float evaluate(char axis, node new_node1, node new_node2, float curr_cut, RECT pmbr) { int si, ci; float[] min = new float[2]; float[] max = new float[2]; float area; CELL curr_cell; RECT r1, r2; // Set the sweeping index. if (axis == 'x') { si = 0; ci = 1; } else { si = 1; ci = 0; } if (new_node1.getlength() != 0) { // Find the coordinates of the mbr of the first sub-region. curr_cell = new_node1.head; // Initialize the coordinates. min[si] = curr_cell.current.mbr.low[si]; min[ci] = curr_cell.current.mbr.low[ci]; if (curr_cell.current.mbr.high[si] < curr_cut) { max[si] = curr_cell.current.mbr.high[si]; } else { max[si] = curr_cut; } max[ci] = curr_cell.current.mbr.high[ci]; curr_cell = curr_cell.next; // Update the coordinates of the mbr by considering the // cells one by one. while (curr_cell != null) { if (curr_cell.current.mbr.low[si] < min[si]) { min[si] = curr_cell.current.mbr.low[si]; } if (curr_cell.current.mbr.low[ci] < min[ci]) { min[ci] = curr_cell.current.mbr.low[ci]; } if (curr_cell.current.mbr.high[si] >= curr_cut) { max[si] = curr_cut; } else if (curr_cell.current.mbr.high[si] > max[si]) { max[si] = curr_cell.current.mbr.high[si]; } if (curr_cell.current.mbr.high[ci] > max[ci]) { max[ci] = curr_cell.current.mbr.high[ci]; } curr_cell = curr_cell.next; } } else { min[si] = 0; min[ci] = 0; max[si] = 0; max[si] = 0; } // Calculate the area covered by the first sub-region. r1 = new RECT(min[0], min[1], max[0], max[1]); r2 = r1.intersect(pmbr); area = r2.area(); if (new_node2.getlength() != 0) { // Find the coordinates of the mbr of the second sub-region. curr_cell = new_node2.head; // Initialize the coordinates. if (curr_cell.current.mbr.low[si] > curr_cut) { min[si] = curr_cell.current.mbr.low[si]; } else { min[si] = curr_cut; } min[ci] = curr_cell.current.mbr.low[ci]; max[si] = curr_cell.current.mbr.high[si]; max[ci] = curr_cell.current.mbr.high[ci]; curr_cell = curr_cell.next; // Update the coordinates of the mbr by considering the // cells one by one. while (curr_cell != null) { if (curr_cell.current.mbr.low[si] <= curr_cut) { min[si] = curr_cut; } else if (curr_cell.current.mbr.low[si] < min[si]) { min[si] = curr_cell.current.mbr.low[si]; } if (curr_cell.current.mbr.low[ci] < min[ci]) { min[ci] = curr_cell.current.mbr.low[ci]; } if (curr_cell.current.mbr.high[si] > max[si]) { max[si] = curr_cell.current.mbr.high[si]; } if (curr_cell.current.mbr.high[ci] > max[ci]) { max[ci] = curr_cell.current.mbr.high[ci]; } curr_cell = curr_cell.next; } } else { min[si] = 0; min[ci] = 0; max[si] = 0; max[ci] = 0; } // Add the area covered by the second region to the // previous result. r1 = new RECT(min[0], min[1], max[0], max[1]); r2 = r1.intersect(pmbr); area += r2.area(); return (area); }