#define PROG_NAME "TestSubdivideTetrahedron" #define PROG_DESC "???" #define PROG_VERS "1.0" /* Last edited on 2007-02-03 23:14:53 by stolfi */ #define TestSubdivideTetrahedron_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* Testing The SubdivideTetrahedron procedure. */ #include #include #include #define _GNU_SOURCE #include #include #include #include #include uint NVP = 0; TYPE typedef struct Options_t { char *inFile; /* Initial guess file name (minus ".tp") */ char *outFile; /* Output file name prefix */ } 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); */ ??? tc = Triangulation.ReadToMa(o->inFile); ??? top = tc.top; { /* Subdivision of degenerative tetrahedra */ fprintf(stderr, "Eliminating degenerative tetrahedra\n"); for (j = 0; j < top->cell.nel; j++) { ??? r = Srot(top->cell[j]); Place_t a = Tors(r); { SubdivideTetrahedron(a,top); } } ??? newtop = MakeElemTable(top->wedge[1]; with (1), double nc = GenCoords(newtop)^; double cmt = "Created by Selective Subdivision of : " & o->outFile ){ WriteTopology(o->outFile, newtop, cmt & ".tp\n" & "on " & Today()); WriteState(o->outFile,newtop, nc, cmt & ".st\n" & "on " & Today()); Triangulation.FindDegeneracies(newtop); WriteMaterials(o->outFile, newtop, cmt & ".ma\n" & "on " & Today()); } return 0; } PROCEDURE SubdivideTetrahedron(Place_t @p, ElemTableRec_t *top) /* Subdivide a degenerative tetrahedron in four new tetrahedra through the insertion of a new medial node of type "VP" more six walls and three @{edge->?}s. */ @{Node->?} *y; { /* Create the medial node "VP" */ y = MakeNode(NVP); ??? v = (Node_t)(y); { ){ v.label = "VP"; v.radius = 0.00; v.transp = (frgb_t){1.0,1.0,1.0}; v.color = (frgb_t){1.0,1.0,1.0}; NVP++; } Place_t b = PrevF(a); Place_t c = PrevE(b); Place_t d = NextF(c); Place_t e = PrevE(a); Place_t f = PrevF(e); Place_t g = PrevE(f); Place_t h = NextF(g); Wall_t fa = PWall(a); Wall_t fb = PWall(b); Wall_t fg = PWall(g); Wall_t fh = PWall(h); Edge_t ea = PEdge(a); Edge_t ec = PEdge(c); Edge_t ee = PEdge(e); Edge_t eh = PEdge(h); Edge_t eeb = PEdge(NextE(b)); Edge_t eea = PEdge(NextE(a)); Place_t i = NextE(a); Place_t j = PrevF(i); Place_t k = NextE(b); Place_t l = NextF(k); ??? u = OrgV(a); ??? v = OrgV(Clock(a)); ??? w = OrgV(c); ??? x = OrgV(e); ??? f1 = MakeTriangle(); ??? f2 = MakeTriangle(); ??? f3 = MakeTriangle(); ??? f4 = MakeTriangle(); ??? f5 = MakeTriangle(); ??? f6 = MakeTriangle(); Cell_t q1 = MakeCell(0); Cell_t q2 = MakeCell(1); Cell_t q3 = MakeCell(2); Cell_t q4 = MakeCell(3); { /* save attributes for the original walls: "fa", "fb", "fg", "fh". */ fa->exists = top->wall[fa->num]->exists; fa.color = top->wall[fa->num].color; fa.transp = top->wall[fa->num].transp; fb->exists = top->wall[fb->num]->exists; fb.color = top->wall[fb->num].color; fb.transp = top->wall[fb->num].transp; fg->exists = top->wall[fg->num]->exists; fg.color = top->wall[fg->num].color; fg.transp = top->wall[fg->num].transp; fh->exists = top->wall[fh->num]->exists; fh.color = top->wall[fh->num].color; fh.transp = top->wall[fh->num].transp; /* save attributes for the original edgess: "ea", "ec", "ee", "eh", "eeb", and "eea". */ ea->exists = top->edge[ea->num]->exists; ea.color = top->edge[ea->num].color; ea.transp = top->edge[ea->num].transp; ea.radius = top->edge[ea->num].radius; ec->exists = top->edge[ec->num]->exists; ec.color = top->edge[ec->num].color; ec.transp = top->edge[ec->num].transp; ec.radius = top->edge[ec->num].radius; ee->exists = top->edge[ee->num]->exists; ee.color = top->edge[ee->num].color; ee.transp = top->edge[ee->num].transp; ee.radius = top->edge[ee->num].radius; eh->exists = top->edge[eh->num]->exists; eh.color = top->edge[eh->num].color; eh.transp = top->edge[eh->num].transp; eh.radius = top->edge[eh->num].radius; eea->exists = top->edge[eea->num]->exists; eea.color = top->edge[eea->num].color; eea.transp = top->edge[eea->num].transp; eea.radius = top->edge[eea->num].radius; eeb->exists = top->edge[eeb->num]->exists; eeb.color = top->edge[eeb->num].color; eeb.transp = top->edge[eeb->num].transp; eeb.radius = top->edge[eeb->num].radius; /* set the attributes for the new internal walls */ PWall(f1)->exists = FALSE; PWall(f2)->exists = FALSE; PWall(f3)->exists = FALSE; PWall(f4)->exists = FALSE; PWall(f5)->exists = FALSE; PWall(f6)->exists = FALSE; PWall(f1).color = (frgb_t){1.0,1.0,1.0}; PWall(f2).color = (frgb_t){1.0,1.0,1.0}; PWall(f3).color = (frgb_t){1.0,1.0,1.0}; PWall(f4).color = (frgb_t){1.0,1.0,1.0}; PWall(f5).color = (frgb_t){1.0,1.0,1.0}; PWall(f6).color = (frgb_t){1.0,1.0,1.0}; PWall(f1).transp = (frgb_t){1.0,1.0,1.0}; PWall(f2).transp = (frgb_t){1.0,1.0,1.0}; PWall(f3).transp = (frgb_t){1.0,1.0,1.0}; PWall(f4).transp = (frgb_t){1.0,1.0,1.0}; PWall(f5).transp = (frgb_t){1.0,1.0,1.0}; PWall(f6).transp = (frgb_t){1.0,1.0,1.0}; /* insert f1 */ SetNextF(b,f1); SetNextF(f1,a); /* insert f2 */ SetNextF(c,f2); SetNextF(f2,d); /* insert f3 */ SetNextF(f,f3); SetNextF(f3,e); /* set the relations among f1,f2 and f3 */ SetNextF(Clock(NextE(f2)),PrevE(f1)); SetNextF(PrevE(f1),Clock(NextE(f3))); SetNextF(Clock(NextE(f3)),Clock(NextE(f2))); SetRingEdgeInfo(PrevE(f1), PEdge(PrevE(f1))); PEdge(PrevE(f1))->exists = FALSE; PEdge(PrevE(f1)).color = (frgb_t){1.0,1.0,1.0}; PEdge(PrevE(f1)).transp = (frgb_t){1.0,1.0,1.0}; PEdge(PrevE(f1)).radius = 0.004; /* insert f4 */ SetNextF(j,f4); SetNextF(f4,i); /* insert f5 */ SetNextF(k,f5); SetNextF(f5,l); /* insert f6 */ SetNextF(g,f6); SetNextF(f6,h); /* set the internal relations along @{edge->?} "yv" */ SetNextF(PrevE(f5),PrevE(f4)); SetNextF(PrevE(f4),Clock(NextE(f1))); SetNextF(Clock(NextE(f1)), PrevE(f5)); SetRingEdgeInfo(Clock(NextE(f1)),PEdge(Clock(NextE(f1)))); PEdge(NextE(f1))->exists = FALSE; PEdge(NextE(f1)).color = (frgb_t){1.0,1.0,1.0}; PEdge(NextE(f1)).transp = (frgb_t){1.0,1.0,1.0}; PEdge(NextE(f1)).radius = 0.004; /* set the internal relations along @{edge->?} "wy" */ SetNextF(NextE(f5),Clock(PrevE(f6))); SetNextF(Clock(PrevE(f6)),Clock(PrevE(f2))); SetNextF(Clock(PrevE(f2)),NextE(f5)); SetRingEdgeInfo(NextE(f5),PEdge(NextE(f5))); PEdge(NextE(f5))->exists = FALSE; PEdge(NextE(f5)).color = (frgb_t){1.0,1.0,1.0}; PEdge(NextE(f5)).transp = (frgb_t){1.0,1.0,1.0}; PEdge(NextE(f5)).radius = 0.004; /* set the internal relations along @{edge->?} "xy" */ SetNextF(NextE(f6), NextE(f4)); SetNextF(NextE(f4), Clock(PrevE(f3))); SetNextF(Clock(PrevE(f3)), NextE(f6)); SetRingEdgeInfo(NextE(f4), PEdge(NextE(f4))); PEdge(NextE(f4))->exists = FALSE; PEdge(NextE(f4)).color = (frgb_t){1.0,1.0,1.0}; PEdge(NextE(f4)).transp = (frgb_t){1.0,1.0,1.0}; PEdge(NextE(f4)).radius = 0.004; /* set the overall @{edge->?} component */ SetRingEdgeInfo(a, ea); SetRingEdgeInfo(c, ec); SetRingEdgeInfo(e, ee); SetRingEdgeInfo(i, eea); SetRingEdgeInfo(k, eeb); SetRingEdgeInfo(h, eh); SetRingWallInfo(a, fa); SetRingWallInfo(b, fb); SetRingWallInfo(g, fg); SetRingWallInfo(h, fh); /* set the origins */ SetOrgAll(a,u); SetOrgAll(Clock(a),v); SetOrgAll(c,w); SetOrgAll(e,x); SetOrgAll(PrevE(f1),y); /* set the cells */ SetPnegOfNearbyWalls(a,q1); SetPnegOfNearbyWalls(Spin(b),q2); SetPnegOfNearbyWalls(Spin(g),q3); SetPnegOfNearbyWalls(Spin(f6),q4); } } /* END SubdivideTetrahedron */ 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, "-outFile"); o->outFile = argparser_get_next(pp); argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: TestSubdivideTetrahedron\\\n" \ " -inFile -outFile \\\n"); END¦ } } return o; } /* END GetOptions */ { DoIt() } TestSubdivideTetrahedron. /* Copyright © 2000 Universidade Estadual de Campinas (UNICAMP) */