chiark
/
gitweb
/
~ian
/
moebius2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
output now compiles
[moebius2.git]
/
output.c
diff --git
a/output.c
b/output.c
index afdc3df5d02bfef56bfdd87d2a730459cc0daa00..39a25356b9a9b352a03891c7f2337cb44b0ca3ec 100644
(file)
--- a/
output.c
+++ b/
output.c
@@
-140,6
+140,9
@@
static Vertices in;
static double thick; /* in input units */
static double scale;
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;
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) {
}
}
FOR_VERTEX(v0) {
- double centroid[D3];
int vw= EDGE_END2(v0,3);
int vnw= EDGE_END2(v0,2);
int vsw= EDGE_END2(v0,4);
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 {
continue;
}
FOR_SIDE {
+ double adjust[D3];
+ int e;
K adjust[k]= 0;
FOR_VPEDGE(e) {
OutVertex *ovab= invertex2outvertexab(v0,e,side);
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];
}
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) {
}
}
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
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);
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[
v
fwd][k] - in[vback][k];
/* compute the inner centroid */
vback= EDGE_END2(v0,4);
/* 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<NDEF; around++) {
normalise_thick(radius_sin);
for (around=0; around<NDEF; around++) {
- double angle= around * PI / (NDEF-1);
- double result[D3];
+ double angle= around * M_PI / (NDEF-1);
K ovDEF[x][!!y][around].p[k]=
in[v0][k] +
cos(angle) * radius_cos[k] +
K ovDEF[x][!!y][around].p[k]=
in[v0][k] +
cos(angle) * radius_cos[k] +
@@
-258,6
+261,7
@@
static void compute_outvertices(void) {
FOR_RIM_VERTEX(y,x,v0) {
int vfwd= EDGE_END2(v0,0);
assert(vfwd >= 0);
FOR_RIM_VERTEX(y,x,v0) {
int vfwd= EDGE_END2(v0,0);
assert(vfwd >= 0);
+ int around;
for (around=0; around<NG; around++) {
K ovG[x][!!y][around].p[k]=
(ovDEF[ x ][!!y][around*2].p[k] +
for (around=0; around<NG; around++) {
K ovG[x][!!y][around].p[k]=
(ovDEF[ x ][!!y][around*2].p[k] +
@@
-281,14
+285,17
@@
static void outtriangles_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 outtriangles(void) {
static void outtriangles(void) {
- int v0,e
0,e1
;
+ int v0,e
,side,aroung
;
FOR_VERTEX(v0) {
OutVertex *defs=0, *defs1=0;
FOR_VERTEX(v0) {
OutVertex *defs=0, *defs1=0;
- int (*defs1aroundmap)(int)=0, rimy;
+ int (*defs1aroundmap)(int)=0, rimy
=-1
;
if (RIM_VERTEX_P(v0)) {
if (RIM_VERTEX_P(v0)) {
- Out
v
ertex *gs;
+ Out
V
ertex *gs;
rimy= !!(v0 & ~XMASK);
int v1= EDGE_END2(v0,0); assert(v1>=0);
gs= ovG [v0 & XMASK][rimy];
rimy= !!(v0 & ~XMASK);
int v1= EDGE_END2(v0,0); assert(v1>=0);
gs= ovG [v0 & XMASK][rimy];
@@
-307,21
+314,22
@@
static void outtriangles(void) {
outtriangles_around(rimy, &gs[aroung], 6,surround);
}
}
outtriangles_around(rimy, &gs[aroung], 6,surround);
}
}
-
+
FOR_SIDE {
FOR_SIDE {
+ OutVertex *cd;
if (defs) {
int around= side ? NDEF-1 : 0;
cd= &defs[around];
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 *cd1= &defs1[defs1aroundmap(around)];
outtriangle(side^rimy,cd,ab,cd1);
} else {
cd= &ovC[v0][side];
}
- OutVertex *ab
s
[6];
+ OutVertex *ab[6];
FOR_VPEDGE(e)
FOR_VPEDGE(e)
- ab
s[e0
]= invertex2outvertexab(v0,e,side);
- outtriangles_around(side, cd, 6,ab
s
);
+ 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]) {
/*---------- transformation (scale and perhaps shift) ----------*/
static void scaleshift_outvertex_array(int n, OutVertex ovX[n]) {
+ int i, k;
for (i=0; i<n; i++)
K ovX[i].p[k] *= scale;
/*
for (i=0; i<n; i++)
K ovX[i].p[k] *= scale;
/*
@@
-360,12
+369,12
@@
static void wr(const void *p, size_t sz) {
#define WR(x) wr((const void*)&(x), sizeof((x)))
static void wf(double d) {
#define WR(x) wr((const void*)&(x), sizeof((x)))
static void wf(double d) {
-#if sizeof(float)==4
typedef float ieee754single;
typedef float ieee754single;
-#endif
+
+ assert(sizeof(ieee754single)==4);
#if defined(BIG_ENDIAN)
#if defined(BIG_ENDIAN)
- union {
Byte
b[4]; ieee754single f; } value; value.f= d;
+ union {
uint8_t
b[4]; ieee754single f; } value; value.f= d;
int i; for (i=3; i>=0; i--) WR(value.b[i]);
#elif defined(LITTLE_ENDIAN)
ieee754single f= d;
int i; for (i=3; 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 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;
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]);
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";
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);
WR(header);