value = Convert.ToInt32(ztb.Text);
this.Hide();
this.Close();
4)添加一个公有字段value
1.3.增加一个排序类,根据Pixelposition_T类中的code(morton码)对其排序
算法参考代码
/*总体框架*/
Graphics gra = panel1.CreateGraphics();
ZForm zform=new ZForm();//新窗体对话框
zform.ShowDialog();
int order = (int)Math.Pow(2,zform.value);//获得阶数
Rectangle rect = new Rectangle(0, 0, panel1.Width, panel1.Height);//获得要填充的窗体/面板
List<Point_T> zpts = ZFill(rect,order);//调用z曲线排序
for (int i = 0; i < zpts.Count - 1; i++)//绘制z填充曲线
{
gra.DrawLine(Pens.Red,new Point((int)zpts[i].X,(int)zpts[i].Y),new Point((int)zpts[i+1].X,(int)zpts[i+1].Y));
}
/*Z曲线算法*/
public List<Point_T> ZFill(Rectangle rect, int order)//z曲线排序
{
List<Point_T> pts = new List<Point_T>();
List<PixelPosition_T> zpps = new List<PixelPosition_T>();
for (int i = 0; i < order; i++)
{
for (int j = 0; j < order; j++)
{
int[] biri = DecToBir(i);//十进制转二进制
int[] birj = DecToBir(j);//十进制转二进制
int[] birmor = MortonCode(birj, biri);//morton码
int decmor = BirToDec(birmor);//二进制转十进制
PixelPosition_T pp = new PixelPosition_T(i, j, decmor);//构建包含morton码的网格
zpps.Add(pp);//添加存储