Added level sample cache

Added 100 point disk
This commit is contained in:
LarsBrubaker 2018-04-28 16:59:21 -07:00
parent bdc74fbdfc
commit 553e822e56
9 changed files with 116 additions and 31 deletions

View file

@ -0,0 +1,68 @@
/*
Copyright (c) 2018, Lars Brubaker
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Collections.Generic;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class LevelWizard100PointRadial : LevelWizardBase
{
public LevelWizard100PointRadial(PrinterConfig printer, ThemeConfig theme)
: base(printer, theme)
{
}
public override int ProbeCount => 100;
public override IEnumerable<Vector2> GetPrintLevelPositionToSample()
{
// the center
foreach (var sample in GetSampleRing(1, 0, 0))
{
yield return sample;
}
int[] ringCounts = { 3, 6, 12, 26, 52 };
double[] ringPhase = { 0, MathHelper.Tau * 2 / 3, MathHelper.Tau / 2, 26, 52 };
double step = .9 / 5;
// and several rings
for (int i = 0; i < 5; i++)
{
foreach (var sample in GetSampleRing(ringCounts[i], step + step * i, ringPhase[i]))
{
yield return sample;
}
}
}
}
}

View file

@ -46,31 +46,22 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public override IEnumerable<Vector2> GetPrintLevelPositionToSample()
{
double bedRadius = Math.Min(printer.Settings.GetValue<Vector2>(SettingsKey.bed_size).X, printer.Settings.GetValue<Vector2>(SettingsKey.bed_size).Y) / 2;
Vector2 bedCenter = printer.Settings.GetValue<Vector2>(SettingsKey.print_center);
// the center
yield return bedCenter;
foreach (var sample in GetSampleRing(1, 0, 0))
{
yield return sample;
}
// around an inner circle
int numberOfInnerSamples = 4;
for (int i = 0; i < numberOfInnerSamples; i++)
foreach (var sample in GetSampleRing(4, .45, 0))
{
Vector2 position = new Vector2(bedRadius * .45, 0);
position.Rotate(MathHelper.Tau / numberOfInnerSamples * i);
position += bedCenter;
yield return position;
yield return sample;
}
// around the outside
int numberOfOuterSamples = 8;
for (int i = 0; i < numberOfOuterSamples; i++)
foreach (var sample in GetSampleRing(8, .9, MathHelper.Tau * 3 / 4))
{
Vector2 position = new Vector2(bedRadius * .9, 0);
// the -MathHelper.Tau / 4 is to start out just under the last inner point
position.Rotate(MathHelper.Tau / numberOfOuterSamples * i - MathHelper.Tau / 4);
position += bedCenter;
yield return position;
yield return sample;
}
}
}

View file

@ -46,18 +46,16 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public override IEnumerable<Vector2> GetPrintLevelPositionToSample()
{
int numberOfRadialSamples = 6;
double bedRadius = Math.Min(printer.Settings.GetValue<Vector2>(SettingsKey.bed_size).X, printer.Settings.GetValue<Vector2>(SettingsKey.bed_size).Y) / 2;
Vector2 bedCenter = printer.Settings.GetValue<Vector2>(SettingsKey.print_center);
yield return bedCenter;
for (int i = 0; i < numberOfRadialSamples; i++)
// the center
foreach (var sample in GetSampleRing(1, 0, 0))
{
Vector2 position = new Vector2(bedRadius * .9, 0);
position.Rotate(MathHelper.Tau / numberOfRadialSamples * i);
position += bedCenter;
yield return position;
yield return sample;
}
// around the outside
foreach (var sample in GetSampleRing(6, .9, 0))
{
yield return sample;
}
}
}

View file

@ -295,6 +295,20 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
}
}
public IEnumerable<Vector2> GetSampleRing(int numberOfSamples, double ratio, double phase)
{
double bedRadius = Math.Min(printer.Settings.GetValue<Vector2>(SettingsKey.bed_size).X, printer.Settings.GetValue<Vector2>(SettingsKey.bed_size).Y) / 2;
Vector2 bedCenter = printer.Settings.GetValue<Vector2>(SettingsKey.print_center);
for (int i = 0; i < numberOfSamples; i++)
{
Vector2 position = new Vector2(bedRadius * ratio, 0);
position.Rotate(MathHelper.Tau / numberOfSamples * i + phase);
position += bedCenter;
yield return position;
}
}
public abstract IEnumerable<Vector2> GetPrintLevelPositionToSample();
private static LevelWizardBase CreateAndShowWizard(PrinterConfig printer, ThemeConfig theme)
@ -322,6 +336,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
printLevelWizardWindow = new LevelWizard13PointRadial(printer, theme);
break;
case LevelingSystem.Probe100PointRadial:
printLevelWizardWindow = new LevelWizard100PointRadial(printer, theme);
break;
case LevelingSystem.Probe3x3Mesh:
printLevelWizardWindow = new LevelWizardMesh(printer, 3, 3, theme);
break;

View file

@ -10,7 +10,7 @@ using System.Linq;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
[JsonConverter(typeof(StringEnumConverter))]
public enum LevelingSystem { Probe3Points, Probe7PointRadial, Probe13PointRadial, Probe3x3Mesh, Probe5x5Mesh, Probe10x10Mesh }
public enum LevelingSystem { Probe3Points, Probe7PointRadial, Probe13PointRadial, Probe100PointRadial, Probe3x3Mesh, Probe5x5Mesh, Probe10x10Mesh }
public class PrintLevelingData
{
@ -105,6 +105,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
}
break;
case LevelingSystem.Probe100PointRadial:
if (levelingData.SampledPositions.Count != 100) // different criteria for what is not initialized
{
return true;
}
break;
case LevelingSystem.Probe3x3Mesh:
if (levelingData.SampledPositions.Count != 9) // different criteria for what is not initialized
{