Skip to content

Commit 633cc6f

Browse files
committed
Handle empty ranges in RelativeEnvelopeLon() Interval calculation.
1 parent ad793dd commit 633cc6f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Visual_Studio_2015/GraphicalDebugging/ExpressionDrawer.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ public Settings CopyColored(System.Windows.Media.Color color)
6868

6969
private static Geometry.Interval RelativeEnvelopeLon(Geometry.IRandomAccessRange<Geometry.Point> points, bool closed, Geometry.Unit unit)
7070
{
71+
Geometry.Interval result = null;
72+
73+
if (points.Count < 1)
74+
{
75+
result = new Geometry.Interval();
76+
Geometry.AssignInverse(result);
77+
return result;
78+
}
79+
7180
double x0 = points[0][0];
72-
Geometry.Interval result = new Geometry.Interval(x0);
81+
result = new Geometry.Interval(x0);
82+
7383
int count = points.Count + (closed ? 1 : 0);
7484
for (int ii = 1; ii < count; ++ii)
7585
{

Visual_Studio_2015/GraphicalDebugging/Geometry.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public override string ToString()
109109

110110
public class Interval
111111
{
112+
public Interval()
113+
{ }
114+
112115
public Interval(double v)
113116
{
114117
Min = v;
@@ -293,6 +296,12 @@ public static void AssignInverse(Box b)
293296
b.Max = new Point(double.MinValue, double.MinValue);
294297
}
295298

299+
public static void AssignInverse(Interval i)
300+
{
301+
i.Min = double.MaxValue;
302+
i.Max = double.MinValue;
303+
}
304+
296305
public static Box Aabb(Point p1, Point p2, Unit unit)
297306
{
298307
if (unit == Unit.None)

0 commit comments

Comments
 (0)