#define PROG_NAME "Anaglyphs" #define PROG_DESC "???" #define PROG_VERS "1.0" #define Anaglyphs_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " #include #include #include #include #include #include #define _GNU_SOURCE #include #include #include /* [[!!! DOES THIS COMMENT FROM Octf.h APPLY HERE ??? */ /* A '@{chip->?}' is a group of four @places, consisting of two mutually dual wedges. */ TYPE double FourNodes_t = RECORD u, v, w, x: uint; } typedef struct Options_t { char *inFileTp; inFileSt3: char *; char *outFile; bool_t wire; bool_t all; bool_t texture; bool_t silhouette;/* TRUE draws the silhouette walls */ REAL opacity; /* walls; Transparent (opacity==1) Opaque (opacity==0)*/ } bool_t Sign(d: double) /* Return TRUE iff the longreal value is positive, FALSE c.c. */ { assert(d!=0.0); if (d < 0.0){ return FALSE }else{ return TRUE; }; } /* END Sign */ void DoIt() { 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.ReadToTaMa(o->inFileTp); ??? rc3 = Tridimensional.ReadState3D(o->inFileSt3); ??? top = tc.top; ??? c3 = rc3^; ??? color1 = "RED"; ??? color2 = "CYAN"; { WritePOVFile(top, c3, o, color1); WritePOVFile(top, c3, o, color2); return 0; } void WritePOVFile(ElemTableRec_t *top, * c3: Tridimensional.Coord3D; Options_t * o; char *color; ) <* FATAL Wr.Failure, Thread.Alerted, OSError.E); { ??? wr = FileWr.Open(o->outFile & color & ".inc"); { fprintf(wr, "// Include File: <" & o->outFile & ".inc>\n"); WritePOV(wr, top, c3, o, color); fclose(wr) } } /* END WritePOVFile */ void WritePOV( FILE *wr, *ElemTableRec_t *top; * c3: Coord3D; Options_t * o; char *color; ) double FindOriR3(q: FourNodes_t) /* For each tetrahedron with extremus nodes numbers u,v,w,x computes its orientation in R^{3} through the 4x4 determinant: _ _ | c3[q.u][0] c3[q.u][1] c3[q.u][2] 1.0 | double B = | c3[q.v][0] c3[q.v][1] c3[q.v][2] 1.0 | | c3[q.w][0] c3[q.w][1] c3[q.w][2] 1.0 | | c3[q.x][0] c3[q.x][1] c3[q.x][2] 1.0 | - - */ { double a = (r4_t){c3[q.u][0], c3[q.u][1], c3[q.u][2], 1.0}; double b = (r4_t){c3[q.v][0], c3[q.v][1], c3[q.v][2], 1.0}; double c = (r4_t){c3[q.w][0], c3[q.w][1], c3[q.w][2], 1.0}; double d = (r4_t){c3[q.x][0], c3[q.x][1], c3[q.x][2], 1.0}; { return r4_det(a,b,c,d); } } FindOriR3; bool_t SilhouetteWalls(Place_t @p) /* Return TRUE iff the wall associated to the @place "a" is a silhouette wall, FALSE c.c. */ { ??? t = TetraNegPosNodes(a); ??? un = t[0]->num; ??? vn = t[1]->num; ??? wn = t[2]->num; ??? xn = t[3]->num; ??? yn = t[4]->num; double t1 = FourNodes_t{un,vn,wn,xn}; double t2 = FourNodes_t{un,vn,wn,yn}; double d1 = FindOriR3(t1); double d2 = FindOriR3(t2); { if (((Sign(d1)) && (Sign(d2))) || (((NOT Sign(d1))) && ((NOT Sign(d2))))) { return TRUE; } else { return FALSE; } } } SilhouetteWalls; cor: frgb_t; { /* Drawing @{edge->?}s */ if (0 == strcmp(color,"RED"))){ cor = (frgb_t){1.0,0.0,0.0}; } else { cor = (frgb_t){0.0,1.0,1.0} } if ((! (o->wire) && (o->all))) { for (i = 0; i < top->NE; i++) { ??? e = top->edge[i]; { if ((e->exists) || (o->all)) { ??? o = e.node[0]->num; ??? d = e.node[1]->num; ??? t3 = e.transp; ??? transp = (t3[0] + t3[1] + t3[2]) / 3.0; { WritePOVCylinder(wr,c3[o],c3[d],e.radius,cor,transp); } } } } } if (((o->wire) && (o->all))) { for (i = 0; i < top->NE; i++) { ??? e = top->edge[i]; ??? o = e.node[0]->num; ??? d = e.node[1]->num; ??? t = e.transp; double transp = (t[0] + t[1] + t[2]) / 3.0; { if (e->exists) { WritePOVCylinder(wr,c3[o],c3[d],e.radius,cor,transp); } else { WritePOVCylinder(wr,c3[o],c3[d],(e.radius)*0.75,cor,transp); } } } } /* Drawing nodes */ for (i = 0; i < top->node.nel; i++) { Node_t v = OrgV(top->node.el[i]); { if (((v->exists) && (v.radius > 0.0)) || (o->all)) { ??? t3 = v.transp; ??? transp = (t3[0] + t3[1] + t3[2]) / 3.0; { if (v->exists) { WritePOVSphere(wr,c3[i],v.radius,cor,transp); } else { WritePOVSphere(wr,c3[i],v.radius*0.75,cor,transp); } } } } } if (! o->wire) { /* drawing walls */ for (i = 0; i < top->wall.nel; i++) { ??? f = top->wall[i]; { if ((f->exists) || (o->all)) { if (top->der == 3) { ??? a = f.pa; Node_t an = OrgV(a)->num; Node_t bn = OrgV(NextE(a))->num; Node_t cn = OrgV(NextE(NextE(a)))->num; ??? t3 = f.transp; ??? transp = (t3[0] + t3[1] + t3[2]) / 3.0; { if (! o->texture) { WritePOVTriangle(wr,c3[an],c3[bn],c3[cn],cor,transp); } else { WritePOVTriangleTex(wr,c3[an],c3[bn],c3[cn],cor,transp); } } } else if (top->der == 4){ ??? a = f.pa; Node_t an = OrgV(a)->num; Node_t bn = OrgV(NextE(a))->num; Node_t cn = OrgV(NextE(NextE(a)))->num; Node_t dn = OrgV(PrevE(a))->num; ??? t3 = f.transp; ??? transp = (t3[0] + t3[1] + t3[2]) / 3.0; { WritePOVSquare(wr,c3[an],c3[bn],c3[cn],c3[dn],cor,transp); } } } } } if ((o->silhouette) && (top->der == 3)) { for (i = 0; i < top->wall.nel; i++) { ??? f = top->wall[i]; ??? a = f.pa; Node_t un = OrgV(a)->num; Node_t vn = OrgV(NextE(a))->num; Node_t wn = OrgV(PrevE(a))->num; ??? t = o->opacity; { if ((SilhouetteWalls(a)) && (NOT f->exists)) { WritePOVTriangle(wr,c3[un], c3[vn], c3[wn],cor,t); } } } } } fflush(wr); } /* END WritePOV */ void GetOptions (): Options_t == { 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, "-inFileTp"); o->inFileTp = argparser_get_next(pp); argparser_get_keyword(pp, "-inFileSt3"); o->inFileSt3 = argparser_get_next(pp); if ((argparser_keyword_present(pp, "-outFile"))) { o->outFile = argparser_get_next(pp) } else { o->outFile = o->inFileTp } o->wire = argparser_keyword_present(pp, "-wire"); o->all = argparser_keyword_present(pp, "-all"); o->texture = argparser_keyword_present(pp, "-texture"); if ((argparser_keyword_present(pp, "-silhouette"))) { o->silhouette = TRUE; if ((argparser_keyword_present(pp, "-opacity"))) { o->opacity = pp.getNextReal(0.0,1.0); } else { o->opacity = 0.85; } } argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: Anaglyphs \\\n"); fprintf(stderr," -inFileTp -inFileSt3 \\\n"); fprintf(stderr," [ -outFile ] \\\n"); fprintf(stderr," [ -wire ] [ -all ] [ -texture ] \\\n"); fprintf(stderr," [ -silhouette [ -opacity ] ]\n"); END¦ } } return o; } /* END GetOptions */ { DoIt(); } Anaglyphs. /* Copyright © 2000 Universidade Estadual de Campinas (UNICAMP) */