chiark / gitweb /
now right except for at join
[moebius2.git] / output.c
index e37aa7c21775c3383381b856685fd7ed1be6370b..95a26c3dbcf0d6f4e7a1db83f4026ef9919f0fcc 100644 (file)
--- a/output.c
+++ b/output.c
  *   - scale the coordinates
  *   - translate the coordinates so they're all positive
  */
+/*
+ *  ./output-64 <dense-64.cfm 0.1 50 >t.stl
+ *  meshlab t.stl
+ */
 /*
  * Re STL, see:
  *  http://www.ennex.com/~fabbers/StL.asp
@@ -149,6 +153,10 @@ static double scale;
 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 int_identity_function(int i) { return i; }
+
 static void normalise_thick(double a[D3]) {
   /* multiplies a by a scalar so that its magnitude is thick */
   int k;
@@ -262,8 +270,10 @@ static void compute_outvertices(void) {
     normalise_thick(radius_cos);
     normalise_thick(radius_sin);
 
+    int_map *around_map= y ? int_identity_function : defs_aroundmap_swap;
+
     for (around=0; around<NDEF; around++) {
-      double angle= around * M_PI / (NDEF-1);
+      double angle= around_map(around) * M_PI / (NDEF-1);
       K Ok(ovDEF[x][!!y][around],
           in[v0][k] +
           cos(angle) * radius_cos[k] +
@@ -297,15 +307,13 @@ static void outfacets_around(int reverse, OutVertex *middle,
   }
 }
 
-static int defs_aroundmap_swap(int around) { return NDEF-around; }
-static int int_identity_function(int i) { return i; }
-
 static void outfacets(void) {
   int v0,e,side,aroung, k;
   
   FOR_VERTEX(v0) {
     OutVertex *defs=0, *defs1=0;
-    int (*defs1aroundmap)(int)=0, rimy=-1;
+    int rimy=-1;
+    int_map *defs1aroundmap= 0;
     if (RIM_VERTEX_P(v0)) {
       OutVertex *gs;
       rimy= !!(v0 & ~XMASK);