Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 2f5f8a0c authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding check for duplicate points: same x/y coordinate but different z coordinate

parent f975d7fc
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,8 @@ namespace TUGraz.VectoCore.Utils
throw new ArgumentException(string.Format("Triangulation needs at least 3 Points. Got {0} Points.", Points.Count));
}
SanitycheckInputPoints();
// The "supertriangle" encompasses all triangulation points.
// This is just a helper triangle which initializes the algorithm and will be removed later.
const int superTriangleScalingFactor = 10;
......@@ -132,6 +134,20 @@ namespace TUGraz.VectoCore.Utils
_triangles = triangles.FindAll(t => !t.SharesVertexWith(superTriangle));
}
private void SanitycheckInputPoints()
{
var duplicates = Points.GroupBy(pt => new { pt.X, pt.Y }, x => x).Where(g => g.Count() > 1).ToList();
foreach (var duplicate in duplicates) {
Log.Error("{0}: Input Point appears twice: x: {1}, y: {2}", duplicate.Key.X, duplicate.Key.Y);
}
if (duplicates.Any()) {
throw new VectoException("{0}: Input Data for Delauney map contains duplicates! \n{1}", _mapName,
string.Join("\n", duplicates.Select(pt => string.Format("{0} / {1}", pt.Key.X, pt.Key.Y))));
}
}
/// <summary>
/// Draws the delauney map (except supertriangle).
/// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment