using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RichCreator.Utility.Structs
{
///
/// 路径信息
///
public class FindPathInfo
{
public FindPathInfo()
{
Vertexs = new List();
Edges = new List();
Positions = new List();
}
public FindPathInfo(Int32 width,Int32 height,Int32 rowcount,Int32 colcount):this()
{
this.Width = width;
this.Height = height;
this.RowCount = rowcount;
this.ColCount = colcount;
}
///
/// 宽
///
public int Width { get; set; }
///
/// 高
///
public int Height { get; set; }
///
/// 行数量
///
public int RowCount { get; set; }
///
/// 列数量
///
public int ColCount { get; set; }
///
/// 顶点列表,顶点x_index,y_index
///
public List Vertexs { get; set; }
///
/// 顶点连接信息,线信息ZTPoint是index ->index
///
public List Edges { get; set; }
///
/// 定位信息
///
public List Positions { get; set; }
///
/// 添加靠近点
///
///
public void AddVertex(Int32 index,Int32 vertexType,Int32 nearVetexIndex)
{
VertexInfo vertex = new VertexInfo() { Index = index, VertexType = vertexType, NearVertexIndex = nearVetexIndex };
AddVertex(vertex);
}
///
/// 添加靠近点
///
///
public void AddVertex(VertexInfo vertex)
{
for (int i = 0; i < Vertexs.Count; i++)
{
if (Vertexs[i].Index ==vertex.Index)
{
this.Vertexs[i] = vertex;
return;
}
}
this.Vertexs.Add(vertex);
}
///
/// 是否存在顶点
///
///
///
public bool VertexCanAddEdge(Int32 index)
{
for (int i = 0; i < this.Vertexs.Count; i++)
{
if (this.Vertexs[i].Index==index)
{
if (this.Vertexs[i].VertexType != 1)
{
return true;
}
else
{
return false;
}
}
}
return false;
}
///
/// 得到顶点的行列
///
///
///
public void GetVertexRowColumn(out Int32 row,out Int32 col,int index)
{
row = index / this.ColCount;
col = index % this.ColCount;
}
///
/// 获取json
///
///
public string ToJsonString()
{
string json = ZTImage.Json.JsonBuilder.ToJsonString(this);
return json;
}
///
/// 从json字符串生成对象
///
///
///
public static FindPathInfo FromJsonString(string json)
{
return ZTImage.Json.JsonParser.ToObject(json);
}
///
/// 顶点信息
///
public class VertexInfo
{
///
/// 顶点索引
///
public Int32 Index { get; set; }
///
/// 顶点类型,0:普通顶点,1:依附顶点,2:起点,3:终点
///
public Int32 VertexType { get; set; }
///
/// 依附顶点所依附顶点的索引
///
public Int32 NearVertexIndex { get; set; }
}
///
/// 边信息
///
public class EdgeInfo
{
///
/// 起点索引
///
public Int32 StartIndex { get; set; }
///
/// 终点索引
///
public Int32 EndIndex { get; set; }
}
///
/// 可序列化点
///
public class PointSerialize
{
public PointSerialize()
{}
public PointSerialize(Int32 x, Int32 y,Int32 number)
{
this.X = x;
this.Y = y;
this.Parameter = number;
}
public int X { get; set; }
public int Y { get; set; }
///
/// 参数
///
public Int32 Parameter { get; set; }
}
}
}