#define PROG_NAME "MakeComplexWf" #define PROG_DESC "???" #define PROG_VERS "1.0" #define MakeComplexWf_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* Generates ".tp",".tb",".st" and ".ma" files for some simples tridimensional maps with boundary. The node coordinates are random numbers in [-1..+1]. */ #define MakeComplexWf_C_author \ "Created by L. A. P. Lozada, 1999-2000.\n" \ "Revisions:\n" \ " 30-08-2000 : nice version of the {MakeOctahedron} procedure." #include #include #include #include #include #define _GNU_SOURCE #include #include TYPE double Shape = { Triang, Tetra1, Tetra2, Tetra3, TetraRe, CubeTriang, BigCube, Octa1, Octa2, Octa3, Pyramid }; typedef struct Options_t { uint order; Shape shape; char *shapeName; } Options_t *GetOptions(int argc, char **argv); int main(int argc, char **argv) t : Triangulation.Topology; { Options_t *o = GetOptions(argc, argv); char *topo_cmt = NULL; asprintf(&topo_cmt, "Created by %s on %s", PROG_NAME, Today()); /* Random_t coins = MakeRandomSource(4615); */ ??? m = MakeMap(o->shape; with ( o->order) ){ t = MakeTopology(m); Coords_t c = GenCoords(&t);; { /* set the edge and wall roots */ for (i = 0; i < t.NF; i++) { ??? f = t.wall[i]; { f->root = f->num; } }; for (i = 0; i < t.NE; i++) { ??? e = t.edge[i]; { e->root = e->num; } }; /* Now writes */ WriteTopology(o->shapeName & "-" & Fmt.Int(o->order), t, "Created by MakeComplexWf: " & o->shapeName & "-" & Fmt.Int(o->order) \ ".tp on " & Today()); WriteState(o->shapeName & "-" & Fmt.Int(o->order), t, c, "Created by MakeComplexWf: " & o->shapeName & "-" & Fmt.Int(o->order) \ ".st on " & Today() &"\nRandom Geometry"); WriteMaterials(o->shapeName & "-" & Fmt.Int(o->order), t, "Created by MakeComplexWf: " & o->shapeName & "-" & Fmt.Int(o->order) \ ".ma on " & Today()); } return 0; } Place_t MakeMap(shape: Shape; order: uint) { CASE shape OF break; case Shape_Triang: return Squared.MakeTriangle(); break; case Shape_Tetra1: return MakeTetra(order); break; case Shape_Tetra2: return MakeTetra2(order); break; case Shape_Tetra3: return MakeTetra3(order); break; case Shape_TetraRe: return Make12Fold(order); break; case Shape_CubeTriang: return MakeCubeTriang(order); break; case Shape_BigCube: return MakeBigcube(order); break; case Shape_Octa1: return MakeOctahedron(order); break; case Shape_Octa2: return MakeTwoOctaGlue(order); break; case Shape_Octa3: return MakeThreeOctaGlue(order); break; case Shape_Pyramid: return MakePyramid(order); } } /* END MakeMap */ /* Shape builders: */ PROCEDURE MakeTetra(/* UNUSED */ or: uint): Place_t == /* unglued topological tetrahedron */ { ??? a = Squared.MakeTetrahedron(); { fprintf(stderr,"Building topology of one topological tetrahedron\n"); return a[0]; } } /* END MakeTetra */ PROCEDURE MakeOctahedron(/* UNUSED */ or: uint): Place_t == { ??? o = Squared.MakeOctahedron(); { fprintf(stderr, "Building the topology of one octahedral cell\n"); return o[0]; } } /* END MakeOctahedron */ PROCEDURE MakeTwoOctaGlue(/* UNUSED */ or: uint): Place_t == /* Builds the topology of the map with two octahedral cell gluing them along of a common wall. */ { ??? o1 = Squared.MakeOctahedron(); ??? o2 = Squared.MakeOctahedron(); { Glue(Spin(o1[1]), o2[6],1); fprintf(stderr,"Building the topology of two octahedral cells\n"); return o1[0]; } } /* END MakeTwoOctaGlue */ PROCEDURE MakeThreeOctaGlue(/* UNUSED */ or: uint): Place_t == /* Build the topology of the map with three octahedral cell gluing them along of common @{edge->?}. */ { ??? o1 = Squared.MakeOctahedron(); ??? o2 = Squared.MakeOctahedron(); ??? o3 = Squared.MakeOctahedron(); { Glue(Spin(o1[1]), o2[6],1); Glue(Spin(o1[5]), Spin(PrevE(o3[2])), 1, TRUE); Glue(Clock(NextE(o3[1])), o2[2],1); fprintf(stderr,"Building the topology of three octahedral cells\n"); return o1[0]; } } /* END MakeThreeOctaGlue */ PROCEDURE Make12Fold(/* UNUSED */ or: uint): Place_t == /* This procedure builds a refined tetrahedron as the subdivision scheme know as "12fold", but with one octahedral cell more eigth tetrahedral cells. */ { ??? o = Squared.MakeOctahedron(); ??? t0 = Squared.MakeTetrahedron(); ??? t1 = Squared.MakeTetrahedron(); ??? t2 = Squared.MakeTetrahedron(); ??? t3 = Squared.MakeTetrahedron(); ??? t4 = Squared.MakeTetrahedron(); ??? t5 = Squared.MakeTetrahedron(); ??? t6 = Squared.MakeTetrahedron(); ??? t7 = Squared.MakeTetrahedron(); { /* first glue the 8 tetrahedra to the central octahedron */ Glue(t0[0],o[0],1); /* 5 */ Glue(t1[0],o[1],1); /* 6 */ Glue(t2[0],o[2],1); /* 7 */ Glue(t3[0],o[3],1); /* 8 */ Glue(t4[0],NextF(t0[0]),1); /* 5 */ Glue(t5[0],NextF(t1[0]),1); /* 6 */ Glue(t6[0],NextF(t2[0]),1); /* 7 */ Glue(t7[0],NextF(t3[0]),1); /* 8 */ Glue(o[4],NextF(t4[0]),1); /* 5 */ Glue(o[5],NextF(t5[0]),1); /* 6 */ Glue(o[6],NextF(t6[0]),1); /* 7 */ Glue(o[7],NextF(t7[0]),1); /* 8 */ Glue(Clock(NextF(PrevE(t1[0]))),NextF(NextE(t0[0])),1); /* 9 */ Glue(Clock(NextF(PrevE(t2[0]))),NextF(NextE(t1[0])),1); /* 10 */ Glue(Clock(NextF(PrevE(t3[0]))),NextF(NextE(t2[0])),1); /* 11 */ Glue(Clock(NextF(PrevE(t0[0]))),NextF(NextE(t3[0])),1); /* 12 */ Glue(PrevF(NextE(o[4])),Clock(PrevF(PrevE(o[5]))), 1, TRUE); Glue(PrevF(NextE(o[5])),Clock(PrevF(PrevE(o[6]))), 1, TRUE); Glue(PrevF(NextE(o[6])),Clock(PrevF(PrevE(o[7]))), 1, TRUE); Glue(PrevF(NextE(o[7])),Clock(PrevF(PrevE(o[4]))), 1, TRUE); fprintf(stderr, "Building a refined tetrahedron with an octahedral cell in the center\n"); return t0[0]; } } /* END Make12Fold */ Place_t MakeTetra2(or: uint) /* Glues two topological tetrahedron along a one triangulated wall. */ { ??? a = MakeTetraTopo(or; with (or), double b = MakeTetraTopo(or,or) ){ Glue(Spin(b[3]),a[2],or); fprintf(stderr, "Building the topology of 2 tetrahedra glued along one triang. wall\n"); return b[3]; } } /* END MakeTetra2 */ Place_t MakeTetra3(or: uint) /* Glues three topological tetrahedron two by two along a common @{edge->?}, i.e. builds a map "@{edge->?}star" of degree three. */ { ??? a = MakeTetraTopo(or; with (or), double b = MakeTetraTopo(or,or); double c = MakeTetraTopo(or,or) ){ Glue(Spin(a[1]),b[0],or); Glue(Spin(b[1]),c[0],or); Glue(Spin(c[1]),a[0],or); fprintf(stderr, "Building the topology of 3 tetrahedra glued along a common @{edge->?}\n"); return a[1]; } } /* END MakeTetra3 */ Place_t MakeCubeTriang(or: uint) /* A simple triangulated cube, building by the glue of six simples tetrahedron. */ { ??? a = MakeTetraTopo(or; with (or), double b = MakeTetraTopo(or,or); double c = MakeTetraTopo(or,or); double d = MakeTetraTopo(or,or); double e = MakeTetraTopo(or,or); double f = MakeTetraTopo(or,or) ){ Glue(Spin(b[1]),a[0],or); Glue(Spin(c[1]),b[0],or); Glue(Spin(d[1]),c[0],or); Glue(Spin(e[1]),d[0],or); Glue(Spin(f[1]),e[0],or); Glue(Spin(a[1]),f[0],or); fprintf(stderr,"Building the topology of one triangulated cube\n"); return a[1]; } } /* END MakeCubeTriang */ Place_t MakeBigcube(or: uint) { ??? a = Squared.MakeBigCube(or); { fprintf(stderr, "Building the topology of an array of cubes\n"); return a[0,0,0]; } } /* END MakeBigcube */ Place_t MakePyramid(or: uint) { ??? a = Squared.MakePyramid(or); { fprintf(stderr, "Building the topology of a pyramid with base as a " \ Fmt.Int(or) & "-gon\n"); return a[0]; } } /* END MakePyramid */ /* UNUSED */ PROCEDURE Prt (Place_t @p) { fprintf(stderr, "wedge: "); PrintPlace(stderr, a, 1); fprintf(stderr, " fnext: "); PrintPlace(stderr, NextF(a)); fprintf(stderr, "\n"); } /* END Prt */ Options_t GetOptions () { 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, "-order"); o->order = argparser_get_next_int(pp, 1, 9); argparser_get_keyword(pp, "-shape"); o->shapeName = argparser_get_next(pp); if (0 == strcmp(o->shapeName , "tetra1"))) { o->shape = Shape_Tetra1 } else if (0 == strcmp(o->shapeName, "tetra2"))){ o->shape = Shape_Tetra2 } else if (0 == strcmp(o->shapeName, "tetra3"))){ o->shape = Shape_Tetra3 } else if (0 == strcmp(o->shapeName, "tetrare"))){ o->shape = Shape_TetraRe } else if (0 == strcmp(o->shapeName, "cubetriang"))){ o->shape = Shape_CubeTriang } else if (0 == strcmp(o->shapeName, "bigcube"))){ o->shape = Shape_BigCube } else if (0 == strcmp(o->shapeName, "octa1"))){ o->shape = Shape_Octa1 } else if (0 == strcmp(o->shapeName, "octa2"))){ o->shape = Shape_Octa2 } else if (0 == strcmp(o->shapeName, "octa3"))){ o->shape = Shape_Octa3 } else if (0 == strcmp(o->shapeName, "pyramid"))){ o->shape = Shape_Pyramid } else if (0 == strcmp(o->shapeName, "triangle"))){ o->shape = Shape_Triang } else { argparser_error(pp, "Bad shape \"" & argparser_get_next(pp) & "\"\n") } argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: MakeComplexWf -order \\\n" \ " -shape { tetra1 | ... | cubetriang | ...}\n"); END¦ } } return o; } /* END GetOptions */ /* end MakeComplexWf */ /* Copyright © 1999 Universidade Estadual de Campinas (UNICAMP) */