void CutHorizontalStrip(Section section, Rectangle rect) { CutMatcher matcher = new CutMatcher(); matcher.Bounds = rect; List <Line> sectionCuts = new List <Line>(); BazUtils.TakeFrom(_cuts, sectionCuts, matcher.MatchVerticalCut); if (sectionCuts.Count > 0) { sectionCuts.Sort(BazUtils.VertCutsComparer); double from = rect.LeftBottom.X; Section right = section; foreach (Line cut in sectionCuts) { Section left = _scheme.Cut(right, (decimal)((cut.P1.X - from - _cutterThick / 2.0) * 10.0), CutType.Vertical, out right); //_scheme.MakeSureEdgeEven(ref left, CutType.Vertical); CutVerticalStrip(left, rect.VerticalStrip(from, cut.P1.X - _cutterThick / 2.0)); from = cut.P1.X + _cutterThick / 2.0; } if (right != null) { CutVerticalStrip(right, rect.VerticalStrip(from, rect.RightTop.X)); } } else { Text text = BazUtils.FindText(rect, _texts); if (text != null) { section.SectionType = SectionType.Element; section.Label = text.Value; } else { section.SectionType = SectionType.Scrap; } } }
void CutVerticalStrip(Section section, Rectangle rect) { CutMatcher matcher = new CutMatcher(); matcher.Bounds = rect; List <Line> sectionCuts = new List <Line>(); BazUtils.TakeFrom(_cuts, sectionCuts, matcher.MatchHorizontalCut); if (sectionCuts.Count > 0) { sectionCuts.Sort(BazUtils.HorzCutsComparer); double from = rect.LeftBottom.Y; Section top = section; foreach (Line cut in sectionCuts) { Section bottom = _scheme.Cut(top, (decimal)((cut.P1.Y - from - _cutterThick / 2.0) * 10.0), CutType.Horizontal, out top); _scheme.MakeSureEdgeEven(ref bottom, CutType.Horizontal); CutHorizontalStrip(bottom, rect.HorizStrip(from, cut.P1.Y - _cutterThick / 2.0)); from = cut.P1.Y + _cutterThick / 2.0; } if (top != null) { CutHorizontalStrip(top, rect.HorizStrip(from, rect.RightTop.Y)); } } else // деталь { Text text = BazUtils.FindText(rect, _texts); if (text != null) { section.SectionType = SectionType.Element; section.Label = text.Value; } else { section.SectionType = SectionType.Scrap; } } }