public override void Transform(Matrix4x4 transformationMatrixIn) { for (int i = 0; i < Points.Count; i++) { Points[i].Transform(transformationMatrixIn); } Width = GeometricArithmeticModule.ABSMeasure2D(TopLeftPoint, TopRightPoint); Height = GeometricArithmeticModule.ABSMeasure2D(TopLeftPoint, BottomLeftPoint); Update(); }
public bool GenerateHatches(MHatchSettings settings) { HatchLines.Clear(); _totalHatchesJumpDistance = 0; _totalHatchesMarkDistance = 0; var lines = new List <MarkGeometryLine>(); var angleRad = GeometricArithmeticModule.ToRadians(settings.Angle); var size = Extents.Hypotenuse; var howmany = (int)Math.Ceiling(size / settings.Pitch); var yStart = Extents.Centre.Y - (0.5 * size); // generate lines to calculate intersections for hatch if (settings.Style == HatchStyle.RASTER || settings.Style == HatchStyle.RASTER_GRID) { for (int i = 0; i < howmany; i++) { double y = yStart + (i * settings.Pitch); var line = new MarkGeometryLine( new MarkGeometryPoint( -size + Extents.Centre.X, y ), new MarkGeometryPoint( size + Extents.Centre.X, y ) ); // apply angular rotation GeometricArithmeticModule.Rotate(line, 0, 0, angleRad, Extents.Centre.X, Extents.Centre.Y, Extents.Centre.Z); lines.Add(line); } } else if (settings.Style == HatchStyle.SERPENTINE || settings.Style == HatchStyle.SERPENTINE_GRID) { for (int i = 0; i < howmany; i++) { double y = yStart + (i * settings.Pitch); if (i % 2 == 0) { var line = new MarkGeometryLine( new MarkGeometryPoint( -size + Extents.Centre.X, y ), new MarkGeometryPoint( size + Extents.Centre.X, y ) ); // apply angular rotation GeometricArithmeticModule.Rotate(line, 0, 0, angleRad, Extents.Centre.X, Extents.Centre.Y, Extents.Centre.Z); lines.Add(line); } else { var line = new MarkGeometryLine( new MarkGeometryPoint( size + Extents.Centre.X, y ), new MarkGeometryPoint( -size + Extents.Centre.X, y ) ); // apply angular rotation GeometricArithmeticModule.Rotate(line, 0, 0, angleRad, Extents.Centre.X, Extents.Centre.Y, Extents.Centre.Z); lines.Add(line); } } } // duplicate lines if using grid var perpendicularAngleForGridLines = GeometricArithmeticModule.ToRadians(90); if (settings.Style == HatchStyle.RASTER_GRID || settings.Style == HatchStyle.SERPENTINE_GRID) { int startIndex = lines.Count - 1; for (int i = startIndex; i >= 0; i--) { var ln = (MarkGeometryLine)lines[i].Clone(); GeometricArithmeticModule.Rotate(ln, 0, 0, perpendicularAngleForGridLines, Extents.Centre.X, Extents.Centre.Y, Extents.Centre.Z); lines.Add(ln); } } // used to track jumps MarkGeometryPoint lastPoint = null; // generate hatch lines with extension for (int i = 0; i < lines.Count; i++) { List <MarkGeometryPoint> intersections = _contourQuadTree.Intersect(lines[i])?.ToList(); if (intersections == null) { continue; } int startIndex = (settings.Invert) ? 1 : 0; int endIndex = intersections.Count - 1; while (startIndex < endIndex) { var hatch = new MarkGeometryLine( intersections[startIndex], intersections[startIndex + 1] ); HatchLines.Add(hatch); // increase mark and jump distance if (lastPoint != null) { _totalHatchesJumpDistance += GeometricArithmeticModule.ABSMeasure2D( lastPoint, hatch.StartPoint ); } _totalHatchesMarkDistance += hatch.Length; lastPoint = hatch.EndPoint; startIndex += 2; } } return(true); }
public TimeSpan EstimateProcessTime(MRecipeDeviceLayer layer) { const double kConst = 0.000001; double totalTaktTime = 0; IMarkParametersComplete processParams = FetchDXFParameters(layer); if (processParams == null) { return(TimeSpan.Zero); } int numOfJoints = 0; double jumpDistance = 0; double markDistance = 0; double minX = double.MaxValue; double minY = double.MaxValue; double maxX = double.MinValue; double maxY = double.MinValue; MarkGeometryPoint lastPosition = null; foreach (var geometry in FetchDXF(layer)) { if (geometry is MarkGeometryPoint point) { if (lastPosition != null) { jumpDistance += GeometricArithmeticModule.ABSMeasure2D(lastPosition, point); } markDistance += point.Perimeter; lastPosition = point; } else if (geometry is MarkGeometryLine line) { if (lastPosition != null) { jumpDistance += GeometricArithmeticModule.ABSMeasure2D(lastPosition, line.StartPoint); } markDistance += line.Perimeter; lastPosition = line.EndPoint; } else if (geometry is MarkGeometryCircle circle) { if (lastPosition != null) { jumpDistance += GeometricArithmeticModule.ABSMeasure2D( lastPosition, GeometricArithmeticModule.GetPointAtPosition( circle, 0 ) ); } markDistance += circle.Perimeter; numOfJoints += Math.Max(circle.VertexCount - 1, 0); lastPosition = GeometricArithmeticModule.GetPointAtPosition(circle, 1.0); } else if (geometry is MarkGeometryArc arc) { if (lastPosition != null) { jumpDistance += GeometricArithmeticModule.ABSMeasure2D(lastPosition, arc.StartPoint); } markDistance += arc.Perimeter; numOfJoints += Math.Max(arc.VertexCount - 1, 0); lastPosition = arc.EndPoint; } else if (geometry is MarkGeometryPath path) { if (lastPosition != null) { jumpDistance += GeometricArithmeticModule.ABSMeasure2D(lastPosition, path.StartPoint); } markDistance += path.Perimeter; numOfJoints += Math.Max(path.Points.Count - 1, 0); lastPosition = path.EndPoint; } if (geometry.Extents.MinX < minX) { minX = geometry.Extents.MinX; } if (geometry.Extents.MinY < minY) { minY = geometry.Extents.MinY; } if (geometry.Extents.MaxX > maxX) { maxX = geometry.Extents.MaxX; } if (geometry.Extents.MaxY > maxY) { maxY = geometry.Extents.MaxY; } } double taktTime = ( (markDistance / processParams.MarkSpeed) + (jumpDistance / processParams.JumpSpeed) + (kConst * numOfJoints * (processParams.JumpDelay_us + processParams.MarkDelay - processParams.Nprev)) ); // account for repeats and stepping between tiles - convert millisecond to second totalTaktTime += ((taktTime * processParams.Passes) + (0.001 * layer.TileDescriptions.Count() * processParams.SettlingTimems)); return(TimeSpan.FromSeconds(Math.Round(totalTaktTime, 4))); }
public static bool IsLesser(MarkGeometryPoint origin, MarkGeometryPoint p1, MarkGeometryPoint p2) { return(GeometricArithmeticModule.ABSMeasure2D(origin, p1) < GeometricArithmeticModule.ABSMeasure2D(origin, p2)); }