#define PROG_NAME "AutoDodeIco" #define PROG_DESC "???" #define PROG_VERS "1.0" #define AutoDodeIco_C_COPYRIGHT \ "" #define PROG_INFO \ "" \ " " /* This program implements the automatic gluing of cells (tetrahedra, triangulated octahedra) for the 4D non-regular polytope: "pentaocta" */ #include #include #include #define _GNU_SOURCE #include #include #include #include TYPE double Row2I = ARRAY[0..1] OF uint; double z4_t = ARRAY[0..3] OF uint; double Shape_t = {Dodecahedron, Icosahedron}; typedef struct Options_t { bool_t detail; bool_t free; Shape_t shape; char *shapeName; } REF ARRAY OF z4_t cell4 ; tetra : REF ARRAY OF ARRAY [0..3] OF Place_t; Options_t o; uint cellnum; /* UNUSED */ void WriteCells(*g: REF ARRAY OF z4_t) <* FATAL Wr.Failure, Thread.Alerted, OSError.E); { ??? st = FileWr.Open(o->shapeName); { void WriteNode(x: uint) { fprintf(st, Fmt.Pad(Fmt.Int(x),7)); } WriteNode; void WriteCell(*c: z4_t) { WriteNode(c[0]); fprintf(st, " "); WriteNode(c[1]); fprintf(st, " "); WriteNode(c[2]); fprintf(st, " "); WriteNode(c[3]); } WriteCell; { for(i = 0; i < g.nel; i++) { WriteNode(i); WriteCell(g[i]); fprintf(st, "\n"); } } fclose(st); } } /* END WriteCells */ void DoIt() Place_t GlueTetras(Ti,Tj,Ci,Cj: uint) /* Gluing the tetrahedra Ti with Tj through the free walls Ci and Cj respectively. */ void PrintInfo(case: uint;oi,oj,di,dj: uint) /* Prints information about the three possible cases in the gluing procedure. */ { fprintf(stderr, "case " & Fmt.Int(case) & ": "); fprintf(stderr, Fmt.Int(oi) & " " & Fmt.Int(di)&"\n"); fprintf(stderr, " "); fprintf(stderr, Fmt.Int(oj) & " " & Fmt.Int(dj)&"\n\n"); } PrintInfo; void UngluedInfo(ci,cj,ti,tj: uint) /* Prints information about unglued case in the gluing procedure. This procedure cause the halt of the program. */ { fprintf(stderr, "Not glue this case " & Fmt.Int(ci) & " " \ Fmt.Int(cj) & "\n"); fprintf(stderr, " Tetrahedra " & Fmt.Int(ti) & " " \ Fmt.Int(tj) & "\n"); Process.Exit¦(1); } UngluedInfo; { if (o->detail) { fprintf(stderr,"Ci=="&Fmt.Int(Ci)&" Cj=="&Fmt.Int(Cj)&", "); } IF /* 1 */ double Ci = 0) && (Cj == 0)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1]; { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[3]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 2 */ double Ci = 0) && (Cj == 1)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[0]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 3 */ double Ci = 0) && (Cj == 2)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[2]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 4 */ double Ci = 0) && (Cj == 3)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[1]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 5 */ double Ci = 1) && (Cj == 0)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[3]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 6 */ double Ci = 1) && (Cj == 1)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[0] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 7 */ double Ci = 1) && (Cj == 2)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[2] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 8 */ double Ci = 1) && (Cj == 3)) { int Oi = cell4[Ti].ix[0]; int Di = cell4[Ti].ix[1] { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[1]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 9 */ double Ci = 2) && (Cj == 0)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[3]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 10 */ double Ci = 2) && (Cj == 1)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[0] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 11 */ double Ci = 2) && (Cj == 2)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[2] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 12 */ double Ci = 2) && (Cj == 3)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[1]; { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 13 */ double Ci = 3) && (Cj == 0)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[3]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 14 */ double Ci = 3) && (Cj == 1)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[1] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[0] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 15 */ double Ci = 3) && (Cj == 2)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Spin(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Spin(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[0] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Spin(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[0]; int Dj = cell4[Tj].ix[2] { if ((Oi == Oj) && (Di == Dj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Spin(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Spin(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } ELSIF /* 16 */ double Ci = 3) && (Cj == 3)) { int Oi = cell4[Ti].ix[2]; int Di = cell4[Ti].ix[3]; { int Oj = cell4[Tj].ix[2]; int Dj = cell4[Tj].ix[3] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(1,Oi,Oj,Di,Dj); } Glue(Clock(tetra[Tj].p[Cj]), tetra[Ti].p[Ci], 1); return Clock(tetra[Tj].p[Cj]); } } int Oj = cell4[Tj].ix[3]; int Dj = cell4[Tj].ix[1]; { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(2,Oi,Oj,Di,Dj); } Glue(Clock(NextE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(NextE(tetra[Tj].p[Cj])); } } int Oj = cell4[Tj].ix[1]; int Dj = cell4[Tj].ix[2] { if ((Oi == Dj) && (Di == Oj)) { if (o->detail){ PrintInfo(3,Oi,Oj,Di,Dj); } Glue(Clock(PrevE(tetra[Tj].p[Cj])), tetra[Ti].p[Ci], 1); return Clock(PrevE(tetra[Tj].p[Cj])); } } UngluedInfo(Ci,Cj,Ti,Tj); } } return tetra[Ti].p[0]; } /* END GlueTetras */ void SetCornersTetra(uint Ti, z4_t row) /* Set the labels "row" in the tetrahedron Ti. */ { Node_t a = OrgV(tetra[Ti].p[0]); double b = OrgV(Clock(tetra[Ti].p[0])); double c = OrgV(PrevE(tetra[Ti].p[1])); double d = OrgV(PrevE(tetra[Ti].p[0])); { a->num = row[0]; b->num = row[1]; c->num = row[2]; d->num = row[3]; } } SetCornersTetra; void EffaceNode(uint Ti, uint nn) /* Set one node onto the tetrahedra "Ti" as non-existing. */ { Node_t a = OrgV(tetra[Ti].p[0]); Node_t b = OrgV(Clock(tetra[Ti].p[0])); Node_t c = OrgV(PrevE(tetra[Ti].p[1])); Node_t d = OrgV(PrevE(tetra[Ti].p[0])); { if (a->num == @{node->?}) { a->exists = FALSE; } if (b->num == @{node->?}) { b->exists = FALSE; } if (c->num == @{node->?}) { c->exists = FALSE; } if (d->num == @{node->?}) { d->exists = FALSE; } } } EffaceNode; PROCEDURE EffaceEdgesOfNode(uint Ti, uint nn) == /* Set all @{edge->?}s incidents in the node "@{node->?}" as non-existing.*/ { Node_t a = OrgV(tetra[Ti].p[0])->num; Node_t b = OrgV(Clock(tetra[Ti].p[0]))->num; Node_t c = OrgV(PrevE(tetra[Ti].p[1]))->num; Node_t d = OrgV(PrevE(tetra[Ti].p[0]))->num; ??? e0 = PWedge(tetra[Ti].p[0]).edge; ??? e1 = PWedge(tetra[Ti].p[2]).edge; ??? e2 = PWedge(NextE(tetra[Ti].p[2])).edge; ??? e3 = PWedge(PrevE(tetra[Ti].p[2])).edge; ??? e4 = PWedge(NextE(tetra[Ti].p[0])).edge; ??? e5 = PWedge(NextE(tetra[Ti].p[1])).edge { if ((a == @{node->?}) || (b == @{node->?})) { e0->exists = FALSE; } if ((c == @{node->?}) || (d == @{node->?})) { e1->exists = FALSE; } if ((a == @{node->?}) || (d == @{node->?})) { e2->exists = FALSE; } if ((a == @{node->?}) || (c == @{node->?})) { e3->exists = FALSE; } if ((b == @{node->?}) || (d == @{node->?})) { e4->exists = FALSE; } if ((b == @{node->?}) || (c == @{node->?})) { e5->exists = FALSE; } } } EffaceEdgesOfNode; void EffaceWallsOfNode(uint Ti, @{node->?}: uint) /* Set all wallse incidents in the node "@{node->?}" as non-existing.*/ { Node_t a = OrgV(tetra[Ti].p[0])->num; Node_t b = OrgV(Clock(tetra[Ti].p[0]))->num; Node_t c = OrgV(PrevE(tetra[Ti].p[1]))->num; Node_t d = OrgV(PrevE(tetra[Ti].p[0]))->num; double f0 = PWedge(tetra[Ti].p[0]).wall; double f1 = PWedge(tetra[Ti].p[1]).wall; double f2 = PWedge(tetra[Ti].p[2]).wall; double f3 = PWedge(tetra[Ti].p[3]).wall; { if ((a == @{node->?}) || (b == @{node->?}) || (d == @{node->?})) { f0->exists = FALSE; } if ((a == @{node->?}) || (b == @{node->?}) || (c == @{node->?})) { f1->exists = FALSE; } if ((a == @{node->?}) || (c == @{node->?}) || (d == @{node->?})) { f2->exists = FALSE; } if ((b == @{node->?}) || (c == @{node->?}) || (d == @{node->?})) { f3->exists = FALSE; } } } EffaceWallsOfNode; bool_t MustBeGlued(Ti,Tj: Place_t) /* Return TRUE if the walls "PWall(Ti)" and "PWall(Tj)" have coherent orientations and must be glued. */ { Node_t a = OrgV(Ti)->num; Node_t ae = OrgV(NextE(Ti))->num; ??? ae_1 = OrgV(PrevE(Ti))->num; Node_t b = OrgV(Tj)->num; Node_t be = OrgV(NextE(Tj))->num; ??? be_1 = OrgV(PrevE(Tj))->num; { if (((a == b) && (ae == be) && (ae_1 == be_1) OR (a == b) && (ae == be_1) && (ae_1 == be))){ return TRUE; } return FALSE } } MustBeGlued; bool_t BadAttribution(Ti,Tj: Place_t) /* Return TRUE if the walls "PWall(Ti)" and "PWall(Tj)" have incoherent orientations. */ { Node_t i0 = OrgV(Ti)->num; ??? i1 = OrgV(NextE(Ti))->num; ??? i2 = OrgV(PrevE(Ti))->num; Node_t j0 = OrgV(Tj)->num; ??? j1 = OrgV(NextE(Tj))->num; ??? j2 = OrgV(PrevE(Tj))->num; { if ((SpinBit(Ti)!=SpinBit(Tj))) { if (((i0 == j0) && (i1 == j2) && (i2 == j1) OR (i0 == j2) && (i1 == j1) && (i2 == j0) OR (i0 == j1) && (i1 == j0) && (i2 == j2) )){ return TRUE } }; if ((SpinBit(Ti) == SpinBit(Tj))) { if (((i0 == j0) && (i1 == j1) && (i2 == j2) OR (i0 == j2) && (i0 == j0) && (i2 == j1) OR (i0 == j1) && (i1 == j2) && (i2 == j0) )){ return TRUE } }; return FALSE } } BadAttribution; void PrintCorners(Tuint i) /* Print the corners of the triangular wall "Ti". */ { Node_t a = OrgV(walls[Ti])->num; Node_t ae = OrgV(NextE(walls[Ti]))->num; ??? ae_1 = OrgV(PrevE(walls[Ti]))->num; { fprintf(stderr, Fmt.Pad(Fmt.Int(a),3) & " " \ Fmt.Pad(Fmt.Int(ae),3) \ " " & Fmt.Pad(Fmt.Int(ae_1),3) & " "); } } PrintCorners; void PrintFreeCorners(number: uint) { for (i = 0; i < number; i++) { for (j = 0; j < 4; j++) { ??? a = tetra[i].p[j]; double d = Octf.DegreeOfWall(a); { if ((d!=1) && (PposP(a) == NULL)) { fprintf(stderr, "tetra[" & Fmt.Pad(Fmt.Int(i),2) & "," \ Fmt.Pad(Fmt.Int(j),2) & "]\n") } } } } } PrintFreeCorners; REF ARRAY OF EightPlaces_t poly ; id : uint = 0; count : uint = 1; walls : REF Place_vec_t; glues : REF ARRAY OF z4_t; { o = GetOptions(); if ( o->shape == Shape_Dodecahedron) { cellnum = 60; cell4 = NEW(REF ARRAY OF z4_t, cellnum); } else if (o->shape == Shape_Icosahedron){ cellnum = 20; cell4 = NEW(REF ARRAY OF z4_t, cellnum); } poly = NEW(REF ARRAY OF EightPlaces_t,cellnum); tetra = NEW(REF ARRAY OF ARRAY [0..3] OF Place_t,cellnum); Place_vec_t walls = Place_vec_new( 4*cellnum); glues = NEW(REF ARRAY OF z4_t, 2*cellnum); /* Create topological tetrahedra */ for (i = 0; i < cellnum; i++) { poly[i] = MakeTetraTopo(1,1); } /* Create the tetrahedra */ for (i = 0; i < cellnum; i++) { for (j = 0; j < 4; j++) { tetra[i].p[j] = poly[i,j]; assert(PposP(tetra[i].p[j]) == NULL); } } /* cells with corners perfectly assigments */ if (o->shape == Shape_Dodecahedron) { cell4[ 0]=(z4_t){{100,500, 0, 1}}; cell4[ 1]=(z4_t){{100,500, 1, 4}}; cell4[ 2]=(z4_t){{100,500, 4, 7}}; cell4[ 3]=(z4_t){{100,500, 7, 2}}; cell4[ 4]=(z4_t){{100,500, 2, 0}}; cell4[ 5]=(z4_t){{500,101, 0, 1}}; cell4[ 6]=(z4_t){{500,101, 1, 5}}; cell4[ 7]=(z4_t){{500,101, 5, 8}}; cell4[ 8]=(z4_t){{500,101, 8, 3}}; cell4[ 9]=(z4_t){{500,101, 3, 0}}; cell4[ 10]=(z4_t){{500,102, 2, 0}}; cell4[ 11]=(z4_t){{500,102, 0, 3}}; cell4[ 12]=(z4_t){{500,102, 3, 9}}; cell4[ 13]=(z4_t){{500,102, 9, 6}}; cell4[ 14]=(z4_t){{500,102, 6, 2}}; cell4[ 15]=(z4_t){{103,500, 6, 2}}; cell4[ 16]=(z4_t){{500,103, 7, 2}}; cell4[ 17]=(z4_t){{103,500, 7, 13}}; cell4[ 18]=(z4_t){{103,500, 13, 12}}; cell4[ 19]=(z4_t){{500,103, 6, 12}}; cell4[ 20]=(z4_t){{500,104, 1, 4}}; cell4[ 21]=(z4_t){{500,104, 4, 10}}; cell4[ 22]=(z4_t){{500,104, 10, 11}}; cell4[ 23]=(z4_t){{500,104, 11, 5}}; cell4[ 24]=(z4_t){{500,104, 5, 1}}; cell4[ 25]=(z4_t){{500,105, 9, 3}}; cell4[ 26]=(z4_t){{500,105, 3, 8}}; cell4[ 27]=(z4_t){{500,105, 8, 14}}; cell4[ 28]=(z4_t){{500,105, 14, 15}}; cell4[ 29]=(z4_t){{500,105, 15, 9}}; cell4[ 30]=(z4_t){{500,106, 12, 6}}; cell4[ 31]=(z4_t){{500,106, 6, 9}}; cell4[ 32]=(z4_t){{500,106, 9, 15}}; cell4[ 33]=(z4_t){{500,106, 15, 18}}; cell4[ 34]=(z4_t){{500,106, 18, 12}}; cell4[ 35]=(z4_t){{500,107, 4, 7}}; cell4[ 36]=(z4_t){{500,107, 7, 13}}; cell4[ 37]=(z4_t){{500,107, 13, 16}}; cell4[ 38]=(z4_t){{500,107, 16, 10}}; cell4[ 39]=(z4_t){{500,107, 10, 4}}; cell4[ 40]=(z4_t){{108,500, 5, 8}}; cell4[ 41]=(z4_t){{108,500, 8, 14}}; cell4[ 42]=(z4_t){{108,500, 14, 17}}; cell4[ 43]=(z4_t){{108,500, 17, 11}}; cell4[ 44]=(z4_t){{108,500, 11, 5}}; cell4[ 45]=(z4_t){{109,500, 18, 12}}; cell4[ 46]=(z4_t){{109,500, 12, 13}}; cell4[ 47]=(z4_t){{109,500, 13, 16}}; cell4[ 48]=(z4_t){{109,500, 16, 19}}; cell4[ 49]=(z4_t){{109,500, 19, 18}}; cell4[ 50]=(z4_t){{500,110, 18, 15}}; cell4[ 51]=(z4_t){{500,110, 15, 14}}; cell4[ 52]=(z4_t){{500,110, 14, 17}}; cell4[ 53]=(z4_t){{500,110, 17, 19}}; cell4[ 54]=(z4_t){{500,110, 19, 18}}; cell4[ 55]=(z4_t){{111,500, 10, 11}}; cell4[ 56]=(z4_t){{111,500, 11, 17}}; cell4[ 57]=(z4_t){{111,500, 17, 19}}; cell4[ 58]=(z4_t){{111,500, 19, 16}}; cell4[ 59]=(z4_t){{111,500, 16, 10}}; } else if (o->shape == Shape_Icosahedron){ cell4[ 0]=(z4_t){{100, 0, 1, 2}}; cell4[ 1]=(z4_t){{ 0,100, 1, 4}}; cell4[ 2]=(z4_t){{ 2,100, 0, 3}}; cell4[ 3]=(z4_t){{100, 4, 0, 5}}; cell4[ 4]=(z4_t){{100, 3, 2, 8}}; cell4[ 5]=(z4_t){{ 1,100, 2, 6}}; cell4[ 6]=(z4_t){{ 5,100, 4, 10}}; cell4[ 7]=(z4_t){{100, 1, 4, 7}}; cell4[ 8]=(z4_t){{ 8,100, 3, 9}}; cell4[ 9]=(z4_t){{100, 0, 3, 5}}; cell4[ 10]=(z4_t){{100, 6, 1, 7}}; cell4[ 11]=(z4_t){{100, 10, 5, 9}}; cell4[ 12]=(z4_t){{100, 9, 8, 11}}; cell4[ 13]=(z4_t){{ 2,100, 8, 6}}; cell4[ 14]=(z4_t){{ 7,100, 6, 11}}; cell4[ 15]=(z4_t){{ 9,100, 10, 11}}; cell4[ 16]=(z4_t){{100, 4, 10, 7}}; cell4[ 17]=(z4_t){{100, 3, 9, 5}}; cell4[ 18]=(z4_t){{100, 11, 7, 10}}; cell4[ 19]=(z4_t){{ 8,100, 11, 6}}; } /* set the labels for each tetrahedra */ for (i = 0; i < cellnum; i++) { SetCornersTetra(i,cell4[i]); } /* set the non-existing nodes,@{edge->?}s and walls.*/ if (o->shape == Shape_Dodecahedron) { for (i = 0; i < cellnum; i++) { EffaceNode(i,500); EffaceEdgesOfNode(i,500); EffaceWallsOfNode(i,500); for (j = 100; j < 112; j++) { EffaceNode(i,j); EffaceEdgesOfNode(i,j); } } } else if (o->shape == Shape_Icosahedron){ for (i = 0; i < cellnum; i++) { EffaceNode(i,100); EffaceEdgesOfNode(i,100); EffaceWallsOfNode(i,100); } } /*WriteCells(cell4);*/ /* builds the table of walls for choose which tetrahedra must be gluing. */ if (o->detail) { fprintf(stderr, "C id table wall\n"); fprintf(stderr, "-------------------------\n"); } for (i = 0; i < cellnum; i++) { if (o->detail) { fprintf(stderr, Fmt.Int(i) & "\n"); } for (k = 0; k < 4; k++) { walls[(4*i)+k] = tetra[i].p[k]; if (o->detail) { fprintf(stderr," "& Fmt.Pad(Fmt.Int(id),4)&" "); id++; PrintCorners((4*i)+k); fprintf(stderr, " " & Fmt.Int(k) & "\n"); } } } /* computing which cells must be gluing. */ for(k = 0; k < walls.nel; k++) { for (l = k+1 TO LAST(walls^)) { for (m = 0; m < 3; m++) { ??? e = NextEK(walls[l],m); { if ((MustBeGlued(walls[k],e))) { if (o->detail) { fprintf(stderr, Fmt.Int(count) & "\n"); fprintf(stderr, "must be gluing: walls[" & Fmt.Int(k) \ "] with "); fprintf(stderr, "walls[" & Fmt.Int(l) &"]\n"); } ??? kc = k % 4; ??? kt = k DIV 4; ??? lc = l % 4; ??? lt = l DIV 4; { if (o->detail) { fprintf(stderr, " tetra["&Fmt.Int(kt) & "," \ Fmt.Int(kc) & "] and tetra[" & Fmt.Int(lt) & "," \ Fmt.Int(lc) & "]\n\n"); } glues[count-1] = (z4_t){{kt,lt,kc,lc}}; count++; if ((BadAttribution(walls[k],e))) { fprintf(stderr, "Bad Attribution " & " tetra["& Fmt.Int(kt) &"] and tetra[" & Fmt.Int(lt) & "]\n"); } } } } } } } /* Do the automatic gluing of tetrahedra */ for(i = 0; i < glues.nel; i++) { ??? c = glues[i]; { if (c!=(z4_t){{0,0,0,0}}) { EVAL GlueTetras(c[0],c[1],c[2],c[3]); } } } if (o->free){ fprintf(stderr,"Listing free corners\n"); PrintFreeCorners(cellnum) } /* Set the origins. */ for (i = 0; i < cellnum; i++) { for (j = 0; j < 4; j++) { ??? a = tetra[i].p[j]; Place_t b = NextE(a); Place_t c = PrevE(a); { SetOrgAll(a,OrgV(a)); SetOrgAll(b,OrgV(b)); SetOrgAll(c,OrgV(c)); } } } /* Builds and writes the topology. */ if ( o->shape == Shape_Dodecahedron) { fprintf(stderr, "Building the topology of dodecahedron:\n"); } else if (o->shape == Shape_Icosahedron){ fprintf(stderr, "Building the topology of icosahedron:\n"); } ??? a = tetra[cellnum-1].p[0]; double top = MakeElemTable(a); double c = GenCoords(top)^; { /* seting the elements root for edges and walls.*/ for (i = 0; i < top.wall.nel; i++) { ??? f = top.wall[i]; { f->root = f->num; } } for (i = 0; i < top.edge.nel; i++) { ??? e = top.edge[i]; { e->root = e->num; } } WriteTopology(o->shapeName, top, "Created by AutoDodeIco: " & o->shapeName & ".tp on " \ Today()); WriteMaterials(o->shapeName, top, "Created by AutoDodeIco: " & o->shapeName & ".ma on " \ Today()); WriteState(o->shapeName, top, c, "Created by AutoDodeIco: " & o->shapeName & ".st on " \ Today() &"\nRandom Geometry"); } } DoIt; /* UNUSED */ void PrintRow4I(m: z4_t) /* Print an array of four integer values. */ { fprintf(stderr,Fmt.Int(m[0]) & " " & Fmt.Int(m[1]) & " " \ Fmt.Int(m[2]) & " " & Fmt.Int(m[3]) & "\n"); } /* END PrintRow4I */ /* UNUSED */ void PrintRow2I(m: Row2I) /* Print an array of two integer values. */ { fprintf(stderr,Fmt.Int(m[0]) & " " & Fmt.Int(m[1]) & "\n"); } /* END PrintRow2I */ 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, "-shape"); o->shapeName = argparser_get_next(pp); if (0 == strcmp(o->shapeName, "icosahedron"))) { o->shape = Shape_Icosahedron } else if (0 == strcmp(o->shapeName, "dodecahedron"))){ o->shape = Shape_Dodecahedron } else { argparser_error(pp, "Bad shape \"" & argparser_get_next(pp) & "\"\n"); } o->detail = argparser_keyword_present(pp, "-detail"); o->free = argparser_keyword_present(pp, "-free"); argparser_finish(pp); ----------------------------------- #define _HELP \ fprintf(stderr, "Usage: AutoDodeIco \\\n" \ " -shape { icosahedron | dodecahedron } \\\n" \ " [ -free ] [ -detail ] \n"); END¦ } } return o; } /* END GetOptions */ { DoIt() } AutoDodeIco. /* Copyright © 2000 Universidade Estadual de Campinas (UNICAMP) */