/// <summary> /// Calculate the extrusion and travel times /// </summary> public void Calculate() { // [TODO] could do this inline... // filter paths List <IToolpath> allPaths = new List <IToolpath>(); foreach (IToolpath ipath in Paths) { ToolpathUtil.ApplyToLeafPaths(ipath, (p) => { if (p is LinearToolpath3 <PrintVertex> ) { allPaths.Add(p); } }); } int N = allPaths.Count; TimeStatistics = new PrintTimeStatistics(); for (int pi = 0; pi < N; ++pi) { LinearToolpath3 <PrintVertex> path = allPaths[pi] as LinearToolpath3 <PrintVertex>; if (path == null || (path.Type != ToolpathTypes.Deposition && path.Type != ToolpathTypes.Travel)) { continue; } double path_time = 0; Vector3d curPos = path[0].Position; for (int i = 1; i < path.VertexCount; ++i) { bool last_vtx = (i == path.VertexCount - 1); Vector3d newPos = path[i].Position; double newRate = path[i].FeedRate; double dist = (newPos - curPos).Length; double rate_mm_per_s = newRate / 60; // feed rates are in mm/min path_time += dist / rate_mm_per_s; curPos = newPos; } if (path.Type == ToolpathTypes.Deposition) { TimeStatistics.ExtrudeTimeS += path_time; } else { TimeStatistics.TravelTimeS += path_time; } } } // Calculate()
public void Add(PrintTimeStatistics other) { ExtrudeTimeS += other.ExtrudeTimeS; TravelTimeS += other.TravelTimeS; }