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.DoApplyLeveling(GetGCodeString(testUnleveled), testUnleveled);

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

            if (levelingData != null &&
                printerSettings?.GetValue <bool>(SettingsKey.print_leveling_enabled) == true &&
                (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
            {
                if (currentLevelingFunctions == null ||
                    currentProbeOffset != printerSettings.GetValue <double>(SettingsKey.z_probe_z_offset) ||
                    !levelingData.SamplesAreSame(currentLevelingFunctions.SampledPositions))
                {
                    currentProbeOffset       = printerSettings.GetValue <double>(SettingsKey.z_probe_z_offset);
                    currentLevelingFunctions = new LevelingFunctions(printerSettings, levelingData);
                }

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

            return(lineBeingSent);
        }