2 * Moebius main program.
14 #include "postscript.hh"
17 #include "transforms.hh"
18 #include "graphics.hh"
19 #include "parameter.hh"
21 template class Parameter<int>;
22 Parameter<int> tn("tn", "Number of sections around `strip'", 30, 1, 1, 500);
23 Parameter<int> un("un", "Number of sections across `strip'", 15, 1, 1, 500);
24 Parameter<double> theta("theta", "Angle of model rotation",
25 /*-PI/2.*/0, PI/8., -PI*2., PI*2.);
26 Parameter<double> eta("eta", "Angle of model elevation", 0., PI/8., -PI*2., PI*2.);
27 Parameter<double> planedistance("plane", "Distance from projection plane to origin",
29 Parameter<double> eyedistance("eye", "Distance from projection eye to origin",
31 Parameter<double> cutoffdistance("cutoff", "Distance from projection cutoff to origin",
32 10., .25, -10., 100.);
33 Parameter<double> width("width", "Width of the `strip' before transformation",
35 Parameter<double> thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.);
36 Parameter<double> bottomportion("bp", "Proportion in the bottom half",
38 //Parameter<double> tear("tear", "Angle factor in tear-open", 0/*1.1*/, .1, -5., 5.);
39 //Parameter<double> teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.);
40 //Parameter<double> twist("twist", "Angle per length in twist", 0/*.8*/, .25, -5., 5.);
41 //Parameter<double> twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.);
42 //Parameter<double> bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.);
43 //Parameter<double> bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.);
44 //Parameter<double> bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.);
45 //Parameter<double> shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.);
46 //Parameter<double> sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.);
47 //Parameter<double> shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.);
48 //Parameter<double> shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.);
49 //Parameter<double> shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.);
51 SortedCellList *list=0;
53 DualX11Output *dualx11= 0;
56 if (list) delete list;
57 // MoebiusStrip strip(width);
58 MoebiusEnfoldment strip(thickness,bottomportion);
59 list= new SortedCellList;
61 for (int ti=0; ti<tn; ti++) {
62 double t1= (double)(ti+1)/tn;
64 for (int ui=0; ui<un; ui++) {
65 double u1= (double)(ui+1)/un;
68 cell->p[0]= strip.middlepoint(t0,u0);
69 //fprintf(stderr,"t %7.4f u %7.4f %7.4f,%7.4f,%7.4f\n",
70 // t0,u0, cell->p[0][0], cell->p[0][1], cell->p[0][2]);
71 cell->p[1]= strip.middlepoint(t0,u1);
72 cell->p[2]= strip.middlepoint(t1,u1);
73 cell->p[3]= strip.middlepoint(t1,u0);
81 int main(int argc, char **argv) {
85 Point::setobserver(theta,eta,planedistance,eyedistance,cutoffdistance);
86 Point::cleartransform();
87 // if (tear != 0.0) Point::appendtransform(new TearOpenTransform(tear,teary));
88 // if (twist != 0.0) Point::appendtransform(new TwistTransform(twist,twisty));
89 // if (bulge != 0.0) Point::appendtransform(new BulgeTransform(bulge,bulgesd,bulgey));
90 // if (shearx != 0.0 || sheary != 0.0)
91 // Point::appendtransform(new ShearTransform(Point(0.0,shearey,0.0),
92 // Point(shearx,sheary,0.0),
93 // Point(shearsdx,shearsdy,1e20)));
95 if (x11) list->display(*x11);
96 if (dualx11) list->display(*dualx11);
98 cin.get(buf,100,'\n');
100 if (!cin.get(c) || c!='\n') {
101 cerr << "error reading command input, giving up\n";
104 char *equals= strchr(buf,'=');
107 AnyParameter *param= AnyParameter::find(buf);
109 *param= atof(equals);
112 cerr << "parameter `" << buf << "' not found\n";
114 } else if (!strncmp(buf,"postscript ",11)) {
115 const char *filename= buf+11;
116 ofstream file(filename);
118 PostScriptOutput psout(file);
119 list->display(psout);
121 cerr << "Failed to open `" << filename << "'\n";
124 cerr << "PostScript written to `" << filename <<"'\n";
125 } else if (!strcmp(buf,"x11")) {
133 } else if (!strcmp(buf,"dualx11")) {
138 dualx11= new DualX11Output;
141 } else if (!strcmp(buf,"quit")) {
143 } else if (!strcmp(buf,"list")) {
144 AnyParameter::list();
148 cerr << "command not understood\n";