#define PROG_NAME "TestSubdivideTetra" #define PROG_DESC "???" #define PROG_VERS "1.0" /* Last edited on 2007-02-03 23:14:36 by stolfi */ #define TestSubdivideTetra_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* Testing The SubdivideTetrahedron procedure. */ #include #include #include #include #define _GNU_SOURCE #include #include #include // #include #include #include uint NVP = 0; X : REF r4_vec_t; ElemTableRec_t oldtop; /* Was {oldtopology} */; 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; ??? rc = Triangulation.ReadState(o->inFile); ??? c = rc^; ??? nc = NEW(REF Coords_t; with (top->node.nel+top->cell.nel)^, double cmt = "Created by Selective Subdivision of : " & o->outFile ){ /* 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,c,nc); } } ??? newtop = MakeElemTable(top->wedge[1]); { WriteTopology(o->outFile, newtop, cmt & ".tp\n" & "on " & Today()); WriteState(o->outFile,newtop, nc, cmt & ".st\n" & "on " & Today()); WriteMaterials(o->outFile, newtop, cmt & ".ma\n" & "on " & Today()); } return 0; } PROCEDURE SubdivideTetrahedron(Place_t @p, ElemTableRec_t *top; *co: Coords_t; VAR nc: Coords_t) /* 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(0); ??? vv = (Node_t)(y); { double b = PrevF(a); double c = PrevE(b); double d = NextF(c); double e = PrevE(a); double f = PrevF(e); double g = PrevE(f); double h = NextF(g); double fa = PWall(a); double fb = PWall(b); double fg = PWall(g); double fh = PWall(h); double ea = PEdge(a); double ec = PEdge(c); double ee = PEdge(e); double eh = PEdge(h); eeb = PEdge(NextE(b)), eea = PEdge(NextE(a)), double i = NextE(a); double j = PrevF(i); double k = NextE(b); double l = NextF(k); double u = OrgV(a); double v = OrgV(Clock(a)); double w = OrgV(c); double x = OrgV(e); double f1 = MakeTriangle(); double f2 = MakeTriangle(); double f3 = MakeTriangle(); double f4 = MakeTriangle(); double f5 = MakeTriangle(); double f6 = MakeTriangle(); double q1 = MakeCell(0); double q2 = MakeCell(1); double q3 = MakeCell(2); double q4 = MakeCell(3) ){ vv.label = "VP"; vv.radius = 0.0001; vv.transp = (frgb_t){1.0,1.0,1.0}; vv.color = (frgb_t){1.0,1.0,1.0}; vv->num = NVP; NVP++; nc[u->num] = co.el[u->num]; nc[v->num] = co.el[v->num]; nc[w->num] = co.el[w->num]; nc[x->num] = co.el[x->num]; nc[vv->num] = r4_Scale(0.25, r4_Add(co.el[u->num], r4_Add(r4_Add(co.el[v->num],co.el[w->num]),co.el[x->num]))); /* 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 */ /* PROCEDURE FixaTetrahedron(Place_t @p, Coords_t *c, VAR nc: Coords_t) /* */ { assert(! (Pneg(a)!=NULL) && (Ppos(a)!=NULL)); Node_t u = OrgV(a); Node_t v = OrgV(Clock(a)); Node_t x = OrgV(PrevE(a)); Node_t w = OrgV(PrevE(NextF(a))); Node_t y = OrgV(PrevE(PrevF(a))); { Mis.WriteInt(stderr, u->num); Mis.WriteInt(stderr, v->num); Mis.WriteInt(stderr, w->num); Mis.WriteInt(stderr, x->num); Mis.WriteInt(stderr, y->num); fprintf(stderr, y.label); } } FixaTetrahedron; */ 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: TestSubdivideTetra \\\n" \ " -inFile -outFile \\\n"); END¦ } } return o; } /* END GetOptions */ { DoIt() } TestSubdivideTetra. /* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP) */