X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=output.c;fp=output.c;h=f8fdd3b595a5250f345146b2d6c38e18c1267bff;hb=62eac09041f09319ed3abf08ea78c1695003f5a5;hp=b9bad149a09aafd446e706420833ee464c78b3bf;hpb=2ea75be20bbd2882b5b6b807fb173b7dd8cff73c;p=moebius2.git diff --git a/output.c b/output.c index b9bad14..f8fdd3b 100644 --- a/output.c +++ b/output.c @@ -107,14 +107,8 @@ * * The outfacets are: * - * For each non-rim vertex on each side, the six triangles formed by - * its C and the surrounding A's and B's. - * - * For each rim vertex on each side, the two triangles formed by its - * D and the nearest As and Bs (two As and one B or vice versa). - * - * For each rim edge on each side, the triangle formed by that edge's - * ends' Ds and the corresponding A or B. + * For each input vertex on each side, the six (or perhaps only three) + * triangles formed by its C or D and the surrounding Cs and/or Ds. * * For each G, the six triangles formed by that G and the adjacent * four Fs (or two Fs and two Ds) and two Es. @@ -307,8 +301,16 @@ static void outfacets_around(int reverse, OutVertex *middle, } } +static OutVertex *invertex2outvertexcd(v0,side) { + if (!RIM_VERTEX_P(v0)) return &ovC[v0][side]; + + int around= side ? NDEF-1 : 0; + int rimy= !!(v0 & ~XMASK); + return &ovDEF[v0 & XMASK][rimy][around]; +} + static void outfacets(void) { - int v0,e,side,aroung, k; + int v0,e,side,aroung; FOR_VERTEX(v0) { OutVertex *defs=0, *defs1=0; @@ -336,23 +338,16 @@ static void outfacets(void) { } FOR_SIDE { - OutVertex *cd; - if (defs) { - int around= side ? NDEF-1 : 0; - cd= &defs[around]; - OutVertex *ab= &ovAB[v0][!rimy][side]; - OutVertex *cd1= &defs1[defs1aroundmap(around)]; - outfacet(side^rimy,cd,ab,cd1); - } else { - cd= &ovC[v0][side]; - } - OutVertex *ab[6]; - FOR_VPEDGE(e) { - ab[e]= invertex2outvertexab(v0,e,side); - if (ab[e]) - K assert(!isnan(ab[e]->p[k])); + int ab; + for (ab=0; ab<2; ab++) { + int v1= EDGE_END2(v0, ab ? 5 : 0); + int v2= EDGE_END2(v0, ab ? 0 : 1); + if (v1<0 || v2<0) continue; + outfacet(side, + invertex2outvertexcd(v0,side), + invertex2outvertexcd(v1,side^vertices_span_join_p(v0,v1)), + invertex2outvertexcd(v2,side^vertices_span_join_p(v0,v2))); } - outfacets_around(side, cd, 6,ab); } } }