momenteel geen errors, begonnen nieuwe items toe te voegen op ui

This commit is contained in:
BuildTools
2020-07-26 20:28:32 +02:00
parent 2cea96e863
commit b2ad2d4611
22 changed files with 312 additions and 34 deletions

Binary file not shown.

View File

@@ -5,8 +5,6 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Shapes;
using GeoJSON.Net.Geometry;
using Polygon = GeoJSON.Net.Geometry.Polygon;
namespace Globals
{
public class PolygonPunten
@@ -25,7 +23,7 @@ namespace Globals
MinimumY = punten.Min(punt => punt.Y);
}
public PolygonPunten(Polygon p, string naam = "")
public PolygonPunten(GeoJSON.Net.Geometry.Polygon p, string naam = "")
{
Naam = naam;
Punten = new List<Punt>();
@@ -45,6 +43,7 @@ namespace Globals
}
}
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Globals
else return Naam;
}
public Point GetPoint()
public Point ToPoint()
{
return new Point(X, Y);
}

View File

@@ -41,7 +41,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="PolygonManipulatie.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -16,28 +16,67 @@ namespace Logica
JsonReader = jsonReader;
}
public List<PolygonPunten> getPolygons()
public List<PolygonPunten> GetPolygons()
{
return JsonReader._polygons;
}
public List<MultiPolygonPunten> getMultiPolygons()
public List<MultiPolygonPunten> GetMultiPolygons()
{
return JsonReader._multiPolygons;
}
public List<PolygonPunten> getAllPolygons()
public PolygonPunten GetPolygonByName(string naam)
{
return JsonReader._polygons.Find(punten => punten.Naam == naam);
}
public List<PolygonPunten> GetTrianglesPolygon(PolygonPunten polygon, double scaleX
= 1, double scaleY = 1, double epsilonPercet = 0)
{
double grootsteAfstandX = Math.Abs(polygon.MaximumX - polygon.MinimumX);
double grootsteAfstandY = Math.Abs(polygon.MaximumY - polygon.MinimumY);
double epsilon = ((grootsteAfstandX + grootsteAfstandY) / 2) * epsilonPercet;
polygon.Punten = Peuker(polygon.Punten, epsilon);
polygon = ScalePolygon(polygon, scaleX, scaleY);
return TriangulatePolygon(polygon);
}
private PolygonPunten ScalePolygon(PolygonPunten polygon, double scaleX, double scaleY)
{
double maxX = polygon.MaximumX;
double maxY = polygon.MaximumY;
double minX = polygon.MinimumX;
double minY = polygon.MinimumY;
maxX -= minX;
maxY -= minY;
List<Punt> returnWaarde = new List<Punt>();
foreach (Punt punt in polygon.Punten)
{
double x = punt.X - minX;
x /= maxX;
x *= scaleX;
double y = punt.Y - minY;
y /= maxY;
y *= scaleY;
returnWaarde.Add(new Punt(x, y, punt.Naam));
}
return new PolygonPunten(returnWaarde, polygon.Naam);
}
public List<PolygonPunten> GetAllPolygons()
{
List<PolygonPunten> lijst = new List<PolygonPunten>();
lijst.AddRange(getPolygons());
foreach (MultiPolygonPunten multiPolygonPunten in getMultiPolygons())
lijst.AddRange(GetPolygons());
foreach (MultiPolygonPunten multiPolygonPunten in GetMultiPolygons())
{
lijst.AddRange(multiPolygonPunten.PolygonPunten);
}
return lijst;
}
public List<PolygonPunten> triangulatePolygon(List<Punt> punten)
public List<PolygonPunten> TriangulatePolygon(List<Punt> punten)
{
List<PolygonPunten> returnWaarde = new List<PolygonPunten>();
int i = 0;
@@ -45,7 +84,6 @@ namespace Logica
int BACKBACKUP = punten.Count;
while (true)
{
if (i >= punten.Count)
{
i = 0;
@@ -56,13 +94,11 @@ namespace Logica
BACKBACKUP = punten.Count;
}
int punt1Index = i;
int punt2Index = i + 1;
if (punt2Index >= punten.Count) punt2Index -= punten.Count;
int punt3Index = i + 2;
if (punt3Index >= punten.Count) punt3Index -= punten.Count;
if (punten.Count < 3)
{
break;
@@ -71,20 +107,14 @@ namespace Logica
if (hoek < 180)
{
returnWaarde.Add(MaakNieuweDriehoek(punten[punt2Index], punten[punt3Index],
punten[punt1Index]));
punten[punt1Index], punten[punt1Index].Naam));
punten.RemoveAt(punt2Index);
Debug.WriteLine("added a triangle, polygonLijst count " + punten.Count);
i = punt1Index;
BACKUP = 0;
continue;
}
Debug.WriteLine(hoek);
i++;
if (BACKUP >= punten.Count)
{
@@ -92,10 +122,61 @@ namespace Logica
break;
}
}
return returnWaarde;
}
public List<PolygonPunten> TriangulatePolygon(PolygonPunten polygon)
{
List<Punt> punten = polygon.Punten;
List<PolygonPunten> returnWaarde = new List<PolygonPunten>();
int i = 0;
int BACKUP = 0;
int BACKBACKUP = punten.Count;
while (true)
{
if (i >= punten.Count)
{
i = 0;
if (punten.Count == BACKBACKUP)
{
BACKUP++;
}
BACKBACKUP = punten.Count;
}
int punt1Index = i;
int punt2Index = i + 1;
if (punt2Index >= punten.Count) punt2Index -= punten.Count;
int punt3Index = i + 2;
if (punt3Index >= punten.Count) punt3Index -= punten.Count;
if (punten.Count < 3)
{
break;
}
double hoek = VindHoek(punten[punt2Index], punten[punt1Index], punten[punt3Index]);
if (hoek < 180)
{
returnWaarde.Add(MaakNieuweDriehoek(punten[punt2Index], punten[punt3Index],
punten[punt1Index], punten[punt1Index].Naam));
punten.RemoveAt(punt2Index);
Debug.WriteLine("added a triangle, polygonLijst count " + punten.Count);
i = punt1Index;
BACKUP = 0;
continue;
}
Debug.WriteLine(hoek);
i++;
if (BACKUP >= punten.Count)
{
Debug.WriteLine("FUCK, couldnt parse " + punten.Count + " points");
break;
}
}
return returnWaarde;
}
private PolygonPunten MaakNieuweDriehoek(Punt punt, Punt punt1, Punt punt2, string naam = "")
{
return new PolygonPunten(new List<Punt>() { punt, punt1, punt2 }, naam);
@@ -111,7 +192,7 @@ namespace Logica
return hoek;
}
private List<Punt> peuker(List<Punt> punten, double epsilon)
private List<Punt> Peuker(List<Punt> punten, double epsilon)
{
double dmax = -1;
int index = 0;
@@ -132,8 +213,8 @@ namespace Logica
if (dmax > epsilon)
{
List<Punt> recResults1 = peuker(punten.GetRange(0, index), epsilon);
List<Punt> recResults2 = peuker(punten.GetRange(index, end - 1 - index), epsilon);
List<Punt> recResults1 = Peuker(punten.GetRange(0, index), epsilon);
List<Punt> recResults2 = Peuker(punten.GetRange(index, end - 1 - index), epsilon);
returnWaarde.AddRange(recResults1);

View File

@@ -7,7 +7,7 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Canvas x:Name="someCanvas" RenderTransformOrigin="0.5,0.5" Margin="315,128,249,128">
<Canvas x:Name="someCanvas" RenderTransformOrigin="0.5,0.5" Margin="436,114,128,113">
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="2" ScaleX="2"/>
@@ -17,6 +17,10 @@
</TransformGroup>
</Canvas.RenderTransform>
</Canvas>
<ListBox Margin="10,94,568,93"/>
<Button x:Name="LoadFile" Content="LoadFile" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="27" Width="65"/>
<Slider HorizontalAlignment="Left" Margin="10,406,0,0" VerticalAlignment="Top" Width="120" Maximum="100" SmallChange="1"/>
<Label Content="Epsilon (0.001 - 0.1%)" HorizontalAlignment="Left" Margin="8,375,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>

View File

@@ -5,6 +5,7 @@ using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -18,6 +19,10 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Globals;
using Brush = System.Windows.Media.Brush;
using Brushes = System.Windows.Media.Brushes;
using Point = System.Windows.Point;
namespace opdracht2
{
@@ -32,6 +37,9 @@ namespace opdracht2
List<Polygon> buffer;
public MainWindow()
{
//todo logica toevoegen als object
//todo datalaag toevoegen als object en passen naar logica
f = new List<Polygon>();
el = new List<Ellipse>();
buffer = new List<Polygon>();
@@ -84,6 +92,28 @@ namespace opdracht2
}
}
private Polygon makePolygon(PolygonPunten polygonPunten)
{
PointCollection punten = new PointCollection();
foreach (Punt p in polygonPunten.Punten)
{
punten.Add(p.ToPoint());
}
Polygon polygon = new Polygon();
polygon.Points = punten;
polygon.StrokeThickness = 1;
// deze code zorgt ervoor dat de driehoeken duidelijker zijn op de afbeelding door de kleur willekeurig te selecteren
Random random = new Random();
Type brushType = typeof(Brushes);
PropertyInfo[] properties = brushType.GetProperties();
int randomIndex = random.Next(properties.Length);
Brush willekeurigeBrush = (Brush) properties[randomIndex].GetValue(null, null);
polygon.Fill = willekeurigeBrush;
polygon.Stroke = willekeurigeBrush;
return polygon;
}
//zoom https://stackoverflow.com/a/44593026
private void Button_Click(object sender, RoutedEventArgs e)

View File

@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "70D66715C0FFCAB3A710CE2C4D05885847B9E526"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "68E7240A4F498547AC7EFB2C2D5F594143259E09"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -49,6 +49,14 @@ namespace opdracht2 {
#line default
#line hidden
#line 21 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button LoadFile;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
@@ -82,6 +90,9 @@ namespace opdracht2 {
case 1:
this.someCanvas = ((System.Windows.Controls.Canvas)(target));
return;
case 2:
this.LoadFile = ((System.Windows.Controls.Button)(target));
return;
}
this._contentLoaded = true;
}

View File

@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "70D66715C0FFCAB3A710CE2C4D05885847B9E526"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "68E7240A4F498547AC7EFB2C2D5F594143259E09"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -49,6 +49,14 @@ namespace opdracht2 {
#line default
#line hidden
#line 21 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button LoadFile;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
@@ -82,6 +90,9 @@ namespace opdracht2 {
case 1:
this.someCanvas = ((System.Windows.Controls.Canvas)(target));
return;
case 2:
this.LoadFile = ((System.Windows.Controls.Button)(target));
return;
}
this._contentLoaded = true;
}

View File

@@ -13,7 +13,7 @@ C:\Users\Beppe\source\repos\opdracht2\opdracht2\App.xaml
11151548125
4-1295637703
195549397899
1981362301543
MainWindow.xaml;
True

View File

@@ -4,6 +4,60 @@
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\opdracht2\\opdracht2.csproj": {}
},
"projects": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj",
"projectName": "Datalaag",
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj",
"frameworks": {
"net472": {
"projectReferences": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj"
}
}
}
}
},
"frameworks": {
"net472": {}
}
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj",
"projectName": "Globals",
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj"
},
"frameworks": {
"net472": {}
}
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj",
"projectName": "Logica",
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj",
"frameworks": {
"net472": {
"projectReferences": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj"
}
}
}
}
},
"frameworks": {
"net472": {}
}
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\opdracht2\\opdracht2.csproj": {
"version": "1.0.0",
"restore": {
@@ -26,7 +80,17 @@
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
"projectReferences": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj"
}
}
}
},
"warningProperties": {

View File

@@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Beppe\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

View File

@@ -1448,6 +1448,40 @@
"runtime": {
"lib/netstandard1.3/System.Xml.XmlDocument.dll": {}
}
},
"Datalaag/1.0.0": {
"type": "project",
"dependencies": {
"Globals": "1.0.0"
},
"compile": {
"bin/placeholder/Datalaag.dll": {}
},
"runtime": {
"bin/placeholder/Datalaag.dll": {}
}
},
"Globals/1.0.0": {
"type": "project",
"compile": {
"bin/placeholder/Globals.dll": {}
},
"runtime": {
"bin/placeholder/Globals.dll": {}
}
},
"Logica/1.0.0": {
"type": "project",
"dependencies": {
"Datalaag": "1.0.0",
"Globals": "1.0.0"
},
"compile": {
"bin/placeholder/Logica.dll": {}
},
"runtime": {
"bin/placeholder/Logica.dll": {}
}
}
}
},
@@ -5338,11 +5372,29 @@
"system.xml.xmldocument.4.3.0.nupkg.sha512",
"system.xml.xmldocument.nuspec"
]
},
"Datalaag/1.0.0": {
"type": "project",
"path": "../Datalaag/Datalaag.csproj",
"msbuildProject": "../Datalaag/Datalaag.csproj"
},
"Globals/1.0.0": {
"type": "project",
"path": "../Globals/Globals.csproj",
"msbuildProject": "../Globals/Globals.csproj"
},
"Logica/1.0.0": {
"type": "project",
"path": "../Logica/Logica.csproj",
"msbuildProject": "../Logica/Logica.csproj"
}
},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.1": [
"Datalaag >= 1.0.0",
"GeoJSON.Net >= 1.2.19",
"Globals >= 1.0.0",
"Logica >= 1.0.0",
"System.Drawing.Common >= 4.7.0"
]
},
@@ -5371,7 +5423,17 @@
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
"projectReferences": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj"
}
}
}
},
"warningProperties": {

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "004Za2WhRXMEOU9Vs9RvspLpxPR0PMz9MFv2oy1y1VjRaQ7utidJwPCE8do7YCIt6avrMQpX4x9fh1RCVVj3UQ==",
"dgSpecHash": "p426YNxR+un7rXUpsV3S3g0htKyuFPUxB5pYHNl1fsHxje10LlIJDBLjupJb2IZCMEZ+Cv3TXWBEUMbbMYO5hA==",
"success": true,
"projectFilePath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\opdracht2\\opdracht2.csproj",
"expectedPackageFiles": [

View File

@@ -15,7 +15,17 @@
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
"projectReferences": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj"
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj": {
"projectPath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj"
}
}
}
},
"warningProperties": {

View File

@@ -11,4 +11,10 @@
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Datalaag\Datalaag.csproj" />
<ProjectReference Include="..\Globals\Globals.csproj" />
<ProjectReference Include="..\Logica\Logica.csproj" />
</ItemGroup>
</Project>