private void BTN_StateCheck_Click(object sender, RoutedEventArgs e) { BallConcave cc = new BallConcave(this.pointList); ShowMessage(GetRNeighboursMessage(cc)); this.slider.Value = cc.GetRecomandedR() + 1; }
private void SetEdge(Triangle t, int i) { if (t.P0Index < t.P1Index) { Edges[t.P0Index, t.P1Index].P0Index = t.P0Index; Edges[t.P0Index, t.P1Index].P1Index = t.P1Index; Edges[t.P0Index, t.P1Index].AdjTriangle.Add(i); Edges[t.P0Index, t.P1Index].Length = BallConcave.GetDistance(Points[t.P0Index], Points[t.P1Index]); } else { Edges[t.P1Index, t.P0Index].P0Index = t.P1Index; Edges[t.P1Index, t.P0Index].P1Index = t.P0Index; Edges[t.P1Index, t.P0Index].AdjTriangle.Add(i); Edges[t.P1Index, t.P0Index].Length = BallConcave.GetDistance(Points[t.P0Index], Points[t.P1Index]); } if (t.P1Index < t.P2Index) { Edges[t.P1Index, t.P2Index].P0Index = t.P1Index; Edges[t.P1Index, t.P2Index].P1Index = t.P2Index; Edges[t.P1Index, t.P2Index].AdjTriangle.Add(i); Edges[t.P1Index, t.P2Index].Length = BallConcave.GetDistance(Points[t.P1Index], Points[t.P2Index]); } else { Edges[t.P2Index, t.P1Index].P0Index = t.P2Index; Edges[t.P2Index, t.P1Index].P1Index = t.P1Index; Edges[t.P2Index, t.P1Index].AdjTriangle.Add(i); Edges[t.P2Index, t.P1Index].Length = BallConcave.GetDistance(Points[t.P1Index], Points[t.P2Index]); } if (t.P0Index < t.P2Index) { Edges[t.P0Index, t.P2Index].P0Index = t.P0Index; Edges[t.P0Index, t.P2Index].P1Index = t.P2Index; Edges[t.P0Index, t.P2Index].AdjTriangle.Add(i); Edges[t.P0Index, t.P2Index].Length = BallConcave.GetDistance(Points[t.P0Index], Points[t.P2Index]); } else { Edges[t.P2Index, t.P0Index].P0Index = t.P2Index; Edges[t.P2Index, t.P0Index].P1Index = t.P0Index; Edges[t.P2Index, t.P0Index].AdjTriangle.Add(i); Edges[t.P2Index, t.P0Index].Length = BallConcave.GetDistance(Points[t.P0Index], Points[t.P2Index]); } }
private void BTN_Cal_Click(object sender, RoutedEventArgs e) { if (CB_List.SelectedIndex == 0) { this.retMesh = DelaunayConcave.GetMesh(pointList); for (int i = 0; i < retMesh.Faces.Count; i++) { ConcaveGenerator.DelaunayConcave.Triangle t = retMesh.Faces[i]; DrawLine_Delauney(retMesh.Points[t.P0Index], retMesh.Points[t.P1Index], "A0"); DrawLine_Delauney(retMesh.Points[t.P0Index], retMesh.Points[t.P2Index], "A0"); DrawLine_Delauney(retMesh.Points[t.P1Index], retMesh.Points[t.P2Index], "A0"); } retMesh.InitEdgesInfo(); retMesh.ExecuteEdgeDecimation(R); List <ConcaveGenerator.DelaunayConcave.EdgeInfo> edges = retMesh.GetBoundaryEdges(); for (int i = 0; i < edges.Count; i++) { DrawLine(retMesh.Points[edges[i].P0Index], retMesh.Points[edges[i].P1Index], null); } } if (CB_List.SelectedIndex == 1) { BallConcave cc = new BallConcave(this.pointList); if (cc.GetRecomandedR() > R) { ShowMessage("R值不合法,可点检查参数!"); return; } cc.main = this; List <Point2d> ret = cc.GetConcave_Ball(R); DrawPolyline(ret); } if (CB_List.SelectedIndex == 2) { BallConcave cc = new BallConcave(this.pointList); if (cc.GetRecomandedR() > R) { ShowMessage("R值不合法,可点检查参数!"); return; } cc.main = this; List <Point2d> ret = cc.GetConcave_Edge(R); DrawPolyline(ret); } }
public string GetRNeighboursMessage(BallConcave cc) { List <int>[] nlist = cc.GetInRNeighbourList(this.R); StringBuilder sb = new StringBuilder(); sb.Append("半径领域列表如下:\n"); for (int i = 0; i < nlist.Length; i++) { sb.Append("P" + pointList[i].Index + "的R近邻点有" + nlist[i].Count + "个: "); for (int j = 0; j < nlist[i].Count; j++) { sb.Append(string.Format("P{0},", pointList[nlist[i][j]].Index)); } sb.Append("\n"); } sb.Append("执行算法的R值应大于: " + cc.GetRecomandedR()); return(sb.ToString()); }
public List <Point2d> GetConcave_Ball(double radius) { List <Point2d> ret = new List <Point2d>(); List <int>[] adjs = GetInRNeighbourList(2 * radius); ret.Add(points[0]); //flags[0] = true; int i = 0, j = -1, prev = -1; while (true) { j = GetNextPoint_BallPivoting(prev, i, adjs[i], radius); if (j == -1) { break; } Point2d p = BallConcave.GetCircleCenter(points[i], points[j], radius); ret.Add(points[j]); flags[j] = true; prev = i; i = j; } return(ret); }