#define PROG_NAME "TestSubdivideWall" #define PROG_DESC "???" #define PROG_VERS "1.0" /* Last edited on 2007-02-03 23:24:27 by stolfi */ #define TestSubdivideWall_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* Testing the SubdivideWall procedure. */ #include #include #include #define _GNU_SOURCE #include #include #include #include #include #include VAR NVF = 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 walls */ fprintf(stderr, "Eliminating degenerative walls\n"); for (j = 0; j < top->wall.nel; j++) { ??? f = top->wall[j]; ??? a = f.pa; { IF((PnegP(a)!=NULL)) && ((PposP(a) #NULL)))) { SubdivideWall(a,top); } } } ??? newtop = MakeElemTable(top->wedge[0]); ??? nc = GenCoords(newtop)^; ??? 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()); WriteMaterials(o->outFile, newtop, cmt & ".ma\n" & "on " & Today()); } return 0; } PROCEDURE SubdivideWall(Place_t @p, ElemTableRec_t *top) /* Subdivide a degenerative triangular wall in three new walls through the insertion of a new medial node of type "VF" and six wall-@{edge->?} @places. Then, expand this subdivision on the wall's star. */ VAR @{Node->?} x; { /* Create the medial node "VF" */ x = MakeNode(NVF); ??? v = (Node_t)(x); { ){ v.label = "VF"; v.radius = 0.000; v.transp = (frgb_t){1.0,1.0,1.0}; v.color = (frgb_t){1.0,1.0,1.0}; NVF++; } Wall_t fa = PWall(a); Edge_t ea = PEdge(a); Place_t b = NextE(a); Edge_t eb = PEdge(b); Place_t c = PrevE(a); Edge_t ec = PEdge(c); Place_t af = NextF(a); Place_t bf = NextF(b); Place_t cf = NextF(c); Place_t af_ = PrevF(a); Place_t bf_ = PrevF(b); Place_t cf_ = PrevF(c); Edge_t eaf = PEdge(PrevE(af)); Edge_t eaf_ = PEdge(PrevE(af_)); Wall_t faf = PWall(af); Wall_t faf_ = PWall(af_); Edge_t ebf = PEdge(PrevE(bf)); Edge_t ebf_ = PEdge(PrevE(bf_)); Wall_t fbf = PWall(bf); Wall_t fbf_ = PWall(bf_); Edge_t ecf = PEdge(PrevE(cf)); Edge_t ecf_ = PEdge(PrevE(cf_)); Wall_t fcf = PWall(cf); ??? fcf_ == PWall(cf_), ??? u = OrgV(a); ??? v = OrgV(b); ??? w = OrgV(c); Place_t d = MakeWedge(); Place_t e = MakeWedge(); Place_t f = MakeWedge(); Place_t g = MakeWedge(); Place_t h = MakeWedge(); Place_t i = MakeWedge(); Wall_t df = PWall(d); Wall_t ff = PWall(f); Wall_t hf = PWall(h); /* new walls to insert on the wall's star */ ??? 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); Cell_t q5 = MakeCell(4); Cell_t q6 = MakeCell(5); { if (top->wall[fa->num]->exists) { df->exists = TRUE; ff->exists = TRUE; hf->exists = TRUE; } else { df->exists = FALSE; ff->exists = FALSE; hf->exists = FALSE; } df.color = top->wall[fa->num].color; df.transp = top->wall[fa->num].transp; ff.color = top->wall[fa->num].color; ff.transp = top->wall[fa->num].transp; hf.color = top->wall[fa->num].color; hf.transp = top->wall[fa->num].transp; /* first link connecting the @place "a" */ SetNextE(a,d); SetNextE(d,e); SetNextE(e,a); SetRingWallInfo(d,df); /* second link connecting the @place "b" */ SetNextE(b,f); SetNextE(f,g); SetNextE(g,b); SetRingWallInfo(f,ff); /* third link connecting the @place "c" */ SetNextE(c,h); SetNextE(h,i); SetNextE(i,c); SetRingWallInfo(h,hf); /* save information about the original edges "PEdge(a)": "ea" */ 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; /* save information about the original edges "PEdge(b)": "eb" */ eb->exists = top->edge[eb->num]->exists; eb.color = top->edge[eb->num].color; eb.transp = top->edge[eb->num].transp; eb.radius = top->edge[eb->num].radius; /* save information about the original edges "PEdge(c)": "ec" */ 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; /* save information about the wall "PWall(af)" : "faf" */ faf->exists = top->wall[faf->num]->exists; faf.color = top->wall[faf->num].color; faf.transp = top->wall[faf->num].transp; /* save information about the edge "PEdge(af)" : "eaf" */ eaf->exists = top->edge[eaf->num]->exists; eaf.color = top->edge[eaf->num].color; eaf.transp = top->edge[eaf->num].transp; eaf.radius = top->edge[eaf->num].radius; /* save information about the wall "PWall(af_)" : "faf_" */ faf_->exists = top->wall[faf_->num]->exists; faf_.color = top->wall[faf_->num].color; faf_.transp= top->wall[faf_->num].transp; /* save information about the edge "PEdge(af_)" : "eaf_" */ eaf_->exists = top->edge[eaf_->num]->exists; eaf_.color = top->edge[eaf_->num].color; eaf_.transp = top->edge[eaf_->num].transp; eaf_.radius = top->edge[eaf_->num].radius; /* save information about the wall "PWall(bf)" : "fbf" */ fbf->exists = top->wall[fbf->num]->exists; fbf.color = top->wall[fbf->num].color; fbf.transp= top->wall[fbf->num].transp; /* save information about the edge "PEdge(bf)" : "ebf" */ ebf->exists = top->edge[ebf->num]->exists; ebf.color = top->edge[ebf->num].color; ebf.transp = top->edge[ebf->num].transp; ebf.radius = top->edge[ebf->num].radius; /* save information about the wall "PWall(bf_)" : "fbf_" */ fbf_->exists= top->wall[fbf_->num]->exists; fbf_.color = top->wall[fbf_->num].color; fbf_.transp= top->wall[fbf_->num].transp; /* save information about the edge "PEdge(bf_)" : "ebf_" */ ebf_->exists = top->edge[ebf_->num]->exists; ebf_.color = top->edge[ebf_->num].color; ebf_.transp = top->edge[ebf_->num].transp; ebf_.radius = top->edge[ebf_->num].radius; /* save information about the wall "PWall(cf)" : "fcf" */ fcf->exists = top->wall[fcf->num]->exists; fcf.color = top->wall[fcf->num].color; fcf.transp= top->wall[fcf->num].transp; /* save information about the edge "PEdge(cf)" : "ecf" */ ecf->exists = top->edge[ecf->num]->exists; ecf.color = top->edge[ecf->num].color; ecf.transp = top->edge[ecf->num].transp; ecf.radius = top->edge[ecf->num].radius; /* save information about the wall "PWall(cf_)" : "fcf_" */ fcf_->exists = top->wall[fcf_->num]->exists; fcf_.color = top->wall[fcf_->num].color; fcf_.transp= top->wall[fcf_->num].transp; /* save information about the edge "PEdge(cf_)" : "ecf_" */ ecf_->exists = top->edge[ecf_->num]->exists; ecf_.color = top->edge[ecf_->num].color; ecf_.transp = top->edge[ecf_->num].transp; ecf_.radius = top->edge[ecf_->num].radius; /* set the attributes for the 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}; /* Now make the connections in the interior of wall */ SetNextF(g,Clock(d)); SetNextF(i,Clock(f)); SetNextF(e,Clock(h)); /* Now subdivide the "PposP(a)" tetrahedron ( the superior tetrahedron in my plan */ /* first we, insert f1 */ SetNextF(d, Clock(f1)); SetNextF(Clock(f1), Clock(g)); assert(NextF(Clock(g)) == d); SetNextF(NextE(f1),NextE(af)); SetNextF(Clock(PrevE(bf)), NextE(f1)); /* now, we insert f2 */ SetNextF(f, Clock(f2)); SetNextF(Clock(f2), Clock(i)); assert(NextF(Clock(i)) == f); SetNextF(NextE(f2),NextE(bf)); SetNextF(Clock(PrevE(cf)), NextE(f2)); /* now, we insert f3 */ SetNextF(h, Clock(f3)); SetNextF(Clock(f3), Clock(e)); assert(NextF(Clock(e)) == h); SetNextF(NextE(f3),NextE(cf)); SetNextF(Clock(PrevE(af)), NextE(f3)); /* now make connections between the internal walls inserted */ SetNextF(PrevE(f1),PrevE(f3)); SetNextF(PrevE(f3),PrevE(f2)); assert(NextF(PrevE(f2)) == PrevE(f1)); /* set the superior axial @{edge->?} */ SetRingEdgeInfo(PrevE(f1), PEdge(PrevE(f1))); /* OK */ 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; /* Now subdivide the "PnegP(a)" tetrahedron ( the inferior tetrahedron in my plan */ /* now, we insert f4 */ SetNextF(Clock(g), Clock(f4)); assert(NextF(Clock(f4)) == d); SetNextF(NextE(af_), NextE(f4)); SetNextF(NextE(f4), Clock(PrevE(bf_))); /* now, we insert f5 */ SetNextF(Clock(i), Clock(f5)); assert(NextF(Clock(f5)) == f); SetNextF(NextE(bf_), NextE(f5)); SetNextF(NextE(f5), Clock(PrevE(cf_))); /* now, we insert f6 */ SetNextF(Clock(e), Clock(f6)); assert(NextF(Clock(f6)) == h); SetNextF(NextE(cf_), NextE(f6)); SetNextF(NextE(f6), Clock(PrevE(af_))); /* now make connections between the internal walls inserted */ SetNextF(PrevE(f4),PrevE(f5)); SetNextF(PrevE(f5),PrevE(f6)); assert(NextF(PrevE(f6)) == PrevE(f4)); /* set the inferior axial @{edge->?} */ SetRingEdgeInfo(PrevE(f4), PEdge(PrevE(f4))); /* OK */ PEdge(PrevE(f4))->exists = FALSE; PEdge(PrevE(f4)).color = (frgb_t){1.0,1.0,1.0}; PEdge(PrevE(f4)).transp = (frgb_t){1.0,1.0,1.0}; PEdge(PrevE(f4)).radius = 0.004; /* set the origins */ SetOrgAll(f1, x); SetOrgAll(a, u); SetOrgAll(b, v); SetOrgAll(c, w); SetOrgAll(PrevE(f1), OrgV(PrevE(af))); SetOrgAll(PrevE(f4), OrgV(PrevE(af_))); /* set the new internal @{edge->?}s */ SetRingEdgeInfo(f1,PEdge(f1)); PEdge(f1)->exists = FALSE; PEdge(f1).color = (frgb_t){1.0,1.0,1.0}; PEdge(f1).transp = (frgb_t){1.0,1.0,1.0}; PEdge(f1).radius = 0.004; SetRingEdgeInfo(f2,PEdge(f2)); PEdge(f2)->exists = FALSE; PEdge(f2).color = (frgb_t){1.0,1.0,1.0}; PEdge(f2).transp = (frgb_t){1.0,1.0,1.0}; PEdge(f2).radius = 0.004; SetRingEdgeInfo(f3,PEdge(f3)); PEdge(f3)->exists = FALSE; PEdge(f3).color = (frgb_t){1.0,1.0,1.0}; PEdge(f3).transp = (frgb_t){1.0,1.0,1.0}; PEdge(f3).radius = 0.004; /* set the original edgess and walls in the superior level */ SetRingEdgeInfo(PrevE(af),eaf); SetRingEdgeInfo(PrevE(bf),ebf); SetRingEdgeInfo(PrevE(cf),ecf); SetRingWallInfo(af,faf); SetRingWallInfo(bf,fbf); SetRingWallInfo(cf,fcf); /* set the original edgess and walls in the inferior label */ SetRingEdgeInfo(PrevE(af_),eaf_); SetRingEdgeInfo(PrevE(bf_),ebf_); SetRingEdgeInfo(PrevE(cf_),ecf_); SetRingWallInfo(af_,faf_); SetRingWallInfo(bf_,fbf_); SetRingWallInfo(cf_,fcf_); /* set the original edgess in the half label */ SetRingEdgeInfo(a,ea); SetRingEdgeInfo(b,eb); SetRingEdgeInfo(c,ec); SetPnegOfNearbyWalls(Clock(PrevE(f1)),q1); SetPnegOfNearbyWalls(Clock(PrevE(f2)),q2); SetPnegOfNearbyWalls(Clock(PrevE(f3)),q3); SetPnegOfNearbyWalls(PrevE(f4),q4); SetPnegOfNearbyWalls(PrevE(f5),q5); SetPnegOfNearbyWalls(PrevE(f6),q6); } } /* END SubdivideWall */ 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: TestSubdivideWall \\\n" \ " -inFile -outFile \\\n"); END¦ } } return o; } /* END GetOptions */ /* UNUSED */ uint NumInternalWalls(ElemTableRec_t *top) number: uint = 0; { for (j = 0; j < top->wall.nel; j++){ ??? a = top->wall[j].pa; { if (((PposP(a)!=NULL)) && ((PnegP(a)!=NULL))){ number++; } } } return number; } NumInternalWalls; { DoIt() } TestSubdivideWall. /* Copyright © 2000 Universidade Estadual de Campinas (UNICAMP) */