chiark / gitweb /
fix up rim join mistakes
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Mon, 18 Feb 2008 01:03:51 +0000 (01:03 +0000)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Mon, 18 Feb 2008 01:03:51 +0000 (01:03 +0000)
output.c

index f8fdd3b..7a12628 100644 (file)
--- a/output.c
+++ b/output.c
@@ -148,7 +148,7 @@ static void outfacet(int rev, const OutVertex *a,
                     const OutVertex *b, const OutVertex *c);
 
 typedef int int_map(int);
-static int defs_aroundmap_swap(int around) { return NDEF-around; }
+static int defs_aroundmap_swap(int around) { return NDEF-1-around; }
 static int int_identity_function(int i) { return i; }
 
 static void normalise_thick(double a[D3]) {
@@ -277,11 +277,13 @@ static void compute_outvertices(void) {
   FOR_RIM_VERTEX(y,x,v0) {
     int vfwd= EDGE_END2(v0,0);
     assert(vfwd >= 0);
-    int around;
-    for (around=0; around<NG; around++) {
-      K Ok(ovG[x][!!y][around],
-          0.5 * (ovDEF[ x          ][!!y][around*2].p[k] +
-                 ovDEF[vfwd & XMASK][!!y][around*2].p[k]));
+    int aroung;
+    int_map *around_map= vertices_span_join_p(v0,vfwd)
+      ? defs_aroundmap_swap : int_identity_function;
+    for (aroung=0; aroung<NG; aroung++) {
+      K Ok(ovG[x][!!y][aroung],
+          0.5 * (ovDEF[ x          ][!! y             ][aroung*2+1].p[k] +
+                 ovDEF[vfwd & XMASK][!!(vfwd & ~XMASK)][around_map(aroung*2+1)].p[k]));
     }
   }
 }
@@ -322,7 +324,7 @@ static void outfacets(void) {
       int v1= EDGE_END2(v0,0);  assert(v1>=0);
       gs=    ovG  [v0 & XMASK][rimy];
       defs=  ovDEF[v0 & XMASK][rimy];
-      defs1= ovDEF[v1 & XMASK][rimy];
+      defs1= ovDEF[v1 & XMASK][!!(v1 & ~XMASK)];
       defs1aroundmap= vertices_span_join_p(v0,v1)
        ? defs_aroundmap_swap : int_identity_function;