public ModelPathEntity Clone() { var m = new ModelPathEntity(); m.IntersectionIndices.AddRange(IntersectionIndices); m.ActiveMcodes.AddRange(ActiveMcodes); m.Ccomp = Ccomp; m.CcompTangent = CcompTangent; m.ContainsF = ContainsF; m.ContainsX = ContainsX; m.ContainsY = ContainsY; m.ContainsZ = ContainsZ; m.ControlFlag = ControlFlag; m.CumulativeTime = CumulativeTime; m.Depth = Depth; m.DirVector = new Vector3(DirVector); m.Feedrate = new Feedrate(Feedrate); m.JetOn = JetOn; m.JetVector = new Vector3(JetVector); m.Length = Length; m.PathNumber = PathNumber; m.LineNumber = LineNumber; m.Position = new CNCLib.XYZBCMachPosition(); m.SurfNormal = new Vector3(SurfNormal); m.TargetDepth = TargetDepth; m.TravelTime = TravelTime; m.Type = Type; return(m); }
private ModelPathEntity interpolateLine(PathEntity5Axis p1, PathEntity5Axis p2, double currentTime) { ModelPathEntity mpe = new ModelPathEntity(p2); double dt = currentTime - p1.CumulativeTime; if (p1.Type == BlockType.FiveAxis) { isFiveAxis = true; } else { p1.JetVector = GeometryLib.Vector3.ZAxis; } if (p2.Type == BlockType.FiveAxis) { isFiveAxis = true; } else { p2.JetVector = GeometryLib.Vector3.ZAxis; } mpe.Position = interpolatePosition(p1, p2, currentTime); mpe.JetVector = interpolateVector(p1, p2, currentTime); return(mpe); }
private ModelPathEntity interpolateArc(PathEntity5Axis p1, PathEntity5Axis p2, double currentTime) { ModelPathEntity mpe = new ModelPathEntity(p2); ArcPathEntity arc = p2 as ArcPathEntity; double dt = currentTime - p1.CumulativeTime; mpe.Position = getNewArcEndpoint(arc, dt); return(mpe); }
private ModelPathEntity interpolate(PathEntity5Axis p1, PathEntity5Axis p2, double currentTime, double timeInc) { ModelPathEntity mpe = new ModelPathEntity(p1); if (p2 is LinePathEntity) { mpe = interpolateLine(p1, p2, currentTime); } if (p2 is ArcPathEntity) { mpe = interpolateArc(p1, p2, currentTime); } if (p2 is DelayPathEntity) { mpe = interpolateDelay(p1, p2, currentTime); } mpe.CumulativeTime = currentTime; mpe.TravelTime = timeInc; return(mpe); }
private List <ModelPathEntity> parseArc(double increment, PathEntity5Axis entity, CNCLib.XYZBCMachPosition startPoint) { try { List <ModelPathEntity> path = new List <ModelPathEntity>(); ArcPathEntity arc = entity as ArcPathEntity; Vector3 vEnd = new GeometryLib.Vector3(arc.Position.X, arc.Position.Y, arc.Position.Z); Vector3 vStart = new Vector3(startPoint.X, startPoint.Y, startPoint.Z); double segLength = Math.Abs(arc.SweepAngle * arc.Radius); int parseCount = (int)Math.Round(segLength / increment); if (parseCount == 0) { parseCount = 1; } double dA = arc.SweepAngle / parseCount; for (int j = 0; j < parseCount; j++) { ModelPathEntity pathSeg = new ModelPathEntity(arc); pathSeg.Position = getNewArcEndpoint(arc, j * dA); if (entity.JetOn == true) { pathSeg.JetOn = true; } else { pathSeg.JetOn = false; } path.Add(pathSeg); } return(path); } catch (Exception) { throw; } }
private List <ModelPathEntity> parseLine(double increment, PathEntity5Axis p2, PathEntity5Axis p1) { try { List <ModelPathEntity> path = new List <ModelPathEntity>(); double segLength = p2.Position.DistanceTo(p1.Position); int parseCount = (int)Math.Round(segLength / increment); if (parseCount == 0) { parseCount = 1; } if (p1.Type == BlockType.FiveAxis) { isFiveAxis = true; } else { p1.JetVector = GeometryLib.Vector3.ZAxis; } if (p2.Type == BlockType.FiveAxis) { isFiveAxis = true; } else { p2.JetVector = GeometryLib.Vector3.ZAxis; } double dx = p2.Position.X - p1.Position.X; double dy = p2.Position.Y - p1.Position.Y; double dz = p2.Position.Z - p1.Position.Z; double db = p2.Position.Bdeg - p1.Position.Bdeg; double dc = p2.Position.Cdeg - p1.Position.Cdeg; double dvx = p2.JetVector.X - p1.JetVector.X; double dvy = p2.JetVector.Y - p1.JetVector.Y; double dvz = p2.JetVector.Z - p1.JetVector.Z; if (Math.Abs(dc) > .5 || Math.Abs(db) > .5) { isFiveAxis = true; } double pathsegF = p2.Feedrate.Value; for (int j = 0; j < parseCount; j++) { ModelPathEntity pathSeg = new ModelPathEntity(p2); //calc new position pathSeg.Position = new CNCLib.XYZBCMachPosition(); pathSeg.Position.X = p1.Position.X + j * dx / parseCount; pathSeg.Position.Y = p1.Position.Y + j * dy / parseCount; pathSeg.Position.Z = p1.Position.Z + j * dz / parseCount; pathSeg.Position.Bdeg = p1.Position.Bdeg + j * db / parseCount; pathSeg.Position.Cdeg = p1.Position.Cdeg + j * dc / parseCount; //calc new jet vector double vx = p1.JetVector.X + j * dvx / parseCount; double vy = p1.JetVector.Y + j * dvy / parseCount; double vz = p1.JetVector.Z + j * dvz / parseCount; pathSeg.JetVector = new GeometryLib.Vector3(vx, vy, vz); if (p2.Feedrate.Inverted) { pathSeg.Feedrate.Value = pathsegF; } else { pathSeg.Feedrate.Value = p2.Feedrate.Value; } if (p2.JetOn == true) { pathSeg.JetOn = true; } else { pathSeg.JetOn = false; } path.Add(pathSeg); } return(path); } catch (Exception) { throw; } }
private ModelPathEntity interpolateDelay(PathEntity5Axis p1, PathEntity5Axis p2, double currentTime) { ModelPathEntity mpe = new ModelPathEntity(p1); return(mpe); }