/* See {Octahedron.h} */ #include /* Last edited on 2007-02-03 23:04:13 by stolfi */ #define Octahedron_C_COPYRIGHT \ "Copyright © 2000,2007 Universidade Estadual de Campinas (UNICAMP)" #include #include #include #include #include #include #include #include #include #include FourPlaces_t MakeHalfOct(void); /* Builds half octahedron without cell information. */ FourPlaces_t MakeHalfOct(void) /* [!!!] From {Squared.c} */ { FourPlaces_t p; int i; for (i = 0; i < 4; i++){ p.p[i] = MakeTriangle(); } for (i = 0; i < 4; i++) { Place_t a = NextE(p.p[i]); Place_t b = Clock(PrevE(p.p[(i+1) % 4])); { SetNextF(a, b); SetRingEdgeInfo(a, PEdge(a)); } } for (i = 0; i < 4; i++) { SetOrgAll(PrevE(p.p[i]), OrgV(PrevE(p.p[i]))); } return p; } Place_t MakeOcta(void) { EightPlaces_t o = MakeOctahedron(); return o.p[0]; } EightPlaces_t MakeOctahedron(void) /* From {VStar.c}/{Squared.c}/{MakePlatonic.c} */ { EightPlaces_t p ; FourPlaces_t sup = MakeHalfOct(); FourPlaces_t inf = MakeHalfOct(); /* Builds an octahedron with two half-octahedra {s} (superior) and {i} (inferior). */ int j; for (j = 0; j < 4; j++) { p.p[j] = sup.p[j]; } for (j = 4; j < 8; j++) { p.p[j] = inf.p[j-4]; } /* Set the shared elements: */ for (j = 0; j < 4; j++) { SetNextF(p.p[j],p.p[j+4]); SetRingEdgeInfo(p.p[j],PEdge(p.p[j])); SetOrgAll(p.p[j], OrgV(p.p[j])); SetOrgAll(NextE(p.p[j]), OrgV(NextE(p.p[j]))); } /* Set the cell attribute; the 24 places have the same cell. */ Cell_t q = MakeCell(0); int i; for (i = 0; i < 8; i++) { SetPnegOfWall(p.p[i], q); } /* This test is applies for assert that any place {p[i]} really underly on a topological octahedron.*/ for (i = 0; i < 8; i++) { int d = DegreeOfNode(Srot(p.p[i])); assert(d == 8); } return p; } EightPlaces_t MakeOctahedronTriang(bool_t original) /* From {Squared.c} */ { EightPlaces_t a[8]; EightPlaces_t b; int i; for (i = 0; i < 8; i++) { a[i] = MakeTetraTopo(1,1); } /* first level gluing tetrahedra */ Glue(Spin(a[1].p[1]),a[0].p[0],1, TRUE); Glue(Spin(a[2].p[1]),a[1].p[0],1, TRUE); Glue(Spin(a[3].p[1]),a[2].p[0],1, TRUE); Glue(Spin(a[0].p[1]),a[3].p[0],1, TRUE); /* second level gluing tetrahedra */ Glue(Spin(a[0].p[3]),a[4].p[2],1, TRUE); Glue(Spin(a[1].p[3]),a[5].p[2],1, TRUE); Glue(Spin(a[2].p[3]),a[6].p[2],1, TRUE); Glue(Spin(a[3].p[3]),a[7].p[2],1, TRUE); /* gluing between levels */ Glue(Spin(a[5].p[1]),a[4].p[0],1, TRUE); Glue(Spin(a[6].p[1]),a[5].p[0],1, TRUE); Glue(Spin(a[7].p[1]),a[6].p[0],1, TRUE); Glue(Spin(a[4].p[1]),a[7].p[0],1, TRUE); if (original) { /* Emphasize the original elements */ SetExWallsOfEdge(a[0].p[1],FALSE); SetExWallsOfEdge(a[4].p[1],FALSE); SetExEdge(a[0].p[1],FALSE); SetExEdge(a[4].p[1],FALSE); for (i = 0; i < 4; i++) { SetExWallsOfEdge(NextE(a[i].p[1]),FALSE); } for (i = 4; i < 8; i++) { SetExEdge(PrevE(a[i].p[1]),FALSE); } SetExNode(a[4].p[1], FALSE); } b.p[0] = a[0].p[2]; b.p[1] = a[1].p[2]; b.p[2] = a[2].p[2]; b.p[3] = a[3].p[2]; b.p[4] = a[4].p[3]; b.p[5] = a[5].p[3]; b.p[6] = a[6].p[3]; b.p[7] = a[7].p[3]; return b; } Place_t MakeTwoOctaGlue(void) { EightPlaces_t o1 = MakeOctahedron(); EightPlaces_t o2 = MakeOctahedron(); Glue(Spin(o1.p[1]), o2.p[6],1, TRUE); return o1.p[0]; } Place_t MakeThreeOctaGlue(void) { EightPlaces_t o1 = MakeOctahedron(); EightPlaces_t o2 = MakeOctahedron(); EightPlaces_t o3 = MakeOctahedron(); Glue(Spin(o1.p[1]), o2.p[6],1, TRUE); Glue(Spin(o1.p[5]), Spin(PrevE(o3.p[2])), 1, TRUE); Glue(Clock(NextE(o3.p[1])), o2.p[2],1, TRUE); return o1.p[0]; } #define Octahedron_C_author \ "Created by L. A. P. Lozada, 2000.\n" \ "Modification history:\n" \ " 2000-08-30 : Nice version of the {MakeOctahedron} procedure.\n" \ " 2007-02-01 : [???] Added {MakeTwoOctaGlue}, {MakeThreeOctaGlue} from {MakeComplexWf}."