public static int LookupChildPartition(Point p, PartitionNode parent_node) { int offset = parent_node.getNodeSize() / 4; int x1 = parent_node.getCenter().X - offset; int x2 = parent_node.getCenter().X + offset; int y1 = parent_node.getCenter().Y - offset; int y2 = parent_node.getCenter().Y + offset; int childNum = -1; if (p.X < x1) { if (p.Y < y1) { childNum = 0; } else if (p.Y < y2) { childNum = 3; } else { childNum = 6; } } else if (p.X < x2) { if (p.Y < y1) { childNum = 1; } else if (p.Y < y2) { childNum = 4; } else { childNum = 7; } } else { if (p.Y < y1) { childNum = 2; } else if (p.Y < y2) { childNum = 5; } else { childNum = 8; } } return(childNum); }
public static Point GetChildCenter(PartitionNode parent, int child_num) { int children_size = parent.getNodeSize() / 2; int x1 = parent.getCenter().X - children_size; int x2 = x1 + children_size; int x3 = x2 + children_size; int y1 = parent.getCenter().Y - children_size; int y2 = y1 + children_size; int y3 = y2 + children_size; switch (child_num) { case 0: return(new Point(x1, y1)); case 1: return(new Point(x2, y1)); case 2: return(new Point(x3, y1)); case 3: return(new Point(x1, y2)); case 4: return(new Point(x2, y2)); case 5: return(new Point(x3, y2)); case 6: return(new Point(x1, y3)); case 7: return(new Point(x2, y3)); case 8: return(new Point(x3, y3)); default: return(new Point(0, 0)); } }
private void btnSetExtent_Click(object sender, EventArgs e) { if (rdbPartition.Checked) { type_partition = true; } else { type_partition = false; } int size = Convert.ToInt32(tbWidth.Text); int capacity = Convert.ToInt32(tbCapacity.Text); double pValue = Convert.ToDouble(tb_pValue.Text); bool overflow = chbOverFlow.Checked; canvas_size = size; CreationMode mode; if (cmbCreationMode.SelectedIndex == 0) { mode = CreationMode.LAZY; } else { mode = CreationMode.ALL_AT_ONCE; } root_node = new PartitionNode(0, size, new Point(size / 2, size / 2), capacity); cover_root = new CoverNode(size, new Point(size / 2, size / 2), capacity, null, pValue); if (type_partition) { rect_database_partition = new FieldTreeStructure <PartitionNode>(size, size, root_node, root_node.capacity, overflow, mode); } else { rect_database_cover = new FieldTreeStructure <CoverNode>(size, size, cover_root, cover_root.capacity, overflow, mode); } dbCanvas.SetupCanvas(size, size); UpdateCanvasBounds(); }