chiark / gitweb /
report on degenerate facets
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Mon, 18 Feb 2008 00:34:38 +0000 (00:34 +0000)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Mon, 18 Feb 2008 00:34:38 +0000 (00:34 +0000)
output.c

index d6eb877badd66576589725bc405951cff2f3fe9f..b9bad149a09aafd446e706420833ee464c78b3bf 100644 (file)
--- a/output.c
+++ b/output.c
@@ -423,6 +423,7 @@ assert(d >= -1e3 && d <= 1e3);
 
 static uint32_t noutfacets;
 static uint32_t noutfacets_counted;
+static long badfacets;
 
 static void outfacet(int rev, const OutVertex *a,
                     const OutVertex *b, const OutVertex *c) {
@@ -440,8 +441,10 @@ static void outfacet(int rev, const OutVertex *a,
   triangle_normal(normal, a->p, b->p, c->p);
   double multby= 1/magnD(normal);
   
-  if (multby > 1e6)
+  if (multby > 1e6) {
+    badfacets++;
     return;
+  }
 
   noutfacets++;
   if (!~noutfacets_counted) return;
@@ -474,6 +477,11 @@ static void write_file(void) {
   assert(noutfacets == noutfacets_counted);
 
   if (fflush(stdout)) diee("fflush stdout");
+
+  if (badfacets) {
+    fprintf(stderr,"%ld degenerate facets!\n",badfacets);
+    exit(4);
+  }
 }