Beispiel #1
0
        void AssertMeshLevelPoint(Vector3 testUnleveled, Vector3 controlLeveled, LevelingFunctions levelingFunctions)
        {
            Vector3 testLeveled = levelingFunctions.GetPositionWithZOffset(testUnleveled);

            Assert.AreEqual(testLeveled.X, testUnleveled.X, .001, "We don't adjust the x or y on mesh leveling");
            Assert.AreEqual(testLeveled.X, controlLeveled.X, .001, "We don't adjust the x or y on mesh leveling");
            Assert.AreEqual(testLeveled.Y, testUnleveled.Y, .001, "We don't adjust the x or y on mesh leveling");
            Assert.AreEqual(testLeveled.Y, controlLeveled.Y, .001, "We don't adjust the x or y on mesh leveling");
            Assert.AreEqual(testLeveled.Z, controlLeveled.Z, .001);
            string outPositionString = levelingFunctions.ApplyLeveling(GetGCodeString(testUnleveled), testUnleveled);

            Assert.AreEqual(GetGCodeString(testLeveled), outPositionString);
        }
        private string GetLeveledPosition(string lineBeingSent, PrinterMove currentDestination)
        {
            PrintLevelingData levelingData = printer.Settings.Helpers.PrintLevelingData;

            if (levelingData != null &&
                printer.Settings?.GetValue <bool>(SettingsKey.print_leveling_enabled) == true &&
                (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
            {
                if (currentLevelingFunctions == null ||
                    currentProbeZOffset != printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset) ||
                    !levelingData.SamplesAreSame(currentLevelingFunctions.SampledPositions))
                {
                    currentProbeZOffset      = printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset);
                    currentLevelingFunctions = new LevelingFunctions(printer, levelingData);
                }

                lineBeingSent = currentLevelingFunctions.ApplyLeveling(lineBeingSent, currentDestination.position);
            }

            return(lineBeingSent);
        }