alphashapes2d can handle degenerate inputs (thanks to Taras Galkovskyi for the bug report and the fix) dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Tue, 05 Apr 2011 18:29:50 -0700
branchdev
changeset 242 a06b4b515476
parent 241 2ca64ce7d57c
child 243 c9b8c98187a8
alphashapes2d can handle degenerate inputs (thanks to Taras Galkovskyi for the bug report and the fix)
examples/alphashapes/alphashapes2d.hpp
--- a/examples/alphashapes/alphashapes2d.hpp	Fri Jan 28 08:01:37 2011 -0800
+++ b/examples/alphashapes/alphashapes2d.hpp	Tue Apr 05 18:29:50 2011 -0700
@@ -5,7 +5,7 @@
 AlphaSimplex2D(const Delaunay2D::Vertex& v): alpha_(0), attached_(false)
 {
 	for (int i = 0; i < 3; ++i)
-		if (v.face()->vertex(i)->point() == v.point())
+		if (v.face()->vertex(i) != Vertex_handle() && v.face()->vertex(i)->point() == v.point())
 			Parent::add(v.face()->vertex(i));
 }
 
@@ -26,13 +26,18 @@
 		if (i != e.second)
 			Parent::add(f->vertex(i));
 
-	Face_handle o = f->neighbor(e.second);
-	int oi = o->index(f);
-
 	VertexSet::const_iterator v = static_cast<const Parent*>(this)->vertices().begin();
 	const Point& p1 = (*v++)->point();
 	const Point& p2 = (*v)->point();
 	
+	Face_handle o = f->neighbor(e.second);
+    if (o == Face_handle())
+    {
+        alpha_ = squared_radius(p1, p2);
+        return;
+    }
+	int oi = o->index(f);
+
 	attached_ = false;
 	if (!Dt.is_infinite(f->vertex(e.second)) &&
         CGAL::side_of_bounded_circle(p1, p2,