2 * Moebius main program.
14 #include "postscript.hh"
17 #include "transforms.hh"
18 #include "graphics.hh"
19 #include "parameter.hh"
21 static Parameter<int> tn("tn", "Number of sections around `strip'", 30, 1, 1, 500);
22 static Parameter<int> un("un", "Number of sections across `strip'", 15, 1, 1, 500);
23 static Parameter<int> version("version",
24 "Version to use: 0=original strip, 1=reformulated,"
25 " 2=reformulated again", 0, 1, 0, 2);
26 static Parameter<double> theta("theta", "Angle of model rotation",
27 /*-PI/2.*/0, M_PI/8., -M_PI*2., M_PI*2.);
28 static Parameter<double> eta("eta", "Angle of model elevation",
29 0., M_PI/8., -M_PI*2., M_PI*2.);
30 static Parameter<double> scale("scale", "Scale factor for resulting object",
31 1.0, 0.25, 0.001, 1000.);
32 static Parameter<double> planedistance("plane",
33 "Distance from projection plane to origin",
35 static Parameter<double> eyedistance("eye", "Distance from projection eye to origin",
37 static Parameter<double> cutoffdistance("cutoff",
38 "Distance from projection cutoff to origin",
39 10., .25, -10., 100.);
40 static Parameter<double> width("width", "Width of the `strip' before transformation",
42 static Parameter<double> thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.);
43 static Parameter<double> bottomportion("bp", "Proportion in the bottom half",
45 static Parameter<double> tear("tear", "Angle factor in tear-open",
46 0/*1.1*/, .1, -5., 5.);
47 static Parameter<double> teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.);
48 static Parameter<double> twist("twist", "Angle per length in twist",
49 0/*.8*/, .25, -5., 5.);
50 static Parameter<double> twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.);
51 static Parameter<double> bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.);
52 static Parameter<double> bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.);
53 static Parameter<double> bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.);
54 static Parameter<double> shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.);
55 static Parameter<double> sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.);
56 static Parameter<double> shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.);
57 static Parameter<double> shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.);
58 static Parameter<double> shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.);
60 SortedCellList *list=0;
62 DualX11Output *dualx11= 0;
65 if (list) delete list;
68 case 0: strip= new MoebiusStrip(width); break;
69 case 1: strip= new MoebiusEnfoldment(thickness,bottomportion); break;
70 case 2: strip= new MoebiusEnfoldmentNew(); break;
73 list= new SortedCellList;
75 for (int ti=0; ti<tn; ti++) {
76 double t1= (double)(ti+1)/tn;
78 for (int ui=0; ui<un; ui++) {
79 double u1= (double)(ui+1)/un;
82 cell->p[0]= strip->middlepoint(t0,u0);
83 //fprintf(stderr,"t %7.4f u %7.4f %7.4f,%7.4f,%7.4f\n",
84 // t0,u0, cell->p[0][0], cell->p[0][1], cell->p[0][2]);
85 cell->p[1]= strip->middlepoint(t0,u1);
86 cell->p[2]= strip->middlepoint(t1,u1);
87 cell->p[3]= strip->middlepoint(t1,u0);
96 int main(int argc, char **argv) {
100 Point::setobserver(theta,eta,planedistance,eyedistance,cutoffdistance);
101 Point::cleartransform();
102 if (tear != 0.0) Point::appendtransform(new TearOpenTransform(tear,teary));
103 if (twist != 0.0) Point::appendtransform(new TwistTransform(twist,twisty));
104 if (bulge != 0.0) Point::appendtransform(new BulgeTransform(bulge,bulgesd,bulgey));
105 if (shearx != 0.0 || sheary != 0.0)
106 Point::appendtransform(new ShearTransform(Point(0.0,shearey,0.0),
107 Point(shearx,sheary,0.0),
108 Point(shearsdx,shearsdy,1e20)));
109 Point::appendtransform(new ScaleTransform(scale));
111 if (x11) list->display(*x11);
112 if (dualx11) list->display(*dualx11);
114 cin.get(buf,100,'\n');
116 if (!cin.get(c) || c!='\n') {
117 cerr << "error reading command input, giving up\n";
120 char *equals= strchr(buf,'=');
123 AnyParameter *param= AnyParameter::find(buf);
125 *param= atof(equals);
128 cerr << "parameter `" << buf << "' not found\n";
130 } else if (!strncmp(buf,"postscript ",11)) {
131 const char *filename= buf+11;
132 ofstream file(filename);
134 PostScriptOutput psout(file);
135 list->display(psout);
137 cerr << "Failed to open `" << filename << "'\n";
140 cerr << "PostScript written to `" << filename <<"'\n";
141 } else if (!strcmp(buf,"x11")) {
149 } else if (!strcmp(buf,"dualx11")) {
154 dualx11= new DualX11Output;
157 } else if (!strcmp(buf,"quit")) {
159 } else if (!strcmp(buf,"list")) {
160 AnyParameter::list();
164 cerr << "command not understood\n";