public void Add(int value, Range1d range) { List <Range1d> segments; if (!m_lines.TryGetValue(value, out segments)) { segments = new List <Range1d>(); m_lines[value] = segments; segments.Add(range); return; } segments.Add(range); segments.Sort(new Range1d.Comparer()); for (int index = 0; index < segments.Count - 1; ++index) { if (segments[index].Overlaps(segments[index + 1])) { segments[index] = new Range1d(segments[index], segments[index + 1]); segments.RemoveAt(index + 1); --index; } } }
public bool Overlaps(Range1d other) { if (m_max.CompareLess(other.Min)) { return(false); } if (other.Max.CompareLess(m_min)) { return(false); } return(true); }
public bool Compare(Range1d value) { if (!value.m_min.Compare(m_min)) { return(false); } if (!value.m_max.Compare(m_max)) { return(false); } return(true); }
internal Range1d(Range1d r0, Range1d r1) { if (r0 == null) { m_min = r1.m_min; m_max = r1.m_max; } else { m_min = Math.Min(r0.m_min, r1.m_min); m_max = Math.Max(r0.m_max, r1.m_max); } }
public Range2d(Range2d r0, Range2d r1) { if (r0 == null) { m_x = new Range1d(r1.m_x); m_y = new Range1d(r1.m_y); } else { m_x = new Range1d(r0.m_x, r1.m_x); m_y = new Range1d(r0.m_y, r1.m_y); } }
public Range2d(Range2d other, Point2d point) { if (other == null) { m_x = new Range1d(point.X, point.X); m_y = new Range1d(point.Y, point.Y); } else { m_x = new Range1d(other.m_x, point.X); m_y = new Range1d(other.m_y, point.Y); } }
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); }
public Range3d(Range3d other, Point3d point) { if (other == null) { m_x = new Range1d(point.X); m_y = new Range1d(point.Y); m_z = new Range1d(point.Z); } else { m_x = new Range1d(other.m_x, point.X); m_y = new Range1d(other.m_y, point.Y); m_z = new Range1d(other.m_z, point.Z); } }
public List <RangeAxis2d.Value> CreateExtentsList() { List <RangeAxis2d.Value> extentLines = new List <RangeAxis2d.Value>(); foreach (KeyValuePair <int, List <Range1d> > line in m_lines) { Range1d extents = null; foreach (Range1d range in line.Value) { extents = new Range1d(extents, range); } extentLines.Add(new RangeAxis2d.Value(line.Key, extents)); } return(extentLines); }
internal Range1d(Range1d other, double value) { m_min = Math.Min(other.m_min, value); m_max = Math.Max(other.m_max, value); }
internal Range1d(Range1d other) { m_min = other.Min; m_max = other.Max; }
//added code : SD public Range2d(Range1d x1, Range1d x2) { m_x = x1; m_y = x2; }
public Range2d(Point2d point0, Point2d point1) { m_x = new Range1d(point0.X, point1.X); m_y = new Range1d(point0.Y, point1.Y); }
public Value(int abscissa, Range1d ordinate) { m_abscissa = abscissa; m_ordinate = ordinate; }