public OptionArea NewByOffsetS(List <OffsetInfo> offsetInfos) { var newOptionArea = new OptionArea() { Options = this.Options, WidthInterval = this.WidthInterval, HeightInterval = this.HeightInterval }; var offsetCol = OffsetInfo.GetNearestByColumn(offsetInfos, this.Area); var offsetRow = OffsetInfo.GetNearestByRow(offsetInfos, this.Area); int xAvgCount = 0, yavgCount = 0; xAvgCount += offsetCol.offsetX == 0 ? 0 : 1; xAvgCount += offsetRow.offsetX == 0 ? 0 : 1; yavgCount += offsetCol.offsetY == 0 ? 0 : 1; yavgCount += offsetRow.offsetY == 0 ? 0 : 1; newOptionArea.Area = CVHelper.MoveRect(this.Area, (offsetCol.offsetX + offsetRow.offsetX), (offsetCol.offsetY + offsetRow.offsetY)); return(newOptionArea); }
public Paper NewPaperByOffsetS(List <OffsetArea> newOffsetAreaList) { var paper = new Paper(); //列偏移模块 var newColOffsetList = new List <Rectangle>(); //相对0,0 var originalColOffsetList = new List <Rectangle>(); //相对0,0 //行偏移模块 var newRowOffsetList = new List <Rectangle>(); //相对0,0 var originalRowOffsetList = new List <Rectangle>(); //相对0,0 newOffsetAreaList.ForEach(a => { if (a.OffsetType == OffsetType.Column) { newColOffsetList.AddRange(CVHelper.MoveRects(a.OffsetList, a.Area.X, a.Area.Y)); } else { newRowOffsetList.AddRange(CVHelper.MoveRects(a.OffsetList, a.Area.X, a.Area.Y)); } }); //tmpColOffsetList = tmpColOffsetList.OrderBy(r => r.Y).ToList(); this.OffsetAreas.ForEach(a => { if (a.OffsetType == OffsetType.Column) { originalColOffsetList.AddRange(CVHelper.MoveRects(a.OffsetList, a.Area.X, a.Area.Y)); } else { originalRowOffsetList.AddRange(CVHelper.MoveRects(a.OffsetList, a.Area.X, a.Area.Y)); } }); //originalColOffsetList = originalColOffsetList.OrderBy(r => r.Y).ToList(); var offsetInfoList = OffsetInfo.NewListByColumn(originalColOffsetList, newColOffsetList); offsetInfoList.AddRange(OffsetInfo.NewListByRow(originalRowOffsetList, newRowOffsetList)); //定位点 暂不处理 paper.FixedPoint = this.FixedPoint.NewFixedPointByOffset(0, 0); //选项区域 this.OptionAreaList.ForEach(o => { paper.OptionAreaList.Add(o.NewByOffsetS(offsetInfoList)); }); //偏移量 this.OffsetAreas.ForEach(a => { if (a.OffsetType == OffsetType.Column) { var tmpList = OffsetInfo.GetRectsByAreaAndCol(newColOffsetList, a.Area); paper.OffsetAreas.Add(new OffsetArea(a.Area, tmpList, a.OffsetType)); } else { var tmpList = OffsetInfo.GetRectsByAreaAndRow(newRowOffsetList, a.Area); paper.OffsetAreas.Add(new OffsetArea(a.Area, tmpList, a.OffsetType)); } }); return(paper); }