/// <summary> /// Constructor that uses a List of Points and an optional List of Point-Indices /// </summary> /// <param name="points">The Polygon-Defining Points</param> /// <param name="indices">Optional List of Point-Indices</param> public PolygonData(List <Point> points, List <int> indices = null) { // Create and add PolygonPoints for this Polygon Object mPoints = new List <PolygonPoint>(points.Select(p => new PolygonPoint(p))); // If no Indices were specified, add them manually if (indices == null) { for (int i = 0; i < mPoints.Count; i++) { mPoints[i].Index = i; } } // If there were Indices specified, use them to set the PolygonPoint's Index Property else { for (int i = 0; i < mPoints.Count; i++) { mPoints[i].Index = indices[i]; } } // Add Edges between the Points (to be able to navigate along the Polygon easily later) var cnt = mPoints.Count; for (int i = 0; i < cnt; i++) { var lastIdx = (i + cnt - 1) % cnt; var edge = new PolygonEdge(mPoints[lastIdx], mPoints[i]); mPoints[lastIdx].EdgeTwo = edge; mPoints[i].EdgeOne = edge; } }
/// <summary> /// Constructor taking an Edge and a Helper /// </summary> /// <param name="edge">The Edge of the StatusHelperElement</param> /// <param name="point">The Helper for the Edge of the StatusHelperElement</param> internal StatusHelperElement(PolygonEdge edge, PolygonPoint point) { this.Edge = edge; this.Helper = point; }
/// <summary> /// Removes all StatusHelperElements with a specific Edge /// </summary> /// <param name="edge"></param> internal void Remove(PolygonEdge edge) { this.EdgesHelpers.RemoveAll(she => she.Edge == edge); }