Hi,
I've written a method to compute the Minkowski Sum of a polygon and I've based my code on the Buffer code.
I use CoordinateSequences in my code and I happen to reverse this sequence. When noding these sequences
I get in trouble when Slice.GetOverlappingTriples is called on a reversed CoordinateSequence.
The code in GetOverlappingTriples looks like this:
IEnumerator<TItem> it = items.GetEnumerator();
Boolean moveNext = typeof (TItem).IsValueType ? it.Current.Equals(default(TItem)) : it.Current == null;
if(moveNext)
{
if ( !it.MoveNext() ) yield break;
}
CoordinateSequence.GetEnumerator returns a List<T> enumerator if non reversed and a Stack<T> if reversed.
According to documentation it.Current is undefined until MoveNext is called. For the list it.Current works ok and returns null, but for the stack it throws an exception.
I got this working by inserting MoveNext
IEnumerator<TItem> it = items.GetEnumerator();
if (!it.MoveNext()) yield break; // <-------------------- CODE added
Boolean moveNext = typeof (TItem).IsValueType ? it.Current.Equals(default(TItem)) : it.Current == null;
if(moveNext)
{
if ( !it.MoveNext() ) yield break;
}
I'm not sure if this is the correct way to fix, but as it is now it is not working for a reversed CoordinateSequence.
I'm using branch v2.11.
Regards,
Kalle