#define PROG_NAME "MakeVStar" #define PROG_DESC "???" #define PROG_VERS "1.0" /* Last edited on 2007-02-03 23:23:27 by stolfi */ #define MakeVStar_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* Generates ".tp",".tb",".ma" and ".st" files for some simples, triangulated and regular Cells in R^{4}. The node coordinates are random numbers in [-1..+1]. */ #include /* !!! Used to import instead of */ #include #include #include #include #define _GNU_SOURCE #include #include TYPE Shape_t == { sh_4_vstar, sh_8_vstar, sh_20_vstar, sh_60_vstar }; typedef struct Options_t { Shape_t shape; char *shapeName; } Options_t *GetOptions(int argc, char **argv); int main(int argc, char **argv) { Options_t *o = GetOptions(argc, argv); char *topo_cmt = jsprintf("Created by %s on %s", PROG_NAME, Today()); /* Random_t coins = MakeRandomSource(4615); */ ??? m = MakePoly(o->shape); ??? top = MakeElemTable(m); Coords_t c = GenCoords(&top);; { /* Set the "root" attribute for walls and edges. */ for (i = 0; i < top.wall.nel; i++) { Wall_t f = top.wall.el[i]; f->root = f->num; } for (i = 0; i < top.edge.nel; i++) { Edge_t e = top.edge.el[i]; e->root = e->num; } SetElemProperties(top); WriteTopology(o->output, tag, &top, topo_cmt); // shapeName MakeVStar shapeName WriteState( o->shapeName, top, c,"Created by MakeVStar: " & o->shapeName \ ".st on " & Today() & "\nRandom Geometry" ); WriteMaterials(o->output, tag, &top, topo_cmt); // shapeName MakeVStar shapeName return 0; } Place_t MakePoly(Shape_t shape) { CASE shape OF break; case Shape_sh_4_vstar: return Make_4_vstar(); break; case Shape_sh_8_vstar: return Make_8_vstar(); break; case Shape_sh_20_vstar: return Make_20_vstar(); break; case Shape_sh_60_vstar: return Make_60_vstar(); } } /* END MakePoly */ /* Shape_t builders: */ Place_t Make_4_vstar() { fprintf(stderr, "Building topology of 4_vstar" & "\n"); return VStar.MakeTetrahedronTriang()[0]; } /* END Make_4_vstar */ Place_t Make_20_vstar() { fprintf(stderr, "Building Topology of an 20_vstar: \n"); ??? ico = VStar.MakeIcosahedronTriang(); { return ico.el[10]; } } /* END Make_20_vstar */ Place_t Make_8_vstar() { fprintf(stderr, "Building Topology of an 8_vstar: \n"); ??? oct = VStar.MakeOctahedronTriang() /* true for emphasize the origial elements */; { return oct[0]; } } /* END Make_8_vstar */ Place_t Make_60_vstar() { ??? dode = VStar.MakeDodecahedronTriang() /* true for emphasize the origial elements */; { /* safety tests */ for (i = 0; i < 12; i++) { ??? a = dode[i; with (0] DO if ((SpinBit(a) == 0)) { for (j = 1; j < 5; j++) { assert(dode[i,j] == Clock(NextE(NextF(PrevE(dode[i,j-1]))))); } assert(dode[i,0] == Clock(NextE(NextF(PrevE(dode[i,4]))))); } else if ((SpinBit(a) == 1)){ for (j = 1; j < 5; j++) { assert(dode[i,j] == Clock(PrevE(NextF(NextE(dode[i,j-1]))))); } assert(dode[i,0] == Clock(PrevE(NextF(NextE(dode[i,4]))))); } } } /* end safety tests */ fprintf(stderr, "Building topology of an 60_vstar (version 1): \n"); return dode[11,0]; } } /* END Make_60_vstar */ /* Procedures to set element properties */ PROCEDURE SetElemProperties(ElemTableRec_t *top) Place_t *b; { for (i = 0; i < top->node.nel; i++){ SetNodeProperties(top->node[i], border = FALSE); } for (i = 0; i < top->NE; i++){ SetEdgeProperties(top->edge[i].pa, border = FALSE); } for (i = 0; i < top->wall.nel; i++) { SetWallProperties(top->wall[i].pa, border = FALSE); ??? a = top->wall[i].pa; { if (((PposP(a) == NULL)) || ((PnegP(a) == NULL))) { SetWallProperties(a, TRUE); SetNodeProperties(a, border = TRUE); SetEdgeProperties(a, border = TRUE); b = a; do { SetNodeProperties(b, border = TRUE); SetEdgeProperties(b, border = TRUE); b = NextE(b) } while (b != a); } } } } /* END SetElemProperties */ PROCEDURE SetWallProperties(Place_t b, bool_t border) /* Set wall properties according to internal/border. */ { ??? t = NARROW(PWall(b); with ( Triangulation.Wall) ){ if (border) { t.color = (frgb_t){1.00, 0.75, 0.20}; t.transp = (frgb_t){0.90, 0.90, 0.90}; } else { t.color = (frgb_t){0.90, 1.00, 0.20}; t.transp = (frgb_t){0.95, 0.95, 0.95}; } } } /* END SetWallProperties */ PROCEDURE SetEdgeProperties(Place_t @p, bool_t border) /* Set the material proeprties for an @{edge->?} according to internal/border. */ { ??? e = NARROW(PEdge(a), Triangulation.edge); with ( ){ if (border) { e.color = (frgb_t){0.000, 0.000, 0.000}; e.transp = (frgb_t){0.000, 0.000, 0.000}; e.radius = 0.0075 } else { e.color = (frgb_t){0.333, 0.333, 0.333}; e.transp = (frgb_t){0.000, 0.000, 0.000}; e.radius = 0.0050; } } } /* END SetEdgeProperties */ PROCEDURE SetNodeProperties(Place_t @p, bool_t border) /* Set the node material properties. */ { Node_t v = OrgV(a); { if (border) { v.radius = 0.015; v.color = (frgb_t){0.000, 0.000, 0.000} } else { v.radius = 0.025; v.color = (frgb_t){0.333, 0.333, 0.333} } } } /* END SetNodeProperties */ Options_t *GetOptions(int argc, char **argv) { Options_t *o = (Options_t *)malloc(sizeof(Options_t)); argparser_t *pp = argparser_new(stderr, argc, argv); argparser_set_help(pp, PROG_NAME " version " PROG_VERS ", usage:\n" PROG_HELP); argparser_set_info(pp, PROG_INFO); argparser_process_help_info_options(pp); argparser_get_keyword(pp, "-shape"); o->shapeName = argparser_get_next(pp); if (0 == strcmp(o->shapeName, "4-vstar") )) { o->shape = Shape_sh_4_vstar } else if (0 == strcmp(o->shapeName, "8-vstar"))){ o->shape = Shape_sh_8_vstar } else if (0 == strcmp(o->shapeName, "20-vstar"))){ o->shape = Shape_sh_20_vstar } else if (0 == strcmp(o->shapeName, "60-vstar"))){ o->shape = Shape_sh_60_vstar } else { argparser_error(pp, "Bad shape \"" & argparser_get_next(pp) & "\"\n") } argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: MakeVStar \\\n" \ " -shape { 4-vstar | 8-vstar | 20-vstar | 60-vstar }\n"); END¦ } } return o; } /* END GetOptions */ /* end MakeVStar */ /* Copyright © 2000 Universidade Estadual de Campinas (UNICAMP) */