/* See {MakeBigCubeFixed.h} */ /* Create a tridimensional array of cubic cells with fixed geometry. */ /* Last edited on 2007-01-25 14:53:49 by stolfi */ #include #include #include #include #define _GNU_SOURCE #include #include typedef struct Options_t { uint gridOrder; /* order of the grid. */ bool_t original; /* emphazise the original elements on a cube. */ } Options_t; @PLACES == ARRAY[0..3] OF Place_t; double TriPlace_t = ARRAY OF ARRAY OF ARRAY [0..1] OF Place_t; Place_t MakeBigRawCube(uint order, bool_t original) { Place_vec_t cd = BuildBigrawCube(order); TwoPlaces_vec_t a = TwoPlaces_vec_new(order*order); if (original) { /* Selecting the places for emphasize */ for (j = 0; j < order; j++) { for (k = 0; k < order; k++) { a.el[j,k,0] = cd.el[0,k,j,0]; a.el[j,k,1] = cd.el[order-1,k,j,1]; } } } /* Fix the coordinates */ Topology_t top = MakeTopology(cd.el[0].p[0]); Coords_t c = r4_vec_new(top->NV); double zero = 0.0, one = 1.0; char *cmt = " "; name = "Bigcube-" & Fmt.Int(order); void SetCorner(e: Place_t; uint i) { ??? ii = FLOAT(i, double)); with( double cv = (r4_t){ii,zero,zero,zero} ){ c[OrgV(e)->num] = cv; } } SetCorner; void SetCorner1(e: Place_t; o: r4_t) { c[OrgV(e)->num] = (r4_t){o[0], o[1]+one, o[2], o[3]}; } SetCorner1; void SetCorner2(e: Place_t; o: r4_t) { c[OrgV(e)->num] = (r4_t){o[0], o[1], o[2]+one, o[3]}; } SetCorner2; void SetCorner3(e: Place_t; o: r4_t) { c[OrgV(e)->num] = (r4_t){o[0], o[1]-one, o[2], o[3]}; } SetCorner3; Place_t *p; { for (i = 0; i < order; i++) { SetCorner(Clock(NextE(cd[i,0,0,0])),i); for (j = 0; j < order; j++) { p = Clock(NextE(cd[i,j,0,0])); for (k = 0; k < order; k++) { SetCorner1(NextE(p),c[OrgV(p)->num]); SetCorner2(NextE(NextE(p)),c[OrgV(NextE(p))->num]); SetCorner3(NextE(NextE(NextE(p))),c[OrgV(NextE(NextE(p)))->num]); p = NextE(PrevF(PrevF(cd[i,j,k,0]))); } } } /* finally */ SetCorner(PrevE(cd[order-1,0,0,1]),order); for (j = 0; j < order; j++) { p = PrevE(cd[order-1,j,0,1]); for (k = 0; k < order; k++) { SetCorner1(NextE(p),c[OrgV(p)->num]); SetCorner2(NextE(NextE(p)),c[OrgV(NextE(p))->num]); SetCorner3(NextE(NextE(NextE(p))),c[OrgV(NextE(NextE(p)))->num]); p = Clock(PrevE(NextF(cd[order-1,j,k,1]))); } } if (original) { /* Set all elements (nodes, @{edge->?}s, walls, as non-existing */ for (i = 0; i < top->NF; i++) { ??? f = top->wall[i]; { f->exists = FALSE; } } for (i = 0; i < top->NE; i++) { ??? e = top->edge[i]; { e->exists = FALSE; } } for (i = 0; i < top->NV; i++) { Node_t v = top->node.el[i]; { v->exists = FALSE; } } /* Now emphasize the original elements (nodes,@{edge->?}s,walls) */ SetCubeProperties(a, order, top); name = name; } /* set the root elements */ for (i = 0; i < top->NF; i++) { ??? f = top->wall[i]; { f->root = f->num; } } for (i = 0; i < top->NE; i++) { ??? e = top->edge[i]; { e->root = e->num; } } WriteTopology(name,top); WriteState(name, top, c, cmt); WriteMaterials(name, top, cmt); return cd[0,0,0,0]; } } } /* END MakeBigRawCube */ Options_t GetOptions () { 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, "-gridOrder"); o->gridOrder = argparser_get_next_int(pp, 1,10); o->original = argparser_keyword_present(pp, "-original"); argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: MakeRawCube -gridOrder \\\n" \ " [ -original] \n"); END¦ } } return o; } /* END GetOptions */ PROCEDURE Main() Place_t *a; { Options_t *o = GetOptions(argc, argv); char *topo_cmt = NULL; asprintf(&topo_cmt, "Created by %s on %s", PROG_NAME, Today()); /* Random_t coins = MakeRandomSource(4615); */ { a = MakeBigRawCube(o->gridOrder, o->original); } } /* END Main */ { Main(); } MakeBigCubeFixed.