From: Ian Jackson Date: Sun, 17 Feb 2008 17:14:07 +0000 (+0000) Subject: output now compiles X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=commitdiff_plain;h=4f9769b263b5e16c9c94ed3aba3829678a504261 output now compiles --- diff --git a/common.h b/common.h index 9979357..7e70a75 100644 --- a/common.h +++ b/common.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/output.c b/output.c index afdc3df..39a2535 100644 --- a/output.c +++ b/output.c @@ -140,6 +140,9 @@ static Vertices in; static double thick; /* in input units */ static double scale; +static void outtriangle(int rev, const OutVertex *a, + const OutVertex *b, const OutVertex *c); + static void normalise_thick(double a[D3]) { /* multiplies a by a scalar so that its magnitude is thick */ int k; @@ -195,7 +198,6 @@ static void compute_outvertices(void) { } } FOR_VERTEX(v0) { - double centroid[D3]; int vw= EDGE_END2(v0,3); int vnw= EDGE_END2(v0,2); int vsw= EDGE_END2(v0,4); @@ -204,10 +206,12 @@ static void compute_outvertices(void) { continue; } FOR_SIDE { + double adjust[D3]; + int e; K adjust[k]= 0; FOR_VPEDGE(e) { OutVertex *ovab= invertex2outvertexab(v0,e,side); - K adjust[k] += ovab->k[k]; + K adjust[k] += ovab->p[k]; } K adjust[k] /= 6; K adjust[k] -= in[v0][k]; @@ -216,7 +220,7 @@ static void compute_outvertices(void) { } } FOR_RIM_VERTEX(y,x,v0) { - double rim[D3], inner[D3], radius_cos[D3];, radius_sin[D3]; + double rim[D3], inner[D3], radius_cos[D3], radius_sin[D3]; int vback, vfwd, around; /* compute mean rim vector, which is just the vector between @@ -224,7 +228,7 @@ static void compute_outvertices(void) { vback= EDGE_END2(v0,3); vfwd= EDGE_END2(v0,0); assert(vback>=0 && vfwd>=0); - K rim[k]= in[fwd][k] - in[vback][k]; + K rim[k]= in[vfwd][k] - in[vback][k]; /* compute the inner centroid */ vback= EDGE_END2(v0,4); @@ -247,8 +251,7 @@ static void compute_outvertices(void) { normalise_thick(radius_sin); for (around=0; around= 0); + int around; for (around=0; around=0); gs= ovG [v0 & XMASK][rimy]; @@ -307,21 +314,22 @@ static void outtriangles(void) { outtriangles_around(rimy, &gs[aroung], 6,surround); } } - + FOR_SIDE { + OutVertex *cd; if (defs) { int around= side ? NDEF-1 : 0; cd= &defs[around]; - OutVertex *ab= ovAB[v0][!rimy][side]; + OutVertex *ab= &ovAB[v0][!rimy][side]; OutVertex *cd1= &defs1[defs1aroundmap(around)]; outtriangle(side^rimy,cd,ab,cd1); } else { cd= &ovC[v0][side]; } - OutVertex *abs[6]; + OutVertex *ab[6]; FOR_VPEDGE(e) - abs[e0]= invertex2outvertexab(v0,e,side); - outtriangles_around(side, cd, 6,abs); + ab[e]= invertex2outvertexab(v0,e,side); + outtriangles_around(side, cd, 6,ab); } } } @@ -329,6 +337,7 @@ static void outtriangles(void) { /*---------- transformation (scale and perhaps shift) ----------*/ static void scaleshift_outvertex_array(int n, OutVertex ovX[n]) { + int i, k; for (i=0; i=0; i--) WR(value.b[i]); #elif defined(LITTLE_ENDIAN) ieee754single f= d; @@ -378,27 +387,31 @@ static void wf(double d) { static uint32_t nouttriangles; static uint32_t nouttriangles_counted; -static void outtriangle(int rev, OutVertex *a, OutVertex *b, OutVertex *c) { +static void outtriangle(int rev, const OutVertex *a, + const OutVertex *b, const OutVertex *c) { if (rev) { outtriangle(0, c,b,a); return; } nouttriangles++; if (!~nouttriangles_counted) return; - triangle_normal(normal, a.p, b.p, c.p); + double normal[D3]; + int k; + + triangle_normal(normal, a->p, b->p, c->p); double multby= 1/magnD(normal); K normal[k] *= multby; K wf(normal[k]); - K wf(a.p[k]); - K wf(b.p[k]); - K wf(c.p[k]); - uint16_t attrbc; + K wf(a->p[k]); + K wf(b->p[k]); + K wf(c->p[k]); + uint16_t attrbc=0; WR(attrbc); } static void write_file(void) { static const char header[80]= "#!/usr/bin/meshlab\n" "binary STL file\n"; - if (isatty(stdout)) die("will not write binary stl to tty!"); + if (isatty(1)) fail("will not write binary stl to tty!"); WR(header);