chiark / gitweb /
report on degenerate facets
[moebius2.git] / output.c
index 95a26c3dbcf0d6f4e7a1db83f4026ef9919f0fcc..b9bad149a09aafd446e706420833ee464c78b3bf 100644 (file)
--- a/output.c
+++ b/output.c
@@ -49,7 +49,7 @@
  *       /    *B2  2\  / /1   *A    \    /    *A    \    /    *A    \    /
  *   \  /            \/:/     0      \  /            \  /            \  /
  *    *C ____________|*C ____________ *C ___________  *C ___________  *C __
- *    /\          3  | :   0          /\              /\              /\
+ *    /\          3  |/\   0          /\              /\              /\
  *   /  \            / :\            /  \            /  \            /  \
  *       \    *A3  4/ \: \5  5*B    /    \    *B    /    \    *B    /    \
  *        \        /   \  \        /      \        /      \        /
@@ -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);
+  }
 }