public List <PointAxis2d> GetGridLineIntersections(List <RangeAxis2d> gridAxes) { if (gridAxes == null) { return(null); } List <PointAxis2d> pointAxes = new List <PointAxis2d>(); foreach (RangeAxis2d gridAxis in gridAxes) { PointAxis2d pointAxis = new PointAxis2d(m_basis, gridAxis.Ordinal); pointAxes.Add(pointAxis); foreach (Polygon2d polygon in m_outline.Polygons) { if (polygon != null) { GetAxisIntersections(gridAxis, polygon, ref pointAxis); } } } return(pointAxes); }
internal void GetAxisIntersections(RangeAxis2d gridAxis, Polygon2d polygon, ref PointAxis2d pointAxis) { if (polygon == null) { return; } List <Line2d> lines = polygon.Lines; if (lines == null) { return; } foreach (RangeAxis2d.Value axisValue in gridAxis.CreateExtentsList()) { for (int index = 0; index < lines.Count; ++index) { Line2d test = axisValue.ToLine(m_basis, gridAxis.Ordinal); Line2d other = lines[index]; Point2d point = test.Intersect(other, true); if (PointIsValid(point, other)) { pointAxis.Add(PointAxis2d.Value.FromPoint2d(m_basis, gridAxis.Ordinal, point, true)); } } } }
internal RangeAxis2d GetAxisSegments(PointAxis2d intersections) { int ordinal = intersections.Ordinal; RangeAxis2d collinearSegments = new RangeAxis2d(m_basis, ordinal); foreach (Polygon2d polygon in m_outline.Polygons) { foreach (Line2d line in polygon.Lines) { RangeAxis2d.Value value = RangeAxis2d.Value.FromLine2d(m_basis, ordinal, line, false); if (value != null) { collinearSegments.Add(value); } } } RangeAxis2d segments = new RangeAxis2d(m_basis, ordinal); foreach (KeyValuePair <int, List <double> > value in intersections.Points) { int abscissa = value.Key; List <double> ordinates = value.Value; if (ordinates.Count < 2) { continue; } for (int index = 0; index < ordinates.Count - 1;) { double first = ordinates[index++]; double next = ordinates[index++]; if (index < ordinates.Count) { Range1d segment = collinearSegments.Contains(new PointAxis2d.Value(abscissa, next)); if (segment != null && ordinates.Count % 3 == 0) { next = ordinates[index++]; } } segments.Add(abscissa, new Range1d(first, next)); } } return(segments); }