/// <summary> /// The Main GeoPolyLine Constructor /// </summary> /// <param name="xValues">X Coordinates</param> /// <param name="yValues">Y Coordinates</param> /// <param name="bulgeList">A List of Bulges</param> /// <param name="polylineFlag">The isClosed Property of a polyline</param> public GeoPolyline(List <double> xValues, IReadOnlyList <double> yValues, IReadOnlyList <double> bulgeList, bool polylineFlag) { // Throw Exception if the number of vertices does not match the if (xValues.Count != yValues.Count) { throw new EntityException("There must be a matching number of vertices"); } // Initialize and preallocate the vertex list Vertices = new List <Vertex>(xValues.Capacity); // Initializing a pre-allocating the section list SectionList = polylineFlag ? new List <GeoBase>(Vertices.Capacity) : new List <GeoBase>(Vertices.Capacity - 1); // Place x and y into the vertices list Vertices.AddRange(xValues.Select((t, vertexIndex) => new Vertex(t, yValues[vertexIndex]))); // Iterate through all of the vertices and build either GeoArcs or GeoLines for (var vertexIndex = 0; vertexIndex < Vertices.Count; ++vertexIndex) { var currentVertex = Vertices[vertexIndex]; var nextVertex = vertexIndex == Vertices.Count - 1 ? Vertices[0] : Vertices[vertexIndex + 1]; if (Math.Abs(bulgeList[vertexIndex] - Bulge.BulgeNull) > GeoMath.Tolerance) { var geoArc = new GeoArc(currentVertex, nextVertex, bulgeList[vertexIndex]); geoArc.PropertyChanged += GeoArcOnPropertyChanged; SectionList.Add(geoArc); } else { var geoLine = new GeoLine(currentVertex, nextVertex); geoLine.PropertyChanged += GeoLineOnPropertyChanged; SectionList.Add(new GeoLine(currentVertex, nextVertex)); } if (!polylineFlag) { SectionList.RemoveAt(SectionList.Count - 1); } } UpdateGeometry(string.Empty); }