OpenCNCPilot.GCode.HeightMap.FillWithTestPattern C# (CSharp) Method

FillWithTestPattern() public method

public FillWithTestPattern ( string pattern ) : void
pattern string
return void
		public void FillWithTestPattern(string pattern)
		{
			DataTable t = new DataTable();

			for (int x = 0; x < SizeX; x++)
			{
				for (int y = 0; y < SizeY; y++)
				{
					double X = (x * (Max.X - Min.X)) / (SizeX - 1) + Min.X;
					double Y = (y * (Max.Y - Min.Y)) / (SizeY - 1) + Min.Y;

					decimal d = (decimal)t.Compute(pattern.Replace("x", X.ToString()).Replace("y", Y.ToString()), "");
					AddPoint(x, y, (double)d);
				}
			}
		}

Usage Example

		private void NewHeightMapDialog_Size_Ok()
		{
			if (machine.Mode == Machine.OperatingMode.Probe || Map != null)
				return;

			Map = new HeightMap(NewHeightMapDialog.GridSize, NewHeightMapDialog.Min, NewHeightMapDialog.Max);
			
			if (NewHeightMapDialog.GenerateTestPattern)
			{
				try
				{
					Map.FillWithTestPattern(NewHeightMapDialog.TestPattern);
					Map.NotProbed.Clear();
				}
				catch { MessageBox.Show("Error in test pattern"); }
			}

			Map.MapUpdated += Map_MapUpdated;
			UpdateProbeTabButtons();
			Map_MapUpdated();
		}