private void OnSplit(object sender, RoutedEventArgs args) { args.Handled = true; var lines = MultiLineIntersection.Split(_lines, _crossings); DrawIntersections(lines); }
/// <summary> /// Creates a random <see cref="Subdivision"/> with the specified number of full edges and /// comparison epsilon.</summary> /// <param name="size"> /// The number of full edges, i.e. half the number of <see cref="Subdivision.Edges"/>, in /// the returned <see cref="Subdivision"/>.</param> /// <param name="epsilon"> /// The maximum absolute difference at which two coordinates should be considered equal. /// </param> /// <returns> /// A new random <see cref="Subdivision"/> with the specified <paramref name="size"/> and /// <paramref name="epsilon"/>.</returns> private static Subdivision CreateSubdivision(int size, double epsilon) { LineD[] lines = new LineD[size]; for (int i = 0; i < size; i++) { lines[i] = GeoAlgorithms.RandomLine(0, 0, 1000, 1000); } // split random set into non-intersecting line segments var crossings = MultiLineIntersection.FindSimple(lines, epsilon); var splitLines = MultiLineIntersection.Split(lines, crossings); Array.Copy(splitLines, lines, size); // re-randomize lines to eliminate split ordering CollectionsUtility.Randomize(lines); Subdivision division = Subdivision.FromLines(lines); division.Validate(); return(division); }