public GroupObject(string tmpKey, int tnr, string tname, PathObject pathObject) { key = tmpKey; toolNr = tnr; toolName = tname; groupRelatedGCode = ""; pathDimension = new Dimensions(); pathDimension.addDimensionXY(pathObject.Dimension); groupPath = new List <PathObject>(); groupPath.Add(pathObject); AddInfo(pathObject); }
public GroupObject(GroupObject tmp) { key = tmp.key; toolNr = tmp.toolNr; toolName = tmp.toolName; groupRelatedGCode = tmp.groupRelatedGCode; pathDimension = new Dimensions(); pathDimension.addDimensionXY(tmp.pathDimension); groupId = tmp.groupId; groupPath = new List <PathObject>(); foreach (PathObject tmpPath in tmp.groupPath) { groupPath.Add(tmpPath); } }
public static void HatchFill(List <PathObject> graphicToFill) { double distance = (double)Properties.Settings.Default.importGraphicHatchFillDistance; double angle = (double)Properties.Settings.Default.importGraphicHatchFillAngle; double angle2 = (double)Properties.Settings.Default.importGraphicHatchFillAngle2; bool cross = Properties.Settings.Default.importGraphicHatchFillCross; bool incrementAngle = Properties.Settings.Default.importGraphicHatchFillAngleInc; bool nextIsSameHatch; bool fillColor = graphicInformation.ApplyHatchFill; // only hatch if fillColor is set Logger.Trace("...HatchFill distance:{0} angle:{1} cross:{2}", distance, angle, cross); List <Point[]> hatchPattern = new List <Point[]>(); List <Point[]> finalPattern = new List <Point[]>(); int maxObject = graphicToFill.Count; List <PathObject> tmpPath = new List <PathObject>(); Dimensions pathDimension = new Dimensions(); for (int index = 0; index < maxObject; index++) { PathObject item = graphicToFill[index]; if (item is ItemPath) { ItemPath PathData = (ItemPath)item; // is closed polygon? if (isEqual(PathData.Start, PathData.End) && (PathData.path.Count > 2)) //(PathData.Start.X == PathData.End.X) && (PathData.Start.Y == PathData.End.Y)) { string fill = PathData.Info.groupAttributes[(int)GroupOptions.ByFill]; if (fillColor && ((fill == "") || (fill == "none"))) // SVG: only hatch if fillColor is set { Logger.Trace("no fill"); continue; } else { countProperty((int)GroupOptions.ByColor, fill); // now fill-color is also penColor -> for grouping } tmpPath.Add(PathData); // collect paths pathDimension.addDimensionXY(PathData.Dimension); // adapt overall size if (!pathDimension.isXYSet()) // no dimension - nothing to do { Logger.Trace("no dim"); continue; } // collect paths of same id, process if id changes // nextIsSameHatch = ((index != (maxObject - 1)) && (graphicToFill[index].Info.id == graphicToFill[index + 1].Info.id)); nextIsSameHatch = ((index < (maxObject - 1)) && (graphicToFill[index].Info.id == graphicToFill[index + 1].Info.id)); if (logModification) { Logger.Trace(" Add to PathData ID:{0} nextIsSameHatch:{1} max:{2} index:{3} id_now:{4} id_next:{5} fill:{6}", PathData.Info.id, nextIsSameHatch, maxObject, index, graphicToFill[index].Info.id, graphicToFill[index + 1].Info.id, fill); } if (nextIsSameHatch) { continue; } // create hatch pattern hatchPattern.Clear(); hatchPattern.AddRange(CreateLinePattern(pathDimension, angle, distance)); if (cross) { hatchPattern.AddRange(CreateLinePattern(pathDimension, angle + 90, distance)); } if (incrementAngle) { angle += angle2; } // process single hatch lines - shorten to match inside polygone finalPattern.Clear(); foreach (Point[] hatchLine in hatchPattern) { ClipLineByPolygone(hatchLine[0], hatchLine[1], tmpPath, finalPattern); } // add processed hatch lines to final graphic AddLinesToGraphic(finalPattern, PathData); // tidy up for next object with new id tmpPath.Clear(); pathDimension = new Dimensions(); } } else { if (logModification) { Logger.Trace(" is Dot ID:{0} Length:{1:0.00} start x:{2:0.00} y:{3:0.00} end x:{4:0.00} y:{5:0.00} ", item.Info.id, item.PathLength, item.Start.X, item.Start.Y, item.End.X, item.End.Y); } } } if (logModification) { Logger.Trace("HatchFill End --------------------------------------", actualDimension.minx, actualDimension.miny); } }
public void AddInfo(PathObject pathObject) { //groupPath.Add(pathObject); pathLength += pathObject.PathLength; pathDimension.addDimensionXY(pathObject.Dimension); pathArea = pathDimension.getArea(); }
public static void HatchFill(List <PathObject> graphicToFill) { double distance = (double)Properties.Settings.Default.importGraphicHatchFillDistance; double angle = (double)Properties.Settings.Default.importGraphicHatchFillAngle; double angle2 = (double)Properties.Settings.Default.importGraphicHatchFillAngle2; bool cross = Properties.Settings.Default.importGraphicHatchFillCross; bool incrementAngle = Properties.Settings.Default.importGraphicHatchFillAngleInc; bool nextIsSameHatch; Logger.Trace("...HatchFill distance:{0} angle:{1} cross:{3}", distance, angle, cross); List <Point[]> hatchPattern = new List <Point[]>(); List <Point[]> finalPattern = new List <Point[]>(); int maxObject = graphicToFill.Count; List <PathObject> tmpPath = new List <PathObject>(); Dimensions pathDimension = new Dimensions(); for (int index = 0; index < maxObject; index++) { PathObject item = graphicToFill[index]; if (item is ItemPath) { ItemPath PathData = (ItemPath)item; // is closed polygon? if (isEqual(PathData.Start, PathData.End) && (PathData.path.Count > 2)) //(PathData.Start.X == PathData.End.X) && (PathData.Start.Y == PathData.End.Y)) { tmpPath.Add(PathData); // collect paths pathDimension.addDimensionXY(PathData.Dimension); // adapt overall size // collect paths of same id, process if id changes nextIsSameHatch = ((index != (maxObject - 1)) && (graphicToFill[index].Info.id == graphicToFill[index + 1].Info.id)); if ((logFlags & (uint)LogEnable.PathModification) > 0) { Logger.Trace(" Add to PathData ID:{0} nextIsSameHatch:{1} ", PathData.Info.id, nextIsSameHatch); } if (nextIsSameHatch) { continue; } // create hatch pattern hatchPattern.Clear(); hatchPattern.AddRange(CreateLinePattern(pathDimension, angle, distance)); if (cross) { hatchPattern.AddRange(CreateLinePattern(pathDimension, angle + 90, distance)); } if (incrementAngle) { angle += angle2; } // process single hatch lines - shorten to match inside polygone finalPattern.Clear(); foreach (Point[] hatchLine in hatchPattern) { ClipLineByPolygone(hatchLine[0], hatchLine[1], tmpPath, finalPattern); } // add processed hatch lines to final graphic if ((logFlags & (uint)LogEnable.PathModification) > 0) { Logger.Trace(" Add hatch lines, clear tmpPath"); } AddLinesToGraphic(finalPattern, PathData); // tidy up for next object with new id tmpPath.Clear(); pathDimension = new Dimensions(); } } else { if ((logFlags & (uint)LogEnable.PathModification) > 0) { Logger.Trace(" is Dot ID:{0} Length:{1:0.00} start x:{2:0.00} y:{3:0.00} end x:{4:0.00} y:{5:0.00} ", item.Info.id, item.PathLength, item.Start.X, item.Start.Y, item.End.X, item.End.Y); } } } if ((logFlags) > 0) { Logger.Trace("HatchFill End --------------------------------------", actualDimension.minx, actualDimension.miny); } }