#define PROG_NAME "UngluingCell" #define PROG_DESC "???" #define PROG_VERS "1.0" /* Last edited on 2024-12-21 11:37:53 by stolfi */ #define UngluingCell_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* Given a map or any refinement of its, this program unglued any specified cell of the map. */ #include #include #include #include #include // #include // MakeCellTopology, Place_t, PnegP, PposP, OrgV; #include // NextE, Srot; TYPE typedef struct Options_t { char *inFile; uint cellnum; char *outFile; bool_t polyroot; } Options_t *GetOptions(int argc, char **argv); int main(int argc, char **argv) Place_t *b; tc : Triangulation.TopCom_t; ElemTableRec_t top; old@{edge->?}: REF ARRAY OF INTEGER; oldwall: REF ARRAY OF INTEGER; oldcoor: REF ARRAY OF INTEGER; { Options_t *o = GetOptions(argc, argv); char *topo_cmt = jsprintf("Created by %s on %s", PROG_NAME, Today()); /* Random_t coins = MakeRandomSource(4615); */ ??? rc = Triangulation.ReadState(o->inFile); ??? c = rc^; { if (o->polyroot ){ tc = Triangulation.ReadToMa(o->inFile, TRUE); } else { tc = Triangulation.ReadToMa(o->inFile, FALSE); } fprintf(stderr,"Ungluing the cell number "&Fmt.Int(o->cellnum) & "\n"); top = tc.top; old@{edge->?} = NEW(REF ARRAY OF INTEGER, top->wall.nelE); oldwall = NEW(REF ARRAY OF INTEGER, top->wall.nelE); oldcoor = NEW(REF ARRAY OF INTEGER, top->wall.nelE); for (i = 0; i < top->wall.nelE; i++) { old@{edge->?}[i] = PWedge(top->wedge[i]).edge->num; oldwall[i] = PWedge(top->wedge[i]).wall->num; oldcoor[i] = OrgV(top->wedge[i])->num } for (i = 0; i < top->wall.nelE; i++) { ??? a = NARROW(PWedge(top->wedge[i]); with ( TriangulationWedge_t) ){ a.old = i; } } if (o->polyroot) { for (i = 0; i < top->cell.nel; i++) { if (top->cell[i]->root == o->cellnum) { ??? a = Srot(top.cell[i]); ??? top = MakeCellTopology(a); { /* ungluing the cell top->cell[i] */ for (j = 0; j < top.wall.nel; j++) { ??? fer = top.fRef[j]; { b = fer; do { Triangulation.SetOrg(Srot(b), NULL); b = NextE(b) } while (!( b == fer)); } } } } } } else { ??? a = Srot(top->cell[o->cellnum]); ??? top = MakeCellTopology(a); { /* ungluing the cell top->cell[i] */ for (j = 0; j < top.wall.nel; j++) { ??? fer = top.fRef[j]; { b = fer; do { Triangulation.SetOrg(Srot(b), NULL); b = NextE(b) } while (!( b == fer)); } } } } for (i = 0; i < top->wall.nelE; i++) { ??? a = top->wedge[i]; ??? n = PnegP(a); ??? p = PposP(a); { if ((n == NULL) && (p == NULL)) { Place_t *b; { b = a; do { Octf.DeleteWedge(b); b = NextE(b); } while (b != a); } } } } /* building the new topology */ INTEGER Number() { for (k = 0; k < top->wall.nelE; k++) { ??? l = top->wedge[k]; { if (((PposP(l)#NULL)) && ((PnegP(l)#NULL))){ return k; }; } } return -1; } Number; { ??? l = Number(); ??? top = MakeElemTable(top->wedge[l]); ??? cc = GenCoords(top)^; with ( double name = o->outFile DO /* Update the new topology */ for (i = 0; i < top.edge.nel; i++) { ??? a = top.edge[i]; { Octf.SetRingEdgeInfo(a.pa, a); } } for (i = 0; i < top.wall.nel; i++) { ??? a = top.wall[i]; { Octf.SetRingWallInfo(a.pa, a); } } for (i = 0; i < top.wedge.nel; i++) { ??? fe = NARROW(PWedge(top.wedge[i]); with ( TriangulationWedge_t), double o = fe.old; double ne = PWedge(top.wedge[i]).edge->num; double nf = PWedge(top.wedge[i]).wall->num; double nv = OrgV(top.wedge[i])->num; double oe = old@{edge->?}[o]; double of = oldwall[o]; double ov = oldcoor[o] ){ /* @{edge->?} */ top.edge[ne]->exists = top->edge[oe]->exists; top.edge[ne].color = top->edge[oe].color; top.edge[ne].transp = top->edge[oe].transp; top.edge[ne].radius = top->edge[oe].radius; top.edge[ne]->root = top->edge[oe]->root; /* wall */ top.wall[nf]->exists = top->wall[of]->exists; top.wall[nf].color = top->wall[of].color; top.wall[nf].transp = top->wall[of].transp; top.wall[nf]->root = top->wall[of]->root; /* node */ cc.el[nv] = c[ov]; } } WriteTopology(name, top, "Created by MakeGem: " & name & ".tp on " \ Today()); WriteMaterials(name, top, "Created by MakeGem: " & name& ".ma on " \ Today(),FALSE); WriteState(name, top, cc, "Created by MakeGem: " & name & ".st on " \ Today() &"\nRandom Geometry"); } } return 0; } 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, "-inFile"); o->inFile = argparser_get_next(pp); argparser_get_keyword(pp, "-cellnum"); o->cellnum = argparser_get_next_int(pp, ); argparser_get_keyword(pp, "-outFile"); o->outFile = argparser_get_next(pp); o->polyroot = argparser_keyword_present(pp, "-polyroot"); argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: UngluingCell -inFile \\\n" \ " -outFile -cellnum [-polyroot]\n"); END¦ } } return o; } /* END GetOptions */ { DoIt() } UngluingCell. /* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP) */