diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index 237da87a28ac94019f3f65b7b54511417f0a4c1a..3819e88f52d9c82be36946696ff07bd7f8725894 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -13,6 +13,7 @@ <Configurations>Debug;Release;Deploy</Configurations> <DefineDebug>false</DefineDebug> <DefineTrace>false</DefineTrace> + <TargetFrameworks>net45;net48;net5.0-windows</TargetFrameworks> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> @@ -28,17 +29,38 @@ </PackageReference> </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\VectoCommon\VectoCommon\VectoCommon.csproj" /> - <ProjectReference Include="..\VectoCore\VectoCore\VectoCore.csproj" /> + + <ItemGroup Condition="'$(TargetFramework)'=='net45'"> + <Reference Include="Microsoft.Build.Framework" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Windows.Forms.DataVisualization" /> </ItemGroup> - - <ItemGroup> + + <ItemGroup Condition="'$(TargetFramework)'=='net48'"> <Reference Include="Microsoft.Build.Framework" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Windows.Forms.DataVisualization" /> </ItemGroup> + + + <ItemGroup Condition="'$(TargetFramework)'=='net5.0-windows'"> + <PackageReference Include="System.Drawing.Common" Version="6.0.0" /> + <Reference Include="System.Windows.Forms"> + <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll</HintPath> + </Reference> + <Reference Include="System.Windows.Forms.DataVisualization"> + <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.DataVisualization.dll</HintPath> + </Reference> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\VectoCommon\VectoCommon\VectoCommon.csproj" /> + <ProjectReference Include="..\VectoCore\VectoCore\VectoCore.csproj" /> + </ItemGroup> + + + <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index b7f4ce81b8853815ec998696ee49c80aed70cd00..bd42c4ab5d56015f29063753d7b4d728f7d91093 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -31,8 +31,12 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.Windows.Forms.DataVisualization.Charting; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -126,6 +130,7 @@ namespace TUGraz.VectoCore.Utils triangles.AddRange(newTriangles); + //DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax, point); pointCount++; // check invariant: m = 2n-2-k @@ -138,6 +143,9 @@ namespace TUGraz.VectoCore.Utils } } +#if TRACE + DrawGraph(pointCount, triangles, superTriangle, points); +#endif _convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)). SelectMany(t => t.GetEdges()). Where(e => !(superTriangle.Contains(e.P1) || superTriangle.Contains(e.P2))).ToArray(); @@ -158,6 +166,67 @@ namespace TUGraz.VectoCore.Utils } } + public void DrawGraph() + { + var superTriangle = new Triangle(new Point(-1, -1), new Point(4, -1), new Point(-1, 4)); + DrawGraph(0, _triangles, superTriangle, _points.ToArray()); + } + + /// <summary> + /// Draws the delaunay map (except supertriangle). + /// </summary> + private static void DrawGraph(int i, IEnumerable<Triangle> triangles, Triangle superTriangle, Point[] points, + Point lastPoint = null) + { + var xmin = Math.Min(points.Min(p => p.X), lastPoint?.X ?? double.NaN); + var xmax = Math.Max(points.Max(p => p.X), lastPoint?.X ?? double.NaN); + var ymin = Math.Min(points.Min(p => p.Y), lastPoint?.Y ?? double.NaN); + var ymax = Math.Max(points.Max(p => p.Y), lastPoint?.Y ?? double.NaN); + + using (var chart = new Chart { Width = 1000, Height = 1000 }) { + chart.ChartAreas.Add(new ChartArea("main") { + AxisX = new Axis { Minimum = Math.Min(xmin, xmin), Maximum = Math.Max(xmax, xmax) }, + AxisY = new Axis { Minimum = Math.Min(ymin, ymin), Maximum = Math.Max(ymax, ymax) } + }); + + foreach (var tr in triangles) { + if (tr.SharesVertexWith(superTriangle)) { + continue; + } + + var series = new Series { + ChartType = SeriesChartType.FastLine, + Color = lastPoint != null && tr.Contains(lastPoint) ? Color.Red : Color.Blue + }; + series.Points.AddXY(tr.P1.X, tr.P1.Y); + series.Points.AddXY(tr.P2.X, tr.P2.Y); + series.Points.AddXY(tr.P3.X, tr.P3.Y); + series.Points.AddXY(tr.P1.X, tr.P1.Y); + chart.Series.Add(series); + } + + if (lastPoint != null) { + var series = new Series { + ChartType = SeriesChartType.Point, + Color = Color.Red, + MarkerSize = 5, + MarkerStyle = MarkerStyle.Circle + }; + series.Points.AddXY(lastPoint.X, lastPoint.Y); + chart.Series.Add(series); + } + + var frame = new StackFrame(2); + var method = frame.GetMethod(); + System.Diagnostics.Debug.Assert(method.DeclaringType != null, "method.DeclaringType != null"); + var type = method.DeclaringType.Name.Split(Path.GetInvalidFileNameChars()).Join(""); + var methodName = method.Name.Split(Path.GetInvalidFileNameChars()).Join(""); + Directory.CreateDirectory("delaunay"); + chart.SaveImage($"delaunay\\{type}_{methodName}_{superTriangle.GetHashCode()}_{i}.png", + ChartImageFormat.Png); + } + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public double Interpolate(SI x, SI y) { diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 1cd43f48c10b6db34528b5275caa09d886c98c99..819ecfad0b5e5820b5d619b13e1b5501bfc7eb93 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -12,19 +12,33 @@ <PackageReference Include="Ninject.Extensions.Factory" Version="3.3.3" /> <PackageReference Include="NLog" Version="4.7.13" /> <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" /> - - </ItemGroup> + </ItemGroup> - <ItemGroup Condition="'$(TargetFramework)'=='net45'" > + <ItemGroup Condition="'$(TargetFramework)'=='net45'"> <Reference Include="Microsoft.VisualBasic" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Windows.Forms.DataVisualization" /> </ItemGroup> - <ItemGroup Condition="'$(TargetFramework)'=='net48'" > + <ItemGroup Condition="'$(TargetFramework)'=='net48'"> <Reference Include="Microsoft.VisualBasic" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Windows.Forms.DataVisualization" /> </ItemGroup> + <ItemGroup Condition="'$(TargetFramework)'=='net5.0'"> + <PackageReference Include="System.Drawing.Common" Version="6.0.0" /> + <Reference Include="System.Windows.Forms"> + <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll</HintPath> + </Reference> + <Reference Include="System.Windows.Forms.DataVisualization"> + <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.DataVisualization.dll</HintPath> + </Reference> + </ItemGroup> + + <ItemGroup> <InternalsVisibleTo Include="VectoAPI" /> @@ -292,16 +306,13 @@ + <ItemGroup> <Compile Update="JSONKeys.Designer.cs"> <DesignTime>True</DesignTime> <AutoGen>True</AutoGen> <DependentUpon>JSONKeys.resx</DependentUpon> </Compile> - </ItemGroup> - - - <ItemGroup> <EmbeddedResource Update="JSONKeys.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>JSONKeys.Designer.cs</LastGenOutput> diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index 780733442d150fa07c3250d0545ab925b77f582c..2733448c6da0af9bf771551d2f5bb4fd22dbe093 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -7,7 +7,6 @@ <TargetFrameworks>net5.0</TargetFrameworks> </PropertyGroup> - <ItemGroup> <PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" /> @@ -18,11 +17,6 @@ <PackageReference Include="NLog" Version="4.7.13" /> </ItemGroup> - <ItemGroup Condition="'$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net48'"> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Windows.Forms.DataVisualization" /> - </ItemGroup> - <ItemGroup> <ProjectReference Include="..\..\VectoCommon\VectoCommon\VectoCommon.csproj" /> <ProjectReference Include="..\..\VectoCommon\VectoHashing\VectoHashing.csproj" />