/* See {FunnyBall.h} */ #include /* Last edited on 2007-02-04 16:19:20 by stolfi */ #define FunnyBall_C_COPYRIGHT \ "Copyright © 2000,2007 Universidade Estadual de Campinas (UNICAMP)" #include #include #include #include #include #include #include #include #include Place_t GlueBall(Place_t a, Place_t b); /* Make the glueing of two simples 2-gon walls around of one common wall. The place {a} and its adjacent ones with the same wall component are killed. */ void SetFunnyBallInteriorCell(Place_t p, Cell_t n); /* Set to {n} the cell slots of the 8 places on the interior of the funny ball {n}. */ FourPlaces_t MakeFunnyBall(void) { FourPlaces_t co; int i; for (i = 0; i < 4; i++) { co.p[i] = PolygonMakeSng(2); } /* Glue Walls */ for (i = 0; i < 4; i++) { SetNextF(co.p[i],Clock(NextE(co.p[(i+1) % 4]))); SetEdgeInfo(co.p[i], PWedge(Clock(NextE(co.p[(i+1) % 4])))->edge); SetOrgAll(co.p[i], OrgV(co.p[i])); SetOrgAll(Clock(co.p[i]), OrgV(Clock(co.p[i]))); } Cell_t q = MakeCell(0); SetFunnyBallInteriorCell(co.p[0], q); return co; } Place_t GlueBall(Place_t a, Place_t b) { assert(SpinBit(a) == SpinBit(b)); Meld(a,b); /* Update the edge slots */ SetRingEdgeInfo(b, PEdge(b)); SetRingEdgeInfo(NextE(b), PEdge(NextE(b))); /* Update the node slots */ SetOrgAll(b, OrgV(b)); SetOrgAll(NextE(b), OrgV(NextE(b))); /* Update the cell slots */ SetPneg(b, PnegP(a)); SetPneg(PrevE(b), PnegP(PrevE(a))); return b; } void SetFunnyBallInteriorCell(Place_t p, Cell_t n) { SetPnegOfNearbyWalls(p, n); Place_t t = p; do { SetPnegOfNearbyWalls(Clock(PrevF(t)),n); t = PrevE(t); } while (t != p); t = PrevF(PrevE(PrevF(p))); SetPnegOfNearbyWalls(t, n); } #define FunnyBall_C_author \ "Created by L. A. P. Lozada, 2000.\n" \ "Modification history:\n" \ " 26-01-2007 : Converted to C by J. Stolfi, extracted from {}."