From 2ac8b65043d23d2097a4b67a293a44e12e0bfe6c Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Tue, 9 Aug 2016 15:57:30 +0200
Subject: [PATCH] Check if delaunay map was triangulated before Interpolate was
 called

---
 VectoCore/VectoCore/Utils/DelaunayMap.cs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs
index bcb3b8cdd0..5cc64203cb 100644
--- a/VectoCore/VectoCore/Utils/DelaunayMap.cs
+++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs
@@ -222,6 +222,8 @@ namespace TUGraz.VectoCore.Utils
 		///          null if interpolation has failed.</returns>
 		public double? Interpolate(double x, double y)
 		{
+			if (!_triangles.Any())
+				throw new VectoException("Interpolation not possible. Call DelaunayMap.Triangulate first.");
 			x = (x - _minX) / (_maxX - _minX);
 			y = (y - _minY) / (_maxY - _minY);
 			var tr = _triangles.Find(triangle => triangle.IsInside(x, y, exact: true)) ??
-- 
GitLab