InterpolateZ() public method

public InterpolateZ ( double x, double y ) : double
x double
y double
return double
Esempio n. 1
0
        public GCodeFile ApplyHeightMap(HeightMap map)
        {
            double segmentLength = Math.Min(map.GridX, map.GridY);

            List <Command> newToolPath = new List <Command>();

            foreach (Command command in Toolpath)
            {
                if (command is Motion)
                {
                    Motion m = (Motion)command;

                    foreach (Motion subMotion in m.Split(segmentLength))
                    {
                        subMotion.Start.Z += map.InterpolateZ(subMotion.Start.X, subMotion.Start.Y);
                        subMotion.End.Z   += map.InterpolateZ(subMotion.End.X, subMotion.End.Y);

                        newToolPath.Add(subMotion);
                    }
                }
                else
                {
                    newToolPath.Add(command);
                    continue;
                }
            }

            return(new GCodeFile(newToolPath));
        }
Esempio n. 2
0
        public GCodeFile ApplyHeightMap(HeightMap map)
        {
            double segmentLength = Math.Min(map.GridX, map.GridY);

            List <Command> newToolPath = new List <Command>();

            foreach (Command command in Toolpath)
            {
                if (command is Motion)
                {
                    Motion m = (Motion)command;

                    if (m is Arc)
                    {
                        Arc a = m as Arc;
                        if (a.Plane != ArcPlane.XY)
                        {
                            throw new Exception("GCode contains arcs in YZ or XZ plane (G18/19), can't apply height map. Use 'Arcs to Lines' if you really need this.");
                        }
                    }

                    if (m is Line)
                    {
                        Line l = (Line)m;

                        // do not split up or modify any lines that are rapid or not fully defined
                        if (l.PositionValid.Any(isValid => !isValid) || l.Rapid)
                        {
                            newToolPath.Add(l);
                            continue;
                        }
                    }

                    foreach (Motion subMotion in m.Split(segmentLength))
                    {
                        subMotion.Start.Z += map.InterpolateZ(subMotion.Start.X, subMotion.Start.Y);
                        subMotion.End.Z   += map.InterpolateZ(subMotion.End.X, subMotion.End.Y);

                        newToolPath.Add(subMotion);
                    }
                }
                else
                {
                    newToolPath.Add(command);
                    continue;
                }
            }

            return(new GCodeFile(newToolPath));
        }
Esempio n. 3
0
        public GCodeFile ApplyHeightMap(HeightMap map)
        {
            double segmentLength = Math.Min(map.GridX, map.GridY);

            List <Command> newToolPath = new List <Command>();

            foreach (Command command in Toolpath)
            {
                if (command is Motion)
                {
                    Motion m = (Motion)command;

                    if (m is Arc)
                    {
                        Arc a = m as Arc;
                        if (a.Plane != ArcPlane.XY)
                        {
                            throw new Exception("GCode contains arcs in YZ or XZ plane (G18/19), can't apply HeightMap. Use Arcs to Lines if you really need this.");
                        }
                    }

                    foreach (Motion subMotion in m.Split(segmentLength))
                    {
                        subMotion.Start.Z += map.InterpolateZ(subMotion.Start.X, subMotion.Start.Y);
                        subMotion.End.Z   += map.InterpolateZ(subMotion.End.X, subMotion.End.Y);

                        newToolPath.Add(subMotion);
                    }
                }
                else
                {
                    newToolPath.Add(command);
                    continue;
                }
            }

            return(new GCodeFile(newToolPath));
        }
Esempio n. 4
0
		public GCodeFile ApplyHeightMap(HeightMap map)
		{
			double segmentLength = Math.Min(map.GridX, map.GridY);

			List<Command> newToolPath = new List<Command>();

			foreach (Command command in Toolpath)
			{
				if (command is MCode)
				{
					newToolPath.Add(command);
					continue;
				}
				else
				{
					Motion m = (Motion)command;

					foreach (Motion subMotion in m.Split(segmentLength))
					{
						subMotion.Start.Z += map.InterpolateZ(subMotion.Start.X, subMotion.Start.Y);
						subMotion.End.Z += map.InterpolateZ(subMotion.End.X, subMotion.End.Y);

						newToolPath.Add(subMotion);
					}
				}
			}

			return new GCodeFile(newToolPath);
		}