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> orig("orig", "Use original strip (not reformulated)", 1, 0, 0, 1);
24 static Parameter<double> theta("theta", "Angle of model rotation",
25 /*-PI/2.*/0, M_PI/8., -M_PI*2., M_PI*2.);
26 static Parameter<double> eta("eta", "Angle of model elevation",
27 0., M_PI/8., -M_PI*2., M_PI*2.);
28 static Parameter<double> scale("scale", "Scale factor for resulting object",
29 1.0, 0.25, 0.001, 1000.);
30 static Parameter<double> planedistance("plane",
31 "Distance from projection plane to origin",
33 static Parameter<double> eyedistance("eye", "Distance from projection eye to origin",
35 static Parameter<double> cutoffdistance("cutoff",
36 "Distance from projection cutoff to origin",
37 10., .25, -10., 100.);
38 static Parameter<double> width("width", "Width of the `strip' before transformation",
40 static Parameter<double> thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.);
41 static Parameter<double> bottomportion("bp", "Proportion in the bottom half",
43 static Parameter<double> tear("tear", "Angle factor in tear-open",
44 0/*1.1*/, .1, -5., 5.);
45 static Parameter<double> teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.);
46 static Parameter<double> twist("twist", "Angle per length in twist",
47 0/*.8*/, .25, -5., 5.);
48 static Parameter<double> twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.);
49 static Parameter<double> bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.);
50 static Parameter<double> bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.);
51 static Parameter<double> bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.);
52 static Parameter<double> shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.);
53 static Parameter<double> sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.);
54 static Parameter<double> shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.);
55 static Parameter<double> shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.);
56 static Parameter<double> shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.);
58 SortedCellList *list=0;
60 DualX11Output *dualx11= 0;
63 if (list) delete list;
66 strip= new MoebiusStrip(width);
68 strip= new MoebiusEnfoldment(thickness,bottomportion);
70 list= new SortedCellList;
72 for (int ti=0; ti<tn; ti++) {
73 double t1= (double)(ti+1)/tn;
75 for (int ui=0; ui<un; ui++) {
76 double u1= (double)(ui+1)/un;
79 cell->p[0]= strip->middlepoint(t0,u0);
80 //fprintf(stderr,"t %7.4f u %7.4f %7.4f,%7.4f,%7.4f\n",
81 // t0,u0, cell->p[0][0], cell->p[0][1], cell->p[0][2]);
82 cell->p[1]= strip->middlepoint(t0,u1);
83 cell->p[2]= strip->middlepoint(t1,u1);
84 cell->p[3]= strip->middlepoint(t1,u0);
93 int main(int argc, char **argv) {
97 Point::setobserver(theta,eta,planedistance,eyedistance,cutoffdistance);
98 Point::cleartransform();
99 if (tear != 0.0) Point::appendtransform(new TearOpenTransform(tear,teary));
100 if (twist != 0.0) Point::appendtransform(new TwistTransform(twist,twisty));
101 if (bulge != 0.0) Point::appendtransform(new BulgeTransform(bulge,bulgesd,bulgey));
102 if (shearx != 0.0 || sheary != 0.0)
103 Point::appendtransform(new ShearTransform(Point(0.0,shearey,0.0),
104 Point(shearx,sheary,0.0),
105 Point(shearsdx,shearsdy,1e20)));
106 Point::appendtransform(new ScaleTransform(scale));
108 if (x11) list->display(*x11);
109 if (dualx11) list->display(*dualx11);
111 cin.get(buf,100,'\n');
113 if (!cin.get(c) || c!='\n') {
114 cerr << "error reading command input, giving up\n";
117 char *equals= strchr(buf,'=');
120 AnyParameter *param= AnyParameter::find(buf);
122 *param= atof(equals);
125 cerr << "parameter `" << buf << "' not found\n";
127 } else if (!strncmp(buf,"postscript ",11)) {
128 const char *filename= buf+11;
129 ofstream file(filename);
131 PostScriptOutput psout(file);
132 list->display(psout);
134 cerr << "Failed to open `" << filename << "'\n";
137 cerr << "PostScript written to `" << filename <<"'\n";
138 } else if (!strcmp(buf,"x11")) {
146 } else if (!strcmp(buf,"dualx11")) {
151 dualx11= new DualX11Output;
154 } else if (!strcmp(buf,"quit")) {
156 } else if (!strcmp(buf,"list")) {
157 AnyParameter::list();
161 cerr << "command not understood\n";