tis implemented maar werkt nie super goe. kheb geen id waarom

This commit is contained in:
BuildTools
2020-08-01 16:22:53 +02:00
parent 60795e447d
commit ee06557675
19 changed files with 107 additions and 8 deletions

Binary file not shown.

View File

@@ -283,6 +283,29 @@ namespace Logica
return hoek;
}
public PolygonPunten Peuker(PolygonPunten polygon, double epsilon)
{
double nX = Math.Abs(Math.Abs(polygon.MaximumX) - Math.Abs(polygon.MinimumX));
double nY = Math.Abs(Math.Abs(polygon.MaximumY) - Math.Abs(polygon.MinimumY));
epsilon = ((nX + nY) / 2) * epsilon;
polygon.Punten = Peuker(polygon.Punten, epsilon);
return polygon;
}
public MultiPolygonPunten Peuker(MultiPolygonPunten polygons, double epsilon)
{
double nX = Math.Abs(Math.Abs(polygons.MaximumX) - Math.Abs(polygons.MinimumX));
double nY = Math.Abs(Math.Abs(polygons.MaximumY) - Math.Abs(polygons.MinimumY));
epsilon = ((nX + nY) / 2) * epsilon;
foreach (PolygonPunten polygon in polygons.PolygonPunten)
{
polygon.Punten = Peuker(polygon.Punten, epsilon);
}
return polygons;
}
private List<Punt> Peuker(List<Punt> punten, double epsilon)
{
double dmax = -1;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -19,10 +19,11 @@
</Canvas>
<ListBox x:Name="lb" Margin="10,94,568,93" SelectionChanged="lb_SelectionChanged" SelectionMode="Multiple"/>
<Button x:Name="LoadFile" Content="LoadFile" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="27" Width="65" Click="LoadFile_Click"/>
<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"/>
<Slider x:Name="PeukerSlider" HorizontalAlignment="Left" Margin="10,406,0,0" VerticalAlignment="Top" Width="120" Maximum="100" SmallChange="1"/>
<Label x:Name="peukerPercentje" Content="Epsilon (0 - 0.1%)" HorizontalAlignment="Left" Margin="8,375,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="Triangulate" Content="Triangulate" HorizontalAlignment="Left" Margin="10,346,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="Scale" Content="Scale" HorizontalAlignment="Left" Margin="107,349,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="Scale" Content="Scale" HorizontalAlignment="Left" Margin="93,346,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="Peuker" Content="Peuker" HorizontalAlignment="Left" Margin="161,346,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>

View File

@@ -40,6 +40,8 @@ namespace opdracht2
ListBox l;
CheckBox triangulate;
CheckBox scale;
CheckBox peuker;
Slider peukerPercent;
PolygonManipulatie pm;
JsonReader j;
public MainWindow()
@@ -52,9 +54,11 @@ namespace opdracht2
buffer = new List<Polygon>();
InitializeComponent();
c = (Canvas)this.FindName("someCanvas");
peukerPercent = (Slider)this.FindName("PeukerSlider");
CompositionTarget.Rendering += DoUpdates;
l = (ListBox)this.FindName("lb");
triangulate = (CheckBox)this.FindName("Triangulate");
peuker = (CheckBox)this.FindName("Peuker");
scale = (CheckBox)this.FindName("Scale");
Debug.Write("done");
}
@@ -174,9 +178,12 @@ namespace opdracht2
foreach(MultiPolygonPunten mp in mpps)
{
MultiPolygonPunten mps = null;
if (peuker.IsChecked == true) mps = pm.Peuker(mp, peukerPercent.Value / 1000);
else mps = mp;
if (triangulate.IsChecked == true) //kan blkbr ook null zijn, raar
{
foreach(PolygonPunten pp in mp.PolygonPunten)
foreach(PolygonPunten pp in mps.PolygonPunten)
{
foreach(PolygonPunten ppd in pm.TriangulatePolygon(pp))
{
@@ -202,6 +209,7 @@ namespace opdracht2
c.Children.Clear();
MultiPolygonPunten mp = (MultiPolygonPunten)lb.SelectedItem;
if (scale.IsChecked == true) mp = pm.ScaleMultiPolygon(mp, 100, 100, 0, 0);
if (peuker.IsChecked == true) mp = pm.Peuker(mp, peukerPercent.Value/1000);
//hier ervoor zorgen dat scaling, triangulation etc gebeurt door gebruik van logica layer functies te callen
foreach (PolygonPunten pp in mp.PolygonPunten)
{
@@ -224,6 +232,7 @@ namespace opdracht2
c.Children.Clear();
PolygonPunten p = (PolygonPunten)lb.SelectedItem;
if (scale.IsChecked == true) p = pm.ScalePolygon(p, 10000, 10000, 0, 0);
if (peuker.IsChecked == true) p = pm.Peuker(p, peukerPercent.Value / 1000);
if (triangulate.IsChecked == true)
{
foreach(PolygonPunten pp in pm.TriangulatePolygon(p))

View File

@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "E92F073CEE6714AF0A5CB02DB34D14A9EC5D8B57"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "275AB0917A78CC675C19C07620AC1ABD563648FF"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -74,6 +74,22 @@ namespace opdracht2 {
#line hidden
#line 22 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Slider PeukerSlider;
#line default
#line hidden
#line 23 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label peukerPercentje;
#line default
#line hidden
#line 24 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.CheckBox Triangulate;
@@ -89,6 +105,14 @@ namespace opdracht2 {
#line default
#line hidden
#line 26 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.CheckBox Peuker;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
@@ -144,11 +168,20 @@ namespace opdracht2 {
#line hidden
return;
case 5:
this.Triangulate = ((System.Windows.Controls.CheckBox)(target));
this.PeukerSlider = ((System.Windows.Controls.Slider)(target));
return;
case 6:
this.peukerPercentje = ((System.Windows.Controls.Label)(target));
return;
case 7:
this.Triangulate = ((System.Windows.Controls.CheckBox)(target));
return;
case 8:
this.Scale = ((System.Windows.Controls.CheckBox)(target));
return;
case 9:
this.Peuker = ((System.Windows.Controls.CheckBox)(target));
return;
}
this._contentLoaded = true;
}

View File

@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "E92F073CEE6714AF0A5CB02DB34D14A9EC5D8B57"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "275AB0917A78CC675C19C07620AC1ABD563648FF"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -74,6 +74,22 @@ namespace opdracht2 {
#line hidden
#line 22 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Slider PeukerSlider;
#line default
#line hidden
#line 23 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label peukerPercentje;
#line default
#line hidden
#line 24 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.CheckBox Triangulate;
@@ -89,6 +105,14 @@ namespace opdracht2 {
#line default
#line hidden
#line 26 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.CheckBox Peuker;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
@@ -144,11 +168,20 @@ namespace opdracht2 {
#line hidden
return;
case 5:
this.Triangulate = ((System.Windows.Controls.CheckBox)(target));
this.PeukerSlider = ((System.Windows.Controls.Slider)(target));
return;
case 6:
this.peukerPercentje = ((System.Windows.Controls.Label)(target));
return;
case 7:
this.Triangulate = ((System.Windows.Controls.CheckBox)(target));
return;
case 8:
this.Scale = ((System.Windows.Controls.CheckBox)(target));
return;
case 9:
this.Peuker = ((System.Windows.Controls.CheckBox)(target));
return;
}
this._contentLoaded = true;
}