//********************************** //*** corners tools // Written by Jarek Rossignac, June 2006 //********************************** int t (int c) {int r=int(c/3); return(r);}; int n (int c) {int r=3*int(c/3)+(c+1)%3; return(r);}; int p (int c) {int r=3*int(c/3)+(c+2)%3; return(r);}; int v (int c) {return(V[c]);}; int o (int c) {return(O[c]);}; int l (int c) {return(o(n(c)));}; int r (int c) {return(o(p(c)));}; int w (int c) {return(W[c]);}; // temporary indices to mid-edge vertices associated with corners during subdivision boolean border (int c) {return(O[c]==-1);}; // returns true if corner has no opposite boolean nb(int c) {return(O[c]!=-1);}; pt g (int c) {return(G[V[c]]);}; // shortcut to get the point of the vertex v(c) of corner c pt cg(int c) {pt cPt = midPt(g(c),midPt(g(c),triCenter(t(c)))); return(cPt); }; // computes point at corner void showCorner(int c) {pt cPt = midPt(g(c),midPt(g(c),triCenter(t(c)))); cPt.show(3); }; // renders corner c as small ball void drawEdge(int c) {line(g(p(c)).x,g(p(c)).y,g(p(c)).z,g(n(c)).x,g(n(c)).y,g(n(c)).z); }; // draws edge of t(c) opposite to corner c void computeO() { // sets the O table from the V table, assumes consistent orientation of tirangles for (int i=0; i<3*nt; i++) {O[i]=-1;}; // init O table to -1: has no opposite (i.e. is a border corner) for (int i=0; i<3*nt; i++) { for (int j=i+1; j<3*nt; j++) { // for each corner i, for each other corner j if( (v(n(i))==v(p(j))) && (v(p(i))==v(n(j))) ) {O[i]=j; O[j]=i;};};}; // make i and j opposite if they match };