[
  {
    "path": ".gitignore",
    "content": "# Modified from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable files\n*.nuget.props\n*.nuget.targets\n\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!*.[Cc]ache/"
  },
  {
    "path": "DelaunayVoronoi/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<configuration>\n    <startup> \n        <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.6.1\" />\n    </startup>\n</configuration>"
  },
  {
    "path": "DelaunayVoronoi/App.xaml",
    "content": "﻿<Application x:Class=\"DelaunayVoronoi.App\"\n             xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n             xmlns:local=\"clr-namespace:DelaunayVoronoi\"\n             StartupUri=\"MainWindow.xaml\">\n    <Application.Resources>\n         \n    </Application.Resources>\n</Application>\n"
  },
  {
    "path": "DelaunayVoronoi/App.xaml.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Configuration;\nusing System.Data;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing System.Windows;\n\nnamespace DelaunayVoronoi\n{\n    /// <summary>\n    /// Interaction logic for App.xaml\n    /// </summary>\n    public partial class App : Application\n    {\n    }\n}\n"
  },
  {
    "path": "DelaunayVoronoi/Delaunay.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace DelaunayVoronoi\n{\n    public class DelaunayTriangulator\n    {\n        private double MaxX { get; set; }\n        private double MaxY { get; set; }\n        private IEnumerable<Triangle> border;\n\n        public IEnumerable<Point> GeneratePoints(int amount, double maxX, double maxY)\n        {\n            MaxX = maxX;\n            MaxY = maxY;\n\n            // TODO make more beautiful\n            var point0 = new Point(0, 0);\n            var point1 = new Point(0, MaxY);\n            var point2 = new Point(MaxX, MaxY);\n            var point3 = new Point(MaxX, 0);\n            var points = new List<Point>() { point0, point1, point2, point3 };\n            var tri1 = new Triangle(point0, point1, point2);\n            var tri2 = new Triangle(point0, point2, point3);\n            border = new List<Triangle>() { tri1, tri2 };\n\n            var random = new Random();\n            for (int i = 0; i < amount - 4; i++)\n            {\n                var pointX = random.NextDouble() * MaxX;\n                var pointY = random.NextDouble() * MaxY;\n                points.Add(new Point(pointX, pointY));\n            }\n\n            return points;\n        }\n\n        public IEnumerable<Triangle> BowyerWatson(IEnumerable<Point> points)\n        {\n            //var supraTriangle = GenerateSupraTriangle();\n            var triangulation = new HashSet<Triangle>(border);\n\n            foreach (var point in points)\n            {\n                var badTriangles = FindBadTriangles(point, triangulation);\n                var polygon = FindHoleBoundaries(badTriangles);\n\n                foreach (var triangle in badTriangles)\n                {\n                    foreach (var vertex in triangle.Vertices)\n                    {\n                        vertex.AdjacentTriangles.Remove(triangle);\n                    }\n                }\n                triangulation.RemoveWhere(o => badTriangles.Contains(o));\n\n                foreach (var edge in polygon.Where(possibleEdge => possibleEdge.Point1 != point && possibleEdge.Point2 != point))\n                {\n                    var triangle = new Triangle(point, edge.Point1, edge.Point2);\n                    triangulation.Add(triangle);\n                }\n            }\n\n            //triangulation.RemoveWhere(o => o.Vertices.Any(v => supraTriangle.Vertices.Contains(v)));\n            return triangulation;\n        }\n\n        private List<Edge> FindHoleBoundaries(ISet<Triangle> badTriangles)\n        {\n            var edges = new List<Edge>();\n            foreach (var triangle in badTriangles)\n            {\n                edges.Add(new Edge(triangle.Vertices[0], triangle.Vertices[1]));\n                edges.Add(new Edge(triangle.Vertices[1], triangle.Vertices[2]));\n                edges.Add(new Edge(triangle.Vertices[2], triangle.Vertices[0]));\n            }\n            var grouped = edges.GroupBy(o => o);\n            var boundaryEdges = edges.GroupBy(o => o).Where(o => o.Count() == 1).Select(o => o.First());\n            return boundaryEdges.ToList();\n        }\n\n        private Triangle GenerateSupraTriangle()\n        {\n            //   1  -> maxX\n            //  / \\\n            // 2---3\n            // |\n            // v maxY\n            var margin = 500;\n            var point1 = new Point(0.5 * MaxX, -2 * MaxX - margin);\n            var point2 = new Point(-2 * MaxY - margin, 2 * MaxY + margin);\n            var point3 = new Point(2 * MaxX + MaxY + margin, 2 * MaxY + margin);\n            return new Triangle(point1, point2, point3);\n        }\n\n        private ISet<Triangle> FindBadTriangles(Point point, HashSet<Triangle> triangles)\n        {\n            var badTriangles = triangles.Where(o => o.IsPointInsideCircumcircle(point));\n            return new HashSet<Triangle>(badTriangles);\n        }\n    }\n}"
  },
  {
    "path": "DelaunayVoronoi/DelaunayVoronoi.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{0FC94494-D51B-49E9-927D-1F0007C1FEA1}</ProjectGuid>\n    <OutputType>WinExe</OutputType>\n    <RootNamespace>Delaunay</RootNamespace>\n    <AssemblyName>Delaunay</AssemblyName>\n    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>\n    <FileAlignment>512</FileAlignment>\n    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n    <WarningLevel>4</WarningLevel>\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugSymbols>true</DebugSymbols>\n    <DebugType>full</DebugType>\n    <Optimize>false</Optimize>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugType>pdbonly</DebugType>\n    <Optimize>true</Optimize>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <DefineConstants>TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n    <Reference Include=\"System.Data\" />\n    <Reference Include=\"System.Xml\" />\n    <Reference Include=\"Microsoft.CSharp\" />\n    <Reference Include=\"System.Core\" />\n    <Reference Include=\"System.Xml.Linq\" />\n    <Reference Include=\"System.Data.DataSetExtensions\" />\n    <Reference Include=\"System.Net.Http\" />\n    <Reference Include=\"System.Xaml\">\n      <RequiredTargetFramework>4.0</RequiredTargetFramework>\n    </Reference>\n    <Reference Include=\"WindowsBase\" />\n    <Reference Include=\"PresentationCore\" />\n    <Reference Include=\"PresentationFramework\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ApplicationDefinition Include=\"App.xaml\">\n      <Generator>MSBuild:Compile</Generator>\n      <SubType>Designer</SubType>\n    </ApplicationDefinition>\n    <Compile Include=\"Point.cs\" />\n    <Compile Include=\"Edge.cs\" />\n    <Compile Include=\"Properties\\Annotations.cs\" />\n    <Compile Include=\"Triangle.cs\" />\n    <Compile Include=\"Voronoi.cs\" />\n    <Page Include=\"MainWindow.xaml\">\n      <Generator>MSBuild:Compile</Generator>\n      <SubType>Designer</SubType>\n    </Page>\n    <Compile Include=\"App.xaml.cs\">\n      <DependentUpon>App.xaml</DependentUpon>\n      <SubType>Code</SubType>\n    </Compile>\n    <Compile Include=\"Delaunay.cs\" />\n    <Compile Include=\"MainWindow.xaml.cs\">\n      <DependentUpon>MainWindow.xaml</DependentUpon>\n      <SubType>Code</SubType>\n    </Compile>\n  </ItemGroup>\n  <ItemGroup>\n    <Compile Include=\"Properties\\AssemblyInfo.cs\">\n      <SubType>Code</SubType>\n    </Compile>\n    <Compile Include=\"Properties\\Resources.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DesignTime>True</DesignTime>\n      <DependentUpon>Resources.resx</DependentUpon>\n    </Compile>\n    <Compile Include=\"Properties\\Settings.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Settings.settings</DependentUpon>\n      <DesignTimeSharedInput>True</DesignTimeSharedInput>\n    </Compile>\n    <EmbeddedResource Include=\"Properties\\Resources.resx\">\n      <Generator>ResXFileCodeGenerator</Generator>\n      <LastGenOutput>Resources.Designer.cs</LastGenOutput>\n    </EmbeddedResource>\n    <None Include=\"Properties\\Settings.settings\">\n      <Generator>SettingsSingleFileGenerator</Generator>\n      <LastGenOutput>Settings.Designer.cs</LastGenOutput>\n    </None>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"App.config\" />\n  </ItemGroup>\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n</Project>"
  },
  {
    "path": "DelaunayVoronoi/Edge.cs",
    "content": "﻿namespace DelaunayVoronoi\n{\n    public class Edge\n    {\n        public Point Point1 { get; }\n        public Point Point2 { get; }\n\n        public Edge(Point point1, Point point2)\n        {\n            Point1 = point1;\n            Point2 = point2;\n        }\n\n        public override bool Equals(object obj)\n        {\n            if (obj == null) return false;\n            if (obj.GetType() != GetType()) return false;\n            var edge = obj as Edge;\n\n            var samePoints = Point1 == edge.Point1 && Point2 == edge.Point2;\n            var samePointsReversed = Point1 == edge.Point2 && Point2 == edge.Point1;\n            return samePoints || samePointsReversed;\n        }\n\n        public override int GetHashCode()\n        {\n            int hCode = (int)Point1.X ^ (int)Point1.Y ^ (int)Point2.X ^ (int)Point2.Y;\n            return hCode.GetHashCode();\n        }\n    }\n}"
  },
  {
    "path": "DelaunayVoronoi/MainWindow.xaml",
    "content": "﻿<Window x:Class=\"DelaunayVoronoi.MainWindow\"\n        xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n        xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n        xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n        xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n        xmlns:local=\"clr-namespace:DelaunayVoronoi\"\n        mc:Ignorable=\"d\"\n        Title=\"Voronoi Diagram Generator\" Height=\"480\" Width=\"850\">\n    <DockPanel>\n        <DockPanel DockPanel.Dock=\"Bottom\" Margin=\"10\">\n            <Grid DockPanel.Dock=\"Right\">\n                <Grid.RowDefinitions>\n                    <RowDefinition Height=\"Auto\" />\n                </Grid.RowDefinitions>\n                <Button Content=\"Draw\" Command=\"{Binding Path=DrawCommand}\" DockPanel.Dock=\"Right\" Padding=\"10,0,10,0\" />\n            </Grid>\n            <Grid DockPanel.Dock=\"Left\" Margin=\"0,0,10,0\">\n                <Grid.Resources>\n                    <Thickness x:Key=\"TextBoxMargin\" Left=\"0\" Top=\"2\" Bottom=\"2\" />\n                </Grid.Resources>\n                <Grid.RowDefinitions>\n                    <RowDefinition Height=\"Auto\" />\n                    <RowDefinition Height=\"Auto\" />\n                    <RowDefinition Height=\"Auto\" />\n                </Grid.RowDefinitions>\n                <Grid.ColumnDefinitions>\n                    <ColumnDefinition Width=\"Auto\" />\n                    <ColumnDefinition Width=\"10\" />\n                    <ColumnDefinition Width=\"Auto\" />\n                </Grid.ColumnDefinitions>\n\n                <TextBlock Text=\"Points\" Grid.Row=\"0\" Grid.Column=\"0\" VerticalAlignment=\"Center\" />\n                <TextBox Text=\"{Binding PointCount}\" Grid.Row=\"0\" Grid.Column=\"2\" Width=\"100\" Margin=\"{StaticResource TextBoxMargin}\" />\n\n                <TextBlock Text=\"Width\" Grid.Row=\"1\" Grid.Column=\"0\" VerticalAlignment=\"Center\" />\n                <TextBox Text=\"{Binding Path=DiagramWidth, Mode=OneWay}\" IsReadOnly=\"True\" Grid.Row=\"1\" Grid.Column=\"2\" Width=\"100\" Margin=\"{StaticResource TextBoxMargin}\" />\n\n                <TextBlock Text=\"Height\" Grid.Row=\"2\" Grid.Column=\"0\" VerticalAlignment=\"Center\" />\n                <TextBox Text=\"{Binding Path=DiagramHeight, Mode=OneWay}\" IsReadOnly=\"True\" Grid.Row=\"2\" Grid.Column=\"2\" Width=\"100\" Margin=\"{StaticResource TextBoxMargin}\" />\n            </Grid>\n            <Grid />\n        </DockPanel>\n        <Canvas Name=\"Canvas\" Margin=\"20,20,20,20\" />\n    </DockPanel>\n</Window>"
  },
  {
    "path": "DelaunayVoronoi/MainWindow.xaml.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Runtime.CompilerServices;\nusing System.Windows;\nusing System.Windows.Input;\nusing System.Windows.Shapes;\nusing Delaunay.Annotations;\n\nnamespace DelaunayVoronoi\n{\n    public partial class MainWindow : Window, INotifyPropertyChanged\n    {\n        private DelaunayTriangulator delaunay = new DelaunayTriangulator();\n        private Voronoi voronoi = new Voronoi();\n        public int PointCount { get; set; } = 2000;\n        public double DiagramWidth => (int)Canvas.ActualWidth;\n        public double DiagramHeight => (int)Canvas.ActualHeight;\n\n        public ICommand DrawCommand { get; set; }\n\n        public MainWindow()\n        {\n            InitializeComponent();\n\n            DataContext = this;\n\n            DrawCommand = new Command(param => GenerateAndDraw());\n            Canvas.SizeChanged += (sender, args) =>\n            {\n                OnPropertyChanged(nameof(DiagramHeight));\n                OnPropertyChanged(nameof(DiagramWidth));\n            };\n\n        }\n\n        private void GenerateAndDraw()\n        {\n            Canvas.Children.Clear();\n            Canvas.ClipToBounds = true;\n            var points = delaunay.GeneratePoints(PointCount, DiagramWidth, DiagramHeight);\n\n            var delaunayTimer = Stopwatch.StartNew();\n            var triangulation = delaunay.BowyerWatson(points);\n            delaunayTimer.Stop();\n            DrawTriangulation(triangulation);\n\n            var voronoiTimer = Stopwatch.StartNew();\n            var vornoiEdges = voronoi.GenerateEdgesFromDelaunay(triangulation);\n            voronoiTimer.Stop();\n            DrawVoronoi(vornoiEdges);\n\n            DrawPoints(points);\n        }\n\n        private void DrawPoints(IEnumerable<Point> points)\n        {\n            foreach (var point in points)\n            {\n                var myEllipse = new Ellipse();\n                myEllipse.Fill = System.Windows.Media.Brushes.Red;\n                myEllipse.HorizontalAlignment = HorizontalAlignment.Left;\n                myEllipse.VerticalAlignment = VerticalAlignment.Top;\n                myEllipse.Width = 1;\n                myEllipse.Height = 1;\n                var ellipseX = point.X - 0.5 * myEllipse.Height;\n                var ellipseY = point.Y - 0.5 * myEllipse.Width;\n                myEllipse.Margin = new Thickness(ellipseX, ellipseY, 0, 0);\n\n                Canvas.Children.Add(myEllipse);\n            }\n        }\n\n        private void DrawTriangulation(IEnumerable<Triangle> triangulation)\n        {\n            var edges = new List<Edge>();\n            foreach (var triangle in triangulation)\n            {\n                edges.Add(new Edge(triangle.Vertices[0], triangle.Vertices[1]));\n                edges.Add(new Edge(triangle.Vertices[1], triangle.Vertices[2]));\n                edges.Add(new Edge(triangle.Vertices[2], triangle.Vertices[0]));\n            }\n\n            foreach (var edge in edges)\n            {\n                var line = new Line();\n                line.Stroke = System.Windows.Media.Brushes.LightSteelBlue;\n                line.StrokeThickness = 0.5;\n\n                line.X1 = edge.Point1.X;\n                line.X2 = edge.Point2.X;\n                line.Y1 = edge.Point1.Y;\n                line.Y2 = edge.Point2.Y;\n\n                Canvas.Children.Add(line);\n            }\n        }\n\n        private void DrawVoronoi(IEnumerable<Edge> voronoiEdges)\n        {\n            foreach (var edge in voronoiEdges)\n            {\n                var line = new Line();\n                line.Stroke = System.Windows.Media.Brushes.DarkViolet;\n                line.StrokeThickness = 1;\n\n                line.X1 = edge.Point1.X;\n                line.X2 = edge.Point2.X;\n                line.Y1 = edge.Point1.Y;\n                line.Y2 = edge.Point2.Y;\n\n                Canvas.Children.Add(line);\n            }\n        }\n\n        public event PropertyChangedEventHandler PropertyChanged;\n\n        [NotifyPropertyChangedInvocator]\n        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)\n        {\n            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));\n        }\n    }\n\n    public class Command : ICommand\n    {\n        private readonly Action<object> _execute;\n        private readonly Func<object, bool> _canExecute;\n\n        public Command(Action<object> execute)\n            : this(execute, param => true)\n        {\n        }\n\n        public Command(Action<object> execute, Func<object, bool> canExecute)\n        {\n            _execute = execute;\n            _canExecute = canExecute;\n        }\n\n        public void Execute(object parameter)\n        {\n            _execute(parameter);\n        }\n\n        public event EventHandler CanExecuteChanged;\n\n        public bool CanExecute(object parameter)\n        {\n            return (_canExecute == null) || _canExecute(parameter);\n        }\n    }\n}"
  },
  {
    "path": "DelaunayVoronoi/Point.cs",
    "content": "﻿using System.Collections.Generic;\n\nnamespace DelaunayVoronoi\n{\n    public class Point\n    {\n        /// <summary>\n        /// Used only for generating a unique ID for each instance of this class that gets generated\n        /// </summary>\n        private static int _counter;\n\n        /// <summary>\n        /// Used for identifying an instance of a class; can be useful in troubleshooting when geometry goes weird\n        /// (e.g. when trying to identify when Triangle objects are being created with the same Point object twice)\n        /// </summary>\n        private readonly int _instanceId = _counter++;\n\n        public double X { get; }\n        public double Y { get; }\n        public HashSet<Triangle> AdjacentTriangles { get; } = new HashSet<Triangle>();\n\n        public Point(double x, double y)\n        {\n            X = x;\n            Y = y;\n        }\n\n        public override string ToString()\n        {\n            // Simple way of seeing what's going on in the debugger when investigating weirdness\n            return $\"{nameof(Point)} {_instanceId} {X:0.##}@{Y:0.##}\";\n        }\n    }\n}"
  },
  {
    "path": "DelaunayVoronoi/Properties/Annotations.cs",
    "content": "﻿/* MIT License\n\nCopyright (c) 2016 JetBrains http://www.jetbrains.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE. */\n\nusing System;\n// ReSharper disable InheritdocConsiderUsage\n\n#pragma warning disable 1591\n// ReSharper disable UnusedMember.Global\n// ReSharper disable MemberCanBePrivate.Global\n// ReSharper disable UnusedAutoPropertyAccessor.Global\n// ReSharper disable IntroduceOptionalParameters.Global\n// ReSharper disable MemberCanBeProtected.Global\n// ReSharper disable InconsistentNaming\n\nnamespace Delaunay.Annotations\n{\n  /// <summary>\n  /// Indicates that the value of the marked element could be <c>null</c> sometimes,\n  /// so checking for <c>null</c> is required before its usage.\n  /// </summary>\n  /// <example><code>\n  /// [CanBeNull] object Test() => null;\n  /// \n  /// void UseTest() {\n  ///   var p = Test();\n  ///   var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]\n  public sealed class CanBeNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the value of the marked element can never be <c>null</c>.\n  /// </summary>\n  /// <example><code>\n  /// [NotNull] object Foo() {\n  ///   return null; // Warning: Possible 'null' assignment\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]\n  public sealed class NotNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task\n  /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property\n  /// or of the Lazy.Value property can never be null.\n  /// </summary>\n  /// <example><code>\n  /// public void Foo([ItemNotNull]List&lt;string&gt; books)\n  /// {\n  ///   foreach (var book in books) {\n  ///     if (book != null) // Warning: Expression is always true\n  ///      Console.WriteLine(book.ToUpper());\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field)]\n  public sealed class ItemNotNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task\n  /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property\n  /// or of the Lazy.Value property can be null.\n  /// </summary>\n  /// <example><code>\n  /// public void Foo([ItemCanBeNull]List&lt;string&gt; books)\n  /// {\n  ///   foreach (var book in books)\n  ///   {\n  ///     // Warning: Possible 'System.NullReferenceException'\n  ///     Console.WriteLine(book.ToUpper());\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |\n    AttributeTargets.Delegate | AttributeTargets.Field)]\n  public sealed class ItemCanBeNullAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the marked method builds string by the format pattern and (optional) arguments.\n  /// The parameter, which contains the format string, should be given in constructor. The format string\n  /// should be in <see cref=\"string.Format(IFormatProvider,string,object[])\"/>-like form.\n  /// </summary>\n  /// <example><code>\n  /// [StringFormatMethod(\"message\")]\n  /// void ShowError(string message, params object[] args) { /* do something */ }\n  /// \n  /// void Foo() {\n  ///   ShowError(\"Failed: {0}\"); // Warning: Non-existing argument in format string\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Constructor | AttributeTargets.Method |\n    AttributeTargets.Property | AttributeTargets.Delegate)]\n  public sealed class StringFormatMethodAttribute : Attribute\n  {\n    /// <param name=\"formatParameterName\">\n    /// Specifies which parameter of an annotated method should be treated as the format string\n    /// </param>\n    public StringFormatMethodAttribute([NotNull] string formatParameterName)\n    {\n      FormatParameterName = formatParameterName;\n    }\n\n    [NotNull] public string FormatParameterName { get; }\n  }\n\n  /// <summary>\n  /// Use this annotation to specify a type that contains static or const fields\n  /// with values for the annotated property/field/parameter.\n  /// The specified type will be used to improve completion suggestions.\n  /// </summary>\n  /// <example><code>\n  /// namespace TestNamespace\n  /// {\n  ///   public class Constants\n  ///   {\n  ///     public static int INT_CONST = 1;\n  ///     public const string STRING_CONST = \"1\";\n  ///   }\n  ///\n  ///   public class Class1\n  ///   {\n  ///     [ValueProvider(\"TestNamespace.Constants\")] public int myField;\n  ///     public void Foo([ValueProvider(\"TestNamespace.Constants\")] string str) { }\n  ///\n  ///     public void Test()\n  ///     {\n  ///       Foo(/*try completion here*/);//\n  ///       myField = /*try completion here*/\n  ///     }\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,\n    AllowMultiple = true)]\n  public sealed class ValueProviderAttribute : Attribute\n  {\n    public ValueProviderAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [NotNull] public string Name { get; }\n  }\n\n  /// <summary>\n  /// Indicates that the function argument should be a string literal and match one\n  /// of the parameters of the caller function. For example, ReSharper annotates\n  /// the parameter of <see cref=\"System.ArgumentNullException\"/>.\n  /// </summary>\n  /// <example><code>\n  /// void Foo(string param) {\n  ///   if (param == null)\n  ///     throw new ArgumentNullException(\"par\"); // Warning: Cannot resolve symbol\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class InvokerParameterNameAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the method is contained in a type that implements\n  /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method\n  /// is used to notify that some property value changed.\n  /// </summary>\n  /// <remarks>\n  /// The method should be non-static and conform to one of the supported signatures:\n  /// <list>\n  /// <item><c>NotifyChanged(string)</c></item>\n  /// <item><c>NotifyChanged(params string[])</c></item>\n  /// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item>\n  /// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item>\n  /// <item><c>SetProperty{T}(ref T, T, string)</c></item>\n  /// </list>\n  /// </remarks>\n  /// <example><code>\n  /// public class Foo : INotifyPropertyChanged {\n  ///   public event PropertyChangedEventHandler PropertyChanged;\n  /// \n  ///   [NotifyPropertyChangedInvocator]\n  ///   protected virtual void NotifyChanged(string propertyName) { ... }\n  ///\n  ///   string _name;\n  /// \n  ///   public string Name {\n  ///     get { return _name; }\n  ///     set { _name = value; NotifyChanged(\"LastName\"); /* Warning */ }\n  ///   }\n  /// }\n  /// </code>\n  /// Examples of generated notifications:\n  /// <list>\n  /// <item><c>NotifyChanged(\"Property\")</c></item>\n  /// <item><c>NotifyChanged(() =&gt; Property)</c></item>\n  /// <item><c>NotifyChanged((VM x) =&gt; x.Property)</c></item>\n  /// <item><c>SetProperty(ref myField, value, \"Property\")</c></item>\n  /// </list>\n  /// </example>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute\n  {\n    public NotifyPropertyChangedInvocatorAttribute() { }\n    public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)\n    {\n      ParameterName = parameterName;\n    }\n\n    [CanBeNull] public string ParameterName { get; }\n  }\n\n  /// <summary>\n  /// Describes dependency between method input and output.\n  /// </summary>\n  /// <syntax>\n  /// <p>Function Definition Table syntax:</p>\n  /// <list>\n  /// <item>FDT      ::= FDTRow [;FDTRow]*</item>\n  /// <item>FDTRow   ::= Input =&gt; Output | Output &lt;= Input</item>\n  /// <item>Input    ::= ParameterName: Value [, Input]*</item>\n  /// <item>Output   ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>\n  /// <item>Value    ::= true | false | null | notnull | canbenull</item>\n  /// </list>\n  /// If the method has a single input parameter, its name could be omitted.<br/>\n  /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for the method output\n  /// means that the method doesn't return normally (throws or terminates the process).<br/>\n  /// Value <c>canbenull</c> is only applicable for output parameters.<br/>\n  /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute\n  /// with rows separated by semicolon. There is no notion of order rows, all rows are checked\n  /// for applicability and applied per each program state tracked by the analysis engine.<br/>\n  /// </syntax>\n  /// <examples><list>\n  /// <item><code>\n  /// [ContractAnnotation(\"=&gt; halt\")]\n  /// public void TerminationMethod()\n  /// </code></item>\n  /// <item><code>\n  /// [ContractAnnotation(\"null &lt;= param:null\")] // reverse condition syntax\n  /// public string GetName(string surname)\n  /// </code></item>\n  /// <item><code>\n  /// [ContractAnnotation(\"s:null =&gt; true\")]\n  /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()\n  /// </code></item>\n  /// <item><code>\n  /// // A method that returns null if the parameter is null,\n  /// // and not null if the parameter is not null\n  /// [ContractAnnotation(\"null =&gt; null; notnull =&gt; notnull\")]\n  /// public object Transform(object data)\n  /// </code></item>\n  /// <item><code>\n  /// [ContractAnnotation(\"=&gt; true, result: notnull; =&gt; false, result: null\")]\n  /// public bool TryParse(string s, out Person result)\n  /// </code></item>\n  /// </list></examples>\n  [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]\n  public sealed class ContractAnnotationAttribute : Attribute\n  {\n    public ContractAnnotationAttribute([NotNull] string contract)\n      : this(contract, false) { }\n\n    public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)\n    {\n      Contract = contract;\n      ForceFullStates = forceFullStates;\n    }\n\n    [NotNull] public string Contract { get; }\n\n    public bool ForceFullStates { get; }\n  }\n\n  /// <summary>\n  /// Indicates whether the marked element should be localized.\n  /// </summary>\n  /// <example><code>\n  /// [LocalizationRequiredAttribute(true)]\n  /// class Foo {\n  ///   string str = \"my string\"; // Warning: Localizable string\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.All)]\n  public sealed class LocalizationRequiredAttribute : Attribute\n  {\n    public LocalizationRequiredAttribute() : this(true) { }\n\n    public LocalizationRequiredAttribute(bool required)\n    {\n      Required = required;\n    }\n\n    public bool Required { get; }\n  }\n\n  /// <summary>\n  /// Indicates that the value of the marked type (or its derivatives)\n  /// cannot be compared using '==' or '!=' operators and <c>Equals()</c>\n  /// should be used instead. However, using '==' or '!=' for comparison\n  /// with <c>null</c> is always permitted.\n  /// </summary>\n  /// <example><code>\n  /// [CannotApplyEqualityOperator]\n  /// class NoEquality { }\n  /// \n  /// class UsesNoEquality {\n  ///   void Test() {\n  ///     var ca1 = new NoEquality();\n  ///     var ca2 = new NoEquality();\n  ///     if (ca1 != null) { // OK\n  ///       bool condition = ca1 == ca2; // Warning\n  ///     }\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]\n  public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }\n\n  /// <summary>\n  /// When applied to a target attribute, specifies a requirement for any type marked\n  /// with the target attribute to implement or inherit specific type or types.\n  /// </summary>\n  /// <example><code>\n  /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement\n  /// class ComponentAttribute : Attribute { }\n  /// \n  /// [Component] // ComponentAttribute requires implementing IComponent interface\n  /// class MyComponent : IComponent { }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]\n  [BaseTypeRequired(typeof(Attribute))]\n  public sealed class BaseTypeRequiredAttribute : Attribute\n  {\n    public BaseTypeRequiredAttribute([NotNull] Type baseType)\n    {\n      BaseType = baseType;\n    }\n\n    [NotNull] public Type BaseType { get; }\n  }\n\n  /// <summary>\n  /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),\n  /// so this symbol will not be reported as unused (as well as by other usage inspections).\n  /// </summary>\n  [AttributeUsage(AttributeTargets.All, Inherited = false)]\n  public sealed class UsedImplicitlyAttribute : Attribute\n  {\n    public UsedImplicitlyAttribute()\n      : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }\n\n    public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)\n      : this(useKindFlags, ImplicitUseTargetFlags.Default) { }\n\n    public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)\n      : this(ImplicitUseKindFlags.Default, targetFlags) { }\n\n    public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)\n    {\n      UseKindFlags = useKindFlags;\n      TargetFlags = targetFlags;\n    }\n\n    public ImplicitUseKindFlags UseKindFlags { get; }\n\n    public ImplicitUseTargetFlags TargetFlags { get; }\n  }\n\n  /// <summary>\n  /// Can be applied to attributes, type parameters, and parameters of a type assignable from <see cref=\"System.Type\"/> .\n  /// When applied to an attribute, the decorated attribute behaves the same as <see cref=\"UsedImplicitlyAttribute\"/>.\n  /// When applied to a type parameter or to a parameter of type <see cref=\"System.Type\"/>,  indicates that the corresponding type\n  /// is used implicitly.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)]\n  public sealed class MeansImplicitUseAttribute : Attribute\n  {\n    public MeansImplicitUseAttribute()\n      : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }\n\n    public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)\n      : this(useKindFlags, ImplicitUseTargetFlags.Default) { }\n\n    public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)\n      : this(ImplicitUseKindFlags.Default, targetFlags) { }\n\n    public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)\n    {\n      UseKindFlags = useKindFlags;\n      TargetFlags = targetFlags;\n    }\n\n    [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; }\n\n    [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; }\n  }\n\n  /// <summary>\n  /// Specify the details of implicitly used symbol when it is marked\n  /// with <see cref=\"MeansImplicitUseAttribute\"/> or <see cref=\"UsedImplicitlyAttribute\"/>.\n  /// </summary>\n  [Flags]\n  public enum ImplicitUseKindFlags\n  {\n    Default = Access | Assign | InstantiatedWithFixedConstructorSignature,\n    /// <summary>Only entity marked with attribute considered used.</summary>\n    Access = 1,\n    /// <summary>Indicates implicit assignment to a member.</summary>\n    Assign = 2,\n    /// <summary>\n    /// Indicates implicit instantiation of a type with fixed constructor signature.\n    /// That means any unused constructor parameters won't be reported as such.\n    /// </summary>\n    InstantiatedWithFixedConstructorSignature = 4,\n    /// <summary>Indicates implicit instantiation of a type.</summary>\n    InstantiatedNoFixedConstructorSignature = 8,\n  }\n\n  /// <summary>\n  /// Specify what is considered to be used implicitly when marked\n  /// with <see cref=\"MeansImplicitUseAttribute\"/> or <see cref=\"UsedImplicitlyAttribute\"/>.\n  /// </summary>\n  [Flags]\n  public enum ImplicitUseTargetFlags\n  {\n    Default = Itself,\n    Itself = 1,\n    /// <summary>Members of entity marked with attribute are considered used.</summary>\n    Members = 2,\n    /// <summary>Entity marked with attribute and all its members considered used.</summary>\n    WithMembers = Itself | Members\n  }\n\n  /// <summary>\n  /// This attribute is intended to mark publicly available API\n  /// which should not be removed and so is treated as used.\n  /// </summary>\n  [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]\n  [AttributeUsage(AttributeTargets.All, Inherited = false)]\n  public sealed class PublicAPIAttribute : Attribute\n  {\n    public PublicAPIAttribute() { }\n\n    public PublicAPIAttribute([NotNull] string comment)\n    {\n      Comment = comment;\n    }\n\n    [CanBeNull] public string Comment { get; }\n  }\n\n  /// <summary>\n  /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack.\n  /// If the parameter is a delegate, indicates that delegate is executed while the method is executed.\n  /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class InstantHandleAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that a method does not make any observable state changes.\n  /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.\n  /// </summary>\n  /// <example><code>\n  /// [Pure] int Multiply(int x, int y) => x * y;\n  /// \n  /// void M() {\n  ///   Multiply(123, 42); // Waring: Return value of pure method is not used\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class PureAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the return value of the method invocation must be used.\n  /// </summary>\n  /// <remarks>\n  /// Methods decorated with this attribute (in contrast to pure methods) might change state,\n  /// but make no sense without using their return value. <br/>\n  /// Similarly to <see cref=\"PureAttribute\"/>, this attribute\n  /// will help detecting usages of the method when the return value in not used.\n  /// Additionally, you can optionally specify a custom message, which will be used when showing warnings, e.g.\n  /// <code>[MustUseReturnValue(\"Use the return value to...\")]</code>.\n  /// </remarks>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class MustUseReturnValueAttribute : Attribute\n  {\n    public MustUseReturnValueAttribute() { }\n\n    public MustUseReturnValueAttribute([NotNull] string justification)\n    {\n      Justification = justification;\n    }\n\n    [CanBeNull] public string Justification { get; }\n  }\n\n  /// <summary>\n  /// Indicates the type member or parameter of some type, that should be used instead of all other ways\n  /// to get the value of that type. This annotation is useful when you have some \"context\" value evaluated\n  /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.\n  /// </summary>\n  /// <example><code>\n  /// class Foo {\n  ///   [ProvidesContext] IBarService _barService = ...;\n  /// \n  ///   void ProcessNode(INode node) {\n  ///     DoSomething(node, node.GetGlobalServices().Bar);\n  ///     //              ^ Warning: use value of '_barService' field\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(\n    AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)]\n  public sealed class ProvidesContextAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that a parameter is a path to a file or a folder within a web project.\n  /// Path can be relative or absolute, starting from web root (~).\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class PathReferenceAttribute : Attribute\n  {\n    public PathReferenceAttribute() { }\n\n    public PathReferenceAttribute([NotNull, PathReference] string basePath)\n    {\n      BasePath = basePath;\n    }\n\n    [CanBeNull] public string BasePath { get; }\n  }\n\n  /// <summary>\n  /// An extension method marked with this attribute is processed by code completion\n  /// as a 'Source Template'. When the extension method is completed over some expression, its source code\n  /// is automatically expanded like a template at call site.\n  /// </summary>\n  /// <remarks>\n  /// Template method body can contain valid source code and/or special comments starting with '$'.\n  /// Text inside these comments is added as source code when the template is applied. Template parameters\n  /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.\n  /// Use the <see cref=\"MacroAttribute\"/> attribute to specify macros for parameters.\n  /// </remarks>\n  /// <example>\n  /// In this example, the 'forEach' method is a source template available over all values\n  /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:\n  /// <code>\n  /// [SourceTemplate]\n  /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; xs) {\n  ///   foreach (var x in xs) {\n  ///      //$ $END$\n  ///   }\n  /// }\n  /// </code>\n  /// </example>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class SourceTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// Allows specifying a macro for a parameter of a <see cref=\"SourceTemplateAttribute\">source template</see>.\n  /// </summary>\n  /// <remarks>\n  /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression\n  /// is defined in the <see cref=\"MacroAttribute.Expression\"/> property. When applied on a method, the target\n  /// template parameter is defined in the <see cref=\"MacroAttribute.Target\"/> property. To apply the macro silently\n  /// for the parameter, set the <see cref=\"MacroAttribute.Editable\"/> property value = -1.\n  /// </remarks>\n  /// <example>\n  /// Applying the attribute on a source template method:\n  /// <code>\n  /// [SourceTemplate, Macro(Target = \"item\", Expression = \"suggestVariableName()\")]\n  /// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; collection) {\n  ///   foreach (var item in collection) {\n  ///     //$ $END$\n  ///   }\n  /// }\n  /// </code>\n  /// Applying the attribute on a template method parameter:\n  /// <code>\n  /// [SourceTemplate]\n  /// public static void something(this Entity x, [Macro(Expression = \"guid()\", Editable = -1)] string newguid) {\n  ///   /*$ var $x$Id = \"$newguid$\" + x.ToString();\n  ///   x.DoSomething($x$Id); */\n  /// }\n  /// </code>\n  /// </example>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]\n  public sealed class MacroAttribute : Attribute\n  {\n    /// <summary>\n    /// Allows specifying a macro that will be executed for a <see cref=\"SourceTemplateAttribute\">source template</see>\n    /// parameter when the template is expanded.\n    /// </summary>\n    [CanBeNull] public string Expression { get; set; }\n\n    /// <summary>\n    /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.\n    /// </summary>\n    /// <remarks>\n    /// If the target parameter is used several times in the template, only one occurrence becomes editable;\n    /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,\n    /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.\n    /// </remarks>\n    public int Editable { get; set; }\n\n    /// <summary>\n    /// Identifies the target parameter of a <see cref=\"SourceTemplateAttribute\">source template</see> if the\n    /// <see cref=\"MacroAttribute\"/> is applied on a template method.\n    /// </summary>\n    [CanBeNull] public string Target { get; set; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute\n  {\n    public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcMasterLocationFormatAttribute : Attribute\n  {\n    public AspMvcMasterLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]\n  public sealed class AspMvcViewLocationFormatAttribute : Attribute\n  {\n    public AspMvcViewLocationFormatAttribute([NotNull] string format)\n    {\n      Format = format;\n    }\n\n    [NotNull] public string Format { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC action. If applied to a method, the MVC action name is calculated\n  /// implicitly from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcActionAttribute : Attribute\n  {\n    public AspMvcActionAttribute() { }\n\n    public AspMvcActionAttribute([NotNull] string anonymousProperty)\n    {\n      AnonymousProperty = anonymousProperty;\n    }\n\n    [CanBeNull] public string AnonymousProperty { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcAreaAttribute : Attribute\n  {\n    public AspMvcAreaAttribute() { }\n\n    public AspMvcAreaAttribute([NotNull] string anonymousProperty)\n    {\n      AnonymousProperty = anonymousProperty;\n    }\n\n    [CanBeNull] public string AnonymousProperty { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is\n  /// an MVC controller. If applied to a method, the MVC controller name is calculated\n  /// implicitly from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcControllerAttribute : Attribute\n  {\n    public AspMvcControllerAttribute() { }\n\n    public AspMvcControllerAttribute([NotNull] string anonymousProperty)\n    {\n      AnonymousProperty = anonymousProperty;\n    }\n\n    [CanBeNull] public string AnonymousProperty { get; }\n  }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute\n  /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcMasterAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute\n  /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class AspMvcModelTypeAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC\n  /// partial view. If applied to a method, the MVC partial view name is calculated implicitly\n  /// from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcPartialViewAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]\n  public sealed class AspMvcSuppressViewErrorAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcDisplayTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcEditorTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcTemplateAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly\n  /// from the context. Use this attribute for custom wrappers similar to\n  /// <c>System.Web.Mvc.Controller.View(Object)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcViewAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC view component name.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcViewComponentAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter\n  /// is an MVC view component view. If applied to a method, the MVC view component view name is default.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class AspMvcViewComponentViewAttribute : Attribute { }\n\n  /// <summary>\n  /// ASP.NET MVC attribute. When applied to a parameter of an attribute,\n  /// indicates that this parameter is an MVC action name.\n  /// </summary>\n  /// <example><code>\n  /// [ActionName(\"Foo\")]\n  /// public ActionResult Login(string returnUrl) {\n  ///   ViewBag.ReturnUrl = Url.Action(\"Foo\"); // OK\n  ///   return RedirectToAction(\"Bar\"); // Error: Cannot resolve action\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]\n  public sealed class AspMvcActionSelectorAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]\n  public sealed class HtmlElementAttributesAttribute : Attribute\n  {\n    public HtmlElementAttributesAttribute() { }\n\n    public HtmlElementAttributesAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [CanBeNull] public string Name { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]\n  public sealed class HtmlAttributeValueAttribute : Attribute\n  {\n    public HtmlAttributeValueAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [NotNull] public string Name { get; }\n  }\n\n  /// <summary>\n  /// Razor attribute. Indicates that the marked parameter or method is a Razor section.\n  /// Use this attribute for custom wrappers similar to\n  /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]\n  public sealed class RazorSectionAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates how method, constructor invocation, or property access\n  /// over collection type affects the contents of the collection.\n  /// Use <see cref=\"CollectionAccessType\"/> to specify the access type.\n  /// </summary>\n  /// <remarks>\n  /// Using this attribute only makes sense if all collection methods are marked with this attribute.\n  /// </remarks>\n  /// <example><code>\n  /// public class MyStringCollection : List&lt;string&gt;\n  /// {\n  ///   [CollectionAccess(CollectionAccessType.Read)]\n  ///   public string GetFirstString()\n  ///   {\n  ///     return this.ElementAt(0);\n  ///   }\n  /// }\n  /// class Test\n  /// {\n  ///   public void Foo()\n  ///   {\n  ///     // Warning: Contents of the collection is never updated\n  ///     var col = new MyStringCollection();\n  ///     string x = col.GetFirstString();\n  ///   }\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)]\n  public sealed class CollectionAccessAttribute : Attribute\n  {\n    public CollectionAccessAttribute(CollectionAccessType collectionAccessType)\n    {\n      CollectionAccessType = collectionAccessType;\n    }\n\n    public CollectionAccessType CollectionAccessType { get; }\n  }\n\n  /// <summary>\n  /// Provides a value for the <see cref=\"CollectionAccessAttribute\"/> to define\n  /// how the collection method invocation affects the contents of the collection.\n  /// </summary>\n  [Flags]\n  public enum CollectionAccessType\n  {\n    /// <summary>Method does not use or modify content of the collection.</summary>\n    None = 0,\n    /// <summary>Method only reads content of the collection but does not modify it.</summary>\n    Read = 1,\n    /// <summary>Method can change content of the collection but does not add new elements.</summary>\n    ModifyExistingContent = 2,\n    /// <summary>Method can add new elements to the collection.</summary>\n    UpdatedContent = ModifyExistingContent | 4\n  }\n\n  /// <summary>\n  /// Indicates that the marked method is assertion method, i.e. it halts the control flow if\n  /// one of the conditions is satisfied. To set the condition, mark one of the parameters with\n  /// <see cref=\"AssertionConditionAttribute\"/> attribute.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class AssertionMethodAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates the condition parameter of the assertion method. The method itself should be\n  /// marked by <see cref=\"AssertionMethodAttribute\"/> attribute. The mandatory argument of\n  /// the attribute is the assertion type.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class AssertionConditionAttribute : Attribute\n  {\n    public AssertionConditionAttribute(AssertionConditionType conditionType)\n    {\n      ConditionType = conditionType;\n    }\n\n    public AssertionConditionType ConditionType { get; }\n  }\n\n  /// <summary>\n  /// Specifies assertion type. If the assertion method argument satisfies the condition,\n  /// then the execution continues. Otherwise, execution is assumed to be halted.\n  /// </summary>\n  public enum AssertionConditionType\n  {\n    /// <summary>Marked parameter should be evaluated to true.</summary>\n    IS_TRUE = 0,\n    /// <summary>Marked parameter should be evaluated to false.</summary>\n    IS_FALSE = 1,\n    /// <summary>Marked parameter should be evaluated to null value.</summary>\n    IS_NULL = 2,\n    /// <summary>Marked parameter should be evaluated to not null value.</summary>\n    IS_NOT_NULL = 3,\n  }\n\n  /// <summary>\n  /// Indicates that the marked method unconditionally terminates control flow execution.\n  /// For example, it could unconditionally throw exception.\n  /// </summary>\n  [Obsolete(\"Use [ContractAnnotation('=> halt')] instead\")]\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class TerminatesProgramAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select,\n  /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters\n  /// of delegate type by analyzing LINQ method chains.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class LinqTunnelAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that IEnumerable passed as a parameter is not enumerated.\n  /// Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection.\n  /// </summary>\n  /// <example><code>\n  /// static void ThrowIfNull&lt;T&gt;([NoEnumeration] T v, string n) where T : class\n  /// {\n  ///   // custom check for null but no enumeration\n  /// }\n  /// \n  /// void Foo(IEnumerable&lt;string&gt; values)\n  /// {\n  ///   ThrowIfNull(values, nameof(values));\n  ///   var x = values.ToList(); // No warnings about multiple enumeration\n  /// }\n  /// </code></example>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class NoEnumerationAttribute : Attribute { }\n\n  /// <summary>\n  /// Indicates that the marked parameter is a regular expression pattern.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class RegexPatternAttribute : Attribute { }\n\n  /// <summary>\n  /// Prevents the Member Reordering feature from tossing members of the marked class.\n  /// </summary>\n  /// <remarks>\n  /// The attribute must be mentioned in your member reordering patterns.\n  /// </remarks>\n  [AttributeUsage(\n    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]\n  public sealed class NoReorderAttribute : Attribute { }\n\n  /// <summary>\n  /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated\n  /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.\n  /// </summary>\n  [AttributeUsage(AttributeTargets.Class)]\n  public sealed class XamlItemsControlAttribute : Attribute { }\n\n  /// <summary>\n  /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that\n  /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will\n  /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.\n  /// </summary>\n  /// <remarks>\n  /// Property should have the tree ancestor of the <c>ItemsControl</c> type or\n  /// marked with the <see cref=\"XamlItemsControlAttribute\"/> attribute.\n  /// </remarks>\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]\n  public sealed class AspChildControlTypeAttribute : Attribute\n  {\n    public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)\n    {\n      TagName = tagName;\n      ControlType = controlType;\n    }\n\n    [NotNull] public string TagName { get; }\n\n    [NotNull] public Type ControlType { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]\n  public sealed class AspDataFieldAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]\n  public sealed class AspDataFieldsAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class AspMethodPropertyAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]\n  public sealed class AspRequiredAttributeAttribute : Attribute\n  {\n    public AspRequiredAttributeAttribute([NotNull] string attribute)\n    {\n      Attribute = attribute;\n    }\n\n    [NotNull] public string Attribute { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class AspTypePropertyAttribute : Attribute\n  {\n    public bool CreateConstructorReferences { get; }\n\n    public AspTypePropertyAttribute(bool createConstructorReferences)\n    {\n      CreateConstructorReferences = createConstructorReferences;\n    }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorImportNamespaceAttribute : Attribute\n  {\n    public RazorImportNamespaceAttribute([NotNull] string name)\n    {\n      Name = name;\n    }\n\n    [NotNull] public string Name { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorInjectionAttribute : Attribute\n  {\n    public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)\n    {\n      Type = type;\n      FieldName = fieldName;\n    }\n\n    [NotNull] public string Type { get; }\n\n    [NotNull] public string FieldName { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorDirectiveAttribute : Attribute\n  {\n    public RazorDirectiveAttribute([NotNull] string directive)\n    {\n      Directive = directive;\n    }\n\n    [NotNull] public string Directive { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]\n  public sealed class RazorPageBaseTypeAttribute : Attribute\n  {\n      public RazorPageBaseTypeAttribute([NotNull] string baseType)\n      {\n        BaseType = baseType;\n      }\n      public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)\n      {\n          BaseType = baseType;\n          PageName = pageName;\n      }\n\n      [NotNull] public string BaseType { get; }\n      [CanBeNull] public string PageName { get; }\n  }\n\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class RazorHelperCommonAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Property)]\n  public sealed class RazorLayoutAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class RazorWriteLiteralMethodAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Method)]\n  public sealed class RazorWriteMethodAttribute : Attribute { }\n\n  [AttributeUsage(AttributeTargets.Parameter)]\n  public sealed class RazorWriteMethodParameterAttribute : Attribute { }\n}"
  },
  {
    "path": "DelaunayVoronoi/Properties/AssemblyInfo.cs",
    "content": "﻿using System.Reflection;\nusing System.Resources;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\nusing System.Windows;\n\n// General Information about an assembly is controlled through the following\n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n[assembly: AssemblyTitle(\"Delaunay\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"Delaunay\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2018\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible\n// to COM components.  If you need to access a type in this assembly from\n// COM, set the ComVisible attribute to true on that type.\n[assembly: ComVisible(false)]\n\n//In order to begin building localizable applications, set\n//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file\n//inside a <PropertyGroup>.  For example, if you are using US english\n//in your source files, set the <UICulture> to en-US.  Then uncomment\n//the NeutralResourceLanguage attribute below.  Update the \"en-US\" in\n//the line below to match the UICulture setting in the project file.\n\n//[assembly: NeutralResourcesLanguage(\"en-US\", UltimateResourceFallbackLocation.Satellite)]\n\n\n[assembly: ThemeInfo(\n    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located\n                                     //(used if a resource is not found in the page,\n                                     // or application resource dictionaries)\n    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located\n                                              //(used if a resource is not found in the page,\n                                              // app, or any theme specific resource dictionaries)\n)]\n\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version\n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers\n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\n"
  },
  {
    "path": "DelaunayVoronoi/Properties/Resources.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace DelaunayVoronoi.Properties\n{\n\n\n    /// <summary>\n    ///   A strongly-typed resource class, for looking up localized strings, etc.\n    /// </summary>\n    // This class was auto-generated by the StronglyTypedResourceBuilder\n    // class via a tool like ResGen or Visual Studio.\n    // To add or remove a member, edit your .ResX file then rerun ResGen\n    // with the /str option, or rebuild your VS project.\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"4.0.0.0\")]\n    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    internal class Resources\n    {\n\n        private static global::System.Resources.ResourceManager resourceMan;\n\n        private static global::System.Globalization.CultureInfo resourceCulture;\n\n        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n        internal Resources()\n        {\n        }\n\n        /// <summary>\n        ///   Returns the cached ResourceManager instance used by this class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Resources.ResourceManager ResourceManager {\n            get {\n                if ((resourceMan == null))\n                {\n                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(\"Delaunay.Properties.Resources\", typeof(Resources).Assembly);\n                    resourceMan = temp;\n                }\n                return resourceMan;\n            }\n        }\n\n        /// <summary>\n        ///   Overrides the current thread's CurrentUICulture property for all\n        ///   resource lookups using this strongly typed resource class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Globalization.CultureInfo Culture {\n            get {\n                return resourceCulture;\n            }\n            set {\n                resourceCulture = value;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "DelaunayVoronoi/Properties/Resources.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "DelaunayVoronoi/Properties/Settings.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace DelaunayVoronoi.Properties\n{\n\n\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator\", \"11.0.0.0\")]\n    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase\n    {\n\n        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));\n\n        public static Settings Default {\n            get {\n                return defaultInstance;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "DelaunayVoronoi/Properties/Settings.settings",
    "content": "﻿<?xml version='1.0' encoding='utf-8'?>\n<SettingsFile xmlns=\"uri:settings\" CurrentProfile=\"(Default)\">\n  <Profiles>\n    <Profile Name=\"(Default)\" />\n  </Profiles>\n  <Settings />\n</SettingsFile>"
  },
  {
    "path": "DelaunayVoronoi/Triangle.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace DelaunayVoronoi\n{\n    public class Triangle\n    {\n        public Point[] Vertices { get; } = new Point[3];\n        public Point Circumcenter { get; private set; }\n        public double RadiusSquared;\n\n        public IEnumerable<Triangle> TrianglesWithSharedEdge {\n            get {\n                var neighbors = new HashSet<Triangle>();\n                foreach (var vertex in Vertices)\n                {\n                    var trianglesWithSharedEdge = vertex.AdjacentTriangles.Where(o =>\n                    {\n                        return o != this && SharesEdgeWith(o);\n                    });\n                    neighbors.UnionWith(trianglesWithSharedEdge);\n                }\n\n                return neighbors;\n            }\n        }\n\n        public Triangle(Point point1, Point point2, Point point3)\n        {\n            // In theory this shouldn't happen, but it was at one point so this at least makes sure we're getting a\n            // relatively easily-recognised error message, and provides a handy breakpoint for debugging.\n            if (point1 == point2 || point1 == point3 || point2 == point3)\n            {\n                throw new ArgumentException(\"Must be 3 distinct points\");\n            }\n\n            if (!IsCounterClockwise(point1, point2, point3))\n            {\n                Vertices[0] = point1;\n                Vertices[1] = point3;\n                Vertices[2] = point2;\n            }\n            else\n            {\n                Vertices[0] = point1;\n                Vertices[1] = point2;\n                Vertices[2] = point3;\n            }\n\n            Vertices[0].AdjacentTriangles.Add(this);\n            Vertices[1].AdjacentTriangles.Add(this);\n            Vertices[2].AdjacentTriangles.Add(this);\n            UpdateCircumcircle();\n        }\n\n        private void UpdateCircumcircle()\n        {\n            // https://codefound.wordpress.com/2013/02/21/how-to-compute-a-circumcircle/#more-58\n            // https://en.wikipedia.org/wiki/Circumscribed_circle\n            var p0 = Vertices[0];\n            var p1 = Vertices[1];\n            var p2 = Vertices[2];\n            var dA = p0.X * p0.X + p0.Y * p0.Y;\n            var dB = p1.X * p1.X + p1.Y * p1.Y;\n            var dC = p2.X * p2.X + p2.Y * p2.Y;\n\n            var aux1 = (dA * (p2.Y - p1.Y) + dB * (p0.Y - p2.Y) + dC * (p1.Y - p0.Y));\n            var aux2 = -(dA * (p2.X - p1.X) + dB * (p0.X - p2.X) + dC * (p1.X - p0.X));\n            var div = (2 * (p0.X * (p2.Y - p1.Y) + p1.X * (p0.Y - p2.Y) + p2.X * (p1.Y - p0.Y)));\n\n            if (div == 0)\n            {\n                throw new DivideByZeroException();\n            }\n\n            var center = new Point(aux1 / div, aux2 / div);\n            Circumcenter = center;\n            RadiusSquared = (center.X - p0.X) * (center.X - p0.X) + (center.Y - p0.Y) * (center.Y - p0.Y);\n        }\n\n        private bool IsCounterClockwise(Point point1, Point point2, Point point3)\n        {\n            var result = (point2.X - point1.X) * (point3.Y - point1.Y) -\n                (point3.X - point1.X) * (point2.Y - point1.Y);\n            return result > 0;\n        }\n\n        public bool SharesEdgeWith(Triangle triangle)\n        {\n            var sharedVertices = Vertices.Where(o => triangle.Vertices.Contains(o)).Count();\n            return sharedVertices == 2;\n        }\n\n        public bool IsPointInsideCircumcircle(Point point)\n        {\n            var d_squared = (point.X - Circumcenter.X) * (point.X - Circumcenter.X) +\n                (point.Y - Circumcenter.Y) * (point.Y - Circumcenter.Y);\n            return d_squared < RadiusSquared;\n        }\n    }\n}"
  },
  {
    "path": "DelaunayVoronoi/Voronoi.cs",
    "content": "﻿using System.Collections.Generic;\n\nnamespace DelaunayVoronoi\n{\n    public class Voronoi\n    {\n        public IEnumerable<Edge> GenerateEdgesFromDelaunay(IEnumerable<Triangle> triangulation)\n        {\n            var voronoiEdges = new HashSet<Edge>();\n            foreach (var triangle in triangulation)\n            {\n                foreach (var neighbor in triangle.TrianglesWithSharedEdge)\n                {\n                    var edge = new Edge(triangle.Circumcenter, neighbor.Circumcenter);\n                    voronoiEdges.Add(edge);\n                }\n            }\n\n            return voronoiEdges;\n        }\n    }\n}"
  },
  {
    "path": "DelaunayVoronoi.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 15\nVisualStudioVersion = 15.0.27703.2026\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"DelaunayVoronoi\", \"DelaunayVoronoi\\DelaunayVoronoi.csproj\", \"{0FC94494-D51B-49E9-927D-1F0007C1FEA1}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tRelease|Any CPU = Release|Any CPU\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{0FC94494-D51B-49E9-927D-1F0007C1FEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{0FC94494-D51B-49E9-927D-1F0007C1FEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{0FC94494-D51B-49E9-927D-1F0007C1FEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{0FC94494-D51B-49E9-927D-1F0007C1FEA1}.Release|Any CPU.Build.0 = Release|Any CPU\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {20F408B9-D210-4914-B77C-DEA654E925EB}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "DelaunayVoronoi.sln.DotSettings",
    "content": "﻿<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namespace:System;assembly=mscorlib\" xmlns:ss=\"urn:shemas-jetbrains-com:settings-storage-xaml\" xmlns:wpf=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\n\t<s:Boolean x:Key=\"/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=Delaunay_002EAnnotations/@EntryIndexedValue\">True</s:Boolean></wpf:ResourceDictionary>"
  },
  {
    "path": "LICENSE.txt",
    "content": "MIT License\n\nCopyright (c) 2018 Rafael Kübler da Silva\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# C# Delaunay triangulation + Voronoi Diagram\n\nA C# implementation of the [Bowyer–Watson algorithm](https://en.wikipedia.org/wiki/Bowyer%E2%80%93Watson_algorithm).\nThe result is a [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation) for a set of randomly generated points.\nFollowing the Delaunay triangulation, the dual [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram) is constructed.\n\nA screenshot of the Delaunay triangulation and the Voronoi diagram for 5000 points.\n\n<img alt=\"Delaunay triangulation and Voronoi diagram for 5000 points\" src=\"screenshots/delaunay_voronoi.png\" width=\"700\">\n\n## Why C#?\n\nIt just looks good. Also, blog posts listed below talking about procedural content and map generation caught my eye.\nSince my intention is to port the algorithms to the [Unity game engine](https://unity3d.com/) for future projects, I decided to stick to C#, as it is Unity's scripting language of choice.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details\n\n## Acknowledgments\n\n* [Procedural Dungeon Generation Algorithm](https://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php)\n* [Polygonal Map Generation for Games](http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/)\n* [Check if point is in circumcircle of a triangle (TitohuanT's answer)](https://stackoverflow.com/questions/39984709/how-can-i-check-wether-a-point-is-inside-the-circumcircle-of-3-points)\n"
  }
]